Revision 213

View differences:

trunk/libraries/libFMap/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>FMap 03</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
16
		<nature>org.eclipse.jdt.core.javanature</nature>
17
		<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
18
	</natures>
19
</projectDescription>
0 20

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/WFSDriver.java
1
/* Generated by Together */
2

  
3
package com.iver.cit.gvsig.fmap;
4

  
5
import java.io.IOException;
6
import java.net.ProtocolException;
7

  
8
import com.iver.cit.gvsig.fmap.fshape.FGeometry;
9

  
10
public interface WFSDriver extends  VectorialDriver {
11
    void describeFeatureType() throws IOException, WFSException, ProtocolException;
12

  
13
    FGeometry[] getFeature() throws IOException, WFSException, ProtocolException;
14

  
15
    void lockFeature() throws IOException, WFSException, ProtocolException;
16

  
17
    void transaction() throws IOException, WFSException, ProtocolException;
18
}
0 19

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/FeatureVisitor.java
1
/* Generated by Together */
2

  
3
package com.iver.cit.gvsig.fmap;
4

  
5
import com.iver.cit.gvsig.fmap.fshape.FGeometry;
6

  
7
public interface FeatureVisitor {
8
    /**
9
     * Recibe las geometr?as a medida que se van recorriendo en la estrategia.
10
     */
11
    void visit(FGeometry g);
12

  
13
    /**
14
     * M?todo invocado al finalizar las visitas con el fin de que se puedan liberar los recursos reservados en start 
15
     */
16
    void stop();
17

  
18
    /**
19
     * M?todo invocado antes de las visitas para que el visitor pueda reservar alg?n tipo de recurso que sea necesario 
20
     */
21
    void start();
22
}
0 23

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/ExtentListener.java
1
/* Generated by Together */
2

  
3
package com.iver.cit.gvsig.fmap;
4

  
5
public interface ExtentListener {
6
    void extentChanged(ExtentEvent e);
7
}
0 8

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/WFSException.java
1
package com.iver.cit.gvsig.fmap;
2

  
3

  
4
public class WFSException extends Exception {
5

  
6
	/**
7
	 * 
8
	 */
9
	public WFSException() {
10
		super();
11

  
12
	}
13
	/**
14
	 * @param message
15
	 */
16
	public WFSException(String message) {
17
		super(message);
18

  
19
	}
20
	/**
21
	 * @param message
22
	 * @param cause
23
	 */
24
	public WFSException(String message, Throwable cause) {
25
		super(message, cause);
26

  
27
	}
28
	/**
29
	 * @param cause
30
	 */
31
	public WFSException(Throwable cause) {
32
		super(cause);
33

  
34
	}
35
}
0 36

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/WMSDriver.java
1
/* Generated by Together */
2

  
3
package com.iver.cit.gvsig.fmap;
4

  
5
import java.awt.Image;
6
import java.io.IOException;
7
import java.net.ProtocolException;
8
import java.net.URL;
9

  
10
public interface WMSDriver {
11
    void getCapabilities(URL servidor) throws WMSException, IOException, ProtocolException;
12

  
13
    Image getMap(MapQuery mapQuery) throws WMSException, IOException, ProtocolException;
14

  
15
    String getFeatureInfo(InfoQuery infoQuery) throws WMSException, IOException, ProtocolException;
16
}
0 17

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/FMap.java
1
/* Generated by Together */
2
package com.iver.cit.gvsig.fmap;
3

  
4
import java.awt.Graphics2D;
5
import java.awt.geom.Point2D;
6
import java.awt.geom.Rectangle2D;
7
import java.awt.image.BufferedImage;
8

  
9
import org.cresques.cts.ICoordTrans;
10
import org.cresques.cts.IProjection;
11
import org.cresques.geo.Projected;
12

  
13
import com.iver.cit.gvsig.fmap.fshape.FGeometry;
14

  
15

  
16
/**
17
 * DOCUMENT ME!
18
 *
19
 * @author Fernando Gonz?lez Cort?s
20
 */
