svn-gvsig-desktop / branches / simbologia / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / symbols / SimpleFillSymbol.java @ 10436
History | View | Annotate | Download (5.61 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
|
42 |
/* CVS MESSAGES:
|
43 |
*
|
44 |
* $Id: SimpleFillSymbol.java 10436 2007-02-21 07:34:09Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.3.2.5 2007-02-21 07:34:09 jaume
|
47 |
* labeling starts working
|
48 |
*
|
49 |
* Revision 1.3.2.4 2007/02/16 10:54:12 jaume
|
50 |
* multilayer splitted to multilayerline, multilayermarker,and multilayerfill
|
51 |
*
|
52 |
* Revision 1.3.2.3 2007/02/15 16:23:44 jaume
|
53 |
* *** empty log message ***
|
54 |
*
|
55 |
* Revision 1.3.2.2 2007/02/12 15:15:20 jaume
|
56 |
* refactored interval legend and added graduated symbol legend
|
57 |
*
|
58 |
* Revision 1.3.2.1 2007/02/09 07:47:05 jaume
|
59 |
* Isymbol moved
|
60 |
*
|
61 |
* Revision 1.3 2007/01/24 17:58:22 jaume
|
62 |
* new features and architecture error fixes
|
63 |
*
|
64 |
* Revision 1.2 2007/01/10 16:39:41 jaume
|
65 |
* ISymbol now belongs to com.iver.cit.gvsig.fmap.core.symbols package
|
66 |
*
|
67 |
* Revision 1.1 2007/01/10 16:31:36 jaume
|
68 |
* *** empty log message ***
|
69 |
*
|
70 |
* Revision 1.7 2006/11/14 11:10:27 jaume
|
71 |
* *** empty log message ***
|
72 |
*
|
73 |
* Revision 1.6 2006/11/09 18:39:05 jaume
|
74 |
* *** empty log message ***
|
75 |
*
|
76 |
* Revision 1.5 2006/11/09 10:22:50 jaume
|
77 |
* *** empty log message ***
|
78 |
*
|
79 |
* Revision 1.4 2006/11/08 13:05:51 jaume
|
80 |
* *** empty log message ***
|
81 |
*
|
82 |
* Revision 1.3 2006/11/08 10:56:47 jaume
|
83 |
* *** empty log message ***
|
84 |
*
|
85 |
* Revision 1.2 2006/11/06 16:06:52 jaume
|
86 |
* *** empty log message ***
|
87 |
*
|
88 |
* Revision 1.1 2006/10/30 19:30:35 jaume
|
89 |
* *** empty log message ***
|
90 |
*
|
91 |
*
|
92 |
*/
|
93 |
package com.iver.cit.gvsig.fmap.core.symbols; |
94 |
|
95 |
import java.awt.Graphics2D; |
96 |
import java.awt.Rectangle; |
97 |
import java.awt.Shape; |
98 |
import java.awt.geom.AffineTransform; |
99 |
|
100 |
import com.iver.cit.gvsig.fmap.DriverException; |
101 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
102 |
import com.iver.cit.gvsig.fmap.core.FShape; |
103 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
104 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
105 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
106 |
import com.iver.utiles.StringUtilities; |
107 |
import com.iver.utiles.XMLEntity; |
108 |
|
109 |
/**
|
110 |
* Basic fill symbol. It will allow to paint a shape with its filling color (and transparency) and the outline.
|
111 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
112 |
*/
|
113 |
public class SimpleFillSymbol extends AbstractFillSymbol { |
114 |
private SimpleFillSymbol symbolForSelection;
|
115 |
|
116 |
/**
|
117 |
* @return
|
118 |
* @uml.property name="symbolForSelection"
|
119 |
*/
|
120 |
public ISymbol getSymbolForSelection() {
|
121 |
if (symbolForSelection == null) { |
122 |
XMLEntity xml = getXMLEntity(); |
123 |
xml.putProperty("color", StringUtilities.color2String(FSymbol.getSelectionColor()));
|
124 |
symbolForSelection = (SimpleFillSymbol) SymbologyFactory. |
125 |
createSymbolFromXML(xml, getDescription()+" version for selection");
|
126 |
} |
127 |
return symbolForSelection;
|
128 |
} |
129 |
|
130 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) { |
131 |
g.setColor(getFillColor()); |
132 |
g.fill(shp); |
133 |
if (getOutline() != null) |
134 |
getOutline().draw(g, affineTransform, shp); |
135 |
} |
136 |
|
137 |
public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, |
138 |
Shape shp) {
|
139 |
// TODO Auto-generated method stub
|
140 |
throw new Error("Not yet implemented!"); |
141 |
} |
142 |
|
143 |
public XMLEntity getXMLEntity() {
|
144 |
XMLEntity xml = new XMLEntity();
|
145 |
|
146 |
// the class name
|
147 |
xml.putProperty("className", getClassName());
|
148 |
|
149 |
// color
|
150 |
xml.putProperty("color", StringUtilities.color2String(getFillColor()));
|
151 |
|
152 |
// description
|
153 |
xml.putProperty("desc", getDescription());
|
154 |
|
155 |
// is shape visible
|
156 |
xml.putProperty("isShapeVisible", isShapeVisible());
|
157 |
|
158 |
// outline
|
159 |
if (getOutline() != null) |
160 |
xml.addChild(getOutline().getXMLEntity()); |
161 |
return xml;
|
162 |
} |
163 |
|
164 |
public int getSymbolType() { |
165 |
return FShape.POLYGON;
|
166 |
} |
167 |
|
168 |
public void drawInsideRectangle(Graphics2D g, |
169 |
AffineTransform scaleInstance, Rectangle r) { |
170 |
g.setColor(getFillColor()); |
171 |
r.setFrame(((int) r.getMinX())+1, ((int) r.getMinY())+1, ((int) r.getMaxX())-2, ((int) r.getMaxY())-2); |
172 |
g.fillRect(r.x, r.y, r.width, r.height); |
173 |
FShape shp = new FPolygon2D(new GeneralPathX(r)); |
174 |
if (getOutline() != null) |
175 |
getOutline().draw(g, scaleInstance, shp); |
176 |
|
177 |
|
178 |
} |
179 |
|
180 |
public String getClassName() { |
181 |
return getClass().getName();
|
182 |
} |
183 |
|
184 |
public void setXMLEntity(XMLEntity xml) { |
185 |
// color
|
186 |
setFillColor(StringUtilities.string2Color(xml.getStringProperty("color")));
|
187 |
|
188 |
|
189 |
// description
|
190 |
setDescription(xml.getStringProperty("desc"));
|
191 |
|
192 |
// is shape visible
|
193 |
setIsShapeVisible(xml.getBooleanProperty("isShapeVisible"));
|
194 |
|
195 |
// outline
|
196 |
if (xml.getChildrenCount() > 0) |
197 |
setOutline((ILineSymbol) SymbologyFactory.createSymbolFromXML(xml.getChild(0), null)); |
198 |
|
199 |
} |
200 |
|
201 |
public void print(Graphics2D g, AffineTransform at, FShape shape) throws DriverException { |
202 |
// TODO Implement it
|
203 |
throw new Error("Not yet implemented!"); |
204 |
|
205 |
} |
206 |
} |