Revision 2709 branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/DxfGroup.java

View differences:

DxfGroup.java
77 77
                                                          };
78 78
    int code;
79 79
    Object data;
80

  
80
    
81
    /**
82
     * Constructor por defecto.
83
     */
81 84
    public DxfGroup() {
82 85
        code = -1;
83 86
        data = null;
84 87
    }
85

  
88
    
89
    /**
90
     * Constructor habitual. Representa una entidad individual dentro del DXF
91
     * @param code, ?ndice del dato dentro del DxfGroup
92
     * @param data, el propio dato que queda almacenado en el DxfGroup
93
     */
86 94
    public DxfGroup(int code, String data) {
87 95
        this.code = code;
88 96
        this.data = data;
89 97
    }
90

  
98
    
99
    /**
100
     * Lee una entidad del DXF y la empaqueta en un DxfGroup.
101
     * @param fi, BufferedReader mediante el cual accedemos al DXF
102
     * @return DxfGroup con la informaci?n procedente del DXF
103
     * @throws NumberFormatException
104
     * @throws IOException
105
     */
91 106
    public static DxfGroup read(BufferedReader fi)
92 107
                         throws NumberFormatException, IOException {
93 108
        DxfGroup grp = null;
......
105 120

  
106 121
        return grp;
107 122
    }
108

  
123
    
124
    /**
125
     * Devuelve el code
126
     * @return
127
     */
109 128
    public int getCode() {
110 129
        return code;
111 130
    }
112

  
131
    
132
    /**
133
     * Devuelve data
134
     * @return
135
     */
113 136
    public Object getData() {
114 137
        return data;
115 138
    }
116

  
139
    
140
    /**
141
     * Lee un dato individual dentro de un DxfGroup
142
     * @param fi, BufferedReader
143
     * @throws IOException
144
     */
117 145
    private void readData(BufferedReader fi) throws IOException {
118 146
        String txt = fi.readLine().trim();
119 147

  
......
189 217

  
190 218
        //return _dfun
191 219
    }
192

  
220
    
221
    /**
222
     * Permite comparar dos objetos de la clase DxfGroup
223
     * @param c, code
224
     * @param s, data
225
     * @return boolean
226
     */
193 227
    public boolean equals(int c, String s) {
194 228
        if ((c == code) && (s.compareTo((String) data) == 0)) {
195 229
            return true;
......
197 231

  
198 232
        return false;
199 233
    }
200

  
234
    
235
    /**
236
     * Devuelve un dato concreto en forma de String tabulado
237
     * @param code
238
     * @return String
239
     */
201 240
    public static String int34car(int code) {
202 241
        if (code < 10) {
203 242
            return "  " + Integer.toString(code);
......
207 246
            return Integer.toString(code);
208 247
        }
209 248
    }
210

  
249
    
250
    /**
251
     * Devuelve un dato concreto en forma de String tabulado
252
     * @param value
253
     * @return String
254
     */
211 255
    public static String int6car(int value) {
212 256
        String s = "     " + Integer.toString(value);
213 257

  
214 258
        return s.substring(s.length() - 6, s.length());
215 259
    }
216

  
260
    
261
    /**
262
     * Convierte a String un dato del DxfGroup
263
     * @param code
264
     * @param value
265
     * @return String
266
     */
217 267
    public static String toString(int code, String value) {
218 268
        return int34car(code) + "\r\n" + value + "\r\n";
219 269
    }
220

  
270
    
271
    /**
272
     * Convierte a String un dato del DxfGroup
273
     * @param code
274
     * @param value
275
     * @return String
276
     */
221 277
    public static String toString(int code, int value) {
222 278
        return int34car(code) + "\r\n" + int6car(value) + "\r\n";
223 279
    }
224

  
280
    
281
    /**
282
     * Convierte a String un dato del DxfGroup
283
     * @param code
284
     * @param value
285
     * @param decimalPartLength
286
     * @return String
287
     */
225 288
    public static String toString(int code, float value, int decimalPartLength) {
226 289
        return int34car(code) + "\r\n" +
227 290
               decimalFormats[decimalPartLength].format((double) value) +
228 291
               "\r\n";
229 292
    }
230

  
293
    
294
    /**
295
     * Convierte a String un dato del DxfGroup
296
     * @param code
297
     * @param value
298
     * @param decimalPartLength
299
     * @return String
300
     */
231 301
    public static String toString(int code, double value, int decimalPartLength) {
232 302
        return int34car(code) + "\r\n" +
233 303
               decimalFormats[decimalPartLength].format(value) + "\r\n";
234 304
    }
235

  
305
    
306
    /**
307
     * Convierte a String un dato del DxfGroup
308
     * @param code
309
     * @param value
310
     * @return String
311
     */
236 312
    public static String toString(int code, Object value) {
237 313
        if (value instanceof String) {
238 314
            return toString(code, (String) value);
......
246 322
            return toString(code, value.toString());
247 323
        }
248 324
    }
249

  
325
    
326
    /**
327
     * Convierte a String un dato del DxfGroup
328
     */
250 329
    public String toString() {
251 330
        return toString(code, data);
252 331
    }
253 332

  
254 333
    /**
255
     * jmorell: Permite rellenar los datos. ?til en la escirtura de DXFs.
334
     * jmorell: Permite rellenar los datos. ?til en la escritura de DXFs.
256 335
     * @param data The data to set.
257 336
     */
258 337
    public void setData(Object data) {
......
260 339
    }
261 340

  
262 341
    /**
263
     * jmorell: Permite rellenar los c?digos. ?til en la escirtura de DXFs.
342
     * jmorell: Permite rellenar los c?digos. ?til en la escritura de DXFs.
264 343
     * @param code The code to set.
265 344
     */
266 345
    public void setCode(int code) {

Also available in: Unified diff