Revision 11704 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrVect.java

View differences:

FLyrVect.java
46 46
import java.awt.geom.Rectangle2D;
47 47
import java.awt.image.BufferedImage;
48 48
import java.io.File;
49
import java.util.ArrayList;
49 50

  
50 51
import javax.print.attribute.PrintRequestAttributeSet;
51 52

  
......
63 64
import com.iver.cit.gvsig.exceptions.visitors.StartWriterVisitorException;
64 65
import com.iver.cit.gvsig.exceptions.visitors.VisitorException;
65 66
import com.iver.cit.gvsig.fmap.ViewPort;
67
import com.iver.cit.gvsig.fmap.core.IFeature;
66 68
import com.iver.cit.gvsig.fmap.core.IGeometry;
67 69
import com.iver.cit.gvsig.fmap.core.ILabelable;
70
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
68 71
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes;
72
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator;
69 73
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver;
70 74
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver;
71 75
import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend;
......
88 92
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy;
89 93
import com.iver.cit.gvsig.fmap.operations.strategies.StrategyManager;
90 94
import com.iver.cit.gvsig.fmap.rendering.ILegend;
95
import com.iver.cit.gvsig.fmap.rendering.IVectorialLegend;
91 96
import com.iver.cit.gvsig.fmap.rendering.LegendChangedEvent;
92 97
import com.iver.cit.gvsig.fmap.rendering.LegendFactory;
93 98
import com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend;
94
import com.iver.cit.gvsig.fmap.rendering.IVectorialLegend;
95 99
import com.iver.cit.gvsig.fmap.rendering.styling.AttrInTableLabeling;
96 100
import com.iver.cit.gvsig.fmap.rendering.styling.ILabelingStrategy;
97 101
import com.iver.cit.gvsig.fmap.rendering.styling.LabelingFactory;
......
284 288
			return rAux;
285 289
	}
286 290

  
291
	public void _draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
292
			Cancellable cancel, double scale) throws ReadDriverException {
293
// FEATURE ITERATORS
294
		if (isWithinScale(scale)) {
295
			// Las que solo tienen etiquetado sin pintar el shape,
296
			// no pasamos por ellas
297
			boolean bDrawShapes = true;
298
			if (legend instanceof SingleSymbolLegend) {
299
				if (legend.getDefaultSymbol().isShapeVisible() == false)
300
					bDrawShapes = false;
301
			}
302
			if (bDrawShapes) {
303
				try {
304
					prepareDrawing(image, g, viewPort);
305

  
306

  
307

  
308
					ArrayList fieldList = new ArrayList();
309

  
310
					// fields from legend
311
					String[] aux = legend.getUsedFields();
312
					for (int i = 0; i < aux.length; i++) {
313
						fieldList.add(aux[i]);
314
					}
315

  
316
					// fields from labeling
317
					if (isLabeled()) {
318
						aux = getLabelingStrategy().getUsedFields();
319
						for (int i = 0; i < aux.length; i++) {
320
							fieldList.add(aux[i]);
321
						}
322
					}
323

  
324
					IFeatureIterator it = getSource().getFeatureIterator(
325
							viewPort.getAdjustedExtent(),
326
							(String[]) fieldList.toArray(new String[fieldList.size()]),
327
							getProjection());
328

  
329
					while ( !cancel.isCanceled() && it.hasNext() ) {
330
						IFeature feat = it.next();
331
						ISymbol sym = legend.getSymbolByFeature(feat);
332
						IGeometry geom = feat.getGeometry();
333
						geom.drawInts(g, viewPort, sym);
334
					}
335

  
336
				} catch (ReadDriverException e) {
337
					this.setVisible(false);
338
					this.setActive(false);
339
					throw e;
340
				} catch (ExpansionFileReadException e) {
341
					this.setVisible(false);
342
					this.setActive(false);
343
//					throw new DriverException(e);
344
					// TODO throw a correct exception (??? ReadDriverException ???)
345
					e.printStackTrace();
346
				}
347
			}
348
			if (getVirtualLayers() != null) {
349
				getVirtualLayers().draw(image, g, viewPort, cancel, scale);
350
			}
351
		}
352
	}
287 353
	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
288 354
			Cancellable cancel, double scale) throws ReadDriverException {
289 355

  
......
649 715
	    	 * following allows restoring older projects' labelings.
650 716
	    	 */
651 717
			if (legendXML.contains("labelFieldName")) {
652
	    		AttrInTableLabeling labeling = new AttrInTableLabeling();
653
	    		labeling.setLayer(this);
654
	    		labeling.setTextField(legendXML.getStringProperty("labelFieldName"));
655
	    		labeling.setHeightField(legendXML.getStringProperty("labelHeightFieldName"));
656
	    		labeling.setRotationField(legendXML.getStringProperty("labelRotationFieldName"));
657
	    		this.setLabelingStrategy(labeling);
658
	    		this.setIsLabeled(true);
718
				String labelTextField = legendXML.getStringProperty("labelFieldName");
719
				if (labelTextField != null) {
720
					AttrInTableLabeling labeling = new AttrInTableLabeling();
721
					labeling.setLayer(this);
722
					labeling.setTextField(legendXML.getStringProperty("labelFieldName"));
723
					labeling.setHeightField(legendXML.getStringProperty("labelHeightFieldName"));
724
					labeling.setRotationField(legendXML.getStringProperty("labelRotationFieldName"));
725
					this.setLabelingStrategy(labeling);
726
					this.setIsLabeled(true);
727
				}
659 728
	      	}
660 729
	    	/* end patch */
661 730
			try {
......
703 772
			this.setAvailable(false);
704 773
			this.orgXMLEntity = xml;
705 774
		} catch (Exception e) {
775
			e.printStackTrace();
706 776
			this.setAvailable(false);
707 777
			this.orgXMLEntity = xml;
708 778

  
......
879 949
		}
880 950
		return sds;
881 951
	}
882
	
952

  
883 953
	public void setEditing(boolean b) throws StartEditionLayerException {
884 954
		super.setEditing(b);
885 955
		try {
......
903 973
				//references of projection and spatial index
904 974
				vea.setProjection(getProjection());
905 975
				vea.setSpatialIndex(spatialIndex);
906
				
907
				
976

  
977

  
908 978
				// /vea.setSpatialIndex(getSpatialIndex());
909 979
				// /vea.setFullExtent(getFullExtent());
910 980
				vea.startEdition(EditionEvent.GRAPHIC);

Also available in: Unified diff