Revision 23303

View differences:

branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/symbols/SimpleTextSymbol.java
50 50
import java.awt.font.FontRenderContext;
51 51
import java.awt.font.GlyphVector;
52 52
import java.awt.geom.AffineTransform;
53
import java.awt.geom.Point2D;
54 53
import java.awt.geom.Rectangle2D;
55 54

  
56 55
import javax.print.attribute.PrintRequestAttributeSet;
57 56
import javax.print.attribute.standard.PrintQuality;
58 57

  
59
import org.gvsig.fmap.data.ReadException;
58
import org.apache.log4j.Logger;
60 59
import org.gvsig.fmap.geom.Geometry;
61 60
import org.gvsig.fmap.geom.primitive.GeneralPathX;
62 61
import org.gvsig.fmap.geom.primitive.Surface2D;
......
82 81
			new AffineTransform(), false, true);
83 82
	private boolean autoresize;
84 83
	public void draw(Graphics2D g, AffineTransform affineTransform, Geometry geom, Cancellable cancel) {
85
		if (!isShapeVisible()) return;
84
		if (!isShapeVisible()) {
85
			return;
86
		}
86 87
		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
87 88
		g.setColor(textColor);
88 89
		g.setFont(font);
......
218 219
	}
219 220

  
220 221
	public void setFont(Font font) {
222
		if (font == null) {
223
			Logger.getLogger(this.getClass()).warn("font <-- null");
224

  
225
			return;
226
		}
221 227
		this.font = font;
222 228
	}
223 229

  
......
226 232
	}
227 233

  
228 234
	public void setFontSize(double size) {
229
		this.font = new Font(font.getName(), font.getStyle(), (int) size);
235
		Font newFont = new Font(font.getName(), font.getStyle(), (int) size);
236
		if (newFont == null) {
237
			Logger.getLogger(this.getClass()).warn(
238
					"Font(" + font.getName() + ", "
239
					+ font.getStyle() + ", " + (int) size + " --> null");
240
		} else {
241
			this.font = newFont;
242
		}
230 243
	}
231 244

  
232 245
	/**
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/VectorialUniqueValueLegend.java
42 42

  
43 43
import java.awt.Color;
44 44
import java.sql.Types;
45
import java.text.ParseException;
46 45
import java.util.ArrayList;
47 46
import java.util.Comparator;
48 47
import java.util.Iterator;
......
53 52
import org.gvsig.fmap.data.feature.Feature;
54 53
import org.gvsig.fmap.data.feature.FeatureStore;
55 54
import org.gvsig.fmap.data.feature.FeatureType;
56
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
57 55
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendClearEvent;
58 56
import org.gvsig.fmap.mapcontext.rendering.symbols.FSymbol;
59 57
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
......
78 76
			new Comparator() { //<Object>
79 77
		public int compare(Object o1, Object o2) {
80 78
			if ((o1 != null) && (o2 != null)) {
81
				Object v2 = (Object) o2;
82
				Object v1 = (Object) o1;
79
				Object v2 = o2;
80
				Object v1 = o1;
83 81
				Boolean boolVal;
84 82

  
85 83
				// TODO estas dos comprobaciones son por evitar un bug en el gdbms, cuando se solucione se puede eliminar.
......
195 193
        String[] descriptions = new String[symbols.size()];
196 194
        ISymbol[] auxSym = getSymbols();
197 195

  
198
        for (int i = 0; i < descriptions.length; i++)
199
            descriptions[i] = auxSym[i].getDescription();
196
        for (int i = 0; i < descriptions.length; i++) {
197
			descriptions[i] = auxSym[i].getDescription();
198
		}
200 199

  
201 200
        return descriptions;
202 201
    }
......
242 241

  
243 242
        }
244 243

  
245
        if (isUseDefaultSymbol())
246
        	return defaultSymbol;
244
        if (isUseDefaultSymbol()) {
245
			return defaultSymbol;
246
		}
247 247

  
248 248
        return null;
249 249
    }
......
270 270

  
271 271
        xml.putProperty("fieldTypes", getClassifyingFieldTypes()[0]);
272 272

  
273
        String[] strColors = new String[selectedColors.length];
274
		for (int i = 0; i < strColors.length; i++) {
275
			strColors[i] = StringUtilities.color2String(selectedColors[i]);
273
        if (selectedColors != null) {
274
			String[] strColors = new String[selectedColors.length];
275
			for (int i = 0; i < strColors.length; i++) {
276
				strColors[i] = StringUtilities.color2String(selectedColors[i]);
277
			}
278
			xml.putProperty("colorScheme", strColors);
276 279
		}
277
		xml.putProperty("colorScheme", strColors);
278 280

  
279 281
        xml.putProperty("labelfield", labelFieldName);
280 282
        xml.putProperty("labelFieldHeight", labelFieldHeight);
......
343 345

  
344 346
	public void setXMLEntity(XMLEntity xml) {
345 347
        clear();
346
        if (xml.contains("fieldName"))
347
        	setClassifyingFieldNames(new String[] {xml.getStringProperty("fieldName")});
348
        else
349
        	setClassifyingFieldNames(xml.getStringArrayProperty("fieldNames"));
348
        if (xml.contains("fieldName")) {
349
			setClassifyingFieldNames(new String[] {xml.getStringProperty("fieldName")});
350
		} else {
351
			setClassifyingFieldNames(xml.getStringArrayProperty("fieldNames"));
352
		}
350 353

  
351
        //TODO Falta ver de recuperar los tipos que ahroa son String
352
//        if (xml.contains("fieldTypes"))
353
//        	setClassifyingFieldTypes(new int[] {xml.getIntProperty("fieldTypes")});
354
        String[] strColors = xml.getStringArrayProperty("colorScheme");
354
        if (xml.contains("fieldTypes")) {
355
			setClassifyingFieldTypes(xml.getStringArrayProperty("fieldTypes"));
356
		}
357
        if (xml.contains("colorScheme")) {
358
			String[] strColors = xml.getStringArrayProperty("colorScheme");
355 359

  
356
		Color[] cc = new Color[strColors.length];
357
		for (int i = 0; i < cc.length; i++) {
358
			cc[i] = StringUtilities.string2Color(strColors[i]);
360
        	Color[] cc = new Color[strColors.length];
361
			for (int i = 0; i < cc.length; i++) {
362
				cc[i] = StringUtilities.string2Color(strColors[i]);
363
			}
364
			setColorScheme(cc);
359 365
		}
360
		setColorScheme(cc);
361 366
        useDefaultSymbol = xml.getBooleanProperty("useDefaultSymbol");
362 367
        setDefaultSymbol(SymbologyFactory.createSymbolFromXML(xml.getChild(0), null));
363 368

  
......
432 437
	public void setDefaultSymbol(ISymbol s) {
433 438
    	ISymbol mySymbol = defaultSymbol;
434 439

  
435
    	if (s == null)
436
    		throw new NullPointerException("Default symbol cannot be null");
440
    	if (s == null) {
441
			throw new NullPointerException("Default symbol cannot be null");
442
		}
437 443

  
438 444
    	ISymbol old = mySymbol;
439 445
    	defaultSymbol = s;
......
450 456
	 */
