Revision 13073 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MarkerLineSymbol.java
MarkerLineSymbol.java | ||
---|---|---|
58 | 58 |
import com.iver.utiles.XMLEntity; |
59 | 59 |
|
60 | 60 |
/** |
61 |
* @autor jaume dominguez faus - jaume.dominguez@iver.es |
|
61 |
* MarkerLineSymbol allows to use any symbol defined as an image to draw a lineal object. |
|
62 |
* The line will be painted as a run of symbols through the path defined by the line. |
|
63 |
* |
|
64 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
62 | 65 |
*/ |
63 | 66 |
public class MarkerLineSymbol extends AbstractLineSymbol { |
64 | 67 |
private IMarkerSymbol marker; |
65 | 68 |
private MarkerLineSymbol symSelect; |
66 | 69 |
private double separation = 5; |
67 |
|
|
70 |
|
|
68 | 71 |
{ |
69 | 72 |
marker = SymbologyFactory.createDefaultMarkerSymbol(); |
70 | 73 |
marker.setSize(5); |
71 | 74 |
} |
72 |
|
|
75 |
|
|
73 | 76 |
public void setLineWidth(double width) { |
74 | 77 |
getLineStyle().setLineWidth((float) width); |
75 | 78 |
} |
... | ... | |
83 | 86 |
PathLength pl = new PathLength(shp); |
84 | 87 |
float myLineLength = pl.lengthOfPath(); // length without the first and last arrow |
85 | 88 |
float separation = (float) getSeparation(); |
86 |
|
|
89 |
|
|
87 | 90 |
FPoint2D p = new FPoint2D(pl.pointAtLength(0)); |
88 | 91 |
double lineWidth = getLineWidth(); |
89 | 92 |
marker.setSize(lineWidth); |
90 | 93 |
marker.draw(g, affineTransform, p); |
91 |
|
|
92 |
if (separation == 0) separation = 1;
|
|
94 |
|
|
95 |
if (separation == 0) separation = 1; |
|
93 | 96 |
float length = separation; |
94 | 97 |
while (length < myLineLength) { |
95 | 98 |
p = new FPoint2D(pl.pointAtLength(length)); |
... | ... | |
97 | 100 |
length += separation; |
98 | 101 |
} |
99 | 102 |
} |
100 |
|
|
101 |
|
|
102 | 103 |
|
104 |
|
|
105 |
/** |
|
106 |
* Gets the separation between the marker symbols that are used to draw the line. |
|
107 |
* |
|
108 |
* @return separation |
|
109 |
*/ |
|
103 | 110 |
public double getSeparation() { |
104 | 111 |
return separation; |
105 | 112 |
} |
... | ... | |
113 | 120 |
public ISymbol getSymbolForSelection() { |
114 | 121 |
if (symSelect == null) { |
115 | 122 |
symSelect = (MarkerLineSymbol) SymbologyFactory. |
116 |
createSymbolFromXML(getXMLEntity(), "selection derived symbol");
|
|
123 |
createSymbolFromXML(getXMLEntity(), "selection derived symbol"); |
|
117 | 124 |
symSelect.setMarker((IMarkerSymbol) symSelect.getMarker() |
118 | 125 |
.getSymbolForSelection()); |
119 |
|
|
126 |
|
|
120 | 127 |
} |
121 | 128 |
|
122 | 129 |
return symSelect; |
... | ... | |
146 | 153 |
setUnit(xml.getIntProperty("unit")); |
147 | 154 |
setReferenceSystem(xml.getIntProperty("referenceSystem")); |
148 | 155 |
marker = (IMarkerSymbol) SymbologyFactory. |
149 |
createSymbolFromXML(xml.firstChild("id", "marker"), "theMarker");
|
|
156 |
createSymbolFromXML(xml.firstChild("id", "marker"), "theMarker"); |
|
150 | 157 |
setLineStyle((ILineStyle) SymbologyFactory. |
151 | 158 |
createStyleFromXML(xml.firstChild("id", "lineStyle"), "theLineStyle")); |
152 | 159 |
} |
153 |
|
|
160 |
/** |
|
161 |
* Sets the separation between the marker symbols that compose the line |
|
162 |
* |
|
163 |
* @param separation |
|
164 |
*/ |
|
154 | 165 |
public void setSeparation(double separation) { |
155 | 166 |
this.separation = separation; |
156 | 167 |
} |
... | ... | |
164 | 175 |
// TODO Auto-generated method stub |
165 | 176 |
throw new Error("Not yet implemented!"); |
166 | 177 |
} |
167 |
|
|
178 |
/** |
|
179 |
* Returns the marker symbol that compose the line |
|
180 |
* |
|
181 |
* @return marker IMarkerSymbol |
|
182 |
*/ |
|
168 | 183 |
public IMarkerSymbol getMarker() { |
169 | 184 |
return marker; |
170 | 185 |
} |
171 |
|
|
186 |
/** |
|
187 |
* Sets the marker symbol that compose the line |
|
188 |
* |
|
189 |
* @param marker IMarkerSymbol |
|
190 |
*/ |
|
172 | 191 |
public void setMarker(IMarkerSymbol marker) { |
173 | 192 |
this.marker = marker; |
174 | 193 |
} |
175 | 194 |
|
176 | 195 |
public void setCartographicSize(double cartographicSize, FShape shp) { |
177 | 196 |
marker.setCartographicSize(cartographicSize, shp); |
178 |
|
|
197 |
|
|
179 | 198 |
} |
180 |
|
|
199 |
|
|
181 | 200 |
public double toCartographicSize(ViewPort viewPort, double dpi, FShape shp) { |
182 | 201 |
double oldSize = marker.getSize(); |
183 | 202 |
setCartographicSize(getCartographicSize( |
184 |
viewPort,
|
|
185 |
dpi,
|
|
186 |
shp),
|
|
187 |
shp);
|
|
203 |
viewPort, |
|
204 |
dpi, |
|
205 |
shp), |
|
206 |
shp); |
|
188 | 207 |
return oldSize; |
189 | 208 |
} |
190 | 209 |
|
191 | 210 |
public double getCartographicSize(ViewPort viewPort, double dpi, FShape shp) { |
192 | 211 |
return CartographicSupportToolkit. |
193 |
getCartographicLength(this,
|
|
194 |
marker.getSize(),
|
|
195 |
viewPort,
|
|
196 |
dpi);
|
|
212 |
getCartographicLength(this, |
|
213 |
marker.getSize(), |
|
214 |
viewPort, |
|
215 |
dpi); |
|
197 | 216 |
} |
198 | 217 |
|
199 | 218 |
} |
Also available in: Unified diff