Revision 10679 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/SimpleLineSymbol.java
SimpleLineSymbol.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.4 2007-03-06 17:08:54 caballero
|
|
47 |
* Exceptions
|
|
46 |
* Revision 1.5 2007-03-09 11:20:56 jaume
|
|
47 |
* Advanced symbology (start committing)
|
|
48 | 48 |
* |
49 |
* Revision 1.3.2.5 2007/02/21 07:34:09 jaume |
|
50 |
* labeling starts working |
|
51 |
* |
|
52 |
* Revision 1.3.2.4 2007/02/15 16:23:44 jaume |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* Revision 1.3.2.3 2007/02/13 16:19:19 jaume |
|
56 |
* graduated symbol legends (start commiting) |
|
57 |
* |
|
58 |
* Revision 1.3.2.2 2007/02/12 15:15:20 jaume |
|
59 |
* refactored interval legend and added graduated symbol legend |
|
60 |
* |
|
61 |
* Revision 1.3.2.1 2007/02/09 07:47:05 jaume |
|
62 |
* Isymbol moved |
|
63 |
* |
|
49 | 64 |
* Revision 1.3 2007/01/25 16:25:23 jaume |
50 | 65 |
* *** empty log message *** |
51 | 66 |
* |
... | ... | |
59 | 74 |
*/ |
60 | 75 |
package com.iver.cit.gvsig.fmap.core.symbols; |
61 | 76 |
|
62 |
import java.awt.BasicStroke;
|
|
77 |
import java.awt.Color;
|
|
63 | 78 |
import java.awt.Graphics2D; |
64 | 79 |
import java.awt.Rectangle; |
65 | 80 |
import java.awt.Shape; |
... | ... | |
67 | 82 |
|
68 | 83 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
69 | 84 |
import com.iver.cit.gvsig.fmap.core.FShape; |
70 |
import com.iver.cit.gvsig.fmap.core.SymbolFactory; |
|
85 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
86 |
import com.iver.cit.gvsig.fmap.core.styles.ILineStyle; |
|
71 | 87 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
72 | 88 |
import com.iver.utiles.StringUtilities; |
73 | 89 |
import com.iver.utiles.XMLEntity; |
74 | 90 |
|
91 |
/** |
|
92 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
93 |
*/ |
|
75 | 94 |
public class SimpleLineSymbol extends AbstractLineSymbol { |
76 |
SimpleLineSymbol selSym;
|
|
95 |
SimpleLineSymbol symbolForSelection;
|
|
77 | 96 |
|
78 | 97 |
public ISymbol getSymbolForSelection() { |
79 |
if (selSym == null) { |
|
80 |
selSym = (SimpleLineSymbol) SymbolFactory. |
|
81 |
createFromXML(getXMLEntity(), "Selection version"); |
|
82 |
selSym.setColor(FSymbol.getSelectionColor()); |
|
98 |
if (symbolForSelection == null) { |
|
99 |
XMLEntity xml = getXMLEntity(); |
|
100 |
xml.putProperty("color", StringUtilities.color2String(FSymbol.getSelectionColor())); |
|
101 |
symbolForSelection = (SimpleLineSymbol) SymbologyFactory. |
|
102 |
createSymbolFromXML(xml, getDescription()+" version for selection"); |
|
83 | 103 |
} |
84 |
return selSym;
|
|
104 |
return symbolForSelection;
|
|
85 | 105 |
} |
86 | 106 |
|
87 | 107 |
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) { |
88 |
g.setStroke(getStroke()); |
|
108 |
g.setStroke(getLineStyle().getStroke());
|
|
89 | 109 |
g.setColor(getColor()); |
90 | 110 |
g.draw(shp); |
91 | 111 |
} |
... | ... | |
103 | 123 |
XMLEntity xml = new XMLEntity(); |
104 | 124 |
xml.putProperty("className", getClassName()); |
105 | 125 |
xml.putProperty("isShapeVisible", isShapeVisible()); |
106 |
xml.putProperty("color", StringUtilities.color2String(getColor())); |
|
107 |
xml.putProperty("stroke", ((BasicStroke) getStroke()).getLineWidth()); |
|
126 |
xml.putProperty("desc", getDescription()); |
|
127 |
Color c = getColor(); |
|
128 |
if (c!= null) |
|
129 |
xml.putProperty("color", StringUtilities.color2String(getColor())); |
|
130 |
|
|
131 |
xml.addChild(getLineStyle().getXMLEntity()); |
|
108 | 132 |
return xml; |
109 | 133 |
} |
110 | 134 |
|
111 | 135 |
public void drawInsideRectangle(Graphics2D g, |
112 | 136 |
AffineTransform scaleInstance, Rectangle r) { |
113 | 137 |
g.setColor(getColor()); |
114 |
g.setStroke(getStroke()); |
|
138 |
g.setStroke(getLineStyle().getStroke());
|
|
115 | 139 |
final int hGap = (int) (r.getWidth() * 0.1); // the left and right margins |
116 | 140 |
final int vPos = 1; // the top and bottom margins |
117 | 141 |
final int splitCount = 3; // number of lines |
... | ... | |
131 | 155 |
|
132 | 156 |
public void setXMLEntity(XMLEntity xml) { |
133 | 157 |
setIsShapeVisible(xml.getBooleanProperty("isShapeVisible")); |
134 |
setColor(StringUtilities. |
|
158 |
setDescription(xml.getStringProperty("desc")); |
|
159 |
if (xml.contains("color")) |
|
160 |
setColor(StringUtilities. |
|
135 | 161 |
string2Color(xml.getStringProperty("color"))); |
136 |
setStroke(new BasicStroke(xml.getFloatProperty("stroke")));
|
|
162 |
setLineStyle((ILineStyle) SymbologyFactory.createStyleFromXML(xml.getChild(0), null));
|
|
137 | 163 |
} |
138 | 164 |
|
139 | 165 |
public void print(Graphics2D g, AffineTransform at, FShape shape) |
... | ... | |
143 | 169 |
|
144 | 170 |
} |
145 | 171 |
|
172 |
public void setWidth(double width) { |
|
173 |
getLineStyle().setLineWidth((float) width); |
|
174 |
} |
|
175 |
|
|
176 |
public double getWidth() { |
|
177 |
return getLineStyle().getLineWidth(); |
|
178 |
} |
|
179 |
|
|
146 | 180 |
} |
Also available in: Unified diff