Revision 18621 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiLayerMarkerSymbol.java

View differences:

MultiLayerMarkerSymbol.java
98 98
import java.awt.Color;
99 99
import java.awt.Graphics2D;
100 100
import java.awt.Rectangle;
101
import java.awt.Shape;
102 101
import java.awt.geom.AffineTransform;
103 102
import java.awt.geom.Point2D;
104 103
import java.util.ArrayList;
......
106 105
import javax.print.attribute.PrintRequestAttributeSet;
107 106

  
108 107
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
108
import com.iver.cit.gvsig.fmap.ViewPort;
109 109
import com.iver.cit.gvsig.fmap.core.FShape;
110 110
import com.iver.cit.gvsig.fmap.core.IGeometry;
111 111
import com.iver.cit.gvsig.fmap.core.SymbologyFactory;
......
157 157
	}
158 158

  
159 159
	public void setSize(double size) {
160
		if (size > 0) {
160
		if (size > 0 && size != getSize()) {
161
			
161 162
			double scale = size / getSize();
162 163
			super.setSize(size);
163 164
			for (int i = 0; i < layers.length; i++) {
......
173 174
		}
174 175
	}
175 176

  
176
	public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r) {
177
	public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r) throws SymbolDrawingException {
177 178
		for (int i = 0; i < layers.length; i++) {
178 179
			layers[i].drawInsideRectangle(g, scaleInstance, r);
179 180
		}
......
184 185
		return layers[layers.length-1].getOnePointRgb();
185 186
	}
186 187

  
187
	public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform,
188
			Shape shp) {
189
		// TODO Implement it
190
		throw new Error("Not yet implemented!");
191

  
188
	public void getPixExtentPlus(FShape shp, float[] distances,
189
			ViewPort viewPort, int dpi) {
190
		float[] myDistances = new float[] {0,0};
191
		distances[0] = 0;
192
		distances[1] = 0;
193
		for (int i = 0; i < layers.length; i++) {
194
			layers[i].getPixExtentPlus(shp, myDistances, viewPort, dpi);
195
			distances[0] = Math.max(myDistances[0], distances[0]);
196
			distances[1] = Math.max(myDistances[1], distances[1]);
197
		}
192 198
	}
193 199

  
194 200
	public ISymbol getSymbolForSelection() {
195 201
		if (selectionSymbol == null) {
196 202
			selectionSymbol = new MultiLayerMarkerSymbol();
197 203
			selectionSymbol.setDescription(getDescription());
198
//			selectionSymbol.symbolType = symbolType;
199 204
			for (int i = 0; i < layers.length; i++) {
200 205
				selectionSymbol.addLayer(layers[i].getSymbolForSelection());
201 206
			}
......
276 281
	}
277 282

  
278 283
	public void addLayer(ISymbol newLayer) {
279
		if (newLayer == null) return;
284
		addLayer(newLayer, layers.length);
285
	}
286

  
287
	public void addLayer(ISymbol newLayer, int layerIndex) throws IndexOutOfBoundsException {
288
		if (newLayer == null )/*|| newLayer instanceof ILabelStyle)*/ return; // null or symbols that are styles are not allowed
289

  
280 290
		IMarkerSymbol newMarker = (IMarkerSymbol) newLayer;
281 291
		if (getLayerCount() == 0) {
282 292
			// apply the new layer properties to this multilayer
......
291 301
			newMarker.setReferenceSystem(getReferenceSystem());
292 302
			newMarker.setUnit(getUnit());
293 303
		}		
294
		
295 304
		selectionSymbol = null; /* forces the selection symbol to be re-created
296
								 * next time it is required
297
								 */
298
		int size = layers.length+1;
299
		IMarkerSymbol[] newLayers = new IMarkerSymbol[size];
300
		for (int i = 0; i < newLayers.length-1; i++) {
301
			newLayers[i] = layers[i];
302
		}
303
		newLayers[size-1] = (IMarkerSymbol) newLayer;
304
		layers = newLayers;
305
	}
306

  
307
	public void addLayer(ISymbol newLayer, int layerIndex) throws IndexOutOfBoundsException {
308
		if (newLayer == null )/*|| newLayer instanceof ILabelStyle)*/ return; // null or symbols that are styles are not allowed
309

  
310
		selectionSymbol = null; /* forces the selection symbol to be re-created
311 305
		 						 * next time it is required
312 306
		 						 */
313 307
		if (layerIndex < 0 || layers.length < layerIndex)
314 308
			throw new IndexOutOfBoundsException(layerIndex+" < 0 or "+layerIndex+" > "+layers.length);
315
		ArrayList newLayers = new ArrayList();
309
		ArrayList<ISymbol> newLayers = new ArrayList<ISymbol>();
316 310
		for (int i = 0; i < layers.length; i++) {
317 311
			newLayers.add(layers[i]);
318 312
		}

Also available in: Unified diff