Revision 33411

View differences:

branches/v2_0_0_prep/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/Behavior.java
56 56
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
57 57
import org.gvsig.fmap.geom.Geometry.TYPES;
58 58
import org.gvsig.fmap.geom.primitive.Arc;
59
import org.gvsig.fmap.geom.primitive.Circle;
59 60
import org.gvsig.fmap.geom.primitive.Curve;
60 61
import org.gvsig.fmap.geom.primitive.GeneralPathX;
61 62
import org.gvsig.fmap.geom.primitive.Point;
......
198 199
	protected Point createPoint(double x, double y){
199 200
		Point point = null;
200 201
		try {
201
			point = (Point)geomManager.create(TYPES.POINT, SUBTYPES.GEOM3D);
202
			point = (Point)geomManager.create(TYPES.POINT, SUBTYPES.GEOM2D);
202 203
			point.setX(x);
203 204
			point.setY(y);
204 205
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
205
			logger.error(new CreateGeometryException(TYPES.POINT, SUBTYPES.GEOM3D, e));
206
			logger.error(new CreateGeometryException(TYPES.POINT, SUBTYPES.GEOM2D, e));
206 207
		}
207 208
		return point;
208 209
	}
......
234 235
	protected Arc createArc(Point p1, Point p2, Point p3){
235 236
		Arc arc = null;
236 237
		try {
237
			arc = (Arc)geomManager.create(TYPES.ARC, SUBTYPES.GEOM3D);
238
			arc = (Arc)geomManager.create(TYPES.ARC, SUBTYPES.GEOM2D);
238 239
			arc.setPoints(p1, p2, p3);
239 240
	    } catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
240
			logger.error(new CreateGeometryException(TYPES.ARC, SUBTYPES.GEOM3D, e));
241
			logger.error(new CreateGeometryException(TYPES.ARC, SUBTYPES.GEOM2D, e));
241 242
		}
242 243
	    return arc;
243 244
	}
......
271 272
			double angleStart, double angleExtent){
272 273
		Arc arc = null;
273 274
		try {
274
			arc = (Arc)geomManager.create(TYPES.ARC, SUBTYPES.GEOM3D);
275
			arc = (Arc)geomManager.create(TYPES.ARC, SUBTYPES.GEOM2D);
275 276
			arc.setPoints(createPoint(centerX, centerY), radious, angleStart, angleExtent);
276 277
	    } catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
277
			logger.error(new CreateGeometryException(TYPES.ARC, SUBTYPES.GEOM3D, e));
278
			logger.error(new CreateGeometryException(TYPES.ARC, SUBTYPES.GEOM2D, e));
278 279
		}
279 280
	    return arc;
280 281
	}
281
	
282

  
282 283
	/**
284
	 * Create an circle. If there is an
285
	 * error return <code>null</code> and add the error
286
	 * to the log
287
	 * @param centerX
288
	 * @param centerY
289
	 * @return
290
	 * The arc
291
	 */
292
	protected Circle createCircle(double centerX, double centerY, double radious){
293
		Circle circle = null;
294
		try {
295
			circle = (Circle)geomManager.create(TYPES.CIRCLE, SUBTYPES.GEOM2D);
296
			circle.setPoints(createPoint(centerX, centerY), radious);
297
	    } catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
298
			logger.error(new CreateGeometryException(TYPES.CIRCLE, SUBTYPES.GEOM2D, e));
299
		}
300
	    
301
	    return circle;
302
	}
303

  
304
	/**
283 305
	 * Create a lineString from a GeneralPath. If there is an
284 306
	 * error return <code>null</code> and add the error
285 307
	 * to the log
......
291 313
	protected Curve createLineString(GeneralPathX gpx){
292 314
		Curve curve = null;
293 315
		try {
294
			curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM3D);
316
			curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
295 317
			curve.setGeneralPath(gpx);
296 318
		} catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
297
			logger.error(new CreateGeometryException(TYPES.CURVE, SUBTYPES.GEOM3D, e));
319
			logger.error(new CreateGeometryException(TYPES.CURVE, SUBTYPES.GEOM2D, e));
298 320
		}
299 321
		return curve;
300 322
	}
branches/v2_0_0_prep/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/CircleBehavior.java
43 43
import java.awt.Color;
44 44
import java.awt.Rectangle;
45 45
import java.awt.event.MouseEvent;
46
import java.awt.geom.Arc2D;
47 46
import java.awt.geom.Point2D;
48 47
import java.awt.geom.Rectangle2D;
49 48
import java.awt.image.BufferedImage;
50 49

  
51
import org.gvsig.fmap.dal.feature.exception.CreateGeometryException;
52
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
53
import org.gvsig.fmap.geom.Geometry.TYPES;
54 50
import org.gvsig.fmap.geom.primitive.Arc;
55 51
import org.gvsig.fmap.mapcontext.ViewPort;
56 52
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
......
112 108
		BufferedImage img = getMapControl().getImage();
113 109
		mapControlDrawer.drawImage(img, 0, 0);
114 110
		mapControlDrawer.setColor(Color.black);
115
		//g.setXORMode(Color.white);
111

  
112

  
116 113
		if ((m_FirstPoint != null) && (m_LastPoint != null)) {
117
			radio = m_LastPoint.distance(m_FirstPoint);
118
			Arc arc = null;			
119
			Arc2D.Double arc2 = new Arc2D.Double(m_FirstPoint.getX()-radio,
120
					m_FirstPoint.getY()-radio,
121
					2*radio,
122
					2*radio, 0, 360, Arc2D.OPEN);
123
			arc = createArc(arc2.getCenterX(), arc2.getCenterY(),
124
					radio,
125
					arc2.getAngleStart(),
126
					arc2.getAngleExtent());				
127
			mapControlDrawer.draw(arc);
114
			ViewPort vp = getMapControl().getMapContext().getViewPort();
115
			Point2D p1 = vp.toMapPoint(m_FirstPoint);
116
			Point2D p2 = vp.toMapPoint(m_LastPoint);
117

  
118
			radio = p1.distance(p2);
119
			if(radio!=0.0){
120
				Arc arc = null;			
121
					arc = createArc(p1.getX(), p1.getY(),
122
							radio,
123
							0,
124
							Math.PI*2);
125
					mapControlDrawer.draw(arc);
126
			}
127

  
128 128
		}
129 129
	}
130 130

  
branches/v2_0_0_prep/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/tools/Behavior/PolylineBehavior.java
41 41
package org.gvsig.fmap.mapcontrol.tools.Behavior;
42 42

  
43 43
import java.awt.Color;
44
import java.awt.Graphics;
45
import java.awt.Graphics2D;
46 44
import java.awt.event.MouseEvent;
47 45
import java.awt.geom.Point2D;
48 46
import java.util.ArrayList;
......
180 178
	protected void drawPolyLine(MapControlDrawer mapControlDrawer) {
181 179
		GeneralPathX polyline = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, arrayX.size());
182 180

  
183
		Point2D pScreen0=getMapControl().getViewPort().fromMapPoint(new Point2D.Double(((Double) arrayX.get(0)).doubleValue(),
184
				((Double) arrayY.get(0)).doubleValue()));
181
		polyline.moveTo(((Double) arrayX.get(0)).doubleValue(),
182
				((Double) arrayY.get(0)).doubleValue());
185 183

  
186
		polyline.moveTo(pScreen0.getX(), pScreen0.getY());
187

  
188 184
		for (int index = 0; index < arrayX.size(); index++) {
189
			Point2D pScreen=getMapControl().getViewPort().fromMapPoint(new Point2D.Double(((Double) arrayX.get(index)).doubleValue(),
190
					((Double) arrayY.get(index)).doubleValue()));
191

  
192
			polyline.lineTo(pScreen.getX(),pScreen.getY());
185
		    polyline.lineTo(((Double) arrayX.get(index)).doubleValue(),((Double) arrayY.get(index)).doubleValue());
193 186
		}
194 187

  
195 188
		mapControlDrawer.draw(createLineString(polyline));
branches/v2_0_0_prep/libraries/libFMap_controls/src/org/gvsig/fmap/mapcontrol/impl/MapControlDrawer2D.java
47 47
import org.gvsig.fmap.geom.primitive.Curve;
48 48
import org.gvsig.fmap.geom.primitive.GeneralPathX;
49 49
import org.gvsig.fmap.mapcontext.MapContext;
50
import org.gvsig.fmap.mapcontext.MapContextLocator;
50 51
import org.gvsig.fmap.mapcontext.ViewPort;
51 52
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
52 53
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
......
174 175
	 * @see org.gvsig.fmap.mapcontrol.MapControlDrawer#draw(org.gvsig.fmap.geom.Geometry)
175 176
	 */
176 177
	public void draw(Geometry geometry) {
177
		draw(geometry, null);
178
		draw(geometry, MapContextLocator.getSymbolManager().createSymbol(geometry.getType()));
178 179
	}
179 180

  
180 181
	/* (non-Javadoc)

Also available in: Unified diff