21
public class FMap implements Strategy, Projected {
22
	public static final int EQUALS = 0;
23
	public static final int DISJOINT = 1;
24
	public static final int INTERSECTS = 2;
25
	public static final int TOUCHES = 3;
26
	public static final int CROSSES = 4;
27
	public static final int WITHIN = 5;
28
	public static final int CONTAINS = 6;
29
	public static final int OVERLAPS = 7;
30
	private FLayers layers = new FLayers();
31
	private ViewPort viewPort;
32

  
33
	/**
34
	 * DOCUMENT ME!
35
	 *
36
	 * @return DOCUMENT ME!
37
	 */
38
	public FLayers getLayers() {
39
		return layers;
40
	}
41

  
42
	/**
43
	 * Dibuja en la imagen que se pasa como par?metro el contenido de las capas
44
	 * visibles del mapa y teniendo en cuenta los datos del ViewPort contenido
45
	 * en este FMap
46
	 *
47
	 * @param b DOCUMENT ME!
48
	 */
49
	public void drawLabels(BufferedImage b) {
50
	}
51

  
52
	/**
53
	 * DOCUMENT ME!
54
	 *
55
	 * @param g DOCUMENT ME!
56
	 */
57
	public void print(Graphics2D g) {
58
	}
59

  
60
	/**
61
	 * Crea un nuevo FMap con la informaci?n del ViewPort que se pasa como
62
	 * par?metro.
63
	 *
64
	 * @param vp DOCUMENT ME!
65
	 *
66
	 * @return DOCUMENT ME!
67
	 */
68
	public FMap createNewFMap(ViewPort vp) {
69
		FMap ret = new FMap();
70
		ret.layers = this.layers;
71
		ret.viewPort = vp;
72

  
73
		return ret;
74
	}
75

  
76
	/**
77
	 * Crea un nuevo FMap totalmente desligado, se replican las capas y el
78
	 * ViewPort
79
	 *
80
	 * @return DOCUMENT ME!
81
	 */
82
	public FMap cloneFMap() {
83
		return createXMLEntity(getXMLEntity());
84
	}
85

  
86
	/**
87
	 * DOCUMENT ME!
88
	 *
89
	 * @return DOCUMENT ME!
90
	 */
91
	public XMLEntity getXMLEntity() {
92
		return new XMLEntity();
93
	}
94

  
95
	/**
96
	 * DOCUMENT ME!
97
	 *
98
	 * @param xe DOCUMENT ME!
99
	 *
100
	 * @return DOCUMENT ME!
101
	 */
102
	public FMap createXMLEntity(XMLEntity xe) {
103
		// TODO Implementar bien
104
		return new FMap();
105
	}
106

  
107
	/**
108
	 * A?ade la capa que se pasa como par?metro al nodo que se pasa como
109
	 * parametro y lanza ProjectionMismatchException si no est?n todas las
110
	 * capas de este FMap en la misma proyecci?n. Lanza un
111
	 * ChildNotAllowedException si la capa no es un FLayers y no permite hijos
112
	 *
113
	 * @param parent DOCUMENT ME!
114
	 * @param layer DOCUMENT ME!
115
	 *
116
	 * @throws ProjectionMismatchException DOCUMENT ME!
117
	 * @throws ChildrenNotAllowedException DOCUMENT ME!
118
	 */
119
	public void addLayer(LayerPath parent, FLayer layer)
120
		throws ProjectionMismatchException, ChildrenNotAllowedException {
121
		layers.addLayer(parent, layer);
122
	}
123

  
124
	/**
125
	 * A?ade una capa al grupo de capas que se sit?a por encima de todas las
126
	 * otras capas
127
	 *
128
	 * @param vectorial DOCUMENT ME!
129
	 */
130
	public void addToTrackLayer(FLyrVect vectorial) {
131
	}
132

  
133
	/**
134
	 * @see com.iver.cit.gvsig.fmap.Strategy#setVectorial(com.iver.cit.gvsig.fmap.VectorialAdapter)
135
	 */
136
	public void setVectorial(VectorialAdapter v) {
137
	}
138

  
139
	/**
140
	 * @see com.iver.cit.gvsig.fmap.Strategy#process(com.iver.cit.gvsig.fmap.FeatureSelectorVisitor)
141
	 */
142
	public void process(FeatureSelectorVisitor visitor) {
143
	}
144

  
145
	/**
146
	 * @see com.iver.cit.gvsig.fmap.Strategy#processSelected(com.iver.cit.gvsig.fmap.FeatureVisitor)
147
	 */
148
	public void processSelected(FeatureVisitor visitor) {
149
	}
150

  
151
	/**
152
	 * @see com.iver.cit.gvsig.fmap.Strategy#select(com.iver.cit.gvsig.fmap.FeatureSelectorVisitor)
153
	 */
154
	public void select(FeatureSelectorVisitor visitor) {
155
	}
156

  
157
	/**
158
	 * @see com.iver.cit.gvsig.fmap.Strategy#selectFromSelection()
159
	 */
160
	public void selectFromSelection() {
161
	}
162

  
163
	/**
164
	 * @see com.iver.cit.gvsig.fmap.Strategy#createIndex()
165
	 */
166
	public void createIndex() {
167
	}
168

  
169
	/**
170
	 * @see org.cresques.geo.Projected#getProjection()
171
	 */
172
	public IProjection getProjection() {
173
		return null;
174
	}
175

  
176
	/**
177
	 * @see org.cresques.geo.Projected#reProject(org.cresques.cts.ICoordTrans)
178
	 */
179
	public void reProject(ICoordTrans arg0) {
180
	}
181

  
182
	/**
183
	 * @see com.iver.cit.gvsig.fmap.Strategy#selectByPoint(java.awt.geom.Point2D,
184
	 * 		double)
185
	 */
186
	public void selectByPoint(Point2D p, double tolerance) {
187
	}
188

  
189
	/**
190
	 * @see com.iver.cit.gvsig.fmap.Strategy#selectByRect(java.awt.geom.Rectangle2D)
191
	 */
192
	public void selectByRect(Rectangle2D rect) {
193
	}
194

  
195
	/**
196
	 * @see com.iver.cit.gvsig.fmap.Strategy#selectByShape(com.iver.cit.gvsig.fmap.fshape.FGeometry,
197
	 * 		int)
198
	 */
199
	public void selectByShape(FGeometry g, int relationship) {
200
	}
201

  
202
	/**
203
	 * @see com.iver.cit.gvsig.fmap.Strategy#queryByPoint(java.awt.geom.Point2D,
204
	 * 		double)
205
	 */
206
	public Record[] queryByPoint(Point2D p, double tolerance) {
207
		return null;
208
	}
209

  
210
	/**
211
	 * @see com.iver.cit.gvsig.fmap.Strategy#queryByRect(java.awt.geom.Rectangle2D)
212
	 */
213
	public Record[] queryByRect(Rectangle2D rect) {
214
		return null;
215
	}
216

  
217
	/**
218
	 * @see com.iver.cit.gvsig.fmap.Strategy#queryByShape(com.iver.cit.gvsig.fmap.fshape.FGeometry,
219
	 * 		int)
220
	 */
221
	public Record[] queryByShape(FGeometry g, int relationship) {
222
		return null;
223
	}
224

  
225
	/**
226
	 * @see com.iver.cit.gvsig.fmap.Strategy#getSelectionBounds()
227
	 */
228
	public Rectangle2D getSelectionBounds() {
229
		return null;
230
	}
231

  
232
	/**
233
	 * DOCUMENT ME!
234
	 *
235
	 * @param image DOCUMENT ME!
236
	 * @param g DOCUMENT ME!
237
	 * @param viewPort DOCUMENT ME!
238
	 *
239
	 * @throws DriverIOException
240
	 *
241
	 * @see com.iver.cit.gvsig.fmap.Operations#draw(java.awt.image.BufferedImage,
242
	 * 		java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort)
243
	 */
244
	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort)
