root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / symbols / SimpleFillSymbol.java @ 10832
History | View | Annotate | Download (6.04 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 10832 2007-03-21 11:02:17Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.8 2007-03-21 11:02:17 jaume
|
47 |
* *** empty log message ***
|
48 |
*
|
49 |
* Revision 1.7 2007/03/20 17:00:50 jaume
|
50 |
* *** empty log message ***
|
51 |
*
|
52 |
* Revision 1.6 2007/03/20 16:02:09 jaume
|
53 |
* *** empty log message ***
|
54 |
*
|
55 |
* Revision 1.5 2007/03/09 11:20:57 jaume
|
56 |
* Advanced symbology (start committing)
|
57 |
*
|
58 |
* Revision 1.3.2.5 2007/02/21 07:34:09 jaume
|
59 |
* labeling starts working
|
60 |
*
|
61 |
* Revision 1.3.2.4 2007/02/16 10:54:12 jaume
|
62 |
* multilayer splitted to multilayerline, multilayermarker,and multilayerfill
|
63 |
*
|
64 |
* Revision 1.3.2.3 2007/02/15 16:23:44 jaume
|
65 |
* *** empty log message ***
|
66 |
*
|
67 |
* Revision 1.3.2.2 2007/02/12 15:15:20 jaume
|
68 |
* refactored interval legend and added graduated symbol legend
|
69 |
*
|
70 |
* Revision 1.3.2.1 2007/02/09 07:47:05 jaume
|
71 |
* Isymbol moved
|
72 |
*
|
73 |
* Revision 1.3 2007/01/24 17:58:22 jaume
|
74 |
* new features and architecture error fixes
|
75 |
*
|
76 |
* Revision 1.2 2007/01/10 16:39:41 jaume
|
77 |
* ISymbol now belongs to com.iver.cit.gvsig.fmap.core.symbols package
|
78 |
*
|
79 |
* Revision 1.1 2007/01/10 16:31:36 jaume
|
80 |
* *** empty log message ***
|
81 |
*
|
82 |
* Revision 1.7 2006/11/14 11:10:27 jaume
|
83 |
* *** empty log message ***
|
84 |
*
|
85 |
* Revision 1.6 2006/11/09 18:39:05 jaume
|
86 |
* *** empty log message ***
|
87 |
*
|
88 |
* Revision 1.5 2006/11/09 10:22:50 jaume
|
89 |
* *** empty log message ***
|
90 |
*
|
91 |
* Revision 1.4 2006/11/08 13:05:51 jaume
|
92 |
* *** empty log message ***
|
93 |
*
|
94 |
* Revision 1.3 2006/11/08 10:56:47 jaume
|
95 |
* *** empty log message ***
|
96 |
*
|
97 |
* Revision 1.2 2006/11/06 16:06:52 jaume
|
98 |
* *** empty log message ***
|
99 |
*
|
100 |
* Revision 1.1 2006/10/30 19:30:35 jaume
|
101 |
* *** empty log message ***
|
102 |
*
|
103 |
*
|
104 |
*/
|
105 |
package com.iver.cit.gvsig.fmap.core.symbols; |
106 |
|
107 |
import java.awt.Color; |
108 |
import java.awt.Graphics2D; |
109 |
import java.awt.Rectangle; |
110 |
import java.awt.Shape; |
111 |
import java.awt.geom.AffineTransform; |
112 |
|
113 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
114 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
115 |
import com.iver.cit.gvsig.fmap.core.FShape; |
116 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
117 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
118 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
119 |
import com.iver.utiles.StringUtilities; |
120 |
import com.iver.utiles.XMLEntity; |
121 |
|
122 |
/**
|
123 |
* Basic fill symbol. It will allow to paint a shape with its filling color (and transparency) and the outline.
|
124 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
125 |
*/
|
126 |
public class SimpleFillSymbol extends AbstractFillSymbol { |
127 |
private SimpleFillSymbol symbolForSelection;
|
128 |
|
129 |
|
130 |
public ISymbol getSymbolForSelection() {
|
131 |
if (symbolForSelection == null) { |
132 |
XMLEntity xml = getXMLEntity(); |
133 |
xml.putProperty("color", StringUtilities.color2String(FSymbol.getSelectionColor()));
|
134 |
symbolForSelection = (SimpleFillSymbol) SymbologyFactory. |
135 |
createSymbolFromXML(xml, getDescription()+" version for selection");
|
136 |
} |
137 |
return symbolForSelection;
|
138 |
} |
139 |
|
140 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) { |
141 |
Color c = getFillColor();
|
142 |
if (c!=null) { |
143 |
g.setColor(c); |
144 |
g.fill(shp); |
145 |
} |
146 |
if (getOutline() != null) |
147 |
getOutline().draw(g, affineTransform, shp); |
148 |
} |
149 |
|
150 |
public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, |
151 |
Shape shp) {
|
152 |
// TODO Auto-generated method stub
|
153 |
throw new Error("Not yet implemented!"); |
154 |
} |
155 |
|
156 |
public XMLEntity getXMLEntity() {
|
157 |
XMLEntity xml = new XMLEntity();
|
158 |
|
159 |
// the class name
|
160 |
xml.putProperty("className", getClassName());
|
161 |
|
162 |
// color
|
163 |
xml.putProperty("color", StringUtilities.color2String(getFillColor()));
|
164 |
|
165 |
// description
|
166 |
xml.putProperty("desc", getDescription());
|
167 |
|
168 |
// is shape visible
|
169 |
xml.putProperty("isShapeVisible", isShapeVisible());
|
170 |
|
171 |
// outline
|
172 |
if (getOutline() != null) |
173 |
xml.addChild(getOutline().getXMLEntity()); |
174 |
return xml;
|
175 |
} |
176 |
|
177 |
public int getSymbolType() { |
178 |
return FShape.POLYGON;
|
179 |
} |
180 |
|
181 |
public void drawInsideRectangle(Graphics2D g, |
182 |
AffineTransform scaleInstance, Rectangle r) { |
183 |
Rectangle rect = new Rectangle(r.x, r.y, r.width, r.height); |
184 |
rect.setFrame(((int) rect.getMinX())+1, ((int) rect.getMinY())+1, ((int) rect.getMaxX())-2, ((int) rect.getMaxY())-2); |
185 |
FShape shp = new FPolygon2D(new GeneralPathX(rect)); |
186 |
|
187 |
Color c = getFillColor();
|
188 |
if (c != null) { |
189 |
g.setColor(c); |
190 |
g.fillRect(rect.x, rect.y, rect.width, rect.height); |
191 |
} |
192 |
|
193 |
if (getOutline() != null) |
194 |
getOutline().draw(g, scaleInstance, shp); |
195 |
} |
196 |
|
197 |
public String getClassName() { |
198 |
return getClass().getName();
|
199 |
} |
200 |
|
201 |
public void setXMLEntity(XMLEntity xml) { |
202 |
// color
|
203 |
setFillColor(StringUtilities.string2Color(xml.getStringProperty("color")));
|
204 |
|
205 |
// description
|
206 |
setDescription(xml.getStringProperty("desc"));
|
207 |
|
208 |
// is shape visible
|
209 |
setIsShapeVisible(xml.getBooleanProperty("isShapeVisible"));
|
210 |
|
211 |
// outline
|
212 |
if (xml.getChildrenCount() > 0) |
213 |
setOutline((ILineSymbol) SymbologyFactory.createSymbolFromXML(xml.getChild(0), null)); |
214 |
|
215 |
} |
216 |
|
217 |
public void print(Graphics2D g, AffineTransform at, FShape shape) throws ReadDriverException { |
218 |
// TODO Implement it
|
219 |
throw new Error("Not yet implemented!"); |
220 |
|
221 |
} |
222 |
} |