Revision 18621 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiLayerFillSymbol.java
MultiLayerFillSymbol.java | ||
---|---|---|
92 | 92 |
import java.awt.Color; |
93 | 93 |
import java.awt.Graphics2D; |
94 | 94 |
import java.awt.Rectangle; |
95 |
import java.awt.Shape; |
|
96 | 95 |
import java.awt.geom.AffineTransform; |
97 | 96 |
import java.util.ArrayList; |
98 | 97 |
|
... | ... | |
100 | 99 |
|
101 | 100 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
102 | 101 |
import com.iver.cit.gvsig.fmap.MapContext; |
102 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
103 | 103 |
import com.iver.cit.gvsig.fmap.core.FShape; |
104 | 104 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
105 | 105 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
... | ... | |
165 | 165 |
} |
166 | 166 |
|
167 | 167 |
public void drawInsideRectangle(Graphics2D g, |
168 |
AffineTransform scaleInstance, Rectangle r) { |
|
168 |
AffineTransform scaleInstance, Rectangle r) throws SymbolDrawingException {
|
|
169 | 169 |
for (int i = 0; i < layers.length; i++) { |
170 | 170 |
layers[i].drawInsideRectangle(g, scaleInstance, r); |
171 | 171 |
} |
172 | 172 |
} |
173 | 173 |
|
174 |
public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, |
|
175 |
Shape shp) { |
|
176 |
// TODO Implement it |
|
177 |
throw new Error("Not yet implemented!"); |
|
178 |
|
|
174 |
public void getPixExtentPlus(FShape shp, float[] distances, |
|
175 |
ViewPort viewPort, int dpi) { |
|
176 |
float[] myDistances = new float[] {0,0}; |
|
177 |
distances[0] = 0; |
|
178 |
distances[1] = 0; |
|
179 |
for (int i = 0; i < layers.length; i++) { |
|
180 |
layers[i].getPixExtentPlus(shp, myDistances, viewPort, dpi); |
|
181 |
distances[0] = Math.max(myDistances[0], distances[0]); |
|
182 |
distances[1] = Math.max(myDistances[1], distances[1]); |
|
183 |
} |
|
179 | 184 |
} |
180 | 185 |
|
181 | 186 |
public ISymbol getSymbolForSelection() { |
... | ... | |
211 | 216 |
xml.putProperty("className", getClassName()); |
212 | 217 |
xml.putProperty("desc", getDescription()); |
213 | 218 |
xml.putProperty("isShapeVisible", isShapeVisible()); |
219 |
xml.putProperty("referenceSystem", getReferenceSystem()); |
|
220 |
xml.putProperty("unit", getUnit()); |
|
221 |
|
|
214 | 222 |
for (int i = 0; i < layers.length; i++) { |
215 | 223 |
xml.addChild(layers[i].getXMLEntity()); |
216 | 224 |
} |
... | ... | |
233 | 241 |
for (int i = 0; i < xml.getChildrenCount(); i++) { |
234 | 242 |
addLayer((IFillSymbol) SymbologyFactory.createSymbolFromXML(xml.getChild(i), "layer" + i)); |
235 | 243 |
} |
244 |
|
|
245 |
if (xml.contains("unit")) { // remove this line when done |
|
246 |
// measure unit (for outline) |
|
247 |
setUnit(xml.getIntProperty("unit")); |
|
248 |
|
|
249 |
// reference system (for outline) |
|
250 |
setReferenceSystem(xml.getIntProperty("referenceSystem")); |
|
251 |
} |
|
236 | 252 |
} |
237 | 253 |
|
238 | 254 |
public void print(Graphics2D g, AffineTransform at, FShape shape, PrintRequestAttributeSet properties) |
... | ... | |
265 | 281 |
} |
266 | 282 |
|
267 | 283 |
public void addLayer(ISymbol newLayer) { |
268 |
if (newLayer == null) return; |
|
269 |
|
|
270 |
selectionSymbol = null; /* forces the selection symbol to be re-created |
|
271 |
* next time it is required |
|
272 |
*/ |
|
273 |
int size = layers.length+1; |
|
274 |
IFillSymbol[] newLayers = new IFillSymbol[size]; |
|
275 |
for (int i = 0; i < newLayers.length-1; i++) { |
|
276 |
newLayers[i] = layers[i]; |
|
277 |
} |
|
278 |
newLayers[size-1] = (IFillSymbol) newLayer; |
|
279 |
layers = newLayers; |
|
284 |
addLayer(newLayer, layers.length); |
|
280 | 285 |
} |
281 | 286 |
|
282 | 287 |
public void addLayer(ISymbol newLayer, int layerIndex) throws IndexOutOfBoundsException { |
... | ... | |
287 | 292 |
*/ |
288 | 293 |
if (layerIndex < 0 || layers.length < layerIndex) |
289 | 294 |
throw new IndexOutOfBoundsException(layerIndex+" < 0 or "+layerIndex+" > "+layers.length); |
290 |
ArrayList newLayers = new ArrayList();
|
|
295 |
ArrayList<ISymbol> newLayers = new ArrayList<ISymbol>();
|
|
291 | 296 |
for (int i = 0; i < layers.length; i++) { |
292 | 297 |
newLayers.add(layers[i]); |
293 | 298 |
} |
... | ... | |
299 | 304 |
|
300 | 305 |
int capacity = 0; |
301 | 306 |
capacity = layers.length; |
302 |
ArrayList lst = new ArrayList(capacity);
|
|
307 |
ArrayList<IFillSymbol> lst = new ArrayList<IFillSymbol>(capacity);
|
|
303 | 308 |
for (int i = 0; i < capacity; i++) { |
304 | 309 |
lst.add(layers[i]); |
305 | 310 |
} |
... | ... | |
307 | 312 |
layers = (IFillSymbol[])lst.toArray(new IFillSymbol[0]); |
308 | 313 |
return contains; |
309 | 314 |
} |
315 |
|
|
316 |
@Override |
|
317 |
public void setUnit(int unitIndex) { |
|
318 |
super.setUnit(unitIndex); |
|
319 |
for (int i = 0; i < layers.length; i++) { |
|
320 |
layers[i].setUnit(unitIndex); |
|
321 |
} |
|
322 |
} |
|
323 |
|
|
324 |
@Override |
|
325 |
public void setReferenceSystem(int system) { |
|
326 |
super.setReferenceSystem(system); |
|
327 |
for (int i = 0; i < layers.length; i++) { |
|
328 |
layers[i].setReferenceSystem(system); |
|
329 |
} |
|
330 |
} |
|
331 |
|
|
310 | 332 |
/** |
311 | 333 |
*Returns the transparency of the multi layer fill symbol created |
312 | 334 |
*/ |
... | ... | |
321 | 343 |
return (result>255) ? 255 : result; |
322 | 344 |
} |
323 | 345 |
|
346 |
|
|
347 |
public double toCartographicSize(ViewPort viewPort, double dpi, FShape shp) { |
|
348 |
double size = 0; |
|
349 |
for (int i = 0; i < layers.length; i++) { |
|
350 |
size = Math.max(size, layers[i].toCartographicSize(viewPort, dpi, shp)); |
|
351 |
} |
|
352 |
return size; |
|
353 |
} |
|
324 | 354 |
} |
Also available in: Unified diff