245
		throws DriverIOException {
246
		layers.draw(image, g, viewPort);
247
	}
248
	/**
249
	 * @return Returns the viewPort.
250
	 */
251
	public ViewPort getViewPort() {
252
		return viewPort;
253
	}
254
	/**
255
	 * @param viewPort The viewPort to set.
256
	 */
257
	public void setViewPort(ViewPort viewPort) {
258
		this.viewPort = viewPort;
259
	}
260
}
0 261

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/LegendFactory.java
1
/* Generated by Together */
2

  
3
package com.iver.cit.gvsig.fmap;
4

  
5
import java.awt.BasicStroke;
6
import java.awt.Color;
7

  
8
import org.geotools.renderer.style.LineStyle2D;
9
import org.geotools.renderer.style.Style2D;
10

  
11

  
12
public class LegendFactory {
13
	
14
	public static LineStyle2D DEFAULT_LINE_SYMBOL = new LineStyle2D();
15
	
16
	static{
17
		DEFAULT_LINE_SYMBOL.setContour(Color.BLUE);
18
		BasicStroke stroke = new BasicStroke(1);
19
		DEFAULT_LINE_SYMBOL.setStroke(stroke);
20
	}
21
	
22
	// TODO Descomentar esto cuando se tenga la interfaz de datos
23
    /*
24
     * Crea un objeto renderer de valor ?nico con las caracter?sticas que se pasan como par?metro y con los s?mbolos por defecto. En funci?n de la carga del sistema se podr? crear un FRenderer que almacene la referencia al FRecordset, o un FRenderer que haga cach? de los valores necesarios
25
     *
26
    public static Legend createIntervalLegend(FRecordset data, int valueField, int labelField ) {
27
    }
28

  
29
    /*
30
     * Crea un objeto renderer de valor ?nico con las caracter?sticas que se pasan como par?metro y con los s?mbolos por defecto. En funci?n de la carga del sistema se podr? crear un FRenderer que almacene la referencia al FRecordset, o un FRenderer que haga cach? de los valores necesarios
31
     *
32
    public static Legend createUniqueValueLegend(FRecordset data, int valueField, int labelField ) {
33
    }
34
*/
35
    /**
36
     * Crea un objeto renderer de s?mbolo ?nico con las caracter?sticas que se pasan como par?metro
37
     */
38
    public static Legend createUniqueSymbolLegend(Style2D style) {
39
    	return new UniqueSymbolLegend(style);
40
    }
41

  
42
    /**
43
     * Obtiene un objeto con las propiedades del renderer. Este m?todo se invocar? con el fin de guardar el s?mbolo en disco.
44
     */
45
    public static XMLEntity getLegendProperties(Legend r) {
46
    	//TODO Implementar bien
47
    	return null;
48
    }
49

  
50
    /**
51
     * Crea un renderer con la informaci?n contenida en el objeto XMLEntity
52
     */
53
    public static Legend createLegend(XMLEntity info) {
54
    	//TODO Implementar bien
55
    	return null;
56
    }
57

  
58
    public static Legend cloneLegend(Legend l) {
59
    	return createLegend(getLegendProperties(l));
60
    }
61
}
0 62

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/fshape/FLabel.java
1
/* Generated by Together */
2

  
3
package com.iver.cit.gvsig.fmap.fshape;
4

  
5
public class FLabel extends Point2D {
6
}
0 7

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/fshape/NullGeometry.java
1
/* Generated by Together */
2

  
3
package com.iver.cit.gvsig.fmap.fshape;
4

  
5
public class NullGeometry implements FGeometry {
6
}
0 7

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/fshape/Multipolygon2D.java
1
/* Generated by Together */
2

  
3
package com.iver.cit.gvsig.fmap.fshape;
4

  
5
public class Multipolygon2D implements FGeometry, WritableShape {
6
}
0 7

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/fshape/Multipoint2D.java
1
/* Generated by Together */
2

  
3
package com.iver.cit.gvsig.fmap.fshape;
4

  
5
public class Multipoint2D implements FGeometry, WritableShape {
6
    private Point2D[] points;
7

  
8
    /**
9
     * Obtiene el rect?ngulo m?nimo en el que se situa la Shape 
10
     */
11
    public Rectangle2D getBounds(){
12
        Rectangle2D rect = new Rectangle2D.Double(points[0].getX(), points[0].getX(), 0, 0);
13
        for (int i = 1; i < points.length; i++){
14
            rect.add(new Rectangle2D.Double(points[i].getX(), points[i].getX(), 0, 0));
15
        }
16
    }
17
}
0 18

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/fshape/WritableShape.java
1
/* Generated by Together */
2

  
3
package com.iver.cit.gvsig.fmap.fshape;
4

  
5
public interface WritableShape {
6
    /**
7
     * Dispara en el handler que se pasa como par?metro los eventos SAX correspondientes con el GML del Shape 
8
     */
9
    void toGML(ContentHandler handler);
10
}
0 11

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/fshape/GeneralPathXIterator.java
1
/*
2
 * Created on 10-jun-2004
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Generation - Code and Comments
6
 */
7
package com.iver.cit.gvsig.fmap.fshape;
8

  
9
import java.awt.geom.AffineTransform;
10
import java.awt.geom.PathIterator;
11

  
12
/*
13
 * @(#)GeneralPathXIterator.java	1.21 03/01/23
14
 *
15
 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
16
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
17
 */
18

  
19
/**
20
 * This class represents the iterator for General Paths X.
21
 * It can be used to retrieve all of the elements in a GeneralPathX.
22
 * The {@link GeneralPathX#getPathIterator}
23
 *  method is used to create a
24
 * GeneralPathXIterator for a particular GeneralPathX.
25
 * The iterator can be used to iterator the path only once.
26
 * Subsequent iterations require a new iterator.
27
 *
28
 * @see GeneralPathX
29
 *
30
 * @version 10 Feb 1997
31
 * @author	Jim Graham
32
 */
33
class GeneralPathXIterator implements PathIterator {
34
    int typeIdx = 0;
35
    int pointIdx   = 0;
36
    GeneralPathX path;
37
    AffineTransform affine;
38

  
39
    private static final int curvesize[] = {2, 2, 4, 6, 0};
40

  
41
    /**
42
     * Constructs an iterator given a GeneralPathX.
43
     * @see GeneralPathX#getPathIterator
44
     */
45
    GeneralPathXIterator(GeneralPathX path) {
46
	this(path, null);
47
    }
48

  
49
    /**
50
     * Constructs an iterator given a GeneralPathX and an optional
51
     * AffineTransform.
52
     * @see GeneralPathX#getPathIterator
53
     */
54
    GeneralPathXIterator(GeneralPathX path, AffineTransform at) {
55
        this.path = path;
56
	this.affine = at;
57
    }
58

  
59
    /**
60
     * Return the winding rule for determining the interior of the
61
     * path.
62
     * @see PathIterator#WIND_EVEN_ODD
63
     * @see PathIterator#WIND_NON_ZERO
64
     */
65
    public int getWindingRule() {
66
	return path.getWindingRule();
67
    }
68

  
69
    /**
70
     * Tests if there are more points to read.
71
     * @return true if there are more points to read
72
     */
73
    public boolean isDone() {
74
        return (typeIdx >= path.numTypes);
75
    }
76

  
77
    /**
78
     * Moves the iterator to the next segment of the path forwards
79
     * along the primary direction of traversal as long as there are
80
     * more points in that direction.
81
     */
82
    public void next() {
83
	int type = path.pointTypes[typeIdx++];
84
	pointIdx += curvesize[type];
85
    }
86

  
87
    /**
88
     * Returns the coordinates and type of the current path segment in
89
     * the iteration.
90
     * The return value is the path segment type:
91
     * SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE.
92
     * A float array of length 6 must be passed in and may be used to
93
     * store the coordinates of the point(s).
94
     * Each point is stored as a pair of float x,y coordinates.
95
     * SEG_MOVETO and SEG_LINETO types will return one point,
96
     * SEG_QUADTO will return two points,
97
     * SEG_CUBICTO will return 3 points
98
     * and SEG_CLOSE will not return any points.
99
     * @see PathIterator#SEG_MOVETO
100
     * @see PathIterator#SEG_LINETO
101
     * @see PathIterator#SEG_QUADTO
102
     * @see PathIterator#SEG_CUBICTO
103
     * @see PathIterator#SEG_CLOSE
104
     */
105
    public int currentSegment(float[] coords) {
106
	int type = path.pointTypes[typeIdx];
107
	int numCoords = curvesize[type];
108
	if (numCoords > 0 && affine != null) {
109
	    affine.transform(path.pointCoords, pointIdx,
110
			     coords, 0,
111
			     numCoords / 2);
112
	} else {
113
	    for (int i=0; i < numCoords; i++) {
114
			coords[i] = (float) path.pointCoords[pointIdx + i];
115
		    }
116

  
117
	}
118
        return type;
119
    }
120

  
121
    /**
122
     * Returns the coordinates and type of the current path segment in
123
     * the iteration.
124
     * The return value is the path segment type:
125
     * SEG_MOVETO, SEG_LINETO, SEG_QUADTO, SEG_CUBICTO, or SEG_CLOSE.
126
     * A double array of length 6 must be passed in and may be used to
127
     * store the coordinates of the point(s).
128
     * Each point is stored as a pair of double x,y coordinates.
129
     * SEG_MOVETO and SEG_LINETO types will return one point,
130
     * SEG_QUADTO will return two points,
131
     * SEG_CUBICTO will return 3 points
132
     * and SEG_CLOSE will not return any points.
133
     * @see PathIterator#SEG_MOVETO
134
     * @see PathIterator#SEG_LINETO
135
     * @see PathIterator#SEG_QUADTO
136
     * @see PathIterator#SEG_CUBICTO
137
     * @see PathIterator#SEG_CLOSE
138
     */
139
    public int currentSegment(double[] coords) {
140
	int type = path.pointTypes[typeIdx];
141
	int numCoords = curvesize[type];
142
	if (numCoords > 0 && affine != null) {
143
	    affine.transform(path.pointCoords, pointIdx,
144
			     coords, 0,
145
			     numCoords / 2);
146
	} else {
147
	    System.arraycopy(path.pointCoords, pointIdx, coords, 0, numCoords);
148
	}
149
        return type;
150
    }
151
}
0 152

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/fshape/Label.java
1
/* Generated by Together */
2

  
3
package com.iver.cit.gvsig.fmap.fshape;
4

  
5
public class FLabel implements FGeometry {
6
    void setText(String newText);
7
}
0 8

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/fshape/Point2D.java
1
/* Generated by Together */
2

  
3
package com.iver.cit.gvsig.fmap.fshape;
4

  
5
public class Point2D implements FGeometry {
6
}
0 7

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/fshape/FGeometry.java
1
/* Generated by Together */
2
package com.iver.cit.gvsig.fmap.fshape;
3

  
4
import java.awt.Graphics2D;
5
import java.awt.geom.AffineTransform;
6
import java.awt.geom.Rectangle2D;
7
import java.awt.image.BufferedImage;
8

  
9
import org.geotools.renderer.style.Style2D;
10

  
11
import com.iver.cit.gvsig.fmap.ViewPort;
12

  
13

  
14
/**
15
 * DOCUMENT ME!
16
 *
17
 * @author $author$
18
 */
19
public interface FGeometry extends java.awt.Shape {
20
	public static int BEST = 0;
21
	public static int N = 1;
22
	public static int NE = 2;
23
	public static int E = 3;
24
	public static int SE = 4;
25
	public static int S = 5;
26
	public static int SW = 6;
27
	public static int W = 7;
28
	public static int NW = 8;
29
	public final static int POINT = 1;
30
	public final static int LINE = 2;
31
	public final static int POLYGON = 4;
32
	public final static int TEXT = 8;
33

  
34
	/**
35
	 * Dibujar? esta Shape en el Graphics con el s?mbolo que se pasa como
36
	 * par?metro y despues de aplicarle la transformaci?n que se pasa tambi?n
37
	 * como par?metro. El parametro image que recibe es la imagen de la cual
38
	 * se obtuvo el graphics que tambi?n se pasa como par?metro. Dibujar? la
39
	 * geometria en caso de que la FGeometry intersecte o est? contenida en el
40
	 * rect?ngulo que se pasa como par?metro
41
	 *
42
	 * @param image DOCUMENT ME!
43
	 * @param g DOCUMENT ME!
44
	 * @param mt DOCUMENT ME!
45
	 * @param symbol DOCUMENT ME!
46
	 * @param extent DOCUMENT ME!
47
	 */
48
	void draw(BufferedImage image, Graphics2D g, Rectangle2D extent, AffineTransform at,
49
		Style2D symbol);
50

  
51
	/**
52
	 * Dibujar? esta Shape en el Graphics con el s?mbolo que se pasa como
53
	 * par?metro y despues de aplicarle la transformaci?n que se pasa tambi?n
54
	 * como par?metro. Dibujar? la geometria en caso de que la FGeometry
55
	 * intersecte o est? contenida en el rect?ngulo que se pasa como par?metro
56
	 *
57
	 * @param g DOCUMENT ME!
58
	 * @param mt DOCUMENT ME!
59
	 * @param symbol DOCUMENT ME!
60
	 * @param extent DOCUMENT ME!
61
	 */
62
	void print(Graphics2D g, AffineTransform mt, Style2D symbol,
63
		Rectangle2D extent);
64

  
65
	/**
66
	 * Devuelve el tipo de la geometr?a.
67
	 * 
68
	 * @return DOCUMENT ME!
69
	 */
70
	int getType();
71

  
72
	/**
73
	 * Transforma esta Shape en un Geometry de JTS
74
	 *
75
	 * @return DOCUMENT ME!
76
	 */
77
	JTSGeometry toJTSGeometry();
78

  
79
	/**
80
	 * Obtiene las posiciones donde se debe situar la etiqueta para esta
81
	 * FGeometry. Es un array porque si una geometria es un multipunto por
82
	 * ejemplo puede quererse etiquetar todos sus puntos. El par?metro que se
83
	 * pasa indica como debe de colocar la geometria la etiqueta
84
	 *
85
	 * @param position DOCUMENT ME!
86
	 * @param duplicates DOCUMENT ME!
87
	 *
88
	 * @return DOCUMENT ME!
89
	 */
90
	FGeometry[] createLabels(int position, boolean duplicates);
91
}
0 92

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/fshape/Polyline2D.java
1
package com.iver.cit.gvsig.fmap.fshape;
2

  
3
import java.awt.Color;
4
import java.awt.Graphics2D;
5
import java.awt.Rectangle;
6
import java.awt.geom.AffineTransform;
7
import java.awt.geom.PathIterator;
8
import java.awt.geom.Point2D;
9
import java.awt.geom.Rectangle2D;
10
import java.awt.image.BufferedImage;
11

  
12
import org.geotools.renderer.style.Style2D;
13

  
14

  
15
public class Polyline2D implements FGeometry{
16
	private GeneralPathX gp;
17

  
18
	public Polyline2D(GeneralPathX gpx){
19
		gp = gpx;
20
	}
21

  
22
	/**
23
	 * @see com.iver.cit.gvsig.fmap.fshape.FGeometry#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, java.awt.geom.AffineTransform, org.geotools.renderer.style.Style2D, java.awt.geom.Rectangle2D)
24
	 */
25
	public void draw(BufferedImage image, Graphics2D g, Rectangle2D extent, AffineTransform at, Style2D symbol) {
26
//		if (gp.intersects(extent)){
27
			gp.transform(at);
28
			
29
			g.setPaint(Color.BLACK);
30
			g.draw(gp);
31

  
32
/*			StyledShapePainter painter = new StyledShapePainter();
33
			painter.paint(g, this, symbol, vp.getScale());
34
	*/	
35
//		}
36
	}
37

  
38
	/**
39
	 * @see com.iver.cit.gvsig.fmap.fshape.FGeometry#print(java.awt.Graphics2D, java.awt.geom.AffineTransform, org.geotools.renderer.style.Style2D, java.awt.geom.Rectangle2D)
40
	 */
41
	public void print(Graphics2D g, AffineTransform mt, Style2D symbol, Rectangle2D extent) {
42
	}
43

  
44
	/**
45
	 * @see com.iver.cit.gvsig.fmap.fshape.FGeometry#getType()
46
	 */
47
	public int getType() {
48
		return FGeometry.LINE;
49
	}
50

  
51
	/**
52
	 * @see com.iver.cit.gvsig.fmap.fshape.FGeometry#createLabels(int, boolean)
53
	 */
54
	public FGeometry[] createLabels(int position, boolean duplicates) {
55
		return null;
56
	}
57

  
58
	/**
59
	 * @see java.awt.Shape#contains(double, double)
60
	 */
61
	public boolean contains(double x, double y) {
62
		return gp.contains(x, y);
63
	}
64

  
65
	/**
66
	 * @see java.awt.Shape#contains(double, double, double, double)
67
	 */
68
	public boolean contains(double x, double y, double w, double h) {
69
		return gp.contains(x, y, w, h);
70
	}
71

  
72
	/**
73
	 * @see java.awt.Shape#intersects(double, double, double, double)
74
	 */
75
	public boolean intersects(double x, double y, double w, double h) {
76
		return gp.intersects(x, y, w, h);
77
	}
78

  
79
	/**
80
	 * @see java.awt.Shape#getBounds()
81
	 */
82
	public Rectangle getBounds() {
83
		return gp.getBounds();
84
	}
85

  
86
	/**
87
	 * @see java.awt.Shape#contains(java.awt.geom.Point2D)
88
	 */
89
	public boolean contains(Point2D p) {
90
		return gp.contains(p);
91
	}
92

  
93
	/**
94
	 * @see java.awt.Shape#getBounds2D()
95
	 */
96
	public Rectangle2D getBounds2D() {
97
		return gp.getBounds2D();
98
	}
99

  
100
	/**
101
	 * @see java.awt.Shape#contains(java.awt.geom.Rectangle2D)
102
	 */
103
	public boolean contains(Rectangle2D r) {
104
		return gp.contains(r);
105
	}
106

  
107
	/**
108
	 * @see java.awt.Shape#intersects(java.awt.geom.Rectangle2D)
109
	 */
110
	public boolean intersects(Rectangle2D r) {
111
		return gp.intersects(r);
112
	}
113

  
114
	/**
115
	 * @see java.awt.Shape#getPathIterator(java.awt.geom.AffineTransform)
116
	 */
117
	public PathIterator getPathIterator(AffineTransform at) {
118
		return gp.getPathIterator(at);
119
	}
120

  
121
	/**
122
	 * @see java.awt.Shape#getPathIterator(java.awt.geom.AffineTransform, double)
123
	 */
124
	public PathIterator getPathIterator(AffineTransform at, double flatness) {
125
		return gp.getPathIterator(at, flatness);
126
	}
127

  
128
}
0 129

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/fshape/GeneralPathX.java
1
/*
2
 * Created on 10-jun-2004
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Generation - Code and Comments
6
 */
7
package com.iver.cit.gvsig.fmap.fshape;
8

  
9
/**
10
 * @author FJP
11
 *
12
 * TODO To change the template for this generated type comment go to
13
 * Window - Preferences - Java - Code Generation - Code and Comments
14
 */
15
/*
16
 * @(#)GeneralPathX.java	1.58 03/01/23
17
 *
18
 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
19
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
20
 */
21

  
22
import java.awt.Shape;
23
import java.awt.geom.AffineTransform;
24
import java.awt.geom.FlatteningPathIterator;
25
import java.awt.geom.IllegalPathStateException;
26
import java.awt.geom.PathIterator;
27
import java.awt.geom.Point2D;
28
import java.awt.geom.Rectangle2D;
29

  
30
import sun.awt.geom.Crossings;
31
import sun.awt.geom.Curve;
32

  
33
/**
34
 * The <code>GeneralPathX</code> class represents a geometric path 
35
 * constructed from straight lines, and quadratic and cubic
36
 * (B&eacute;zier) curves.  It can contain multiple subpaths.
37
 * <p>
38
 * The winding rule specifies how the interior of a path is
39
 * determined.  There are two types of winding rules:  
40
 * EVEN_ODD and NON_ZERO.
41
 * <p>
42
 * An EVEN_ODD winding rule means that enclosed regions
43
 * of the path alternate between interior and exterior areas as
44
 * traversed from the outside of the path towards a point inside
45
 * the region.  
46
 * <p>
47
 * A NON_ZERO winding rule means that if a ray is 
48
 * drawn in any direction from a given point to infinity
49
 * and the places where the path intersects
50
 * the ray are examined, the point is inside of the path if and only if
51
 * the number of times that the path crosses the ray from
52
 * left to right does not equal the  number of times that the path crosses
53
 * the ray from right to left.  
54
 * @version 1.58, 01/23/03
55
 * @author Jim Graham
56
 */
57
public final class GeneralPathX implements Shape, Cloneable {
58
    /**
59
     * An even-odd winding rule for determining the interior of
60
     * a path.  
61
     */
62
    public static final int WIND_EVEN_ODD = PathIterator.WIND_EVEN_ODD;
63

  
64
    /**
65
     * A non-zero winding rule for determining the interior of a
66
     * path.  
67
     */
68
    public static final int WIND_NON_ZERO = PathIterator.WIND_NON_ZERO;
69
    
70
    // For code simplicity, copy these constants to our namespace
71
    // and cast them to byte constants for easy storage.
72
    private static final byte SEG_MOVETO  = (byte) PathIterator.SEG_MOVETO;
73
    private static final byte SEG_LINETO  = (byte) PathIterator.SEG_LINETO;
74
    private static final byte SEG_QUADTO  = (byte) PathIterator.SEG_QUADTO;
75
    private static final byte SEG_CUBICTO = (byte) PathIterator.SEG_CUBICTO;
76
    private static final byte SEG_CLOSE   = (byte) PathIterator.SEG_CLOSE;
77

  
78
    byte[] pointTypes;
79
    double[] pointCoords;
80
    int numTypes;
81
    int numCoords;
82
    int windingRule;
83

  
84
    static final int INIT_SIZE = 20;
85
    static final int EXPAND_MAX = 500;
86

  
87
    /**
88
     * Constructs a new <code>GeneralPathX</code> object.
89
     * If an operation performed on this path requires the
90
     * interior of the path to be defined then the default NON_ZERO
91
     * winding rule is used.
92
     * @see #WIND_NON_ZERO
93
     */
94
    public GeneralPathX() {
95
	this(WIND_NON_ZERO, INIT_SIZE, INIT_SIZE);
96
    }
97

  
98
    /**
99
     * Constructs a new <code>GeneralPathX</code> object with the specified 
100
     * winding rule to control operations that require the interior of the
101
     * path to be defined.
102
     * @param rule the winding rule
103
     * @see #WIND_EVEN_ODD
104
     * @see #WIND_NON_ZERO
105
     */
106
    public GeneralPathX(int rule) {
107
	this(rule, INIT_SIZE, INIT_SIZE);
108
    }
109

  
110
    /**
111
     * Constructs a new <code>GeneralPathX</code> object with the specified 
112
     * winding rule and the specified initial capacity to store path 
113
     * coordinates. This number is an initial guess as to how many path 
114
     * segments are in the path, but the storage is expanded 
115
     * as needed to store whatever path segments are added to this path.
116
     * @param rule the winding rule
117
     * @param initialCapacity the estimate for the number of path segments
118
     * in the path
119
     * @see #WIND_EVEN_ODD
120
     * @see #WIND_NON_ZERO
121
     */
122
    public GeneralPathX(int rule, int initialCapacity) {
123
	this(rule, initialCapacity, initialCapacity);
124
    }
125

  
126
    /**
127
     * Constructs a new <code>GeneralPathX</code> object with the specified 
128
     * winding rule and the specified initial capacities to store point types
129
     * and coordinates.
130
     * These numbers are an initial guess as to how many path segments
131
     * and how many points are to be in the path, but the
132
     * storage is expanded as needed to store whatever path segments are
133
     * added to this path.
134
     * @param rule the winding rule
135
     * @param initialTypes the estimate for the number of path segments
136
     * in the path
137
     * @param initialCapacity the estimate for the number of points
138
     * @see #WIND_EVEN_ODD
139
     * @see #WIND_NON_ZERO
140
     */
141
    GeneralPathX(int rule, int initialTypes, int initialCoords) {
142
	setWindingRule(rule);
143
	pointTypes = new byte[initialTypes];
144
	pointCoords = new double[initialCoords * 2];
145
    }
146

  
147
    /**
148
     * Constructs a new <code>GeneralPathX</code> object from an arbitrary 
149
     * {@link Shape} object.
150
     * All of the initial geometry and the winding rule for this path are
151
     * taken from the specified <code>Shape</code> object.
152
     * @param s the specified <code>Shape</code> object
153
     */
154
    public GeneralPathX(Shape s) {
155
	this(WIND_NON_ZERO, INIT_SIZE, INIT_SIZE);
156
	PathIterator pi = s.getPathIterator(null);
157
	setWindingRule(pi.getWindingRule());
158
	append(pi, false);
159
    }
160
 
161
    private void needRoom(int newTypes, int newCoords, boolean needMove) {
162
	if (needMove && numTypes == 0) {
163
	    throw new IllegalPathStateException("missing initial moveto "+
164
						"in path definition");
165
	}
166
	int size = pointCoords.length;
167
	if (numCoords + newCoords > size) {
168
	    int grow = size;
169
	    if (grow > EXPAND_MAX * 2) {
170
		grow = EXPAND_MAX * 2;
171
	    }
172
	    if (grow < newCoords) {
173
		grow = newCoords;
174
	    }
175
	    double[] arr = new double[size + grow];
176
	    System.arraycopy(pointCoords, 0, arr, 0, numCoords);
177
	    pointCoords = arr;
178
	}
179
	size = pointTypes.length;
180
	if (numTypes + newTypes > size) {
181
	    int grow = size;
182
	    if (grow > EXPAND_MAX) {
183
		grow = EXPAND_MAX;
184
	    }
185
	    if (grow < newTypes) {
186
		grow = newTypes;
187
	    }
188
	    byte[] arr = new byte[size + grow];
189
	    System.arraycopy(pointTypes, 0, arr, 0, numTypes);
190
	    pointTypes = arr;
191
	}
192
    }
193

  
194
    /**
195
     * Adds a point to the path by moving to the specified
196
     * coordinates.
197
     * @param x,&nbsp;y the specified coordinates
198
     */
199
    public synchronized void moveTo(double x, double y) {
200
	if (numTypes > 0 && pointTypes[numTypes - 1] == SEG_MOVETO) {
201
	    pointCoords[numCoords - 2] = x;
202
	    pointCoords[numCoords - 1] = y;
203
	} else {
204
	    needRoom(1, 2, false);
205
	    pointTypes[numTypes++] = SEG_MOVETO;
206
	    pointCoords[numCoords++] = x;
207
	    pointCoords[numCoords++] = y;
208
	}
209
    }
210

  
211
    /**
212
     * Adds a point to the path by drawing a straight line from the
213
     * current coordinates to the new specified coordinates.
214
     * @param x,&nbsp;y the specified coordinates
215
     */
216
    public synchronized void lineTo(double x, double y) {
217
	needRoom(1, 2, true);
218
	pointTypes[numTypes++] = SEG_LINETO;
219
	pointCoords[numCoords++] = x;
220
	pointCoords[numCoords++] = y;
221
    }
222

  
223
    /**
224
     * Adds a curved segment, defined by two new points, to the path by
225
     * drawing a Quadratic curve that intersects both the current
226
     * coordinates and the coordinates (x2,&nbsp;y2), using the 
227
     * specified point (x1,&nbsp;y1) as a quadratic parametric control
228
     * point.
229
     * @param x1,&nbsp;y1 the coordinates of the first quadratic control
230
     *		point
231
     * @param x2,&nbsp;y2 the coordinates of the final endpoint
232
     */
233
    public synchronized void quadTo(double x1, double y1, double x2, double y2) {
234
	needRoom(1, 4, true);
235
	pointTypes[numTypes++] = SEG_QUADTO;
236
	pointCoords[numCoords++] = x1;
237
	pointCoords[numCoords++] = y1;
238
	pointCoords[numCoords++] = x2;
239
	pointCoords[numCoords++] = y2;
240
    }
241

  
242
    /**
243
     * Adds a curved segment, defined by three new points, to the path by
244
     * drawing a B&eacute;zier curve that intersects both the current
245
     * coordinates and the coordinates (x3,&nbsp;y3), using the    
246
     * specified points (x1,&nbsp;y1) and (x2,&nbsp;y2) as
247
     * B&eacute;zier control points.
248
     * @param x1,&nbsp;y1 the coordinates of the first B&eacute;ezier
249
     *		control point
250
     * @param x2,&nbsp;y2 the coordinates of the second B&eacute;zier
251
     *		control point
252
     * @param x3,&nbsp;y3 the coordinates of the final endpoint
253
     */
254
    public synchronized void curveTo(double x1, double y1,
255
    		double x2, double y2,
256
    		double x3, double y3) {
257
	needRoom(1, 6, true);
258
	pointTypes[numTypes++] = SEG_CUBICTO;
259
	pointCoords[numCoords++] = x1;
260
	pointCoords[numCoords++] = y1;
261
	pointCoords[numCoords++] = x2;
262
	pointCoords[numCoords++] = y2;
263
	pointCoords[numCoords++] = x3;
264
	pointCoords[numCoords++] = y3;
265
    }
266

  
267
    /**
268
     * Closes the current subpath by drawing a straight line back to
269
     * the coordinates of the last <code>moveTo</code>.  If the path is already
270
     * closed then this method has no effect.
271
     */
272
    public synchronized void closePath() {
273
	if (numTypes == 0 || pointTypes[numTypes - 1] != SEG_CLOSE) {
274
	    needRoom(1, 0, true);
275
	    pointTypes[numTypes++] = SEG_CLOSE;
276
	}
277
    }
278

  
279
    /**
280
     * Appends the geometry of the specified <code>Shape</code> object to the
281
     * path, possibly connecting the new geometry to the existing path
282
     * segments with a line segment.
283
     * If the <code>connect</code> parameter is <code>true</code> and the 
284
     * path is not empty then any initial <code>moveTo</code> in the
285
     * geometry of the appended <code>Shape</code>
286
     * is turned into a <code>lineTo</code> segment.
287
     * If the destination coordinates of such a connecting <code>lineTo</code>
288
     * segment match the ending coordinates of a currently open
289
     * subpath then the segment is omitted as superfluous.
290
     * The winding rule of the specified <code>Shape</code> is ignored
291
     * and the appended geometry is governed by the winding
292
     * rule specified for this path.
293
     * @param s the <code>Shape</code> whose geometry is appended 
294
     * to this path
295
     * @param connect a boolean to control whether or not to turn an
296
     * initial <code>moveTo</code> segment into a <code>lineTo</code>
297
     * segment to connect the new geometry to the existing path
298
     */
299
    public void append(Shape s, boolean connect) {
300
	PathIterator pi = s.getPathIterator(null);
301
        append(pi,connect);
302
    }
303

  
304
    /**
305
     * Appends the geometry of the specified
306
     * {@link PathIterator} object 
307
     * to the path, possibly connecting the new geometry to the existing
308
     * path segments with a line segment.
309
     * If the <code>connect</code> parameter is <code>true</code> and the 
310
     * path is not empty then any initial <code>moveTo</code> in the
311
     * geometry of the appended <code>Shape</code> is turned into a
312
     * <code>lineTo</code> segment.
313
     * If the destination coordinates of such a connecting <code>lineTo</code>
314
     * segment match the ending coordinates of a currently open
315
     * subpath then the segment is omitted as superfluous.
316
     * The winding rule of the specified <code>Shape</code> is ignored
317
     * and the appended geometry is governed by the winding
318
     * rule specified for this path.
319
     * @param pi the <code>PathIterator</code> whose geometry is appended to 
320
     * this path
321
     * @param connect a boolean to control whether or not to turn an
322
     * initial <code>moveTo</code> segment into a <code>lineTo</code> segment
323
     * to connect the new geometry to the existing path
324
     */
325
    public void append(PathIterator pi, boolean connect) {
326
	double coords[] = new double[6];
327
	while (!pi.isDone()) {
328
	    switch (pi.currentSegment(coords)) {
329
	    case SEG_MOVETO:
330
		if (!connect || numTypes < 1 || numCoords < 2) {
331
		    moveTo(coords[0], coords[1]);
332
		    break;
333
		}
334
		if (pointTypes[numTypes - 1] != SEG_CLOSE &&
335
		    pointCoords[numCoords - 2] == coords[0] &&
336
		    pointCoords[numCoords - 1] == coords[1])
337
		{
338
		    // Collapse out initial moveto/lineto
339
		    break;
340
		}
341
		// NO BREAK;
342
	    case SEG_LINETO:
343
		lineTo(coords[0], coords[1]);
344
		break;
345
	    case SEG_QUADTO:
346
		quadTo(coords[0], coords[1],
347
		       coords[2], coords[3]);
348
		break;
349
	    case SEG_CUBICTO:
350
		curveTo(coords[0], coords[1],
351
			coords[2], coords[3],
352
			coords[4], coords[5]);
353
		break;
354
	    case SEG_CLOSE:
355
		closePath();
356
		break;
357
	    }
358
	    pi.next();
359
	    connect = false;
360
	}
361
    }
362

  
363
    /**
364
     * Returns the fill style winding rule.
365
     * @return an integer representing the current winding rule.
366
     * @see #WIND_EVEN_ODD  
367
     * @see #WIND_NON_ZERO
368
     * @see #setWindingRule
369
     */
370
    public synchronized int getWindingRule() {
371
        return windingRule;
372
    }
373

  
374
    /**
375
     * Sets the winding rule for this path to the specified value.
376
     * @param rule an integer representing the specified 
377
     * winding rule
378
     * @exception <code>IllegalArgumentException</code> if 
379
     *		<code>rule</code> is not either 
380
     *		<code>WIND_EVEN_ODD</code> or
381
     *		<code>WIND_NON_ZERO</code>
382
     * @see #WIND_EVEN_ODD  
383
     * @see #WIND_NON_ZERO
384
     * @see #getWindingRule
385
     */
386
    public void setWindingRule(int rule) {
387
	if (rule != WIND_EVEN_ODD && rule != WIND_NON_ZERO) {
388
	    throw new IllegalArgumentException("winding rule must be "+
389
					       "WIND_EVEN_ODD or "+
390
					       "WIND_NON_ZERO");
391
	}
392
	windingRule = rule;
393
    }
394

  
395
    /**
396
     * Returns the coordinates most recently added to the end of the path
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff