root / tags / v1_0_2_Build_911 / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfTable.java @ 11388
History | View | Annotate | Download (2.5 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.cresques.px.dxf; |
25 |
|
26 |
import java.util.Vector; |
27 |
|
28 |
|
29 |
/**
|
30 |
* Lista (Tabla) de capas del fichero DXF.
|
31 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
32 |
*/
|
33 |
public class DxfTable { |
34 |
public Vector items = null; |
35 |
public boolean createNotFoundLayers = true; |
36 |
|
37 |
/**
|
38 |
* Constructor de DxfTable.
|
39 |
*/
|
40 |
public DxfTable() {
|
41 |
items = new Vector(); |
42 |
} |
43 |
|
44 |
/**
|
45 |
* A?ade un elemento a la tabla. En la actualidad esta table solo est? implementada
|
46 |
* para soportar capas.
|
47 |
* @param layer, la capa que a?adimos.
|
48 |
*/
|
49 |
public void add(DxfTableItem layer) { |
50 |
items.add(layer); |
51 |
} |
52 |
|
53 |
/**
|
54 |
* Devuelve una de las capas de la tabla de capas dada por su nombre.
|
55 |
* @param name, nombre de la capa que queremos obtener.
|
56 |
* @return DxfTableItem, la capa que buscamos.
|
57 |
*/
|
58 |
public DxfTableItem getByName(String name) { |
59 |
DxfTableItem capa = null;
|
60 |
|
61 |
for (int i = 0; i < items.size(); i++) { |
62 |
capa = (DxfTableItem) items.get(i); |
63 |
|
64 |
if (capa.getName().compareToIgnoreCase(name) == 0) { |
65 |
return capa;
|
66 |
} |
67 |
} |
68 |
|
69 |
if (createNotFoundLayers) {
|
70 |
capa = new DxfLayer(name);
|
71 |
add(capa); |
72 |
} |
73 |
|
74 |
return capa;
|
75 |
} |
76 |
|
77 |
/**
|
78 |
* Permite la escritura de entidades DxfTable en un fichero DXF2000.
|
79 |
* @return String, la cadena que se escribir? en el fichero con la informaci?n
|
80 |
* de la DxfTable.
|
81 |
*/
|
82 |
public String toDxfString() { |
83 |
String txt = ""; |
84 |
|
85 |
for (int i = 0; i < items.size(); i++) { |
86 |
txt += ((DxfLayer) items.get(i)).toDxfString(); |
87 |
} |
88 |
|
89 |
return txt;
|
90 |
} |
91 |
} |