svn-gvsig-desktop / branches / Mobile_Compatible_Hito_1 / libDXF / src / org / cresques / px / dxf / DxfLayer.java @ 21930
History | View | Annotate | Download (3.64 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.awt.Color; |
27 |
|
28 |
import org.cresques.io.DxfGroup; |
29 |
|
30 |
|
31 |
/**
|
32 |
* La clase DxfLayer representa las capas de AutoCAD que aparecen en un fichero
|
33 |
* DXF.
|
34 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
35 |
* @author jmorell
|
36 |
*/
|
37 |
public class DxfLayer extends DxfTableItem { |
38 |
public int colorNumber = 9; |
39 |
public String lType = "CONTINUOUS"; |
40 |
public boolean frozen = false; |
41 |
public boolean isOff = false; |
42 |
|
43 |
/**
|
44 |
* Constructor de DxfLayer.
|
45 |
* @param name, nombre de la capa.
|
46 |
*/
|
47 |
public DxfLayer(String name) { |
48 |
super(name, 0); |
49 |
System.out.println("Dxf: Capa '" + name + "'."); |
50 |
colorNumber = 255;
|
51 |
lType = "CONTINUOUS";
|
52 |
} |
53 |
|
54 |
/**
|
55 |
* Sobrecarga del constructor de DxfLayer. Mediante este constructor tambi?n es
|
56 |
* posible especificar el color de la capa.
|
57 |
* @param name, nombre de la capa.
|
58 |
* @param clr, color de la capa.
|
59 |
*/
|
60 |
public DxfLayer(String name, int clr) { |
61 |
super(name, 0); |
62 |
colorNumber = clr; |
63 |
lType = "CONTINUOUS";
|
64 |
System.out.println("DxfLayer name=" + name + ", color=" + colorNumber); |
65 |
} |
66 |
|
67 |
/**
|
68 |
* Sobrecarga del constructor de DxfLayer. Mediante este constructor es
|
69 |
* posible especificar el nombre, el color y el tipo de l?nea asociado a la capa.
|
70 |
* @param name, nombre de la capa.
|
71 |
* @param clr, color de la capa.
|
72 |
* @param lType, tipo de l?nea asociado a la capa.
|
73 |
*/
|
74 |
public DxfLayer(String name, int clr, String lType) { |
75 |
super(name, 0); |
76 |
colorNumber = clr; |
77 |
this.lType = lType;
|
78 |
} |
79 |
|
80 |
/**
|
81 |
* Devuelve el color asociado a la capa.
|
82 |
* @return Color
|
83 |
*/
|
84 |
public Color getColor() { |
85 |
return AcadColor.getColor(colorNumber);
|
86 |
} |
87 |
|
88 |
/**
|
89 |
* Permite la escritura de capas en un fichero DXF2000.
|
90 |
* @return String, la cadena que se escribir? en el fichero con la informaci?n
|
91 |
* de la capa.
|
92 |
*/
|
93 |
public String toDxfString() { |
94 |
/*5
|
95 |
10
|
96 |
330
|
97 |
2
|
98 |
100
|
99 |
AcDbSymbolTableRecord
|
100 |
100
|
101 |
AcDbLayerTableRecord
|
102 |
2
|
103 |
0
|
104 |
70
|
105 |
0
|
106 |
62
|
107 |
7
|
108 |
6
|
109 |
Continuous
|
110 |
370
|
111 |
-3
|
112 |
390
|
113 |
F*/
|
114 |
StringBuffer sb = new StringBuffer(LAYER.toString() + |
115 |
super.toDxfString());
|
116 |
sb.append(DxfGroup.toString(5, 10)); |
117 |
sb.append(DxfGroup.toString(100, "AcDbSymbolTableRecord")); |
118 |
sb.append(DxfGroup.toString(100, "AcDbLayerTableRecord")); |
119 |
sb.append(DxfGroup.toString(62, colorNumber));
|
120 |
sb.append(DxfGroup.toString(6, lType));
|
121 |
|
122 |
return sb.toString();
|
123 |
} |
124 |
} |