Revision 9511

View differences:

org.gvsig.legend.dotdensity.app.mainplugin/trunk/org.gvsig.legend.dotdensity.app.mainplugin/src/main/java/org/gvsig/symbology/fmap/symbols/DotDensityFillSymbol.java
39 39
 *   dac@iver.es
40 40
 */
41 41

  
42
/* CVS MESSAGES:
43
*
44
* $Id: DotDensityFillSymbol.java 13953 2007-09-21 12:26:04Z jaume $
45
* $Log$
46
* Revision 1.8  2007-09-21 12:25:32  jaume
47
* cancellation support extended down to the IGeometry and ISymbol level
48
*
49
* Revision 1.7  2007/09/18 14:50:31  caballero
50
* Leyendas sobre el Layout
51
*
52
* Revision 1.6  2007/03/26 14:24:24  jaume
53
* IPrintable refactored
54
*
55
* Revision 1.5  2007/03/09 11:20:56  jaume
56
* Advanced symbology (start committing)
57
*
58
* Revision 1.3.2.4  2007/02/21 16:09:02  jaume
59
* *** empty log message ***
60
*
61
* Revision 1.3.2.3  2007/02/16 10:54:12  jaume
62
* multilayer splitted to multilayerline, multilayermarker,and  multilayerfill
63
*
64
* Revision 1.3.2.2  2007/02/15 16:23:44  jaume
65
* *** empty log message ***
66
*
67
* Revision 1.3.2.1  2007/02/09 07:47:04  jaume
68
* Isymbol moved
69
*
70
* Revision 1.3  2007/01/12 10:08:26  jaume
71
* *** empty log message ***
72
*
73
* Revision 1.2  2007/01/10 16:39:41  jaume
74
* ISymbol now belongs to com.iver.cit.gvsig.fmap.core.symbols package
75
*
76
* Revision 1.1  2007/01/10 16:31:36  jaume
77
* *** empty log message ***
78
*
79
* Revision 1.4  2006/11/14 11:10:27  jaume
80
* *** empty log message ***
81
*
82
* Revision 1.3  2006/11/13 09:15:23  jaume
83
* javadoc and some clean-up
84
*
85
* Revision 1.2  2006/11/09 18:39:05  jaume
86
* *** empty log message ***
87
*
88
* Revision 1.1  2006/11/09 10:22:50  jaume
89
* *** empty log message ***
90
*
91
*
92
*/
93 42
package org.gvsig.symbology.fmap.symbols;
94 43

  
95 44
import java.awt.Color;
......
97 46
import java.awt.Rectangle;
98 47
import java.awt.geom.AffineTransform;
99 48
import java.util.Random;
100

  
101 49
import javax.print.attribute.PrintRequestAttributeSet;
102

  
103
import org.gvsig.compat.print.PrintAttributes;
104 50
import org.gvsig.fmap.dal.feature.Feature;
105 51
import org.gvsig.fmap.geom.Geometry;
106 52
import org.gvsig.fmap.geom.GeometryLocator;
107 53
import org.gvsig.fmap.geom.GeometryManager;
108 54
import org.gvsig.fmap.geom.primitive.Point;
109
import org.gvsig.fmap.geom.primitive.Polygon;
110 55
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
111
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException;
112 56
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.impl.AbstractFillSymbol;
113 57
import org.gvsig.tools.ToolsLocator;
114 58
import org.gvsig.tools.dynobject.DynStruct;
......
130 74
 * handled by a SimpleFillSymboll where a DotDensityFillSymbol should be
131 75
 * embedded.<br>
132 76
 * </p>
133
 * @author jaume dominguez faus - jaume.dominguez@iver.es
134 77
 *
135 78
 */
136 79
public class DotDensityFillSymbol extends AbstractFillSymbol {
......
144 87
	private double dotSpacing;
145 88
	private Color dotColor = Color.BLACK;
146 89

  
147
	private boolean fixedPlacement;
148
	private PrintRequestAttributeSet properties;
149
	private GeometryManager geoManager=GeometryLocator.getGeometryManager();
150

  
151 90
	public DotDensityFillSymbol() {
152 91
		super();
153 92
	}
154 93

  
94
    @Override
155 95
	public ISymbol getSymbolForSelection() {
156 96
		return this; // the selection color is applied in the SimpleFillSymbol
157 97
	}
158 98

  
99
    @Override
159 100
    public void draw(Graphics2D g, AffineTransform atr,
160
        Geometry theGeom, Feature f, Cancellable cancel) {
101
        Geometry theGeom, Feature f, Cancellable cancel, Rectangle r) {
102
        if(r != null){
103
            theGeom = getSampleGeometry(r);
104
        }
161 105

  
162 106
        try {
163 107
            Geometry clo_geo = theGeom.cloneGeometry();
164 108
            clo_geo.transform(atr);
165

  
109
            GeometryManager geoManager=GeometryLocator.getGeometryManager();
166 110
            Point interiorPoint=geoManager.createPoint(0, 0, Geometry.SUBTYPES.GEOM2D);
167 111
            int maxIntentos = 35;
168 112
            int width = clo_geo.getBounds().width;
......
192 136
                    interiorPoint.setX(x);
193 137
                    interiorPoint.setY(y);
194 138
                }  while (intentos<maxIntentos && !clo_geo.contains(interiorPoint));
139
                if(!clo_geo.contains(interiorPoint)){
140
                    interiorPoint = clo_geo.getInteriorPoint();
141
                    x = (int) interiorPoint.getX();
142
                    y = (int) interiorPoint.getY();
143
                }
144
                
195 145
                g.fillRect(x, y, size, size);
196 146
            }
197 147
            g.setClip(null);
......
201 151
        }
202 152
	}
203 153

  
154
    @Override
204 155
    public void saveToState(PersistentState state) throws PersistenceException {
205 156

  
206 157
        super.saveToState(state);
......
218 169
    }
219 170

  
220 171

  
172
    @Override
221 173
	public int getSymbolType() {
222 174
		return Geometry.TYPES.SURFACE;
223 175
	}
224 176

  
225
    public void drawInsideRectangle(Graphics2D g,
226
        AffineTransform scaleInstance,
227
        Rectangle r,
228
        PrintAttributes properties) throws SymbolDrawingException {
229

  
230
		int x = r.x;
231
		int y = r.y;
232
		int width = r.width;
233
		int height= r.height;
234
		int size = height / 5;
235
		g.setColor(getDotColor());
236
		g.setBackground(null);
237
		g.fillRect((int) (x+width*0.2), (int) (y+height*0.2), size, size);
238
		g.fillRect((int) (x+width*0.25), (int) (y+height*0.7), size, size);
239
		g.fillRect((int) (x+width*0.35), (int) (y+height*0.5), size, size);
240
		g.fillRect((int) (x+width*0.6), (int) (y+height*0.1), size, size);
241
		g.fillRect((int) (x+width*0.7), (int) (y+height*0.8), size, size);
242
		g.fillRect((int) (x+width*0.8), (int) (y+height*0.3), size, size);
243
		g.fillRect((int) (x+width*0.9), (int) (y+height*0.6), size, size);
244
	}
245

  
177
    @Override
246 178
    public void loadFromState(PersistentState state)
247 179
        throws PersistenceException {
248 180

  
......
309 241
		this.dotColor = dotColor;
310 242
	}
311 243

  
312
    /* (non-Javadoc)
313
     * @see org.gvsig.fmap.mapcontext.rendering.symbols.IPrintable#print(java.awt.Graphics2D, java.awt.geom.AffineTransform, org.gvsig.fmap.geom.Geometry, org.gvsig.compat.print.PrintAttributes)
314
     */
315
    public void print(Graphics2D g, AffineTransform at, Geometry shape,
316
        PrintAttributes prop) {
317

  
318
        // this.properties.=prop;
319
        draw(g, at, shape, null, null);
320
        // this.properties=null;
321

  
322
    }
323

  
324 244
    public static class RegisterPersistence implements Callable {
325 245

  
246
        @Override
326 247
        public Object call() throws Exception {
327 248
            PersistenceManager manager = ToolsLocator.getPersistenceManager();
328 249
            if( manager.getDefinition(
org.gvsig.legend.dotdensity.app.mainplugin/trunk/org.gvsig.legend.dotdensity.app.mainplugin/src/main/java/org/gvsig/symbology/fmap/rendering/DotDensityLegend.java
16 16
 * along with this program; if not, write to the Free Software
17 17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18 18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40 19
 */
41 20

  
42
/* CVS MESSAGES:
43
 *
44
 * $Id: DotDensityLegend.java 14420 2007-10-04 11:23:36Z jvidal $
45
 * $Log$
46
 * Revision 1.6  2007-09-19 16:25:39  jaume
47
 * ReadExpansionFileException removed from this context and removed unnecessary imports
48
 *
49
 * Revision 1.5  2007/07/25 07:13:34  jaume
50
 * code style
51
 *
52
 * Revision 1.4  2007/05/17 09:32:06  jaume
53
 * *** empty log message ***
54
 *
55
 * Revision 1.3  2007/03/09 11:20:56  jaume
56
 * Advanced symbology (start committing)
57
 *
58
 * Revision 1.2.2.5  2007/02/21 07:34:09  jaume
59
 * labeling starts working
60
 *
61
 * Revision 1.2.2.4  2007/02/15 16:23:44  jaume
62
 * *** empty log message ***
63
 *
64
 * Revision 1.2.2.3  2007/02/12 15:15:20  jaume
65
 * refactored interval legend and added graduated symbol legend
66
 *
67
 * Revision 1.2.2.2  2007/02/09 07:47:04  jaume
68
 * Isymbol moved
69
 *
70
 * Revision 1.2.2.1  2007/01/26 13:48:17  jaume
71
 * *** empty log message ***
72
 *
73
 * Revision 1.2  2007/01/16 11:50:50  jaume
74
 * *** empty log message ***
75
 *
76
 * Revision 1.1  2007/01/10 16:39:41  jaume
77
 * ISymbol now belongs to com.iver.cit.gvsig.fmap.core.symbols package
78
 *
79
 * Revision 1.2  2006/11/17 12:49:58  jaume
80
 * *** empty log message ***
81
 *
82
 * Revision 1.1  2006/11/14 12:30:26  jaume
83
 * *** empty log message ***
84
 *
85
 *
86
 */
87 21
package org.gvsig.symbology.fmap.rendering;
88 22

  
89 23
import java.awt.Color;
......
118 52
 * in the surface.
119 53
 *
120 54
 *
121
 * @author  jaume dominguez faus - jaume.dominguez@iver.es
122 55
 */
123 56
public class DotDensityLegend extends VectorialUniqueValueLegend {
124 57

  
......
375 308
        return resp;
376 309
    }
377 310

  
311
    public String[] getDescriptions() {
312
        try {
313
            return new String[]{String.format("%s, %.3f",getClassifyingFieldNames()[0], getDotValue())};
314
        }catch (Exception ex){
315
            return new String[]{"Dot density"};
316
        }
317
    }
378 318

  
379 319
}

Also available in: Unified diff