Revision 41371

View differences:

tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.operation/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
28

  
29
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
30

  
31
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
32
		<layout class="org.apache.log4j.PatternLayout">
33
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
34
		</layout>
35
	</appender>
36

  
37
	<category name="org.gvsig.tools">
38
		<priority value="DEBUG" />
39
	</category>
40
	<category name="org.gvsig.fmap.mapcontext">
41
		<priority value="DEBUG" /> 
42
	</category>
43

  
44
	<root>
45
		<priority value="INFO" />
46
		<appender-ref ref="CONSOLE" />
47
	</root>
48
</log4j:configuration>
0 49

  
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.operation/src/main/java/org/gvsig/fmap/geom/operation/DrawInts.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import java.awt.Graphics2D;
27
import java.awt.geom.AffineTransform;
28
import java.awt.geom.PathIterator;
29

  
30
import org.gvsig.fmap.geom.Geometry;
31
import org.gvsig.fmap.geom.GeometryLocator;
32
import org.gvsig.fmap.geom.GeometryManager;
33
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
34
import org.gvsig.fmap.geom.exception.CreateGeometryException;
35
import org.gvsig.fmap.geom.primitive.GeneralPathX;
36
import org.gvsig.fmap.mapcontext.ViewPort;
37
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport;
38
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
39
import org.gvsig.tools.task.Cancellable;
40
import org.slf4j.Logger;
41
import org.slf4j.LoggerFactory;
42

  
43
public class DrawInts extends GeometryOperation {
44
	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
45
	public static final String NAME = "drawInts";
46
	public static int CODE = Integer.MIN_VALUE;
47

  
48
	final static private Logger logger = LoggerFactory.getLogger(DrawInts.class);
49

  
50
	public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException{
51
		DrawOperationContext doc=(DrawOperationContext)ctx;
52
		ViewPort viewPort = doc.getViewPort();
53
		ISymbol symbol = doc.getSymbol();
54
		Graphics2D g=doc.getGraphics();
55
		Cancellable cancel=doc.getCancellable();
56
		//		 make the symbol to resize itself with the current rendering context
57
		try {
58
			if (doc.hasDPI()){
59
				double previousSize = ((CartographicSupport)symbol).
60
				toCartographicSize(viewPort, doc.getDPI(), geom);
61
				// draw it as normally
62
				Geometry decimatedShape = transformToInts(geom, viewPort.getAffineTransform());
63
				
64
				//the AffineTransform has to be null because the transformToInts method
65
				//reprojects the geometry
66
				symbol.draw(g, null, decimatedShape, doc.getFeature(), cancel);
67
				
68
				// restore previous size
69
				((CartographicSupport)symbol).setCartographicSize(previousSize, geom);
70
			}else{
71
				Geometry decimatedShape = transformToInts(geom, viewPort.getAffineTransform());
72
				symbol.draw(g, viewPort.getAffineTransform(), decimatedShape,
73
						doc.getFeature(), cancel);
74
			}
75
		} catch (CreateGeometryException e) {
76
			e.printStackTrace();
77
			throw new GeometryOperationException(e);
78
		}
79

  
80
		return null;
81
	}
82

  
83
	public int getOperationIndex() {
84
		return CODE;
85
	}
86

  
87
	private Geometry transformToInts(Geometry gp, AffineTransform at) throws CreateGeometryException {
88
		GeneralPathX newGp = new GeneralPathX();
89
		double[] theData = new double[6];
90
		double[] aux = new double[6];
91

  
92
		// newGp.reset();
93
		PathIterator theIterator;
94
		int theType;
95
		int numParts = 0;
96

  
97
		java.awt.geom.Point2D ptDst = new java.awt.geom.Point2D.Double();
98
		java.awt.geom.Point2D ptSrc = new java.awt.geom.Point2D.Double();
99
		boolean bFirst = true;
100
		int xInt, yInt, antX = -1, antY = -1;
101

  
102

  
103
		theIterator = gp.getPathIterator(null); //, flatness);
104
		int numSegmentsAdded = 0;
105
		while (!theIterator.isDone()) {
106
			theType = theIterator.currentSegment(theData);
107

  
108
			switch (theType) {
109
			case PathIterator.SEG_MOVETO:
110
				numParts++;
111
				ptSrc.setLocation(theData[0], theData[1]);
112
				at.transform(ptSrc, ptDst);
113
				antX = (int) ptDst.getX();
114
				antY = (int) ptDst.getY();
115
				newGp.moveTo(antX, antY);
116
				numSegmentsAdded++;
117
				bFirst = true;
118
				break;
119

  
120
			case PathIterator.SEG_LINETO:
121
				ptSrc.setLocation(theData[0], theData[1]);
122
				at.transform(ptSrc, ptDst);
123
				xInt = (int) ptDst.getX();
124
				yInt = (int) ptDst.getY();
125
				if ((bFirst) || ((xInt != antX) || (yInt != antY)))
126
				{
127
					newGp.lineTo(xInt, yInt);
128
					antX = xInt;
129
					antY = yInt;
130
					bFirst = false;
131
					numSegmentsAdded++;
132
				}
133
				break;
134

  
135
			case PathIterator.SEG_QUADTO:
136
				at.transform(theData,0,aux,0,2);
137
				newGp.quadTo(aux[0], aux[1], aux[2], aux[3]);
138
				numSegmentsAdded++;
139
				break;
140

  
141
			case PathIterator.SEG_CUBICTO:
142
				at.transform(theData,0,aux,0,3);
143
				newGp.curveTo(aux[0], aux[1], aux[2], aux[3], aux[4], aux[5]);
144
				numSegmentsAdded++;
145
				break;
146

  
147
			case PathIterator.SEG_CLOSE:
148
				if (numSegmentsAdded < 3) {
149
					newGp.lineTo(antX, antY);
150
				}
151
				newGp.closePath();
152

  
153
				break;
154
			} //end switch
155

  
156
			theIterator.next();
157
		} //end while loop
158

  
159
		Geometry geom = null;
160
		switch (gp.getType()) {
161
		case Geometry.TYPES.POINT:
162
			geom = geomManager.createPoint(ptDst.getX(), ptDst.getY(), SUBTYPES.GEOM2D);
163
			break;
164
		case Geometry.TYPES.CURVE:
165
		case Geometry.TYPES.ARC:
166
			geom = geomManager.createCurve(newGp, SUBTYPES.GEOM2D);
167
			break;
168

  
169
		case Geometry.TYPES.SURFACE:
170
		case Geometry.TYPES.CIRCLE:
171
		case Geometry.TYPES.ELLIPSE:
172

  
173
			geom = geomManager.createSurface(newGp, SUBTYPES.GEOM2D);
174
			break;
175
		}
176
		return geom;
177
	}
178

  
179
	public static void register() {
180
		
181
		GeometryManager gm = GeometryLocator.getGeometryManager();
182
		CODE = gm.getGeometryOperationCode(NAME);
183
		geomManager.registerGeometryOperation(NAME, new DrawInts());
184
	}
185

  
186

  
187
}
0 188

  
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.operation/src/main/java/org/gvsig/fmap/geom/operation/Draw.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import java.awt.geom.AffineTransform;
27

  
28

  
29
import org.gvsig.fmap.geom.Geometry;
30
import org.gvsig.fmap.geom.GeometryManager;
31
import org.gvsig.fmap.geom.GeometryLocator;
32

  
33
public class Draw extends GeometryOperation{
34
	public static final String NAME = "draw";
35
	public static int CODE = Integer.MIN_VALUE;
36

  
37
	public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
38
		DrawOperationContext doc = (DrawOperationContext)ctx;
39
		AffineTransform at = doc.getViewPort().getAffineTransform();		
40
		doc.getSymbol().draw(doc.getGraphics(), at, geom, doc.getFeature(),
41
				doc.getCancellable());
42
		return null;
43
	}
44

  
45
	public int getOperationIndex() {
46
		return CODE;
47
	}
48

  
49
	public static void register() {
50
		
51
		GeometryManager geoMan = GeometryLocator.getGeometryManager();
52
		CODE = geoMan.getGeometryOperationCode(NAME);
53
		geoMan.registerGeometryOperation(NAME, new Draw());
54
	}
55

  
56
}
0 57

  
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.operation/src/main/java/org/gvsig/fmap/geom/operation/AggregateDrawInts.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import org.gvsig.fmap.geom.Geometry;
27
import org.gvsig.fmap.geom.GeometryLocator;
28
import org.gvsig.fmap.geom.GeometryManager;
29
import org.gvsig.fmap.geom.Geometry.TYPES;
30
import org.gvsig.fmap.geom.aggregate.Aggregate;
31
import org.slf4j.Logger;
32
import org.slf4j.LoggerFactory;
33

  
34
/**
35
 * @author jmvivo
36
 *
37
 */
38
public class AggregateDrawInts extends GeometryOperation {
39
	public static final String NAME = "drawInts";
40
	public static int CODE = Integer.MIN_VALUE;
41

  
42
	
43
	final static private Logger logger = LoggerFactory
44
			.getLogger(DrawInts.class);
45

  
46
	/* (non-Javadoc)
47
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
48
	 */
49
	public int getOperationIndex() {
50
		return CODE;
51
	}
52

  
53
	/* (non-Javadoc)
54
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext)
55
	 */
56
	public Object invoke(Geometry geom, GeometryOperationContext ctx)
57
			throws GeometryOperationException {
58

  
59
		Aggregate aggregate = (Aggregate) geom;
60
		for (int i=0;i<aggregate.getPrimitivesNumber();i++){
61
			Geometry prim = aggregate.getPrimitiveAt(i);
62
			try {
63
				prim.invokeOperation(CODE, ctx);
64
			} catch (GeometryOperationNotSupportedException e) {
65
				throw new GeometryOperationException(e);
66
			}
67
		}
68
		return null;
69
	}
70

  
71
	public static void register() {
72
		GeometryManager geoMan = GeometryLocator.getGeometryManager();
73

  
74
		CODE = geoMan.getGeometryOperationCode(NAME);
75
		
76
		geoMan.registerGeometryOperation(NAME, new AggregateDrawInts(),
77
				TYPES.AGGREGATE);
78
		geoMan.registerGeometryOperation(NAME, new AggregateDrawInts(),
79
				TYPES.MULTIPOINT);
80
		geoMan.registerGeometryOperation(NAME, new AggregateDrawInts(),
81
				TYPES.MULTICURVE);
82
		geoMan.registerGeometryOperation(NAME, new AggregateDrawInts(),
83
				TYPES.MULTISURFACE);
84
		geoMan.registerGeometryOperation(NAME, new AggregateDrawInts(),
85
				TYPES.MULTISOLID);
86

  
87
	}
88

  
89
}
0 90

  
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.operation/src/main/java/org/gvsig/fmap/geom/operation/DrawOperationContext.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import java.awt.Graphics2D;
27

  
28
import org.gvsig.fmap.dal.feature.Feature;
29
import org.gvsig.fmap.mapcontext.ViewPort;
30
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
31
import org.gvsig.tools.task.Cancellable;
32

  
33

  
34
public class DrawOperationContext extends GeometryOperationContext{
35
	private ISymbol symbol=null;
36
	private Graphics2D graphics=null;
37
	private Cancellable cancellable;
38
	private double dpi;
39
	private double scale;
40
	private boolean hasDPI=false;
41
	private ViewPort viewPort;
42
	private Feature feature;
43
	
44
	public ViewPort getViewPort() {
45
		return viewPort;
46
	}
47
	public void setViewPort(ViewPort viewPort) {
48
		this.viewPort = viewPort;
49
	}
50
	public Graphics2D getGraphics() {
51
		return graphics;
52
	}
53
	public void setGraphics(Graphics2D graphics) {
54
		this.graphics = graphics;
55
	}
56
	public ISymbol getSymbol() {
57
		return symbol;
58
	}
59
	public void setSymbol(ISymbol symbol) {
60
		this.symbol = symbol;
61
	}
62
	public void setCancellable(Cancellable cancel) {
63
		this.cancellable=cancel;
64

  
65
	}
66
	public Cancellable getCancellable() {
67
		return cancellable;
68
	}
69
	public void setDPI(double dpi) {
70
		this.hasDPI=true;
71
		this.dpi=dpi;
72
	}
73
	public double getDPI(){
74
		return dpi;
75
	}
76
	public boolean hasDPI() {
77
		return hasDPI;
78
	}
79
	/**
80
	 * @param scale the scale to set
81
	 */
82
	public void setScale(double scale) {
83
		this.scale = scale;
84
	}
85
	/**
86
	 * @return the scale
87
	 */
88
	public double getScale() {
89
		return scale;
90
	}
91
	public Feature getFeature() {
92
		return feature;
93
	}
94
	public void setFeature(Feature feature) {
95
		this.feature = feature;
96
	}
97

  
98
}
0 99

  
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.operation/src/main/java/org/gvsig/fmap/geom/operation/MapContextGeomOperationsLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import org.gvsig.fmap.mapcontext.MapContextLibrary;
27
import org.gvsig.tools.library.AbstractLibrary;
28
import org.gvsig.tools.library.LibraryException;
29

  
30
/**
31
 * @author jmvivo
32
 *
33
 */
34
public class MapContextGeomOperationsLibrary extends AbstractLibrary {
35

  
36
    public void doRegistration() {
37
        registerAsServiceOf(MapContextLibrary.class);
38
    }
39

  
40
	protected void doInitialize() throws LibraryException {
41
	}
42

  
43
	protected void doPostInitialize() throws LibraryException {
44
		// Register Draw Operations
45
		Draw.register();
46
		DrawInts.register();
47
		AggregateDrawInts.register();
48
		AggregateDraw.register();
49
	}
50

  
51
}
0 52

  
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.operation/src/main/java/org/gvsig/fmap/geom/operation/AggregateDraw.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.geom.operation;
25

  
26
import org.gvsig.fmap.geom.Geometry;
27
import org.gvsig.fmap.geom.GeometryLocator;
28
import org.gvsig.fmap.geom.GeometryManager;
29
import org.gvsig.fmap.geom.Geometry.TYPES;
30
import org.gvsig.fmap.geom.aggregate.Aggregate;
31
import org.slf4j.Logger;
32
import org.slf4j.LoggerFactory;
33

  
34
/**
35
 * @author Vicente Caballero Navarro
36
 *
37
 */
38
public class AggregateDraw extends GeometryOperation {
39
	
40
	public static final String NAME = "draw";
41
	public static int CODE = Integer.MIN_VALUE;
42

  
43
	final static private Logger logger = LoggerFactory
44
	.getLogger(AggregateDraw.class);
45

  
46
	/* (non-Javadoc)
47
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
48
	 */
49
	public int getOperationIndex() {
50
		return CODE;
51
	}
52

  
53
	/* (non-Javadoc)
54
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext)
55
	 */
56
	public Object invoke(Geometry geom, GeometryOperationContext ctx)
57
	throws GeometryOperationException {
58

  
59
		Aggregate aggregate = (Aggregate) geom;
60
		for (int i=0;i<aggregate.getPrimitivesNumber();i++){
61
			Geometry prim = aggregate.getPrimitiveAt(i);
62
			try {
63
				prim.invokeOperation(CODE, ctx);
64
			} catch (GeometryOperationNotSupportedException e) {
65
				throw new GeometryOperationException(e);
66
			}
67
		}
68
		return null;
69
	}
70

  
71
	public static void register() {
72
		GeometryManager geoMan = GeometryLocator.getGeometryManager();
73
		
74
		CODE = geoMan.getGeometryOperationCode(NAME);
75

  
76
		geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
77
				TYPES.AGGREGATE);
78
		geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
79
				TYPES.MULTIPOINT);
80
		geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
81
				TYPES.MULTICURVE);
82
		geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
83
				TYPES.MULTISURFACE);
84
		geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
85
				TYPES.MULTISOLID);
86

  
87
	}
88

  
89
}
0 90

  
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.operation/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.geom.operation.MapContextGeomOperationsLibrary
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.operation/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
  <modelVersion>4.0.0</modelVersion>
5
  <artifactId>org.gvsig.fmap.mapcontext.operation</artifactId>
6
  <packaging>jar</packaging>
7
  <name>${project.artifactId}</name>
8
  <parent>
9
      <groupId>org.gvsig</groupId>
10
      <artifactId>org.gvsig.fmap.mapcontext</artifactId>
11
      <version>2.0.34</version>
12
  </parent>
13
  <dependencies>
14
    <dependency>
15
      <groupId>org.gvsig</groupId>
16
      <artifactId>org.gvsig.tools.lib</artifactId>
17
      <scope>compile</scope>
18
    </dependency>
19
    <dependency>
20
      <groupId>org.gvsig</groupId>
21
      <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
22
      <scope>compile</scope>
23
    </dependency>
24
    <dependency>
25
      <groupId>org.gvsig</groupId>
26
      <artifactId>org.gvsig.compat.api</artifactId>
27
      <scope>compile</scope>
28
    </dependency>
29
    <dependency>
30
      <groupId>org.gvsig</groupId>
31
      <artifactId>org.gvsig.projection.api</artifactId>
32
      <scope>compile</scope>
33
    </dependency>
34
    <dependency>
35
      <groupId>org.gvsig</groupId>
36
      <artifactId>org.gvsig.fmap.geometry.api</artifactId>
37
      <scope>compile</scope>
38
    </dependency>
39
    <dependency>
40
      <groupId>org.gvsig</groupId>
41
      <artifactId>org.gvsig.fmap.dal.api</artifactId>
42
      <scope>compile</scope>
43
    </dependency>
44
    <dependency>
45
      <groupId>org.gvsig</groupId>
46
      <artifactId>org.gvsig.timesupport.lib.api</artifactId>
47
      <scope>compile</scope>
48
    </dependency>
49
    <dependency>
50
      <groupId>org.slf4j</groupId>
51
      <artifactId>slf4j-api</artifactId>
52
      <scope>compile</scope>
53
    </dependency>
54

  
55

  
56

  
57
  </dependencies>
58

  
59
</project>
60

  
0 61

  
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/java/org/gvsig/fmap/mapcontext/layers/order/impl/RasterPolLinePointOrderManager.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.mapcontext.layers.order.impl;
25

  
26
import java.util.Map;
27

  
28
import org.gvsig.fmap.dal.exception.ReadException;
29
import org.gvsig.fmap.geom.Geometry;
30
import org.gvsig.fmap.geom.Geometry.TYPES;
31
import org.gvsig.fmap.geom.type.GeometryType;
32
import org.gvsig.fmap.mapcontext.layers.FLayer;
33
import org.gvsig.fmap.mapcontext.layers.FLayers;
34
import org.gvsig.fmap.mapcontext.layers.order.LayerOrderManager;
35
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
36
import org.gvsig.i18n.Messages;
37
import org.gvsig.tools.ToolsLocator;
38
import org.gvsig.tools.dynobject.DynStruct;
39
import org.gvsig.tools.persistence.PersistenceManager;
40
import org.gvsig.tools.persistence.PersistentState;
41
import org.gvsig.tools.persistence.exception.PersistenceException;
42
import org.slf4j.Logger;
43
import org.slf4j.LoggerFactory;
44

  
45

  
46
public class RasterPolLinePointOrderManager implements LayerOrderManager {
47

  
48
	public static final String RASTER_POLYGON_LINE_POINT_LAYER_ORDER_MANAGER_PERSISTENCE_NAME =
49
			"RASTER_POLYGON_LINE_POINT_LAYER_ORDER_MANAGER_PERSISTENCE_NAME";
50
	
51
	private static Logger logger =
52
		LoggerFactory.getLogger(RasterPolLinePointOrderManager.class);
53
	
54
	public RasterPolLinePointOrderManager() {
55
		
56
	}
57
	
58
	public int getPosition(FLayers target, FLayer newLayer) {
59
		
60
		int new_weight = 3;
61
		new_weight = getLayerWeight(newLayer);
62
		
63
		int len = target.getLayersCount();
64
		int item_w = 0;
65
		// from top to bottom,
66
		// look for a layer at
67
		// least as "heavy" as this one
68
		for (int i=(len-1); i>=0; i--) {
69
			item_w = getLayerWeight(target.getLayer(i));
70
			if (item_w >= new_weight) {
71
				return (i+1);
72
			}
73
		}
74
		// layer "falls" to bottom
75
		return 0;
76
	}
77

  
78
	public String getDescription() {
79
		return Messages.getText("_Raster_at_bottom_then_polygons_lines_points");
80
	}
81

  
82
	public String getName() {
83
		return Messages.getText("_Raster_Polygon_Line_Point_order_manager");
84
	}
85

  
86
	
87
	public String getCode() {
88
		return this.getClass().getName();
89
	}
90

  
91
	/**
92
	 * 
93
	 * @param lyr
94
	 * @return weight: point=0, line=1, polygon=2, other=3, raster=4
95
	 */
96
	private int getLayerWeight(FLayer lyr) {
97
		
98
		if (lyr.getClass().getName().toLowerCase().indexOf("raster") != -1) {
99
			return 4;
100
		} else {
101
			if (lyr instanceof FLyrVect) {
102
				FLyrVect lyrv = (FLyrVect) lyr;
103
				int type2d = Geometry.TYPES.SURFACE;
104
				try {
105
					type2d = simplifyType(lyrv.getGeometryType());
106
				} catch (ReadException e) {
107
					logger.error("While getting geo type.", e);
108
				}
109
				switch (type2d) {
110
				case TYPES.SURFACE:
111
					return 2;
112
				case TYPES.CURVE:
113
					return 1;
114
				case TYPES.POINT:
115
					return 0;
116
				default:
117
					// should not reach this
118
					return 3;
119
				}
120
			} else {
121
				// other:
122
				return 3;
123
			}
124
		}
125
		
126
	}
127

  
128
	/**
129
	 * 
130
	 */
131
	private int simplifyType(GeometryType gt) {
132

  
133
		if (gt.getType() == TYPES.POINT || gt.getType() == TYPES.MULTIPOINT) {
134
			return TYPES.POINT;
135
		} else {
136
			if (gt.isTypeOf(TYPES.CURVE) || gt.getType() == TYPES.MULTICURVE) {
137
				return TYPES.CURVE;
138
			} else {
139
				if (gt.isTypeOf(TYPES.SURFACE) || gt.getType() == TYPES.MULTISURFACE) {
140
					return TYPES.SURFACE;
141
				} else {
142
					// default
143
					return TYPES.SURFACE;
144
				}
145
			}
146
		}
147
	}
148

  
149
	public void loadFromState(PersistentState state) throws PersistenceException {
150
	}
151

  
152
	public void saveToState(PersistentState state) throws PersistenceException {
153
		state.set("name", this.getName());
154
	}
155
	
156
	public static void registerPersistent() {
157
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
158
		if (manager.getDefinition(RASTER_POLYGON_LINE_POINT_LAYER_ORDER_MANAGER_PERSISTENCE_NAME) == null) {
159
			DynStruct def = manager.addDefinition(
160
					RasterPolLinePointOrderManager.class,
161
					RASTER_POLYGON_LINE_POINT_LAYER_ORDER_MANAGER_PERSISTENCE_NAME,
162
					RASTER_POLYGON_LINE_POINT_LAYER_ORDER_MANAGER_PERSISTENCE_NAME +" Persistence definition",
163
					null, 
164
					null);
165
			def.addDynFieldString("name").setMandatory(true);
166
		}			
167
	}
168
	
169
	public Object clone() throws CloneNotSupportedException {
170
		return new RasterPolLinePointOrderManager();
171
	}
172
	
173

  
174

  
175
}
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/java/org/gvsig/fmap/mapcontext/layers/order/impl/TrivialLayerOrderManager.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.mapcontext.layers.order.impl;
25

  
26
import org.gvsig.fmap.mapcontext.layers.FLayer;
27
import org.gvsig.fmap.mapcontext.layers.FLayers;
28
import org.gvsig.fmap.mapcontext.layers.order.LayerOrderManager;
29
import org.gvsig.i18n.Messages;
30
import org.gvsig.tools.ToolsLocator;
31
import org.gvsig.tools.dynobject.DynStruct;
32
import org.gvsig.tools.persistence.PersistenceManager;
33
import org.gvsig.tools.persistence.PersistentState;
34
import org.gvsig.tools.persistence.exception.PersistenceException;
35

  
36
public class TrivialLayerOrderManager implements LayerOrderManager {
37

  
38
	public static final String TRIVIAL_LAYER_ORDER_MANAGER_PERSISTENCE_NAME =
39
			"TRIVIAL_LAYER_ORDER_MANAGER_PERSISTENCE_NAME";
40

  
41
	public TrivialLayerOrderManager() {
42
		
43
	}
44
	
45
	public int getPosition(FLayers target, FLayer newLayer) {
46
		/*
47
		 * Always on top
48
		 */
49
		return target.getLayersCount();
50
	}
51

  
52
	public String getName() {
53
		return Messages.getText("_Default_order");
54
	}
55

  
56
	public String getDescription() {
57
		return Messages.getText("_Layers_are_placed_always_on_top");
58
	}
59

  
60
	public String getCode() {
61
		return this.getClass().getName();
62
	}
63
	
64
	public void loadFromState(PersistentState state) throws PersistenceException {
65
	}
66

  
67
	public void saveToState(PersistentState state) throws PersistenceException {
68
		state.set("name", this.getName());
69
	}
70
	
71
	public static void registerPersistent() {
72
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
73
		if (manager.getDefinition(TRIVIAL_LAYER_ORDER_MANAGER_PERSISTENCE_NAME) == null) {
74
			DynStruct def = manager.addDefinition(
75
					TrivialLayerOrderManager.class,
76
					TRIVIAL_LAYER_ORDER_MANAGER_PERSISTENCE_NAME,
77
					TRIVIAL_LAYER_ORDER_MANAGER_PERSISTENCE_NAME +" Persistence definition",
78
					null, 
79
					null);
80
			def.addDynFieldString("name").setMandatory(true);
81
		}			
82
	}
83
	
84
	public Object clone() throws CloneNotSupportedException {
85
		return new TrivialLayerOrderManager();
86
	}
87

  
88
}
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/java/org/gvsig/fmap/mapcontext/layers/order/impl/BasicLayerOrderLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25
package org.gvsig.fmap.mapcontext.layers.order.impl;
26

  
27
import org.gvsig.fmap.mapcontext.MapContextLibrary;
28
import org.gvsig.fmap.mapcontext.MapContextLocator;
29
import org.gvsig.fmap.mapcontext.layers.order.LayerOrderManager;
30
import org.gvsig.i18n.Messages;
31
import org.gvsig.tools.library.AbstractLibrary;
32
import org.gvsig.tools.library.LibraryException;
33

  
34

  
35
/**
36
 * Registers the default implementation for {@link LayerOrderManager}
37
 * 
38
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
39
 */
40
public class BasicLayerOrderLibrary extends AbstractLibrary {
41

  
42
    public void doRegistration() {
43
        require(MapContextLibrary.class);
44
    }
45

  
46
    protected void doInitialize() throws LibraryException {
47
        Messages.addResourceFamily(
48
        		"org.gvsig.fmap.mapcontext.impl.i18n.text",
49
        		BasicLayerOrderLibrary.class.getClassLoader(),
50
        		BasicLayerOrderLibrary.class.getClass().getName());
51
    }
52

  
53
    protected void doPostInitialize() throws LibraryException {
54
    	
55
    	TrivialLayerOrderManager.registerPersistent();
56
    	RasterPolLinePointOrderManager.registerPersistent();
57
    	
58
    	MapContextLocator.registerDefaultOrderManager(
59
    			TrivialLayerOrderManager.class);
60
    	MapContextLocator.registerOrderManager(
61
    			RasterPolLinePointOrderManager.class);
62

  
63
    }
64
}
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.mapcontext.layers.order.impl.BasicLayerOrderLibrary
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/resources/org/gvsig/fmap/mapcontext/impl/i18n/text.properties
1
_Raster_at_bottom_then_polygons_lines_points=Capas de im?genes en el fondo, despu?s pol?gonos, l?neas y puntos
2
_Raster_Polygon_Line_Point_order_manager=Orden Im?genes-Pol?gonos-L?neas-Puntos
3
_Default_order=Orden por defecto
4
_Layers_are_placed_always_on_top=Las capas se colocan siempre sobre las existentes
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/src/main/resources/org/gvsig/fmap/mapcontext/impl/i18n/text_en.properties
1
_Raster_at_bottom_then_polygons_lines_points=Raster layers at bottom, then polygon, linear and point layers
2
_Raster_Polygon_Line_Point_order_manager=Raster-Polygon-Line-Point order
3
_Default_order=Default order
4
_Layers_are_placed_always_on_top=Layers are placed always on top
5

  
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.impl/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
  <modelVersion>4.0.0</modelVersion>
5
  <artifactId>org.gvsig.fmap.mapcontext.impl</artifactId>
6
  <packaging>jar</packaging>
7
  <name>${project.artifactId}</name>
8
  <parent>
9
      <groupId>org.gvsig</groupId>
10
      <artifactId>org.gvsig.fmap.mapcontext</artifactId>
11
      <version>2.0.34</version>
12
  </parent>
13
  
14
  <dependencies>
15
    <dependency>
16
      <groupId>org.gvsig</groupId>
17
      <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
18
      <scope>compile</scope>
19
    </dependency>
20
  </dependencies>
21
  
22
</project>
23

  
0 24

  
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
  <modelVersion>4.0.0</modelVersion>
5
  <artifactId>org.gvsig.fmap.mapcontext</artifactId>
6
  <packaging>pom</packaging>
7
  <name>${project.artifactId}</name>
8
  <parent>
9
      <groupId>org.gvsig</groupId>
10
      <artifactId>org.gvsig.desktop.compat.cdc</artifactId>
11
      <version>2.0.34</version>
12
  </parent>
13

  
14
  <modules>
15
      <module>org.gvsig.fmap.mapcontext.api</module>
16
      <module>org.gvsig.fmap.mapcontext.impl</module>
17
      <module>org.gvsig.fmap.mapcontext.operation</module>
18
  </modules>
19

  
20
  <description>This project contains the core of the map drawer of gvSIG.</description>
21
</project>
22

  
0 23

  
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/test/java/org/gvsig/fmap/mapcontext/rendering/symbol/DummyVectorLegend.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.mapcontext.rendering.symbol;
25

  
26
import java.awt.Color;
27
import java.awt.Graphics2D;
28
import java.awt.image.BufferedImage;
29
import java.util.Iterator;
30
import java.util.Map;
31

  
32
import org.cresques.cts.ICoordTrans;
33

  
34
import org.gvsig.compat.print.PrintAttributes;
35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.feature.Feature;
37
import org.gvsig.fmap.dal.feature.FeatureQuery;
38
import org.gvsig.fmap.dal.feature.FeatureSet;
39
import org.gvsig.fmap.dal.feature.FeatureStore;
40
import org.gvsig.fmap.geom.Geometry.TYPES;
41
import org.gvsig.fmap.mapcontext.ViewPort;
42
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
43
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
44
import org.gvsig.fmap.mapcontext.rendering.legend.LegendException;
45
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendContentsChangedListener;
46
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent;
47
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
48
import org.gvsig.tools.ToolsLocator;
49
import org.gvsig.tools.dynobject.DynStruct;
50
import org.gvsig.tools.evaluator.Evaluator;
51
import org.gvsig.tools.observer.Observer;
52
import org.gvsig.tools.persistence.PersistenceManager;
53
import org.gvsig.tools.persistence.PersistentState;
54
import org.gvsig.tools.persistence.exception.PersistenceException;
55
import org.gvsig.tools.task.Cancellable;
56

  
57
public class DummyVectorLegend implements IVectorLegend {
58

  
59
    private long shpType = -1;
60

  
61
    private ISymbol sym = new DummySymbol(Color.RED, TYPES.SOLID);
62

  
63
    public DummyVectorLegend() {
64
        shpType = System.currentTimeMillis() % 1000000;
65
    }
66

  
67
    public DummyVectorLegend(int type) {
68
        shpType = type; // System.currentTimeMillis() % 1000000;
69
    }
70

  
71
    public void draw(BufferedImage image, Graphics2D graphics2D,
72
        ViewPort viewPort, Cancellable cancel, double scale,
73
        Map queryParameters, ICoordTrans coordTrans,
74
        FeatureStore featureStore, FeatureQuery featureQuery) throws LegendException {
75

  
76
    }
77
    public void draw(BufferedImage image, Graphics2D graphics2D,
78
        ViewPort viewPort, Cancellable cancel, double scale,
79
        Map queryParameters, ICoordTrans coordTrans,
80
        FeatureStore featureStore) throws LegendException {
81

  
82
        try {
83
            FeatureSet fs = featureStore.getFeatureSet();
84
            Iterator iter = fs.iterator();
85
            Feature feat = null;
86
            ISymbol symb = null;
87
            while (iter.hasNext()) {
88
                feat = (Feature) iter.next();
89
                symb = this.getSymbolByFeature(feat);
90
                symb.draw(graphics2D, viewPort.getAffineTransform(), feat.getDefaultGeometry(), feat, null);
91
            }
92
        } catch (DataException e) {
93
            // TODO Auto-generated catch block
94
            e.printStackTrace();
95
        }
96
        // TODO Auto-generated method stub
97

  
98
    }
99

  
100
    public int getShapeType() {
101
        // TODO Auto-generated method stub
102
        return (int) shpType;
103
    }
104

  
105
    public ISymbol getSymbolByFeature(Feature feat) {
106
        return sym;
107
    }
108

  
109
    public boolean isSuitableForShapeType(int shapeType) {
110
        return sym.getSymbolType() == shapeType;
111
    }
112

  
113
    public boolean isUseDefaultSymbol() {
114
        return true;
115
    }
116

  
117
    public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
118
        double scale, Object object, ICoordTrans coordTrans,
119
        FeatureStore featureStore, Evaluator evaluator, PrintAttributes properties)
120
    throws LegendException {
121
        // TODO Auto-generated method stub
122

  
123
    }
124

  
125
    public void setDefaultSymbol(ISymbol s) throws IllegalArgumentException {
126
        sym = s;
127
    }
128

  
129
    public void setShapeType(int shapeType) {
130
        shpType = shapeType;
131
    }
132

  
133
    public void useDefaultSymbol(boolean b) {
134
    }
135

  
136
    public void addLegendListener(LegendContentsChangedListener listener) {
137
        // TODO Auto-generated method stub
138

  
139
    }
140

  
141
    public ILegend cloneLegend() {
142
        // TODO Auto-generated method stub
143
        return null;
144
    }
145

  
146
    public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) {
147
        // TODO Auto-generated method stub
148

  
149
    }
150

  
151
    public ISymbol getDefaultSymbol() {
152
        return sym;
153
    }
154

  
155
    public LegendContentsChangedListener[] getListeners() {
156
        // TODO Auto-generated method stub
157
        return null;
158
    }
159

  
160
    public void removeLegendListener(LegendContentsChangedListener listener) {
161
        // TODO Auto-generated method stub
162

  
163
    }
164

  
165
    public String getClassName() {
166
        return this.getClass().getName();
167
    }
168

  
169

  
170

  
171

  
172
    public void addDrawingObserver(Observer observer) {
173
        // TODO Auto-generated method stub
174

  
175
    }
176

  
177
    public void deleteDrawingObserver(Observer observer) {
178
        // TODO Auto-generated method stub
179

  
180
    }
181

  
182
    public void deleteDrawingObservers() {
183
        // TODO Auto-generated method stub
184

  
185
    }
186

  
187
    public void loadFromState(PersistentState state) throws PersistenceException {
188
        shpType = state.getLong("shpType");
189
    }
190

  
191

  
192
    public void saveToState(PersistentState state) throws PersistenceException {
193
        state.set("shpType", shpType);
194
    }
195

  
196
    public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
197
        double scale, Map queryParameters, ICoordTrans coordTrans,
198
        FeatureStore featureStore, FeatureQuery featureQuery, PrintAttributes properties)
199
    throws LegendException {
200
        // TODO Auto-generated method stub
201

  
202
    }
203

  
204
    public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
205
        double scale, Map queryParameters, ICoordTrans coordTrans,
206
        FeatureStore featureStore, PrintAttributes properties)
207
    throws LegendException {
208
        // TODO Auto-generated method stub
209

  
210
    }
211

  
212
    public static void registerPersistent() {
213
        PersistenceManager manager = ToolsLocator.getPersistenceManager();
214
        DynStruct definition = manager.addDefinition(
215
            DummyVectorLegend.class,
216
            "DummyVectorLegend",
217
            "DummyVectorLegend Persistence definition",
218
            null, 
219
            null
220
        );
221
        definition.addDynFieldLong("shpType")
222
        .setMandatory(true);
223
    }
224

  
225

  
226
    public Object clone() throws CloneNotSupportedException {
227
        return super.clone();
228
    }
229

  
230

  
231
}
0 232

  
tags/org.gvsig.desktop-2.0.34/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/test/java/org/gvsig/fmap/mapcontext/rendering/symbol/DummySymbol.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff