Revision 47476 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

View differences:

SimpleFillSymbol.java
27 27
import java.awt.Graphics2D;
28 28
import java.awt.Rectangle;
29 29
import java.awt.geom.AffineTransform;
30
import org.gvsig.compat.print.PrintAttributes;
31 30
import org.gvsig.fmap.dal.feature.Feature;
32 31
import org.gvsig.fmap.geom.Geometry;
33
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
34 32
import org.gvsig.fmap.geom.GeometryLocator;
35 33
import org.gvsig.fmap.geom.GeometryManager;
36
import org.gvsig.fmap.geom.exception.CreateGeometryException;
37 34
import org.gvsig.fmap.geom.primitive.Envelope;
38
import org.gvsig.fmap.geom.primitive.GeneralPathX;
39 35
import org.gvsig.fmap.geom.primitive.Point;
40 36
import org.gvsig.fmap.mapcontext.MapContext;
41 37
import org.gvsig.fmap.mapcontext.MapContextLocator;
42 38
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
43
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException;
39
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol_v2;
44 40
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
45 41
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
46 42
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.ISimpleFillSymbol;
47 43
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol;
48
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.SimpleMarkerSymbol;
49 44
import org.gvsig.tools.ToolsLocator;
50 45
import org.gvsig.tools.dynobject.DynStruct;
51 46
import org.gvsig.tools.persistence.PersistenceManager;
......
75 70
    private static final String FIELD_SYMBOL_FOR_SELECTION = "symbolForSelection";
76 71

  
77 72
    private SimpleFillSymbol symbolForSelection;
78
    private SimpleMarkerSymbol tempSymbol = new SimpleMarkerSymbol();
79 73

  
80 74
    public SimpleFillSymbol() {
81 75
        super();
......
99 93
        return symbolForSelection;
100 94
    }
101 95

  
102
    public void draw(Graphics2D g, AffineTransform affineTransform,
103
            Geometry geom, Feature feature, Cancellable cancel) {
96
    @Override
97
    public void draw(Graphics2D g, AffineTransform affineTransform, Geometry geom, Feature f, Cancellable cancel, Rectangle r) {
98
        if(r != null){
99
            geom = this.getSampleGeometry(r);
100
        }
104 101
        Color c = getFillColor();
105 102

  
106 103
        if (true) {
107
            // Esto deberia ser para optimiza el pintado de 
108
            // geometrias grandes.
104
            // Esto deberia ser para optimizar el pintado de geometrias grandes.
109 105
            try {
110 106
                Geometry env = geom.getEnvelope().getGeometry();
111 107
                env.transform(affineTransform);
......
120 116
                    }
121 117
                    if (getOutline() != null && hasOutline()) {
122 118
                        g.setColor(getOutline().getColor());
123
//                        if (getOutline().getColor() != null) {
124
//
125
//                        }
126 119
                        g.drawLine(x, y, x, y);
127 120
                    }
128 121
                    return;
......
139 132
            g.fill(geom.getShape(affineTransform));
140 133
        }
141 134
        if (getOutline() != null && hasOutline()) {
142
            getOutline().draw(g, affineTransform, geom, feature, cancel);
135
            if (getOutline() instanceof ISymbol_v2) {
136
                getOutline().setCartographicContext(this.getCartographicContext());
137
                ((ISymbol_v2)getOutline()).draw(g, affineTransform, geom, f, cancel, null);
138
            } else {
139
                getOutline().draw(g, affineTransform, geom, f, cancel);
140
            }
143 141
        }
144 142
    }
145 143

  
......
148 146
        return Geometry.TYPES.SURFACE;
149 147
    }
150 148

  
151
    @Override
152
    public void drawInsideRectangle(Graphics2D g,
153
            AffineTransform scaleInstance, Rectangle r, PrintAttributes properties) throws SymbolDrawingException {
154
        Rectangle rect = new Rectangle(r.x, r.y, r.width, r.height);
155
        rect.setFrame(((int) rect.getMinX()) + 1, ((int) rect.getMinY()) + 1, ((int) rect.getWidth()) - 2, ((int) rect.getHeight()) - 2);
156
        Geometry geom;
157
        try {
158
            geom = geomManager.createSurface(new GeneralPathX(rect.getPathIterator(null)), SUBTYPES.GEOM2D);
159
        } catch (CreateGeometryException e) {
160
            LOG.error("Creating a surface", e);
161
            throw new SymbolDrawingException(getSymbolType());
162
        }
163

  
164
        Color c = getFillColor();
165
        if (c != null && hasFill()) {
166
            g.setColor(c);
167
            g.fillRect(rect.x, rect.y, rect.width, rect.height);
168
        }
169

  
170
        if (getOutline() != null && hasOutline()) {
171
            if (properties == null) {
172
                getOutline().draw(g, scaleInstance, geom, null, null);
173
            } else {
174
                print(g, new AffineTransform(), geom, properties);
175
            }
176
        }
177
    }
178

  
179 149
    public String getClassName() {
180 150
        return getClass().getName();
181 151
    }
182 152

  
183 153
    @Override
184
    public void print(Graphics2D g, AffineTransform at, Geometry geom, PrintAttributes properties) {
185
        Color c = getFillColor();
186
        if (c != null && hasFill()) {
187
            g.setColor(c);
188
            g.fill(geom.getShape(at));
189
        }
190
        if (getOutline() != null && hasOutline()) {
191
            getOutline().print(g, at, geom, properties);
192
        }
193
    }
194

  
195
    @Override
196 154
    public Object clone() throws CloneNotSupportedException {
197 155
        SimpleFillSymbol copy = (SimpleFillSymbol) super.clone();
198 156

  
......
246 204
    @Override
247 205
    public void setOutline(ILineSymbol outline) {
248 206
        super.setOutline(outline);
249
//        if (outline != null && outline instanceof TransparencySupport) {
250
//            ((TransparencySupport) outline).setTransparency(this.getTransparency());
251
//        }
252 207
    }
253 208

  
254 209
    @Override

Also available in: Unified diff