svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / symbols / SimpleLineSymbol.java @ 9919
History | View | Annotate | Download (3.96 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: SimpleLineSymbol.java 9919 2007-01-25 16:25:23Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.3 2007-01-25 16:25:23 jaume
|
47 |
* *** empty log message ***
|
48 |
*
|
49 |
* Revision 1.2 2007/01/24 17:58:22 jaume
|
50 |
* new features and architecture error fixes
|
51 |
*
|
52 |
* Revision 1.1 2007/01/16 11:50:44 jaume
|
53 |
* *** empty log message ***
|
54 |
*
|
55 |
*
|
56 |
*/
|
57 |
package com.iver.cit.gvsig.fmap.core.symbols; |
58 |
|
59 |
import java.awt.BasicStroke; |
60 |
import java.awt.Graphics2D; |
61 |
import java.awt.Rectangle; |
62 |
import java.awt.Shape; |
63 |
import java.awt.geom.AffineTransform; |
64 |
|
65 |
import com.iver.cit.gvsig.fmap.DriverException; |
66 |
import com.iver.cit.gvsig.fmap.core.FShape; |
67 |
import com.iver.cit.gvsig.fmap.core.SymbolFactory; |
68 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
69 |
import com.iver.utiles.StringUtilities; |
70 |
import com.iver.utiles.XMLEntity; |
71 |
|
72 |
public class SimpleLineSymbol extends AbstractLineSymbol { |
73 |
SimpleLineSymbol selSym; |
74 |
|
75 |
public ISymbol getSymbolForSelection() {
|
76 |
if (selSym == null) { |
77 |
selSym = (SimpleLineSymbol) SymbolFactory. |
78 |
createFromXML(getXMLEntity(), "Selection version");
|
79 |
selSym.setColor(FSymbol.getSelectionColor()); |
80 |
} |
81 |
return selSym;
|
82 |
} |
83 |
|
84 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) { |
85 |
g.setStroke(getStroke()); |
86 |
g.setColor(getColor()); |
87 |
g.draw(shp); |
88 |
} |
89 |
|
90 |
public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, |
91 |
Shape shp) {
|
92 |
return 0; |
93 |
} |
94 |
|
95 |
public int getOnePointRgb() { |
96 |
return getColor().getRGB();
|
97 |
} |
98 |
|
99 |
public XMLEntity getXMLEntity() {
|
100 |
XMLEntity xml = new XMLEntity();
|
101 |
xml.putProperty("className", getClassName());
|
102 |
xml.putProperty("isShapeVisible", isShapeVisible());
|
103 |
xml.putProperty("color", StringUtilities.color2String(getColor()));
|
104 |
xml.putProperty("stroke", ((BasicStroke) getStroke()).getLineWidth()); |
105 |
return xml;
|
106 |
} |
107 |
|
108 |
public void drawInsideRectangle(Graphics2D g, |
109 |
AffineTransform scaleInstance, Rectangle r) { |
110 |
g.setColor(getColor()); |
111 |
g.setStroke(getStroke()); |
112 |
final int hGap = (int) (r.getWidth() * 0.1); // the left and right margins |
113 |
final int vPos = 1; // the top and bottom margins |
114 |
final int splitCount = 3; // number of lines |
115 |
final int splitHSize = (r.width - hGap - hGap) / splitCount; |
116 |
int hPos = hGap;
|
117 |
boolean swap = false; |
118 |
for (int i = 0; i < splitCount; i++) { |
119 |
swap = !swap; |
120 |
g.drawLine(hPos, swap ? vPos : r.height-vPos, hPos + splitHSize, swap ? r.height-vPos : vPos); |
121 |
hPos += splitHSize; |
122 |
} |
123 |
} |
124 |
|
125 |
public String getClassName() { |
126 |
return getClass().getName();
|
127 |
} |
128 |
|
129 |
public void setXMLEntity(XMLEntity xml) { |
130 |
setIsShapeVisible(xml.getBooleanProperty("isShapeVisible"));
|
131 |
setColor(StringUtilities. |
132 |
string2Color(xml.getStringProperty("color")));
|
133 |
setStroke(new BasicStroke(xml.getFloatProperty("stroke"))); |
134 |
} |
135 |
|
136 |
public void print(Graphics2D g, AffineTransform at, FShape shape) |
137 |
throws DriverException {
|
138 |
// TODO Implement it
|
139 |
throw new Error("Not yet implemented!"); |
140 |
|
141 |
} |
142 |
|
143 |
} |