451 457
    private Object getValue(String s) {
452 458
        Object val = new NullUniqueValue();
453
        if (s.equals("Resto de Valores"))return val;
459
        if (s.equals("Resto de Valores")) {
460
			return val;
461
		}
454 462
//        try {
455 463
            try {
456 464
                val = new Integer(s);//(s, Types.INTEGER);
......
498 506
     */
499 507
    private Object getValue(String s,int type) {
500 508
    	Object val = new NullUniqueValue();
501
    	if (type==Types.OTHER)
502
    		return val;
509
    	if (type==Types.OTHER) {
510
			return val;
511
		}
503 512
    	switch (type) {
504 513
    	case Types.INTEGER:
505 514
    		val = new Integer(s);
......
530 539
     */
531 540
    public void setFeatureStore(FeatureStore fs) throws	ReadException {
532 541
		featureStore = fs;
533
		if (getClassifyingFieldNames()!=null)
542
		if (getClassifyingFieldNames()!=null) {
534 543
			fieldId = ((FeatureType)fs.getFeatureTypes().get(0)).getFieldIndex(getClassifyingFieldNames()[0]);
544
		}
535 545
	}
536 546

  
537 547
    /*
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/rendering/legend/styling/AttrInTableLabelingStrategy.java
12 12
import javax.print.attribute.PrintRequestAttributeSet;
13 13
import javax.print.attribute.standard.PrintQuality;
14 14

  
15
import org.gvsig.tools.exception.BaseException;
16 15
import org.gvsig.fmap.data.ReadException;
17 16
import org.gvsig.fmap.data.feature.Feature;
18 17
import org.gvsig.fmap.data.feature.FeatureCollection;
......
34 33
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport;
35 34
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupportToolkit;
36 35
import org.gvsig.fmap.mapcontext.rendering.symbols.SimpleTextSymbol;
36
import org.gvsig.tools.exception.BaseException;
37 37

  
38
import com.iver.utiles.StringUtilities;
38 39
import com.iver.utiles.XMLEntity;
39 40
import com.iver.utiles.swing.threads.Cancellable;
40 41

  
......
258 259
		} catch (ReadException e) {
259 260
			Logger.getAnonymousLogger().log(Level.SEVERE, "Acessing RotationField field.\n"+e.getMessage());
260 261
		}
261
		xml.putProperty("Font", getFont());
262
		if (getFont() != null) {
263
			xml.putProperty("fontName", getFont().getFontName());
264
			xml.putProperty("fontStyle", getFont().getStyle());
265
			xml.putProperty("fontSize", getFont().getFontName());
266
		}
262 267

  
263
		xml.putProperty("Color", getColorFont());
268
		if (getColorFont() != null) {
269
			xml.putProperty("color", StringUtilities
270
					.color2String(getColorFont()));
271
		}
264 272
		xml.putProperty("Unit", unit);
273

  
265 274
		return xml;
266 275

  
267 276
	}
......
331 340
		if (xml.contains("UnitFactor")) {
332 341
			setUnit(xml.getIntProperty("Unit"));
333 342
		}
334
		if (xml.contains("Font"))
335
			setUnit(xml.getIntProperty("Font"));
343
		if (xml.contains("fontName")) {
344
			Font newFont = new Font(xml.getStringProperty("fontName"), xml
345
					.getIntProperty("fontStyle"), xml
346
					.getIntProperty("fontSize"));
347
			setFont(newFont);
348
		}
336 349

  
337
		if (xml.contains("Color"))
338
			setUnit(xml.getIntProperty("Color"));
350
		if (xml.contains("color")) {
351
			Color newColor = StringUtilities.string2Color(xml
352
					.getStringProperty("color"));
353
			setColorFont(newColor);
354
		}
339 355
	}
340 356

  
341 357
	public void setTextField(String textFieldName) {
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/FLayers.java
57 57
import org.apache.log4j.Logger;
58 58
import org.cresques.cts.ICoordTrans;
59 59
import org.cresques.cts.IProjection;
60
import org.gvsig.tools.exception.BaseException;
61 60
import org.gvsig.fmap.data.ReadException;
62 61
import org.gvsig.fmap.geom.primitive.Envelope;
63 62
import org.gvsig.fmap.mapcontext.MapContext;
......
72 71
import org.gvsig.fmap.mapcontext.layers.operations.LayersVisitable;
73 72
import org.gvsig.fmap.mapcontext.layers.operations.LayersVisitor;
74 73
import org.gvsig.fmap.mapcontext.layers.operations.XMLItem;
74
import org.gvsig.tools.exception.BaseException;
75 75
import org.gvsig.tools.visitor.NotSupportedOperationException;
76 76
import org.gvsig.tools.visitor.Visitor;
77 77

  
......
981 981
		for (int i = 0; i < layers.size(); i++) {
982 982
			try {
983 983
				XMLEntity xmlLayer=((FLayer) layers.get(i)).getXMLEntity();
984
				xmlLayer.putProperty("tagName","layer"+i);
984
				xmlLayer.putProperty("tagName", "layer");
985 985
				xml.addChild(xmlLayer);
986 986
			}catch (XMLException e) {
987 987
				e.printStackTrace();
......
1018 1018
		// try {
1019 1019
		fmap.clearErrors();
1020 1020
		int numLayers=xml.getIntProperty("numLayers");
1021
		for (int i = 0; i < numLayers; i++) {
1022
			XMLEntity xmlLayer=xml.firstChild("tagName","layer"+i);
1021
		Iterator iter = xml.findChildren("tagName","layer");
1022
		XMLEntity xmlLayer;
1023
		while (iter.hasNext()) {
1024
			xmlLayer=(XMLEntity) iter.next();
1023 1025
			try {
1024
				this.addLayerFromXML(xmlLayer,s[i]);
1026
				this.addLayerFromXML(xmlLayer, null);
1025 1027
			} catch (LoadLayerException e) {
1026 1028
				throw new XMLLayerException(getName(),e);
1027 1029
			}
1028

  
1029

  
1030 1030
		}
1031
		if (numLayers != this.layers.size()) {
1032
			logger.warn(this.getName() + ": layer count no match");
1033
		}
1031 1034
	}
1032 1035
	/*
1033 1036
	 * (non-Javadoc)
......
1235 1238
	FLayer layer = null;
1236 1239

  
1237 1240
	try {
1238
		if (name == null) name = xml.getName();
1241
		if (name == null) {
1242
			name = xml.getName();
1243
		}
1239 1244

  
1240 1245

  
1241 1246
		String className = xml.getStringProperty("className");
......
1386 1391
		// Comprobar que la proyecci?n es la misma que la de FMap
1387 1392
		// Si no lo es, es una capa que est? reproyectada al vuelo
1388 1393
		IProjection proj = layer.getProjection();
1389
		if ((proj != null))
1394
		if ((proj != null)) {
1390 1395
			if (!proj.getFullCode().equals(getMapContext().getProjection().getFullCode()))
1391 1396
			{
1392 1397
				ICoordTrans ct = proj.getCT(getMapContext().getProjection());
......
1396 1401

  
1397 1402
				layer.setCoordTrans(ct);
1398 1403
			}
1404
		}
1399 1405
	} catch (XMLException e) {
1400 1406
		fmap.addLayerError(xml.getStringProperty("name"));
1401 1407
		throw new LoadLayerException(name,e);
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/vectorial/FLyrVect.java
55 55

  
56 56
import org.apache.log4j.Logger;
57 57
import org.cresques.cts.ICoordTrans;
58
import org.gvsig.tools.exception.BaseException;
59 58
import org.gvsig.fmap.data.DataManager;
60 59
import org.gvsig.fmap.data.DataStore;
61 60
import org.gvsig.fmap.data.ReadException;
......
107 106
import org.gvsig.fmap.mapcontext.rendering.symbols.FSymbol;
108 107
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol;
109 108
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
109
import org.gvsig.tools.exception.BaseException;
110 110

  
111 111
import com.iver.utiles.NotExistInXMLEntity;
112 112
import com.iver.utiles.XMLEntity;
......
266 266
			} catch (DataStoreOperationException e) {
267 267
				throw new LoadLayerException(this.getName(), e);
268 268
			}
269
			if (legend != null) {
270
				this.setLegend((IVectorLegend) legend);
271
			} else {
272
				try {
273
					this.setLegend(LegendFactory.createSingleSymbolLegend(this
274
							.getShapeType()));
275
				} catch (ReadException e) {
276
					throw new LoadLayerException(this.getName(), e);
277
				}
269 278

  
270
        	this.setLegend((IVectorLegend) legend);
279
			}
280

  
281

  
271 282
		} else {
272 283
			try {
273 284
				this.setLegend(LegendFactory.createSingleSymbolLegend(this
......
905 916
     */
906 917
    public int getShapeType() throws ReadException {
907 918
        if (typeShape == -1) {
908
            typeShape = ((FeatureType)((FeatureStore)getDataStore()).getDefaultFeatureType()).getGeometryTypes()[0];
919
            typeShape = (((FeatureStore)getDataStore()).getDefaultFeatureType()).getGeometryTypes()[0];
909 920
        }
910 921
        return typeShape;
911 922
    }
......
932 943
        xml.putProperty("isLabeled", isLabeled);
933 944
        if (strategy != null) {
934 945
            XMLEntity strategyXML = strategy.getXMLEntity();
935
            strategyXML.putProperty("tagName", "strategy");
946
            strategyXML.putProperty("tagName", "labelingStrategy");
936 947
            xml.addChild(strategy.getXMLEntity());
937 948
        }
938 949
        xml.addChild(getLinkProperties().getXMLEntity());
......
973 984
    				throw new XMLLegendException(e);
974 985
    			}
975 986
    		// set properties for ILabelable
976
    		XMLEntity labelingXML = xml.firstChild("id", "LabelingStrategy");
977
    		if (labelingXML!= null) {
978
    			isLabeled = true;
979
    			try {
980
    				this.strategy = LabelingFactory.createStrategyFromXML(labelingXML, this);
981
    			} catch (NotExistInXMLEntity neXMLEX) {
982
    				// no strategy was set, just continue;
983
    				logger.warn("Reached what should be unreachable code");
987

  
988
    		if (xml.contains("isLabeled")
989
					&& xml.getBooleanProperty(("isLabeled"))) {
990
    			XMLEntity labelingXML = xml.firstChild("tagName", "labelingStrategy");
991
    			if (labelingXML != null){
992

  
993
	    			isLabeled = true;
994
	    			try {
995
	    				this.strategy = LabelingFactory.createStrategyFromXML(labelingXML, this);
996
	    			} catch (NotExistInXMLEntity neXMLEX) {
997
	    				// no strategy was set, just continue;
998
	    				logger.warn("Reached what should be unreachable code");
999
	    			}
1000
    			} else {
1001
					isLabeled = false;
984 1002
    			}
985 1003
    		} else {
986 1004
    			isLabeled = false;
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/FLyrDefault.java
56 56
import org.apache.log4j.Logger;
57 57
import org.cresques.cts.ICoordTrans;
58 58
import org.cresques.cts.IProjection;
59
import org.gvsig.tools.exception.BaseException;
60 59
import org.gvsig.fmap.crs.CRSFactory;
61 60
import org.gvsig.fmap.data.ReadException;
62 61
import org.gvsig.fmap.mapcontext.MapContext;
......
66 65
import org.gvsig.fmap.mapcontext.layers.operations.ComposedLayer;
67 66
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendChangedEvent;
68 67
import org.gvsig.fmap.mapcontext.rendering.legend.events.listeners.LegendListener;
68
import org.gvsig.tools.exception.BaseException;
69 69

  
70 70
import com.iver.utiles.IPersistence;
71 71
import com.iver.utiles.XMLEntity;
......
346 346
		projection = proj;
347 347
		// Comprobar que la proyecci?n es la misma que la de FMap
348 348
		// Si no lo es, es una capa que est? reproyectada al vuelo
349
		if ((proj != null) && (getMapContext() != null))
349
		if ((proj != null) && (getMapContext() != null)) {
350 350
			if (proj != getMapContext().getProjection()) {
351 351
				ICoordTrans ct = proj.getCT(getMapContext().getProjection());
352 352
				setCoordTrans(ct);
......
354 354
						+ getMapContext().getProjection().getAbrev() + " y capa "
355 355
						+ getName() + " con " + proj.getAbrev());
356 356
			}
357
		}
357 358
	}
358 359

  
359 360
	/*
......
469 470
		Set keyset = properties.keySet();
470 471
		Iterator keyitr = keyset.iterator();
471 472
		XMLEntity xmlProperties = new XMLEntity();
472
		xmlProperties.putProperty("childName","properties");
473
		xmlProperties.putProperty("tagName", "properties");
473 474
		while (keyitr.hasNext()) {
474 475
			String propName = (String)keyitr.next();
475 476
			Object obj = properties.get(propName);
......
530 531
		if (xml.contains("proj")) {
531 532
			setProjection(CRSFactory.getCRS(xml.getStringProperty("proj")));
532 533
		}
533
		if (xml.contains("transparency"))
534
		if (xml.contains("transparency")) {
534 535
			transparency = xml.getIntProperty("transparency");
535
		if (xml.contains("isInTOC"))
536
		}
537
		if (xml.contains("isInTOC")) {
536 538
			status.inTOC = xml.getBooleanProperty("isInTOC");
539
		}
537 540

  
538 541
		// recreate Properties hashTable
539
		if (xml.contains("numProperties")) { // for older projects
540
			int numProps = xml.getIntProperty("numProperties");
541
			Object obj= null;
542
		int xmlPropertiesPos = xml.firstIndexOfChild("childName", "properties");
543
		XMLEntity xmlProperties = null;
544
		if (xmlPropertiesPos > -1) {
545
			xmlProperties = xml.getChild(xmlPropertiesPos);
546
		}
547

  
548
		if (xmlProperties != null) {
549

  
550
			int numProps = xmlProperties.getChildrenCount();
551
			Object obj;
552
			String className;
553
			Class classProp;
542 554
			IPersistence objPersist;
543 555
			for (int iProp=0; iProp<numProps; iProp++) {
544
				XMLEntity xmlProp = xml.getChild(0);
556
				XMLEntity xmlProp = xmlProperties.getChild(iProp);
545 557
				try {
546
					String className = xmlProp.getStringProperty("className");
558
					className = xmlProp.getStringProperty("className");
547 559
					if (className.equals(String.class.getName())) {
548 560
						obj = xmlProp.getStringProperty("value");
549 561
					} else {
550
						Class classProp = Class.forName(className);
562
						classProp = Class.forName(className);
551 563
						obj = classProp.newInstance();
552 564
						objPersist = (IPersistence)obj;
553 565
						objPersist.setXMLEntity(xmlProp);
566

  
554 567
					}
555 568
					String propName = xmlProp.getStringProperty("layerPropertyName");
556 569
					properties.put(propName, obj);
557 570
				} catch (Exception e) {
571
					logger.error("Layer:" + this.getName()
572
							+ ": Error loading properties", e);
558 573
					continue;
559 574
				}
560
				// remove Properties children to avoid breaking layers' XML reading logic
561
				xml.removeChild(0);
562 575
			}
563
		}          // newer projects store properties under a node
564
		else {
565
			int xmlPropertiesPos = xml.firstIndexOfChild("childName","properties");
566
			XMLEntity xmlProperties =null;
567
			if (xmlPropertiesPos > -1)
568
				xmlProperties = xml.getChild(xmlPropertiesPos);
569

  
570
			if (xmlProperties != null) {
571

  
572
				int numProps = xmlProperties.getChildrenCount();
573
				Object obj;
574
				String className;
575
				Class classProp;
576
				IPersistence objPersist;
577
				for (int iProp=0; iProp<numProps; iProp++) {
578
					XMLEntity xmlProp = xmlProperties.getChild(iProp);
579
					try {
580
						className = xmlProp.getStringProperty("className");
581
						if (className.equals(String.class.getName())) {
582
							obj = xmlProp.getStringProperty("value");
583
						} else {
584
							classProp = Class.forName(className);
585
							obj = classProp.newInstance();
586
							objPersist = (IPersistence)obj;
587
							objPersist.setXMLEntity(xmlProp);
588

  
589
						}
590
						String propName = xmlProp.getStringProperty("layerPropertyName");
591
						properties.put(propName, obj);
592
					} catch (Exception e) {
593
						//FIXME: OJO !!!!!
594
						continue;
595
					}
596
				}
597
				// remove Properties children to avoid breaking layers' XML reading logic
598
				xml.removeChild(xmlPropertiesPos);
599
			}
600 576
		}
601 577
	}
602 578

  
......
617 593
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#addLayerListener(com.iver.cit.gvsig.fmap.layers.LayerListener)
618 594
	 */
619 595
	public boolean addLayerListener(LayerListener o) {
620
		if (layerListeners.contains(o))
596
		if (layerListeners.contains(o)) {
621 597
			return false;
598
		}
622 599
		return layerListeners.add(o);
623 600
	}
624 601
	/*
......
771 748

  
772 749
		boolean bVisible = true;
773 750
		if (getMinScale() != -1) {
774
			if (scale < getMinScale())
751
			if (scale < getMinScale()) {
775 752
				bVisible = false;
753
			}
776 754
		}
777 755
		if (getMaxScale() != -1) {
778
			if (scale > getMaxScale())
756
			if (scale > getMaxScale()) {
779 757
				bVisible = false;
758
			}
780 759
		}
781 760

  
782 761
		return bVisible;
......
848 827
	 */
849 828
	public void setCachingDrawnLayers(boolean bCacheDrawnLayers) {
850 829
		status.cacheDrawnLayers = bCacheDrawnLayers;
851
		if (status.cacheDrawnLayers == false)
830
		if (status.cacheDrawnLayers == false) {
852 831
			this.cacheImageDrawnLayers = null;
832
		}
853 833
	}
854 834
	/*
855 835
	 * (non-Javadoc)
......
1048 1028
	 */
1049 1029
	protected void callLegendChanged(LegendChangedEvent e) {
1050 1030
		layerChangeSupport.callLegendChanged(e);
1051
		if(parentLayer != null)
1031
		if(parentLayer != null) {
1052 1032
			parentLayer.callLegendChanged(e);
1033
		}
1053 1034
	}
1054 1035

  
1055 1036
	/**
branches/v2_0_0_prep/libraries/libFMap_mapcontext/.classpath
30 30
	<classpathentry kind="lib" path="lib/gt2-legacy.jar"/>
31 31
	<classpathentry kind="lib" path="lib/gt2-main.jar"/>
32 32
	<classpathentry kind="lib" path="lib/units-0.01.jar"/>
33
	<classpathentry kind="lib" path="lib/iver-utiles.jar"/>
33
	<classpathentry kind="lib" path="lib/iver-utiles.jar" sourcepath="/libIverUtiles"/>
34 34
	<classpathentry kind="lib" path="lib/log4j-1.2.8.jar"/>
35 35
	<classpathentry kind="lib" path="lib/castor-0.9.5.3-xml.jar"/>
36 36
	<classpathentry kind="lib" path="lib-references/org.gvsig.tools.jar"/>
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/DefaultFeatureType.java
185 185

  
186 186
	public boolean add(Object arg0) {
187 187
		((AttributeDescriptor)arg0).setOrdinal(count);
188
		((AttributeDescriptor) arg0).setFeatureType(this);
188 189
		count++;
189 190
		return super.add(arg0);
190 191
	}
191 192

  
192 193
	protected boolean addWithoutOrdinal(Object arg0) {
194
		((AttributeDescriptor) arg0).setFeatureType(this);
193 195
		int max=((FeatureAttributeDescriptor)arg0).ordinal();
194 196
		if (count<=max){
195 197
			count=max+1;
......
273 275
	}
274 276
	public FeatureType getSubFeatureType(String[] fields) throws DataException {
275 277
		DefaultFeatureType featureType=(DefaultFeatureType)this.cloneFeatureType();
276
		ArrayList toRemove = new ArrayList();
277
		Iterator iter = this.iterator();
278
		int index=-1;
279
		int i=0;
280
		String name;
281
		boolean found;
282
		for(i=0;i<fields.length;i++){
283
			index=this.getFieldIndex(fields[i]);
284
			if (index<0){
285
				throw new DataException("Field '"+fields[i]+"' not found");
278

  
279
		if (fields != null) {
280
			ArrayList toRemove = new ArrayList();
281
			Iterator iter = this.iterator();
282
			int index = -1;
283
			int i = 0;
284
			String name;
285
			boolean found;
286
			for (i = 0; i < fields.length; i++) {
287
				index = this.getFieldIndex(fields[i]);
288
				if (index < 0) {
289
					throw new DataException("Field '" + fields[i]
290
							+ "' not found");
291
				}
286 292
			}
287
		}
288
		while (iter.hasNext()){
289
			name = ((AttributeDescriptor)iter.next()).getName();
290
			found=false;
291
			for (i=0;i<fields.length;i++){
292
				if (name.equals(fields[i])){
293
					found=true;
294
					break;
293
			while (iter.hasNext()) {
294
				name = ((AttributeDescriptor) iter.next()).getName();
295
				found = false;
296
				for (i = 0; i < fields.length; i++) {
297
					if (name.equals(fields[i])) {
298
						found = true;
299
						break;
300
					}
295 301
				}
302
				if (!found) {
303
					index = this.getFieldIndex(name);
304
					toRemove.add(new Integer(index));
305
				}
306

  
296 307
			}
297
			if (!found){
298
				index=this.getFieldIndex(name);
299
				toRemove.add(new Integer(index));
308
			for (i = toRemove.size() - 1; i >= 0; i--) {
309
				featureType.remove(((Integer) toRemove.get(i)).intValue());
300 310
			}
301

  
302 311
		}
303
		for (i=toRemove.size()-1;i>=0;i--){
304
			featureType.remove(((Integer)toRemove.get(i)).intValue());
305
		}
306 312

  
307 313
		return featureType;
308 314
	}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/operation/LegendLabelingManager.java
1 1
package org.gvsig.fmap.data.feature.operation;
2 2

  
3
import java.util.Map;
4

  
3 5
import org.gvsig.fmap.data.DataException;
4 6
import org.gvsig.fmap.data.feature.Feature;
5 7

  
6 8
public interface LegendLabelingManager {
7 9

  
8
	public void add(Feature feature) throws DataException;
10
	public void startLoading(Map params);
9 11

  
12
	public void add(Feature feature, Map params) throws DataException;
13

  
10 14
	public Object getDefaultLegend();
11 15

  
12 16
	public Object getLabeling();
17

  
18
	public void endLoading();
13 19
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/AbstractFeatureStore.java
5 5
import java.util.Iterator;
6 6
import java.util.List;
7 7

  
8
import org.gvsig.tools.exception.BaseException;
9 8
import org.gvsig.fmap.data.CloseException;
10 9
import org.gvsig.fmap.data.DataCollection;
11 10
import org.gvsig.fmap.data.DataException;
......
34 33
import org.gvsig.fmap.data.operation.DataStoreOperationNotSupportedException;
35 34
import org.gvsig.fmap.geom.Geometry;
36 35
import org.gvsig.fmap.geom.primitive.Envelope;
36
import org.gvsig.tools.exception.BaseException;
37 37
import org.gvsig.tools.observer.ComplexNotification;
38 38
import org.gvsig.tools.observer.DefaultObservable;
39 39
import org.gvsig.tools.observer.Observable;
......
898 898
		return this.getClass().getName();
899 899
	}
900 900

  
901
	protected FeatureType checkFeatureTypeForCollection(FeatureType fType)
902
			throws DataException {
903
		FeatureType defType = this.getDefaultFeatureType();
904
		if (fType == null || fType.equals(defType)) {
905
			//TODO we must return a copy of Ftype but there are probles with
906
			// weakRefs of Ftype of Attributes in edition mode
907
			//			return defType.getSubFeatureType(null);
908
			return defType;
909
		}
910
		if (fType.isSubtypeOf(defType)) {
911
			return fType;
912
		}
913
		Iterator iter = this.getFeatureTypes().iterator();
914
		FeatureType tmpType;
915
		while (iter.hasNext()) {
916
			tmpType = (FeatureType) iter.next();
917
			if (fType.isSubtypeOf(tmpType)) {
918
				return fType;
919
			}
920

  
921
		}
922
		throw new ReadException("invalid type", this.getName());
923
	}
901 924
}
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/joinstore/JoinFeatureStore.java
38 38
import java.util.List;
39 39
import java.util.Map;
40 40

  
41
import org.gvsig.tools.exception.BaseException;
42 41
import org.gvsig.fmap.data.CloseException;
43 42
import org.gvsig.fmap.data.DataCollection;
44 43
import org.gvsig.fmap.data.DataException;
......
58 57
import org.gvsig.fmap.data.feature.IsNotAttributeSettingException;
59 58
import org.gvsig.fmap.data.index.IndexException;
60 59
import org.gvsig.metadata.IMetadata;
60
import org.gvsig.tools.exception.BaseException;
61 61
import org.gvsig.tools.observer.Observable;
62 62
import org.gvsig.tools.observer.Observer;
63 63

  
......
101 101
		//		JoinFeatureCollection complexDataCollection=new JoinFeatureCollection(this,type,filter,order);
102 102
		//		return complexDataCollection;
103 103
		this.checkChanged();
104
		if (type == null) {
105
			type = this.defaultFeatureType;
106
		} else if (!(type instanceof JoinFeatureType)) {
104

  
105
		try {
106
			type = this.checkFeatureTypeForCollection(type);
107
		} catch (DataException e) {
108
			throw new ReadException(this.getName(), e);
109
		}
110

  
111
		if (!(type instanceof JoinFeatureType)) {
107 112
			throw new ReadException("incompatible types", this.getName());
108
		} else if (!(type.isSubtypeOf(this.defaultFeatureType))) {
109
			throw new ReadException("incompatible types", this.getName());
110 113
		}
111 114

  
112 115
		FeatureCollection coll;
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/AttributeManager.java
166 166
			while (iter.hasNext()) {
167 167
				FeatureAttributeDescriptor descriptor= (FeatureAttributeDescriptor) iter.next();
168 168
				if (!deletedAttributes.contains(new Integer(descriptor.ordinal()))){
169
					dft.addWithoutOrdinal(descriptor);
169
					dft.addWithoutOrdinal(descriptor.cloneAttribute());
170 170
				}
171 171
			}
172 172
			for (int i=0;i<relations.size();i++){
173 173
				FeatureAttributeDescriptor descriptor=(FeatureAttributeDescriptor)expansionAdapter.getObject(i);
174 174
				if (!deletedAttributes.contains(new Integer(descriptor.ordinal()))){
175
					dft.addWithoutOrdinal(descriptor);
175
					dft.addWithoutOrdinal(descriptor.cloneAttribute());
176 176
				}
177 177
			}
178 178
			this.currentFeatureType=dft;
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/AttributeDescriptor.java
78 78
	private int originalPosition=-1;
79 79
	private boolean isNew=false;
80 80
	private Class objectClass;
81
	private WeakReference wfFeatureType=null;
81
	private WeakReference wfFeatureType;
82 82

  
83 83
	protected AttributeDescriptor(FeatureType featureType) {
84 84
		this.wfFeatureType = new WeakReference(featureType);
......
92 92

  
93 93
	protected FeatureType getFeatureType(){
94 94
		if (this.wfFeatureType == null){
95
			return null;
95
			throw new RuntimeException();
96
			//			return null;
96 97
		}
97
		return (FeatureType) this.wfFeatureType.get();
98
		FeatureType ftype = (FeatureType) this.wfFeatureType.get();
99
		if (ftype == null) {
100
			throw new RuntimeException();
101
		}
102
		return ftype;
98 103
	}
99 104

  
100 105
	public boolean isFromFeatureType(FeatureType featureType){
......
380 385
	    newFD.srs = this.srs;
381 386
	    newFD.allowNull = this.allowNull;
382 387
	    newFD.evaluator = this.evaluator;
388
	    newFD.expression = this.expression;
389
		newFD.evaluated = this.evaluated;
390
		newFD.readOnly = this.readOnly;
391
		newFD.objectClass = this.objectClass;
392
		newFD.originalPosition = this.originalPosition;
383 393
	}
384 394

  
385 395
	public void loadFrom(FeatureAttributeDescriptor otherFAD) {
......
548 558
		return this.getName() + "{" + this.getDataType() + "}";
549 559
	}
550 560

  
561
	protected void setFeatureType(DefaultFeatureType defaultFeatureType) {
562
		// FIXME
563
		//		this.wfFeatureType = new WeakReference(featureType);
564
	}
551 565

  
566

  
552 567
}
branches/v2_0_0_prep/libraries/libFMap_dataFile/src-test/org/gvsig/fmap/data/feature/file/DataStoreTest.java
6 6
import junit.framework.TestCase;
7 7

  
8 8
import org.cresques.cts.IProjection;
9
import org.gvsig.tools.exception.BaseException;
10 9
import org.gvsig.fmap.crs.CRSFactory;
11 10
import org.gvsig.fmap.data.CloseException;
12 11
import org.gvsig.fmap.data.DataCollection;
......
38 37
import org.gvsig.fmap.data.feature.visitor.PrintlnFeaturesVisitor;
39 38
import org.gvsig.fmap.geom.Geometry;
40 39
import org.gvsig.fmap.geom.handler.Handler;
40
import org.gvsig.tools.exception.BaseException;
41 41
import org.gvsig.tools.observer.Observer;
42 42

  
43 43
import com.iver.utiles.XMLEntity;
......
975 975
			String order, boolean testEdit) {
976 976
		DataManager dsm = DataManager.getManager();
977 977

  
978

  
978 979
		//		DataStoreParameters dsp=dsm.createDataStoreParameters(DriverStore.DATASTORE_NAME);
979 980

  
980 981
		//		((IDriverStoreParameters)dsp).setDriverParameters(dp);
......
1476 1477
		}
1477 1478

  
1478 1479
	}
1480

  
1481
	public void cloneFeatureTypeTest() {
1482

  
1483
		org.gvsig.fmap.data.feature.file.dbf.Register.selfRegister();
1484

  
1485
		DataManager dsm = DataManager.getManager();
1486

  
1487
		DataStoreParameters dp;
1488
		try {
1489
			dp = dsm.createDataStoreParameters(DBFStore.DATASTORE_NAME);
1490
		} catch (InitializeException e1) {
1491
			e1.printStackTrace();
1492
			fail();
1493
			return;
1494
		}
1495
		((DBFStoreParameters) dp).setFile(dbffile);
1496

  
1497
		FeatureStore fs = null;
1498
		try {
1499
			fs = (FeatureStore) dsm.createDataStore(dp);
1500
		} catch (InitializeException e) {
1501
			e.printStackTrace();
1502
			fail("Exception:" + e);
1503
			return;
1504
		}
1505
		assertNotNull("Can't create Feature Store", fs);
1506

  
1507
		compareFeatureType(fs.getDefaultFeatureType(), fs
1508
				.getDefaultFeatureType()
1509
				.cloneFeatureType());
1510

  
1511
		FeatureCollection fc = null;
1512

  
1513
		try {
1514
			fc = (FeatureCollection) fs.getDataCollection();
1515
		} catch (ReadException e1) {
1516
			e1.printStackTrace();
1517
			fail();
1518
			return;
1519
		}
1520

  
1521

  
1522
		compareFeatureType(fs.getDefaultFeatureType(), fc.getFeatureType());
1523

  
1524

  
1525

  
1526
		fc.dispose();
1527

  
1528
		try {
1529
			fs.addEvaluatedAttribute(null, "eva1",
1530
					FeatureAttributeDescriptor.TYPE_STRING, "lower(' ')", null);
1531
		} catch (ReadException e1) {
1532
			e1.printStackTrace();
1533
			fail();
1534
			return;
1535
		}
1536

  
1537

  
1538
		compareFeatureType(fs.getDefaultFeatureType(), fs
1539
				.getDefaultFeatureType().cloneFeatureType());
1540

  
1541
		try {
1542
			fs.dispose();
1543
		} catch (CloseException e) {
1544
			e.printStackTrace();
1545
			fail();
1546
			return;
1547
		}
1548
	}
1549

  
1550
	private void compareFeatureType(FeatureType original, FeatureType copy) {
1551
		AttributeDescriptor attr1, attr2;
1552

  
1553
		assertEquals(original.size(), copy.size());
1554
		assertEquals(original.getDefaultGeometry(), copy.getDefaultGeometry());
1555

  
1556
		int i = 0;
1557

  
1558
		for (i = 0; i < original.size(); i++) {
1559
			attr1 = (AttributeDescriptor) original.get(i);
1560
			attr2 = (AttributeDescriptor) copy.get(i);
1561

  
1562
			assertEquals(attr1.getName(), attr2.getName());
1563
			assertEquals(attr1.getDataType(), attr2.getDataType());
1564
			assertEquals(attr1.getDefaultValue(), attr2.getDefaultValue());
1565
			assertEquals(attr1.ordinal(), attr2.ordinal());
1566
			assertEquals(attr1.originalPosition(), attr2.originalPosition());
1567
			assertEquals(attr1.isEvaluated(), attr2.isEvaluated());
1568
			assertEquals(attr1.getGeometryType(), attr2.getGeometryType());
1569
			assertEquals(attr1.getSize(), attr2.getSize());
1570
			assertEquals(attr1.getSRS(), attr2.getSRS());
1571
			assertEquals(attr1.getPrecision(), attr2.getPrecision());
1572
			assertEquals(attr1.getExpression(), attr2.getExpression());
1573
			assertEquals(attr1.isAllowNull(), attr2.isAllowNull());
1574
			assertEquals(attr1.isPrimaryKey(), attr2.isPrimaryKey());
1575
			assertEquals(attr1.isReadOnly(), attr2.isReadOnly());
1576
		}
1577

  
1578
	}
1479 1579
}
branches/v2_0_0_prep/libraries/libFMap_dataFile/src/org/gvsig/fmap/data/feature/file/dgn/DGNResource.java
32 32

  
33 33
import java.awt.geom.AffineTransform;
34 34
import java.awt.geom.Arc2D;
35
import java.util.HashMap;
36
import java.util.Map;
35 37

  
36 38
import org.gvsig.fmap.data.DataException;
37 39
import org.gvsig.fmap.data.OpenException;
38 40
import org.gvsig.fmap.data.ReadException;
39 41
import org.gvsig.fmap.data.feature.Feature;
40
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
41 42
import org.gvsig.fmap.data.feature.FeatureType;
42 43
import org.gvsig.fmap.data.feature.IsNotFeatureSettingException;
43 44
import org.gvsig.fmap.data.feature.file.FileMemoryResource;
......
49 50
import org.gvsig.fmap.data.feature.file.dgn.utils.DGNElemText;
50 51
import org.gvsig.fmap.data.feature.file.dgn.utils.DGNFileHeader;
51 52
import org.gvsig.fmap.data.feature.file.dgn.utils.DGNReader;
53
import org.gvsig.fmap.data.feature.operation.LegendLabelingManager;
54
import org.gvsig.fmap.data.feature.operation.LegendLabelingManagerFactory;
52 55
import org.gvsig.fmap.geom.Geometry;
53 56
import org.gvsig.fmap.geom.GeometryFactory;
54 57
import org.gvsig.fmap.geom.GeometryManager;
55 58
import org.gvsig.fmap.geom.primitive.Envelope;
56 59
import org.gvsig.fmap.geom.primitive.GeneralPathX;
57
import org.gvsig.fmap.mapcontext.rendering.legend.LegendFactory;
58
import org.gvsig.fmap.mapcontext.rendering.legend.VectorialUniqueValueLegend;
59
import org.gvsig.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy;
60
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
61
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory;
62 60

  
63 61
/**
64 62
 * @author jmvivo
65 63
 *
66 64
 */
67 65
public class DGNResource extends FileMemoryResource {
66
	private static LegendLabelingManagerFactory legendLabelingManagerFactory = null;
68 67

  
68
	public static final int ID_FIELD_ID = 0;
69
	public static final int ID_FIELD_ENTITY = 1;
70
	public static final int ID_FIELD_LAYER = 2;
71
	public static final int ID_FIELD_COLOR = 3;
72
	public static final int ID_FIELD_HEIGHTTEXT = 4;
73
	public static final int ID_FIELD_ROTATIONTEXT = 5;
74
	public static final int ID_FIELD_TEXT = 6;
75
	public static final int ID_FIELD_GEOMETRY = 7;
69 76

  
70
	private final int ID_FIELD_ID = 0;
71
	private final int ID_FIELD_ENTITY = 1;
72
	private final int ID_FIELD_LAYER = 2;
73
	private final int ID_FIELD_COLOR = 3;
74
	private final int ID_FIELD_HEIGHTTEXT = 4;
75
	private final int ID_FIELD_ROTATIONTEXT = 5;
76
	private final int ID_FIELD_TEXT = 6;
77
	private final int ID_FIELD_GEOMETRY = 7;
78 77

  
79

  
80 78
	private FeatureType featureType;
81 79

  
82
	private AttrInTableLabelingStrategy labeling;
83
	private VectorialUniqueValueLegend defaultLegend;
80
	private LegendLabelingManager legendlabelingManager;
84 81

  
85 82
	/**
86 83
	 * @param params
......
114 111
		} catch (ReadException e) {
115 112
			throw new OpenException(this.description(),e);
116 113
		}
114
		if (legendLabelingManagerFactory != null) {
115
			legendlabelingManager = legendLabelingManagerFactory.newManager();
116
			Map params = new HashMap();
117
			params.put("reader", m_DgnReader);
118
			legendlabelingManager.startLoading(params);
119
		} else {
120
			legendlabelingManager = null;
121
		}
117 122

  
118 123
		try{
119 124
//			Value[] auxRow = new Value[7];
......
137 142

  
138 143
//			getTableModel().setColumnIdentifiers(arrayFields.toArray());
139 144

  
140
			// jaume
141
			labeling = new AttrInTableLabelingStrategy();
142
			(labeling).setTextFieldId(featureType.getFieldIndex("Text"));
143
			(labeling).setRotationFieldId(featureType.getFieldIndex("RotationText"));
144
			(labeling).setHeightFieldId(featureType.getFieldIndex("HeightText"));
145
			(labeling).setUnit(1); //MapContext.NAMES[1] (meters)
146 145

  
147

  
148 146
			// Ahora las rellenamos.
149 147
//			FShape aux;
150 148
			boolean bElementoCompuesto = false;
......
166 164
				DGNElemCore elemento = m_DgnReader.DGNReadElement();
167 165
				nClass = 0;
168 166
//				auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0);
167
				auxFeature.set(ID_FIELD_HEIGHTTEXT, 0);
169 168
//				auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0);
169
				auxFeature.set(ID_FIELD_ROTATIONTEXT, 0);
170 170
//				auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue();
171
				auxFeature.set(ID_FIELD_TEXT, null);
171 172

  
172 173
				if (elemento.properties != 0) {
173 174
					nClass = elemento.properties & DGNFileHeader.DGNPF_CLASS;
......
595 596
					addDGNFeature(auxFeature);
596 597
//					addShape(new FPolygon2D(elementoCompuesto), auxRow);
597 598
				}
599

  
598 600
			}
599 601
			cellFeature.stopLoading();
600 602
			auxFeature.stopLoading();
601 603
			complexFeature.stopLoading();
602
			defaultLegend = LegendFactory.createVectorialUniqueValueLegend(Geometry.TYPES.GEOMETRY);
603
			defaultLegend.setClassifyingFieldNames(new String[] {"Color"} );
604
			defaultLegend.setClassifyingFieldTypes(new String[]{FeatureAttributeDescriptor.TYPE_INT,FeatureAttributeDescriptor.TYPE_STRING,FeatureAttributeDescriptor.TYPE_INT,FeatureAttributeDescriptor.TYPE_INT,FeatureAttributeDescriptor.TYPE_FLOAT,FeatureAttributeDescriptor.TYPE_DOUBLE,FeatureAttributeDescriptor.TYPE_STRING});
605 604

  
606

  
607
			ISymbol myDefaultSymbol = SymbologyFactory.
608
			createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY);
609

  
610
			defaultLegend.setDefaultSymbol(myDefaultSymbol);
611 605
		}catch (IsNotFeatureSettingException e) {
612 606
			throw new OpenException(this.description(),e);
613 607
		} catch (ReadException e) {
614 608
			throw new OpenException(this.description(),e);
615 609
		}
616 610

  
611
		if (legendlabelingManager != null) {
612
			legendlabelingManager.endLoading();
613
		}
617 614
//		ISymbol theSymbol = null;
618 615

  
619 616
//		try {
......
660 657
	}
661 658

  
662 659
	private void addDGNFeature(Feature feature) throws DataException{
663
		this.addFeature(new DGNFeature(feature));
660
		DGNFeature newFeature = new DGNFeature(feature);
661
		this.addFeature(newFeature);
662
		if (this.legendlabelingManager != null) {
663
			this.legendlabelingManager.add(newFeature, null);
664
		}
664 665
	}
665 666

  
666 667

  
......
682 683
	 */
683 684
	protected Object getDefaultLegend() throws ReadException {
684 685
		this.checkOpen();
685
		return this.defaultLegend;
686
		if (this.legendlabelingManager == null) {
687
			return null;
688
		}
689
		return this.legendlabelingManager.getDefaultLegend();
686 690
	}
687 691

  
688 692
	/* (non-Javadoc)
......
706 710
		return super.getFeature(index);
707 711
	}
708 712

  
709
	protected AttrInTableLabelingStrategy getDefaultLabelingStrategy()  throws ReadException {
713
	protected Object getDefaultLabelingStrategy() throws ReadException {
710 714
		this.checkOpen();
711
		return labeling;
715

  
716
		if (this.legendlabelingManager == null) {
717
			return null;
718
		}
719
		return this.legendlabelingManager.getLabeling();
712 720
	}
713 721

  
722
	public static void setLegendLabelingManagerFactory(
723
			LegendLabelingManagerFactory factory) {
724
		legendLabelingManagerFactory = factory;
725
	}
726

  
727
	public static LegendLabelingManagerFactory getLegendLabelingManagerFactory() {
728
		return legendLabelingManagerFactory;
729
	}
730

  
714 731
}
715 732

  
branches/v2_0_0_prep/libraries/libFMap_dataFile/src/org/gvsig/fmap/data/feature/file/dgn/operation/DGNLegendLabelingManager.java
1
package org.gvsig.fmap.data.feature.file.dgn.operation;
2

  
3
import java.awt.Color;
4
import java.util.ArrayList;
5
import java.util.Map;
6

  
7
import org.gvsig.fmap.data.DataException;
8
import org.gvsig.fmap.data.feature.Feature;
9
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
10
import org.gvsig.fmap.data.feature.file.dgn.DGNResource;
11
import org.gvsig.fmap.data.feature.file.dgn.utils.DGNReader;
12
import org.gvsig.fmap.data.feature.operation.LegendLabelingManager;
13
import org.gvsig.fmap.geom.Geometry;
14
import org.gvsig.fmap.mapcontext.rendering.legend.LegendFactory;
15
import org.gvsig.fmap.mapcontext.rendering.legend.VectorialUniqueValueLegend;
16
import org.gvsig.fmap.mapcontext.rendering.legend.styling.AttrInTableLabelingStrategy;
17
import org.gvsig.fmap.mapcontext.rendering.symbols.IFillSymbol;
18
import org.gvsig.fmap.mapcontext.rendering.symbols.ILineSymbol;
19
import org.gvsig.fmap.mapcontext.rendering.symbols.IMarkerSymbol;
20
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
21
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory;
22

  
23
public class DGNLegendLabelingManager implements LegendLabelingManager {
24
	private AttrInTableLabelingStrategy labeling;
25
	private VectorialUniqueValueLegend defaultLegend;
26
	private ArrayList colors;
27
	private DGNReader m_DgnReader;
28

  
29
	protected DGNLegendLabelingManager(){
30
		// Legend
31
		defaultLegend = LegendFactory.createVectorialUniqueValueLegend(Geometry.TYPES.GEOMETRY);
32
		defaultLegend.setClassifyingFieldNames(new String[] {"Color"});
33

  
34
		defaultLegend.setClassifyingFieldTypes(new String[]{FeatureAttributeDescriptor.TYPE_INT});
35
		ISymbol myDefaultSymbol = SymbologyFactory.createDefaultSymbolByShapeType(Geometry.TYPES.GEOMETRY, Color.BLACK);
36
		defaultLegend.setDefaultSymbol(myDefaultSymbol);
37
		colors = new ArrayList();
38

  
39
		labeling = new AttrInTableLabelingStrategy();
40
		labeling.setTextFieldId(DGNResource.ID_FIELD_TEXT);
41
		labeling.setRotationFieldId(DGNResource.ID_FIELD_ROTATIONTEXT);
42
		labeling.setHeightFieldId(DGNResource.ID_FIELD_HEIGHTTEXT);
43
		labeling.setUnit(1); //MapContext.NAMES[1] (meters)
44
	}
45

  
46
	public void add(Feature feature, Map params) throws DataException {
47
		// Legend
48
		Integer curColor = (Integer) feature.get(DGNResource.ID_FIELD_COLOR);
49
		if (!colors.contains(curColor)){
50

  
51
			Color curColorObj = m_DgnReader.DGNLookupColor(
52
					curColor.intValue());
53
			ISymbol sym =SymbologyFactory.createDefaultSymbolByShapeType(
54
					Geometry.TYPES.GEOMETRY,
55
					curColorObj);
56
			sym.setDescription(curColor.toString());
57

  
58

  
59
			if (sym instanceof IMarkerSymbol) {
60
				((IMarkerSymbol) sym).setSize(1);
61
			}
62

  
63
			if (sym instanceof ILineSymbol) {
64
				((ILineSymbol) sym).setLineWidth(1);
65
			}
66

  
67
			if (sym instanceof IFillSymbol) {
68
				((IFillSymbol) sym).getOutline().setLineColor(
69
						curColorObj);
70
				((IFillSymbol) sym).getOutline().setLineWidth(1);
71
				((IFillSymbol) sym).setFillColor(null);
72
			}
73

  
74
			defaultLegend.addSymbol(curColor, sym);
75
			colors.add(curColor);
76
		}
77

  
78
	}
79

  
80
	public Object getDefaultLegend() {
81
		return this.defaultLegend;
82
	}
83

  
84
	public Object getLabeling() {
85
		return this.labeling;
86
	}
87

  
88
	public void endLoading() {
89
		this.colors.clear();
90
		this.colors = null;
91
		this.m_DgnReader = null;
92
	}
93

  
94
	public void startLoading(Map params) {
95
		this.m_DgnReader = (DGNReader) params.get("reader");
96
	}
97

  
98

  
99
}
0 100

  
branches/v2_0_0_prep/libraries/libFMap_dataFile/src/org/gvsig/fmap/data/feature/file/dgn/operation/Register.java
1 1
package org.gvsig.fmap.data.feature.file.dgn.operation;
2 2

  
3
import org.gvsig.fmap.data.feature.file.dgn.DGNResource;
3 4

  
5

  
4 6
public class Register {
5 7
	public static void selfRegister() {
6 8
		//Register operations
......
12 14
			throw new RuntimeException("Register Operation exception");
13 15
		}
14 16

  
17
		DGNResource
18
				.setLegendLabelingManagerFactory(new DGNLegendLabelingManagerFactory());
15 19
	}
16 20
}
branches/v2_0_0_prep/libraries/libFMap_dataFile/src/org/gvsig/fmap/data/feature/file/dgn/operation/DGNLegendLabelingManagerFactory.java
1
package org.gvsig.fmap.data.feature.file.dgn.operation;
2

  
3
import org.gvsig.fmap.data.feature.operation.LegendLabelingManager;
4
import org.gvsig.fmap.data.feature.operation.LegendLabelingManagerFactory;
5

  
6
public class DGNLegendLabelingManagerFactory implements
7
		LegendLabelingManagerFactory {
8

  
9
	public LegendLabelingManager newManager() {
10
		return new DGNLegendLabelingManager();
11
	}
12

  
13
}
0 14

  
branches/v2_0_0_prep/libraries/libFMap_dataFile/src/org/gvsig/fmap/data/feature/file/dgn/DGNStore.java
9 9
import java.util.List;
10 10
import java.util.TreeSet;
11 11

  
12
import org.gvsig.tools.exception.BaseException;
13 12
import org.gvsig.fmap.data.CloseException;
14 13
import org.gvsig.fmap.data.DataCollection;
15 14
import org.gvsig.fmap.data.DataException;
......
38 37
import org.gvsig.metadata.IMetadata;
39 38
import org.gvsig.metadata.IMetadataManager;
40 39
import org.gvsig.metadata.MetadataManager;
40
import org.gvsig.tools.exception.BaseException;
41 41

  
42 42
public class DGNStore extends FileStore{
43 43
	public static String DATASTORE_NAME = "DGNStore";
......
165 165
	}
166 166

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff