Revision 38488

View differences:

tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/resources-test/log4j.xml
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
5

  
6
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
7
		<layout class="org.apache.log4j.PatternLayout">
8
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
9
		</layout>
10
	</appender>
11

  
12
	<category name="org.gvsig.tools">
13
		<priority value="DEBUG" />
14
	</category>
15
	<category name="org.gvsig.fmap.mapcontext">
16
		<priority value="DEBUG" /> 
17
	</category>
18

  
19
	<root>
20
		<priority value="INFO" />
21
		<appender-ref ref="CONSOLE" />
22
	</root>
23
</log4j:configuration>
tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/src/org/gvsig/fmap/geom/operation/DrawInts.java
1
package org.gvsig.fmap.geom.operation;
2

  
3
import java.awt.Graphics2D;
4
import java.awt.geom.AffineTransform;
5
import java.awt.geom.PathIterator;
6

  
7
import org.gvsig.fmap.geom.Geometry;
8
import org.gvsig.fmap.geom.GeometryLocator;
9
import org.gvsig.fmap.geom.GeometryManager;
10
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
11
import org.gvsig.fmap.geom.exception.CreateGeometryException;
12
import org.gvsig.fmap.geom.primitive.GeneralPathX;
13
import org.gvsig.fmap.mapcontext.ViewPort;
14
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport;
15
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
16
import org.gvsig.tools.task.Cancellable;
17
import org.slf4j.Logger;
18
import org.slf4j.LoggerFactory;
19

  
20
public class DrawInts extends GeometryOperation {
21
	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
22
	public static final String NAME = "drawInts";
23
	public static int CODE = Integer.MIN_VALUE;
24

  
25
	final static private Logger logger = LoggerFactory.getLogger(DrawInts.class);
26

  
27
	public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException{
28
		DrawOperationContext doc=(DrawOperationContext)ctx;
29
		ViewPort viewPort = doc.getViewPort();
30
		ISymbol symbol = doc.getSymbol();
31
		Graphics2D g=doc.getGraphics();
32
		Cancellable cancel=doc.getCancellable();
33
		//		 make the symbol to resize itself with the current rendering context
34
		try {
35
			if (doc.hasDPI()){
36
				double previousSize = ((CartographicSupport)symbol).
37
				toCartographicSize(viewPort, doc.getDPI(), geom);
38
				// draw it as normally
39
				Geometry decimatedShape = transformToInts(geom, viewPort.getAffineTransform());
40
				
41
				//the AffineTransform has to be null because the transformToInts method
42
				//reprojects the geometry
43
				symbol.draw(g, null, decimatedShape, doc.getFeature(), cancel);
44
				
45
				// restore previous size
46
				((CartographicSupport)symbol).setCartographicSize(previousSize, geom);
47
			}else{
48
				Geometry decimatedShape = transformToInts(geom, viewPort.getAffineTransform());
49
				symbol.draw(g, viewPort.getAffineTransform(), decimatedShape,
50
						doc.getFeature(), cancel);
51
			}
52
		} catch (CreateGeometryException e) {
53
			e.printStackTrace();
54
			throw new GeometryOperationException(e);
55
		}
56

  
57
		return null;
58
	}
59

  
60
	public int getOperationIndex() {
61
		return CODE;
62
	}
63

  
64
	private Geometry transformToInts(Geometry gp, AffineTransform at) throws CreateGeometryException {
65
		GeneralPathX newGp = new GeneralPathX();
66
		double[] theData = new double[6];
67
		double[] aux = new double[6];
68

  
69
		// newGp.reset();
70
		PathIterator theIterator;
71
		int theType;
72
		int numParts = 0;
73

  
74
		java.awt.geom.Point2D ptDst = new java.awt.geom.Point2D.Double();
75
		java.awt.geom.Point2D ptSrc = new java.awt.geom.Point2D.Double();
76
		boolean bFirst = true;
77
		int xInt, yInt, antX = -1, antY = -1;
78

  
79

  
80
		theIterator = gp.getPathIterator(null); //, flatness);
81
		int numSegmentsAdded = 0;
82
		while (!theIterator.isDone()) {
83
			theType = theIterator.currentSegment(theData);
84

  
85
			switch (theType) {
86
			case PathIterator.SEG_MOVETO:
87
				numParts++;
88
				ptSrc.setLocation(theData[0], theData[1]);
89
				at.transform(ptSrc, ptDst);
90
				antX = (int) ptDst.getX();
91
				antY = (int) ptDst.getY();
92
				newGp.moveTo(antX, antY);
93
				numSegmentsAdded++;
94
				bFirst = true;
95
				break;
96

  
97
			case PathIterator.SEG_LINETO:
98
				ptSrc.setLocation(theData[0], theData[1]);
99
				at.transform(ptSrc, ptDst);
100
				xInt = (int) ptDst.getX();
101
				yInt = (int) ptDst.getY();
102
				if ((bFirst) || ((xInt != antX) || (yInt != antY)))
103
				{
104
					newGp.lineTo(xInt, yInt);
105
					antX = xInt;
106
					antY = yInt;
107
					bFirst = false;
108
					numSegmentsAdded++;
109
				}
110
				break;
111

  
112
			case PathIterator.SEG_QUADTO:
113
				at.transform(theData,0,aux,0,2);
114
				newGp.quadTo(aux[0], aux[1], aux[2], aux[3]);
115
				numSegmentsAdded++;
116
				break;
117

  
118
			case PathIterator.SEG_CUBICTO:
119
				at.transform(theData,0,aux,0,3);
120
				newGp.curveTo(aux[0], aux[1], aux[2], aux[3], aux[4], aux[5]);
121
				numSegmentsAdded++;
122
				break;
123

  
124
			case PathIterator.SEG_CLOSE:
125
				if (numSegmentsAdded < 3) {
126
					newGp.lineTo(antX, antY);
127
				}
128
				newGp.closePath();
129

  
130
				break;
131
			} //end switch
132

  
133
			theIterator.next();
134
		} //end while loop
135

  
136
		Geometry geom = null;
137
		switch (gp.getType()) {
138
		case Geometry.TYPES.POINT:
139
			geom = geomManager.createPoint(ptDst.getX(), ptDst.getY(), SUBTYPES.GEOM2D);
140
			break;
141
		case Geometry.TYPES.CURVE:
142
		case Geometry.TYPES.ARC:
143
			geom = geomManager.createCurve(newGp, SUBTYPES.GEOM2D);
144
			break;
145

  
146
		case Geometry.TYPES.SURFACE:
147
		case Geometry.TYPES.CIRCLE:
148
		case Geometry.TYPES.ELLIPSE:
149

  
150
			geom = geomManager.createSurface(newGp, SUBTYPES.GEOM2D);
151
			break;
152
		}
153
		return geom;
154
	}
155

  
156
	public static void register() {
157
		
158
		GeometryManager gm = GeometryLocator.getGeometryManager();
159
		CODE = gm.getGeometryOperationCode(NAME);
160
		geomManager.registerGeometryOperation(NAME, new DrawInts());
161
	}
162

  
163

  
164
}
tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/src/org/gvsig/fmap/geom/operation/Draw.java
1
package org.gvsig.fmap.geom.operation;
2

  
3
import java.awt.geom.AffineTransform;
4

  
5

  
6
import org.gvsig.fmap.geom.Geometry;
7
import org.gvsig.fmap.geom.GeometryManager;
8
import org.gvsig.fmap.geom.GeometryLocator;
9

  
10
public class Draw extends GeometryOperation{
11
	public static final String NAME = "draw";
12
	public static int CODE = Integer.MIN_VALUE;
13

  
14
	public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
15
		DrawOperationContext doc = (DrawOperationContext)ctx;
16
		AffineTransform at = doc.getViewPort().getAffineTransform();		
17
		doc.getSymbol().draw(doc.getGraphics(), at, geom, doc.getFeature(),
18
				doc.getCancellable());
19
		return null;
20
	}
