Revision 42352

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/rendering/symbols/impl/DefaultSymbolManager.java
44 44
import java.util.Collections;
45 45
import java.util.Comparator;
46 46
import java.util.HashMap;
47
import java.util.Iterator;
47 48
import java.util.List;
48 49
import java.util.Map;
49 50
import java.util.Random;
51

  
50 52
import org.apache.commons.io.FileUtils;
51 53
import org.apache.commons.io.FilenameUtils;
52 54
import org.apache.commons.io.filefilter.FileFilterUtils;
53 55
import org.apache.commons.lang3.StringUtils;
56
import org.slf4j.Logger;
57
import org.slf4j.LoggerFactory;
58

  
59
import org.gvsig.fmap.geom.Geometry;
60
import org.gvsig.fmap.geom.GeometryLocator;
61
import org.gvsig.fmap.geom.GeometryManager;
62
import org.gvsig.fmap.geom.type.GeometryType;
63
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException;
64
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException;
54 65
import org.gvsig.fmap.mapcontext.MapContextRuntimeException;
55 66
import org.gvsig.fmap.mapcontext.impl.InvalidRegisteredClassException;
56 67
import org.gvsig.fmap.mapcontext.impl.RegisteredClassInstantiationException;
......
72 83
import org.gvsig.tools.task.TaskStatusManager;
73 84
import org.gvsig.tools.visitor.VisitCanceledException;
74 85
import org.gvsig.tools.visitor.Visitor;
75
import org.slf4j.Logger;
76
import org.slf4j.LoggerFactory;
77 86

  
78 87
/**
79 88
 * Default {@link SymbolManager} implementation.
......
350 359

  
351 360
    public ISymbol createSymbol(int shapeType)
352 361
            throws MapContextRuntimeException {
353
        String symbolName
354
                = (String) symbolsByShapeType.get(new Integer(shapeType));
362
        String symbolName = getSymbolName(symbolsByShapeType, shapeType);
355 363

  
356 364
        return symbolName == null ? null : createSymbol(symbolName);
357 365
    }
......
369 377

  
370 378
    public ISymbol createSymbol(int shapeType, Color color)
371 379
            throws MapContextRuntimeException {
372
        String symbolName
373
                = (String) symbolsByShapeType.get(new Integer(shapeType));
380
        String symbolName = getSymbolName(symbolsByShapeType, shapeType);
374 381

  
375 382
        return symbolName == null ? null : createSymbol(symbolName, color);
376 383
    }
......
384 391

  
385 392
    public IMultiLayerSymbol createMultiLayerSymbol(int shapeType)
386 393
            throws MapContextRuntimeException {
387
        String symbolName
388
                = (String) multiLineSymbolsByShapeType.get(new Integer(shapeType));
394
        String symbolName = getSymbolName(multiLineSymbolsByShapeType, shapeType);
389 395

  
390 396
        return symbolName == null ? null : createMultiLayerSymbol(symbolName);
391 397
    }
392 398

  
399
    /**
400
     * @param shapeType
401
     * @return
402
     */
403
    private String getSymbolName(Map symbols, int shapeType) {
404
        String symbolName
405
                = (String) symbols.get(new Integer(shapeType));
406
        if (symbolName == null) {
407
            GeometryManager geomManager = GeometryLocator.getGeometryManager();
408
            GeometryType shapeGeometryType;
409
            try {
410
                shapeGeometryType = geomManager.getGeometryType(shapeType, Geometry.SUBTYPES.UNKNOWN);
411
                Iterator it = symbols.keySet().iterator();
412
                while (it.hasNext()) {
413
                    Integer geomType = (Integer) it.next();
414
                    GeometryType geomGeometryType =
415
                        geomManager.getGeometryType(geomType.intValue(), Geometry.SUBTYPES.UNKNOWN);
416
                    if (shapeGeometryType.isSubTypeOf(geomGeometryType)) {
417
                        symbolName = (String) symbols.get(geomType);
418
                        break;
419
                    }
420
                }
421
            } catch (GeometryTypeNotSupportedException e) {
422
                // do nothing
423
            } catch (GeometryTypeNotValidException e) {
424
                // do nothing
425
            }
426
        }
427
        return symbolName;
428
    }
429

  
393 430
    public void registerSymbol(String symbolName, Class symbolClass)
394 431
            throws MapContextRuntimeException {
395 432
        if (symbolClass == null || !ISymbol.class.isAssignableFrom(symbolClass)) {
......
578 615
            // ...else resp remains the same
579 616
        }
580 617

  
581
        // finally add some dark noise 
618
        // finally add some dark noise
582 619
        resp = addDarkNoise(resp);
583 620
        return resp;
584 621
    }
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/symbol/fill/impl/SimpleFillSymbol.java
59 59
 * @author 2009-     <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
60 60
 */
61 61
public class SimpleFillSymbol extends AbstractFillSymbol implements ISimpleFillSymbol {
62
	
63 62

  
63

  
64 64
	private static final String SIMPLE_FILL_SYMBOL_PERSISTENCE_DEFINITION_NAME = "SimpleFillSymbol";
65
	
65

  
66 66
	private static final Logger LOG = LoggerFactory.getLogger(SimpleFillSymbol.class);
67 67
	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
68 68

  
......
140 140
			getOutline().print(g, at, geom, properties);
141 141
		}
142 142
	}
143
	
144
	
143

  
144

  
145 145
	public Object clone() throws CloneNotSupportedException {
146 146
		SimpleFillSymbol copy = (SimpleFillSymbol) super.clone();
147 147

  
......
153 153

  
154 154
		return copy;
155 155
	}
156
	
156

  
157 157
	private void setSymbolForSelection(SimpleFillSymbol symbolForSelection) {
158 158
		this.symbolForSelection = symbolForSelection;
159 159
	}
......
183 183
						SimpleFillSymbol.class,
184 184
						SIMPLE_FILL_SYMBOL_PERSISTENCE_DEFINITION_NAME,
185 185
						SIMPLE_FILL_SYMBOL_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
186
						null, 
186
						null,
187 187
						null
188 188
				);
189 189

  
......
195 195
			}
196 196
			return Boolean.TRUE;
197 197
		}
198
		
198

  
199 199
	}
200 200

  
201 201
	public static class RegisterSymbol implements Callable {
......
203 203
		public Object call() throws Exception {
204 204
	        int[] shapeTypes;
205 205
	        SymbolManager manager = MapContextLocator.getSymbolManager();
206
	        
206

  
207 207
	        shapeTypes =
208 208
	            new int[] { Geometry.TYPES.SURFACE, Geometry.TYPES.CIRCLE,
209
	                Geometry.TYPES.ELLIPSE, Geometry.TYPES.MULTISURFACE };
209
	                Geometry.TYPES.ELLIPSE, Geometry.TYPES.MULTISURFACE,
210
	                Geometry.TYPES.ELLIPTICARC, Geometry.TYPES.FILLEDSPLINE,
211
                    Geometry.TYPES.MULTIPOLYGON
212
                    };
210 213
	        manager.registerSymbol(IFillSymbol.SYMBOL_NAME,
211 214
	            shapeTypes,
212 215
	            SimpleFillSymbol.class);
213
	        
216

  
214 217
			return Boolean.TRUE;
215 218
		}
216
		
219

  
217 220
	}
218 221

  
219 222
}
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/symbol/line/impl/SimpleLineSymbol.java
64 64

  
65 65
	private static final Logger LOG = LoggerFactory.getLogger(SimpleLineSymbol.class);
66 66
    public static final String SIMPLE_LINE_SYMBOL_PERSISTENCE_DEFINITION_NAME = "SimpleLineSymbol";
67
  
67

  
68 68
    private static final String SELECTION_SYMBOL = "symbolForSelection";
69 69

  
70 70
	SimpleLineSymbol symbolForSelection;
......
74 74
		super();
75 75
		setLineWidth(1d);
76 76
	}
77
	
77

  
78 78
	public ISymbol getSymbolForSelection() {
79 79
		if (symbolForSelection == null) {
80
			symbolForSelection = (SimpleLineSymbol) cloneForSelection();			
80
			symbolForSelection = (SimpleLineSymbol) cloneForSelection();
81 81
		}
82 82
		return symbolForSelection;
83 83
	}
......
98 98
				LOG.error("Creating a Surface", e);
99 99
			}
100 100
		}
101
		g.setColor(getColor());	
101
		g.setColor(getColor());
102 102
		g.draw(geomToDraw.getShape(affineTransform));
103 103

  
104 104
		ArrowDecoratorStyle arrowDecorator = (ArrowDecoratorStyle) getLineStyle().getArrowDecorator();
......
141 141

  
142 142
		return copy;
143 143
	}
144
	
144

  
145 145
    public void loadFromState(PersistentState state) throws PersistenceException {
146 146
        // Set parent style properties
147 147
        super.loadFromState(state);
......
170 170
						SimpleLineSymbol.class,
171 171
						SIMPLE_LINE_SYMBOL_PERSISTENCE_DEFINITION_NAME,
172 172
						SIMPLE_LINE_SYMBOL_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
173
						null, 
173
						null,
174 174
						null
175 175
				);
176 176
				// Extend the LineSymbol base definition
177 177
				definition.extend(manager.getDefinition(LINE_SYMBOL_PERSISTENCE_DEFINITION_NAME));
178
				
178

  
179 179
                definition.addDynFieldObject(SELECTION_SYMBOL).setClassOfValue(SimpleLineSymbol.class);
180 180

  
181 181
			}
182 182
			return Boolean.TRUE;
183 183
		}
184
		
184

  
185 185
	}
186 186

  
187 187
	public static class RegisterSymbol implements Callable {
......
191 191
			SymbolManager manager = MapContextLocator.getSymbolManager();
192 192

  
193 193
	        shapeTypes = new int[] { Geometry.TYPES.CURVE, Geometry.TYPES.ARC,
194
	                Geometry.TYPES.ELLIPTICARC, Geometry.TYPES.MULTICURVE };
194
	                Geometry.TYPES.MULTICURVE, Geometry.TYPES.CIRCUMFERENCE,
195
	                Geometry.TYPES.PERIELLIPSE, Geometry.TYPES.SPLINE,
196
	                Geometry.TYPES.LINE, Geometry.TYPES.MULTILINE};
195 197
	        manager.registerSymbol(ILineSymbol.SYMBOL_NAME,
196 198
	            shapeTypes,
197 199
	            SimpleLineSymbol.class);
198 200

  
199 201
			return Boolean.TRUE;
200 202
		}
201
		
203

  
202 204
	}
203 205

  
204 206
}

Also available in: Unified diff