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