21

  
22
	public int getOperationIndex() {
23
		return CODE;
24
	}
25

  
26
	public static void register() {
27
		
28
		GeometryManager geoMan = GeometryLocator.getGeometryManager();
29
		CODE = geoMan.getGeometryOperationCode(NAME);
30
		geoMan.registerGeometryOperation(NAME, new Draw());
31
	}
32

  
33
}
tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/src/org/gvsig/fmap/geom/operation/AggregateDrawInts.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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 2
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
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.fmap.geom.operation;
32

  
33
import org.gvsig.fmap.geom.Geometry;
34
import org.gvsig.fmap.geom.GeometryLocator;
35
import org.gvsig.fmap.geom.GeometryManager;
36
import org.gvsig.fmap.geom.Geometry.TYPES;
37
import org.gvsig.fmap.geom.aggregate.Aggregate;
38
import org.slf4j.Logger;
39
import org.slf4j.LoggerFactory;
40

  
41
/**
42
 * @author jmvivo
43
 *
44
 */
45
public class AggregateDrawInts extends GeometryOperation {
46
	public static final String NAME = "drawInts";
47
	public static int CODE = Integer.MIN_VALUE;
48

  
49
	
50
	final static private Logger logger = LoggerFactory
51
			.getLogger(DrawInts.class);
52

  
53
	/* (non-Javadoc)
54
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
55
	 */
56
	public int getOperationIndex() {
57
		return CODE;
58
	}
59

  
60
	/* (non-Javadoc)
61
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext)
62
	 */
63
	public Object invoke(Geometry geom, GeometryOperationContext ctx)
64
			throws GeometryOperationException {
65

  
66
		Aggregate aggregate = (Aggregate) geom;
67
		for (int i=0;i<aggregate.getPrimitivesNumber();i++){
68
			Geometry prim = aggregate.getPrimitiveAt(i);
69
			try {
70
				prim.invokeOperation(CODE, ctx);
71
			} catch (GeometryOperationNotSupportedException e) {
72
				throw new GeometryOperationException(e);
73
			}
74
		}
75
		return null;
76
	}
77

  
78
	public static void register() {
79
		GeometryManager geoMan = GeometryLocator.getGeometryManager();
80

  
81
		CODE = geoMan.getGeometryOperationCode(NAME);
82
		
83
		geoMan.registerGeometryOperation(NAME, new AggregateDrawInts(),
84
				TYPES.AGGREGATE);
85
		geoMan.registerGeometryOperation(NAME, new AggregateDrawInts(),
86
				TYPES.MULTIPOINT);
87
		geoMan.registerGeometryOperation(NAME, new AggregateDrawInts(),
88
				TYPES.MULTICURVE);
89
		geoMan.registerGeometryOperation(NAME, new AggregateDrawInts(),
90
				TYPES.MULTISURFACE);
91
		geoMan.registerGeometryOperation(NAME, new AggregateDrawInts(),
92
				TYPES.MULTISOLID);
93

  
94
	}
95

  
96
}
0 97

  
tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/src/org/gvsig/fmap/geom/operation/DrawOperationContext.java
1
package org.gvsig.fmap.geom.operation;
2

  
3
import java.awt.Graphics2D;
4

  
5
import org.gvsig.fmap.dal.feature.Feature;
6
import org.gvsig.fmap.mapcontext.ViewPort;
7
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
8
import org.gvsig.tools.task.Cancellable;
9

  
10

  
11
public class DrawOperationContext extends GeometryOperationContext{
12
	private ISymbol symbol=null;
13
	private Graphics2D graphics=null;
14
	private Cancellable cancellable;
15
	private double dpi;
16
	private double scale;
17
	private boolean hasDPI=false;
18
	private ViewPort viewPort;
19
	private Feature feature;
20
	
21
	public ViewPort getViewPort() {
22
		return viewPort;
23
	}
24
	public void setViewPort(ViewPort viewPort) {
25
		this.viewPort = viewPort;
26
	}
27
	public Graphics2D getGraphics() {
28
		return graphics;
29
	}
30
	public void setGraphics(Graphics2D graphics) {
31
		this.graphics = graphics;
32
	}
33
	public ISymbol getSymbol() {
34
		return symbol;
35
	}
36
	public void setSymbol(ISymbol symbol) {
37
		this.symbol = symbol;
38
	}
39
	public void setCancellable(Cancellable cancel) {
40
		this.cancellable=cancel;
41

  
42
	}
43
	public Cancellable getCancellable() {
44
		return cancellable;
45
	}
46
	public void setDPI(double dpi) {
47
		this.hasDPI=true;
48
		this.dpi=dpi;
49
	}
50
	public double getDPI(){
51
		return dpi;
52
	}
53
	public boolean hasDPI() {
54
		return hasDPI;
55
	}
56
	/**
57
	 * @param scale the scale to set
58
	 */
59
	public void setScale(double scale) {
60
		this.scale = scale;
61
	}
62
	/**
63
	 * @return the scale
64
	 */
65
	public double getScale() {
66
		return scale;
67
	}
68
	public Feature getFeature() {
69
		return feature;
70
	}
71
	public void setFeature(Feature feature) {
72
		this.feature = feature;
73
	}
74

  
75
}
tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/src/org/gvsig/fmap/geom/operation/MapContextGeomOperationsLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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 2
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
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 IVER T.I   {{Task}}
26
*/
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.fmap.geom.operation;
32

  
33
import org.gvsig.fmap.mapcontext.MapContextLibrary;
34
import org.gvsig.tools.library.AbstractLibrary;
35
import org.gvsig.tools.library.LibraryException;
36

  
37
/**
38
 * @author jmvivo
39
 *
40
 */
41
public class MapContextGeomOperationsLibrary extends AbstractLibrary {
42

  
43
    public void doRegistration() {
44
        registerAsServiceOf(MapContextLibrary.class);
45
    }
46

  
47
	protected void doInitialize() throws LibraryException {
48
	}
49

  
50
	protected void doPostInitialize() throws LibraryException {
51
		// Register Draw Operations
52
		Draw.register();
53
		DrawInts.register();
54
		AggregateDrawInts.register();
55
		AggregateDraw.register();
56
	}
57

  
58
}
0 59

  
tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/src/org/gvsig/fmap/geom/operation/AggregateDraw.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 IVER T.I   {{Task}}
26
 */
27

  
28
/**
29
 *
30
 */
31
package org.gvsig.fmap.geom.operation;
32

  
33
import org.gvsig.fmap.geom.Geometry;
34
import org.gvsig.fmap.geom.GeometryLocator;
35
import org.gvsig.fmap.geom.GeometryManager;
36
import org.gvsig.fmap.geom.Geometry.TYPES;
37
import org.gvsig.fmap.geom.aggregate.Aggregate;
38
import org.slf4j.Logger;
39
import org.slf4j.LoggerFactory;
40

  
41
/**
42
 * @author Vicente Caballero Navarro
43
 *
44
 */
45
public class AggregateDraw extends GeometryOperation {
46
	
47
	public static final String NAME = "draw";
48
	public static int CODE = Integer.MIN_VALUE;
49

  
50
	final static private Logger logger = LoggerFactory
51
	.getLogger(AggregateDraw.class);
52

  
53
	/* (non-Javadoc)
54
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#getOperationIndex()
55
	 */
56
	public int getOperationIndex() {
57
		return CODE;
58
	}
59

  
60
	/* (non-Javadoc)
61
	 * @see org.gvsig.fmap.geom.operation.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.geom.operation.GeometryOperationContext)
62
	 */
63
	public Object invoke(Geometry geom, GeometryOperationContext ctx)
64
	throws GeometryOperationException {
65

  
66
		Aggregate aggregate = (Aggregate) geom;
67
		for (int i=0;i<aggregate.getPrimitivesNumber();i++){
68
			Geometry prim = aggregate.getPrimitiveAt(i);
69
			try {
70
				prim.invokeOperation(CODE, ctx);
71
			} catch (GeometryOperationNotSupportedException e) {
72
				throw new GeometryOperationException(e);
73
			}
74
		}
75
		return null;
76
	}
77

  
78
	public static void register() {
79
		GeometryManager geoMan = GeometryLocator.getGeometryManager();
80
		
81
		CODE = geoMan.getGeometryOperationCode(NAME);
82

  
83
		geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
84
				TYPES.AGGREGATE);
85
		geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
86
				TYPES.MULTIPOINT);
87
		geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
88
				TYPES.MULTICURVE);
89
		geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
90
				TYPES.MULTISURFACE);
91
		geoMan.registerGeometryOperation(NAME, new AggregateDraw(),
92
				TYPES.MULTISOLID);
93

  
94
	}
95

  
96
}
tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/MapContextRuntimeException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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 2
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
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {DiSiD Technologies}  {{Task}}
26
*/
27
package org.gvsig.fmap.mapcontext;
28

  
29
import org.gvsig.tools.exception.BaseException;
30
import org.gvsig.tools.exception.BaseRuntimeException;
31

  
32
/**
33
 * Parent class for MapContext runtime exceptions.
34
 * 
35
 * @author <a href="mailto:cordinyana@gvsig.org">C?sar Ordi?ana</a>
36
 */
37
public class MapContextRuntimeException extends BaseRuntimeException {
38

  
39
	private static final long serialVersionUID = 3993964182701795153L;
40

  
41
	/**
42
     * @see BaseException#BaseException(String, String, long)
43
     */
44
    protected MapContextRuntimeException(String message, String key, long code) {
45
        super(message, null, key, code);
46
    }
47

  
48
    /**
49
     * @see BaseException#BaseException(String, Throwable, String, long)
50
     */
51
    protected MapContextRuntimeException(String message, Throwable cause, String key,
52
            long code) {
53
        super(message, cause, key, code);
54
    }
55
    
56
    public MapContextRuntimeException(Throwable cause) {
57
        this(
58
        		"MapContext related error",
59
        		cause,
60
        		"_MapContext_related_error", 
61
        		serialVersionUID
62
        );
63
    }
64
}
tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/MapContextLocator.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {DiSiD Technologies}  {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontext;
28

  
29
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
30
import org.gvsig.tools.locator.BaseLocator;
31
import org.gvsig.tools.locator.Locator;
32
import org.gvsig.tools.locator.LocatorException;
33

  
34
/**
35
 * Locator for the MapContext library.
36
 * 
37
 * @author <a href="mailto:cordinyana@gvsig.org">C?sar Ordi?ana</a>
38
 */
39
public class MapContextLocator extends BaseLocator {
40

  
41
	public static final String MAPCONTEXT_MANAGER_NAME = "mapcontextlocator.manager";
42

  
43
	private static final String MAPCONTEXT_MANAGER_DESCRIPTION = "MapContext Library manager";
44

  
45
	public static final String SYMBOL_MANAGER_NAME = "symbol.manager";
46

  
47
	private static final String SYMBOL_MANAGER_DESCRIPTION = "Symbols manager";
48

  
49
	private static final MapContextLocator instance = new MapContextLocator();
50

  
51
	/**
52
	 * Private constructor, we don't want it to be able to be instantiated
53
	 * outside this class.
54
	 */
55
	private MapContextLocator() {
56
		// Nothing to do
57
	}
58

  
59
	public static MapContextLocator getInstance() {
60
		return instance;
61
	}
62

  
63
	/**
64
	 * Return a reference to MapContextManager.
65
	 * 
66
	 * @return a reference to MapContextManager
67
	 * @throws LocatorException
68
	 *             if there is no access to the class or the class cannot be
69
	 *             instantiated
70
	 * @see Locator#get(String)
71
	 */
72
	public static MapContextManager getMapContextManager()
73
			throws LocatorException {
74
		return (MapContextManager) getInstance().get(MAPCONTEXT_MANAGER_NAME);
75
	}
76

  
77
	/**
78
	 * Registers the Class implementing the MapContextManager interface.
79
	 * 
80
	 * @param clazz
81
	 *            implementing the MapContextManager interface
82
	 */
83
	public static void registerMapContextManager(Class clazz) {
84
		getInstance().register(MAPCONTEXT_MANAGER_NAME,
85
				MAPCONTEXT_MANAGER_DESCRIPTION, clazz);
86
	}
87

  
88
	/**
89
	 * Return a reference to the {@link SymbolManager}.
90
	 * 
91
	 * @return a reference to the SymbolManager.
92
	 * @throws LocatorException
93
	 *             if there is no access to the class or the class cannot be
94
	 *             instantiated
95
	 * @see Locator#get(String)
96
	 */
97
	public static SymbolManager getSymbolManager() throws LocatorException {
98
		return (SymbolManager) getInstance().get(SYMBOL_MANAGER_NAME);
99
	}
100

  
101
	/**
102
	 * Registers the Class implementing the SymbolManager interface.
103
	 * 
104
	 * @param clazz
105
	 *            implementing the SymbolManager interface
106
	 */
107
	public static void registerSymbolManager(Class clazz) {
108
		getInstance().register(SYMBOL_MANAGER_NAME, SYMBOL_MANAGER_DESCRIPTION,
109
				clazz);
110
	}
111
}
tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/MapContextLibrary.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 IVER T.I. S.A.   {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontext;
28

  
29
import org.slf4j.Logger;
30
import org.slf4j.LoggerFactory;
31

  
32
import org.gvsig.compat.CompatLibrary;
33
import org.gvsig.fmap.dal.DALLibrary;
34
import org.gvsig.fmap.dal.feature.FeatureStore;
35
import org.gvsig.fmap.mapcontext.impl.DefaultMapContextDrawer;
36
import org.gvsig.fmap.mapcontext.layers.FLayerStatus;
37
import org.gvsig.fmap.mapcontext.layers.FLayers;
38
import org.gvsig.fmap.mapcontext.layers.FLyrDefault;
39
import org.gvsig.fmap.mapcontext.layers.LayerFactory;
40
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
41
import org.gvsig.fmap.mapcontext.layers.vectorial.ReprojectDefaultGeometry;
42
import org.gvsig.fmap.mapcontext.tools.persistence.ColorPersistenceFactory;
43
import org.gvsig.fmap.mapcontext.tools.persistence.DimensionPersistenceFactory;
44
import org.gvsig.fmap.mapcontext.tools.persistence.FontPersistenceFactory;
45
import org.gvsig.fmap.mapcontext.tools.persistence.Point2DPersistenceFactory;
46
import org.gvsig.fmap.mapcontext.tools.persistence.Rectangle2DPersistenceFactory;
47
import org.gvsig.tools.ToolsLocator;
48
import org.gvsig.tools.library.AbstractLibrary;
49
import org.gvsig.tools.library.LibraryException;
50
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
51
import org.gvsig.tools.persistence.PersistenceManager;
52
import org.gvsig.tools.util.Caller;
53
import org.gvsig.tools.util.impl.DefaultCaller;
54

  
55
/**
56
 * Library for the MapContext library API.
57
 * @author jmvivo
58
 */
59
public class MapContextLibrary extends AbstractLibrary {
60
	final static private Logger LOG = LoggerFactory.getLogger(FLyrDefault.class);
61

  
62
    public void doRegistration() {
63
        registerAsAPI(MapContextLibrary.class);
64
        require(DALLibrary.class);
65
        require(CompatLibrary.class);
66
    }
67

  
68
	protected void doInitialize() throws LibraryException {
69
		LayerFactory.getInstance().registerLayerToUseForStore(
70
				FeatureStore.class, FLyrVect.class);
71
	}
72

  
73
	protected void doPostInitialize() throws LibraryException {
74
        Caller caller = new DefaultCaller();
75

  
76
        FLyrDefault.registerMetadata();	
77

  
78
		MapContextManager manager = MapContextLocator.getMapContextManager();
79

  
80
		if (manager == null) {
81
			throw new ReferenceNotRegisteredException(
82
					MapContextLocator.MAPCONTEXT_MANAGER_NAME,
83
					MapContextLocator.getInstance());
84
		}
85

  
86
		try {
87
			manager.setDefaultMapContextDrawer(DefaultMapContextDrawer.class);
88
		} catch (MapContextException ex) {
89
			throw new LibraryException(getClass().getName(), ex);
90
		}
91
		
92
        caller.add( new ViewPort.RegisterPersistence() );
93

  
94
        /*
95
         * Do register of all
96
         */
97
        if( !caller.call() ) {
98
        	throw new LibraryException(MapContextLibrary.class, caller.getExceptions());
99
        }
100

  
101
        // persistent classes
102
		MapContext.registerPersistent();
103
		
104
		ExtentHistory.registerPersistent();
105
		
106
//		MappingAnnotation.registerPersistent();
107
		ReprojectDefaultGeometry.registerPersistent();
108

  
109
//		FLayerVectorialDB.registerPersistent();
110
//		FLayerFileVectorial.registerPersistent();
111
		
112
		FLayerStatus.registerPersistent();
113
		FLyrDefault.registerPersistent();
114
		FLyrVect.registerPersistent();
115
		FLayers.registerPersistent();
116
				
117
		////////////////////////////////////////
118
		// Register the persistence factories //
119
		////////////////////////////////////////
120
		PersistenceManager persistenceManager =
121
				ToolsLocator.getPersistenceManager();
122
		// Color
123
		persistenceManager.registerFactory(new ColorPersistenceFactory());
124
		// Point2D
125
		persistenceManager.registerFactory(new Point2DPersistenceFactory());
126
		// Font
127
		persistenceManager.registerFactory(new FontPersistenceFactory());
128
		// Rectangle2D
129
		persistenceManager.registerFactory(new Rectangle2DPersistenceFactory());
130
		// awt Dimension
131
		persistenceManager.registerFactory(new DimensionPersistenceFactory());
132
	}
133

  
134
}
0 135

  
tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/Messages.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
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
 */
41
package org.gvsig.fmap.mapcontext;
42

  
43
import java.util.Locale;
44
import java.util.MissingResourceException;
45
import java.util.ResourceBundle;
46

  
47

  
48
/**
49
 * Clase que accede a los recursos para la i18n
50
 */
51
public class Messages {
52
    /** DOCUMENT ME! */
53
    private static final String BUNDLE_NAME = "com.iver.cit.gvsig.fmap.FMap";
54

  
55
    /** DOCUMENT ME! */
56
    private static ResourceBundle RESOURCE_BUNDLE = null;
57

  
58
    /**
59
     * Inicializa la clase con el locale adecuado
60
     *
61
     * @param loc Locale de la aplicaci?n
62
     */
63
    private static void init() {
64
        Locale loc = Locale.getDefault();
65
        RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, loc);
66
    }
67

  
68
    
69
    /**
70
     * Obtiene el valor del recurso con clave 'key'
71
     *
72
     * @param key clave del recurso que se quiere obtener
73
     *
74
     * @return recurso que se quiere obtener o !key! en caso de no encontrarlo.
75
     *         En dicho caso no se notifica al framework ya que  estos son los
76
     *         mensajes propios de la aplicaci?n y deben de estar todos
77
     */
78
    public static String getString(String key) {
79
        try {
80
            // La primera vez, cargamos las cadenas.
81
            if (RESOURCE_BUNDLE == null)
82
                init();
83
            return RESOURCE_BUNDLE.getString(key);
84
        } catch (MissingResourceException e) {
85
            return '!' + key + '!';
86
        }
87
    }
88
}
tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/MapContextManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {DiSiD Technologies}  {Create Manager to register MapContextDrawer implementation}
26
 */
27
package org.gvsig.fmap.mapcontext;
28

  
29
import java.awt.Color;
30
import java.awt.Font;
31

  
32
import org.cresques.cts.IProjection;
33

  
34
import org.gvsig.fmap.dal.DataStore;
35
import org.gvsig.fmap.dal.DataStoreParameters;
36
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
37
import org.gvsig.fmap.mapcontext.layers.FLayer;
38
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer;
39
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
40
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
41
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendReader;
42
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendWriter;
43
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingStrategy;
44
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol;
45
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
46
import org.gvsig.fmap.mapcontext.rendering.symbols.IWarningSymbol;
47
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
48
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolPreferences;
49

  
50
/**
51
 * Manager of the MapContext library.
52
 * 
53
 * Holds the default implementation of the {@link MapContextDrawer}.
54
 * 
55
 * @author <a href="mailto:cordinyana@gvsig.org">C?sar Ordi?ana</a>
56
 * @author <a href="mailto:jjdelcerro@gvsig.org">Joaquin Jose del Cerro</a>
57
 */
58
public interface MapContextManager {
59

  
60
	/**
61
	 * Create a new layer from the data parameters passed as parameter.
62
	 * 
63
	 * @param layerName name used in for the new layer. 
64
	 * @param parameters used for create the {@link DataStore} of the new layer
65
	 * 
66
	 * @return the new FLayer
67
	 * 
68
	 * @throws LoadLayerException
69
	 */
70
	public FLayer createLayer(String layerName,
71
			DataStoreParameters parameters) throws LoadLayerException;
72

  
73
	/**
74
	 * Create a layer from a {@link DataStore}.
75
	 * 
76
	 * @param layerName name used in for the new layer. 
77
	 * @param store used for the new layer
78
	 * 
79
	 * @return the new FLayer
80
	 * 
81
	 * @throws LoadLayerException
82
	 */
83
	public FLayer createLayer(String layerName, DataStore store)
84
			throws LoadLayerException;
85

  
86
	/**
87
	 * Create a layer to be used as the {@link GraphicLayer}.
88
	 * 
89
	 * @param projection used in the layer.
90
	 * 
91
	 * @return the new {@link GraphicLayer}.
92
	 */
93
	public GraphicLayer createGraphicsLayer(IProjection projection);
94

  
95
	/**
96
	 * Returns the current {@link SymbolManager}.
97
	 * 
98
	 * @return the {@link SymbolManager}
99
	 */
100
	SymbolManager getSymbolManager();
101

  
102
	/**
103
	 * Sets the class to use as the default implementation for the
104
	 * {@link MapContextDrawer}.
105
	 * 
106
	 * @param drawerClazz
107
	 *            the {@link MapContextDrawer} class to use
108
	 * @throws MapContextException
109
	 *             if there is any error setting the class
110
	 */
111
	public void setDefaultMapContextDrawer(Class drawerClazz)
112
			throws MapContextException;
113

  
114
	public void validateMapContextDrawer(Class drawerClazz) throws MapContextException;
115

  
116
	/**
117
	 * Creates a new instance of the default {@link MapContextDrawer}
118
	 * implementation.
119
	 * 
120
	 * @return the new {@link MapContextDrawer} instance
121
	 * @throws MapContextException
122
	 *             if there is an error creating the new object instance
123
	 */
124
	public MapContextDrawer createDefaultMapContextDrawerInstance()
125
			throws MapContextException;
126

  
127
	/**
128
	 * Creates a new instance of the provided {@link MapContextDrawer}
129
	 * implementation.
130
	 * 
131
	 * @param drawerClazz
132
	 *            the {@link MapContextDrawer} implementation class
133
	 * @return the new {@link MapContextDrawer} instance
134
	 * @throws MapContextException
135
	 *             if there is an error creating the new object instance
136
	 */
137
	public MapContextDrawer createMapContextDrawerInstance(Class drawerClazz)
138
			throws MapContextException;
139

  
140
	
141
	
142
	void registerLegend(String legendName, Class legendClass)
143
			throws MapContextRuntimeException;
144

  
145
	ILegend createLegend(String legendName) throws MapContextRuntimeException;
146

  
147
	void setDefaultVectorLegend(String legendName);
148

  
149
	IVectorLegend createDefaultVectorLegend(int shapeType)
150
			throws MapContextRuntimeException;
151

  
152
	void registerLegendWriter(String legendName, String format,
153
			Class writerClass) throws MapContextRuntimeException;
154

  
155
	void registerLegendReader(String format, Class readerClass)
156
			throws MapContextRuntimeException;
157

  
158
	ILegendWriter createLegendWriter(String legendName, String format)
159
			throws MapContextException;
160

  
161
	ILegendReader createLegendReader(String format)
162
			throws MapContextRuntimeException;
163

  
164
	/**
165
	 * @deprecated to be removed in gvSIG 2.0
166
	 * @see {@link SymbolPreferences}.
167
	 */
168
	int getDefaultCartographicSupportMeasureUnit();
169

  
170
	/**
171
	 * @deprecated to be removed in gvSIG 2.0
172
	 * @see {@link SymbolPreferences}.
173
	 */
174
	void setDefaultCartographicSupportMeasureUnit(
175
			int defaultCartographicSupportMeasureUnit);
176

  
177
	/**
178
	 * @deprecated to be removed in gvSIG 2.0
179
	 * @see {@link SymbolPreferences}.
180
	 */
181
	int getDefaultCartographicSupportReferenceSystem();
182

  
183
	/**
184
	 * @deprecated to be removed in gvSIG 2.0
185
	 * @see {@link SymbolPreferences}.
186
	 */
187
	void setDefaultCartographicSupportReferenceSystem(
188
			int defaultCartographicSupportReferenceSystem);
189

  
190
	/**
191
	 * @deprecated to be removed in gvSIG 2.0
192
	 * @see {@link SymbolPreferences}.
193
	 */
194
	Color getDefaultSymbolColor();
195

  
196
	/**
197
	 * @deprecated to be removed in gvSIG 2.0
198
	 * @see {@link SymbolPreferences}.
199
	 */
200
	void setDefaultSymbolColor(Color defaultSymbolColor);
201

  
202
	/**
203
	 * @deprecated to be removed in gvSIG 2.0
204
	 * @see {@link SymbolPreferences}.
205
	 */
206
	void resetDefaultSymbolColor();
207

  
208
	/**
209
	 * @deprecated to be removed in gvSIG 2.0
210
	 * @see {@link SymbolPreferences}.
211
	 */
212
	Color getDefaultSymbolFillColor();
213

  
214
	/**
215
	 * @deprecated to be removed in gvSIG 2.0
216
	 * @see {@link SymbolPreferences}.
217
	 */
218
	void setDefaultSymbolFillColor(Color defaultSymbolFillColor);
219

  
220
	/**
221
	 * @deprecated to be removed in gvSIG 2.0
222
	 * @see {@link SymbolPreferences}.
223
	 */
224
	void resetDefaultSymbolFillColor();
225

  
226
	/**
227
	 * @deprecated to be removed in gvSIG 2.0
228
	 * @see {@link SymbolPreferences}.
229
	 */
230
	boolean isDefaultSymbolFillColorAleatory();
231

  
232
	/**
233
	 * @deprecated to be removed in gvSIG 2.0
234
	 * @see {@link SymbolPreferences}.
235
	 */
236
	void setDefaultSymbolFillColorAleatory(
237
			boolean defaultSymbolFillColorAleatory);
238

  
239
	/**
240
	 * @deprecated to be removed in gvSIG 2.0
241
	 * @see {@link SymbolPreferences}.
242
	 */
243
	void resetDefaultSymbolFillColorAleatory();
244

  
245
	/**
246
	 * @deprecated to be removed in gvSIG 2.0
247
	 * @see {@link SymbolPreferences}.
248
	 */
249
	Font getDefaultSymbolFont();
250

  
251
	/**
252
	 * @deprecated to be removed in gvSIG 2.0
253
	 * @see {@link SymbolPreferences}.
254
	 */
255
	void setDefaultSymbolFont(Font defaultSymbolFont);
256

  
257
	/**
258
	 * @deprecated to be removed in gvSIG 2.0
259
	 * @see {@link SymbolPreferences}.
260
	 */
261
	void resetDefaultSymbolFont();
262

  
263
	/**
264
	 * @deprecated to be removed in gvSIG 2.0
265
	 * @see {@link SymbolPreferences}.
266
	 */
267
	String getSymbolLibraryPath();
268

  
269
	/**
270
	 * @deprecated to be removed in gvSIG 2.0
271
	 * @see {@link SymbolPreferences}.
272
	 */
273
	void setSymbolLibraryPath(String symbolLibraryPath);
274

  
275
	/**
276
	 * @deprecated to be removed in gvSIG 2.0
277
	 * @see {@link SymbolPreferences}.
278
	 */
279
	void resetSymbolLibraryPath();
280
	
281
	
282
	/**
283
	 * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
284
	 */
285
	ISymbol createSymbol(String symbolName) throws MapContextRuntimeException;
286

  
287
	/**
288
	 * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
289
	 */
290
	ISymbol createSymbol(int shapeType) throws MapContextRuntimeException;
291

  
292
	/**
293
	 * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
294
	 */
295
	ISymbol createSymbol(String symbolName, Color color)
296
			throws MapContextRuntimeException;
297

  
298
	/**
299
	 * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
300
	 */
301
	ISymbol createSymbol(int shapeType, Color color)
302
			throws MapContextRuntimeException;
303

  
304
	/**
305
	 * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
306
	 */
307
	IMultiLayerSymbol createMultiLayerSymbol(String symbolName)
308
			throws MapContextRuntimeException;
309

  
310
	/**
311
	 * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
312
	 */
313
	IMultiLayerSymbol createMultiLayerSymbol(int shapeType)
314
			throws MapContextRuntimeException;
315

  
316
	/**
317
	 * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
318
	 */
319
	void registerSymbol(String symbolName, Class symbolClass)
320
			throws MapContextRuntimeException;
321

  
322
	/**
323
	 * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
324
	 */
325
	void registerSymbol(String symbolName, int[] shapeTypes, Class symbolClass)
326
			throws MapContextException;
327

  
328
	/**
329
	 * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
330
	 */
331
	void registerMultiLayerSymbol(String symbolName, Class symbolClass)
332
			throws MapContextRuntimeException;
333

  
334
	/**
335
	 * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
336
	 */
337
	void registerMultiLayerSymbol(String symbolName, int[] shapeTypes,
338
			Class symbolClass) throws MapContextRuntimeException;
339

  
340
	/**
341
	 * @deprecated to be removed in gvSIG 2.0 @see {@link SymbolManager}
342
	 */
343
	IWarningSymbol getWarningSymbol(String message, String symbolDesc,
344
			int symbolDrawExceptionType) throws MapContextRuntimeException;
345
	
346
	/**
347
	 * It returns the legend associated with a {@link DataStore}.
348
	 * If the legend doesn't exist it returns <code>null</code>.
349
	 * @param dataStore
350
	 * the store that could have a legend.
351
	 * @return
352
	 * the legend or <code>null</code>.
353
	 */
354
	ILegend getLegend(DataStore dataStore);	
355
	
356
	/**
357
     * It returns the labeling strategy associated with a {@link DataStore}.
358
     * If the labeling strategy doesn't exist it returns <code>null</code>.
359
     * @param dataStore
360
     * the store that could have a labeling strategy.
361
     * @return
362
     * the labeling strategy or <code>null</code>.
363
     */
364
	ILabelingStrategy getLabelingStrategy(DataStore dataStore);
365

  
366

  
367
    // TODO:
368
    // DynObjectModel getFeatureTypeUIModel(DataStore store,
369
    // FeatureType featureType);
370
}
tags/v2_0_0_Build_2049/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/SelectedZoomVisitor.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
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
 */
41
package org.gvsig.fmap.mapcontext;
42

  
43
import org.gvsig.fmap.dal.DataSet;
44
import org.gvsig.fmap.dal.feature.Feature;
45
import org.gvsig.fmap.dal.feature.FeatureReference;
46
import org.gvsig.fmap.geom.primitive.Envelope;
47
import org.gvsig.fmap.mapcontext.layers.FLayer;
48
import org.gvsig.fmap.mapcontext.layers.operations.LayersVisitor;
49
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer;
50
import org.gvsig.tools.exception.BaseException;
51
import org.gvsig.tools.visitor.NotSupportedOperationException;
52
import org.gvsig.tools.visitor.Visitable;
53
import org.gvsig.tools.visitor.Visitor;
54

  
55

  
56
/**
57
 * Visitor de zoom a lo seleccionado.
58
 *
59
 * @author Vicente Caballero Navarro
60
 */
61
public class SelectedZoomVisitor implements LayersVisitor, Visitor {
62
	private Envelope rectangle = null;
63

  
64
	/**
65
	 * Devuelve el Extent de los shapes seleccionados, y si no hay ning?n shape
66
	 * seleccionado devuelve null.
67
	 *
68
	 * @return Extent de los shapes seleccionados.
69
	 */
70
	public Envelope getSelectBound() {
71
		return rectangle;
72
	}
73

  
74
	public String getProcessDescription() {
75
		return "Defining rectangle to zoom from selected geometries";
76
	}
77

  
78
	public void visit(Feature feature) throws BaseException {
79
		if (rectangle == null) {
80
			rectangle = (feature.getDefaultGeometry()).getEnvelope();
81
		} else {
82
			rectangle.add((feature.getDefaultGeometry())
83
					.getEnvelope());
84
		}
85
	}
86

  
87
	public void visit(FeatureReference featureRefence) throws BaseException {
88
		this.visit(featureRefence.getFeature());
89
	}
90

  
91
	public void visit(Object obj) throws BaseException {
92
		if (obj instanceof FeatureReference) {
93
			this.visit((FeatureReference) obj);
94
			return;
95
		}
96
		if (obj instanceof Feature) {
97
			this.visit((Feature) obj);
98
			return;
99
		}
100
		if (obj instanceof FLayer) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff