Revision 1426

View differences:

branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/cad/CADToolAdapter.java
1 1
package com.iver.cit.gvsig.fmap.edition.cad;
2 2

  
3 3
import com.iver.cit.gvsig.fmap.ViewPort;
4
import com.iver.cit.gvsig.fmap.core.Handler;
4 5
import com.iver.cit.gvsig.fmap.core.IGeometry;
5 6
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
7
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities;
6 8
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
7 9
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
8 10
import com.iver.cit.gvsig.fmap.edition.EditableFeatureSource;
......
69 71
				i = selection.nextSetBit(i + 1)) {
70 72
			try {
71 73
				IGeometry geom = editableFeatureSource.getGeometry(i);
74
				Handler[] handlers=geom.getHandlers();
72 75
				geom.draw((Graphics2D) g, getMapControl().getViewPort(), symbol);
76
				FGraphicUtilities.DrawHandlers((Graphics2D)g,getMapControl().getViewPort().getAffineTransform(),handlers);
73 77
			} catch (IOException e) {
74 78
				e.printStackTrace();
75 79
			} catch (DriverIOException e) {
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/v02/FGraphicUtilities.java
51 51
import com.iver.cit.gvsig.fmap.core.FPolyline2D;
52 52
import com.iver.cit.gvsig.fmap.core.FShape;
53 53
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
54
import com.iver.cit.gvsig.fmap.core.GeneralPathXIterator;
55
import com.iver.cit.gvsig.fmap.core.Handler;
54 56

  
55 57
import com.vividsolutions.jts.geom.Geometry;
56 58
import com.vividsolutions.jts.geom.Point;
......
62 64
import java.awt.Graphics2D;
63 65
import java.awt.Rectangle;
64 66
import java.awt.geom.AffineTransform;
67
import java.awt.geom.NoninvertibleTransformException;
65 68
import java.awt.geom.Point2D;
69
import java.util.ArrayList;
66 70

  
67 71

  
68 72
/**
......
648 652
				break;
649 653
		} // del switch estilo
650 654
	}
655
/*	public static void DrawHandlers(Graphics2D g,AffineTransform at, FShape shp){
656
		GeneralPathXIterator gpi=null;
657
		try {
658
			gpi = (GeneralPathXIterator)shp.getPathIterator(at.createInverse());
659
		} catch (NoninvertibleTransformException e) {
660
			e.printStackTrace();
661
		}
662
		double[] theData = new double[6];
663
			while (!gpi.isDone()) {
664
			//while not done
665
			int theType = gpi.currentSegment(theData);
666
			g.fillRect((int)(theData[0]-3),(int)(theData[1]-3),6,6);
667
				
668
			gpi.next();
669
		}
670
	}
671
	*/
672
	public static void DrawHandlers(Graphics2D g,AffineTransform at,Handler[] handlers){
673
		for (int i=0;i<handlers.length;i++){	
674
			Point2D point=handlers[i].getPoint();
675
			at.transform(point,point);
676
			g.fillRect((int)(point.getX()-3),(int)(point.getY()-3),6,6);
677
		}
678
	}
651 679
}
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FEllipse2D.java
85 85
	 */
86 86
	public void draw(Graphics2D g, ViewPort vp, FSymbol symbol) {
87 87
		Rectangle2D r = elipse.getBounds2D();
88
		g.setColor(symbol.getColor());
88 89
		GeneralPathX gp = new GeneralPathX(r);
89 90
		gp.transform(vp.getAffineTransform());
90 91
		r = gp.getBounds2D();
......
141 142
	 * @see com.iver.cit.gvsig.fmap.core.IGeometry#getBounds2D()
142 143
	 */
143 144
	public Rectangle2D getBounds2D() {
144
		return null;
145
		return elipse.getBounds2D();
145 146
	}
146 147

  
147 148
	/**
......
168 169
	 */
169 170
	public void rotate(double r, double x, double y) {
170 171
	}
172

  
173
	/**
174
	 * @see com.iver.cit.gvsig.fmap.core.IGeometry#getHandlers()
175
	 */
176
	public Handler[] getHandlers() {
177
		Handler[] handlers={
178
				new CenterHandler(elipse.getCenterX(),elipse.getCenterY()),
179
				new RightHandler(elipse.getWidth()/2+elipse.getCenterX(),elipse.getCenterY())
180
		};
181
		return handlers;
182
	}
183
	/**
184
	 * DOCUMENT ME!
185
	 *
186
	 * @author Vicente Caballero Navarro
187
	 */
188
	class CenterHandler implements Handler {
189
		private Point2D center;
190

  
191
		/**
192
		 * Crea un nuevo PointHandler.
193
		 *
194
		 * @param x DOCUMENT ME!
195
		 * @param y DOCUMENT ME!
196
		 */
197
		public CenterHandler(double x, double y) {
198
			center = new Point2D.Double(x, y);
199
		}
200

  
201
		/**
202
		 * DOCUMENT ME!
203
		 *
204
		 * @param x DOCUMENT ME!
205
		 * @param y DOCUMENT ME!
206
		 *
207
		 * @return DOCUMENT ME!
208
		 */
209
		public IGeometry move(double x, double y) {
210
			center.setLocation(center.getX() + x, center.getY() + y);
211

  
212
			return null;
213
		}
214

  
215
		/**
216
		 * @see com.iver.cit.gvsig.fmap.core.Handler#getPoint()
217
		 */
218
		public Point2D getPoint() {
219
			return center;
220
		}
221
	}
222
	/**
223
	 * DOCUMENT ME!
224
	 *
225
	 * @author Vicente Caballero Navarro
226
	 */
227
	class RightHandler implements Handler {
228
		private Point2D right;
229

  
230
		/**
231
		 * Crea un nuevo PointHandler.
232
		 *
233
		 * @param x DOCUMENT ME!
234
		 * @param y DOCUMENT ME!
235
		 */
236
		public RightHandler(double x, double y) {
237
			right = new Point2D.Double(x, y);
238
		}
239

  
240
		/**
241
		 * DOCUMENT ME!
242
		 *
243
		 * @param x DOCUMENT ME!
244
		 * @param y DOCUMENT ME!
245
		 *
246
		 * @return DOCUMENT ME!
247
		 */
248
		public IGeometry move(double x, double y) {
249
			right.setLocation(right.getX() + x, right.getY() + y);
250

  
251
			return null;
252
		}
253

  
254
		/**
255
		 * @see com.iver.cit.gvsig.fmap.core.Handler#getPoint()
256
		 */
257
		public Point2D getPoint() {
258
			return right;
259
		}
260
	}
171 261
}
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FGeometry.java
59 59

  
60 60
import java.awt.Graphics2D;
61 61
import java.awt.geom.AffineTransform;
62
import java.awt.geom.NoninvertibleTransformException;
63
import java.awt.geom.Point2D;
62 64
import java.awt.geom.Rectangle2D;
63 65

  
66
import java.util.ArrayList;
64 67

  
68

  
65 69
/**
66 70
 * Geometr?a.
67 71
 *
......
199 203
	 * @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeneralPathXIterator()
200 204
	 */
201 205
	public GeneralPathXIterator getGeneralPathXIterator() {
202
		return (GeneralPathXIterator)shp.getPathIterator(null);
206
		return (GeneralPathXIterator) shp.getPathIterator(null);
203 207
	}
204 208

  
205
    /* (non-Javadoc)
206
     * @see com.iver.cit.gvsig.fmap.core.IGeometry#fastIntersects(double, double, double, double)
207
     */
208
    public boolean fastIntersects(double x, double y, double w, double h) {
209
        return shp.intersects(x,y,w,h);
210
    }
209
	/* (non-Javadoc)
210
	 * @see com.iver.cit.gvsig.fmap.core.IGeometry#fastIntersects(double, double, double, double)
211
	 */
212
	public boolean fastIntersects(double x, double y, double w, double h) {
213
		return shp.intersects(x, y, w, h);
214
	}
211 215

  
212 216
	/**
213 217
	 * @see com.iver.cit.gvsig.fmap.core.IGeometry#move(double, double)
214 218
	 */
215 219
	public void move(double x, double y) {
216
		AffineTransform at=new AffineTransform();
217
		at.translate(x,y);
220
		AffineTransform at = new AffineTransform();
221
		at.translate(x, y);
218 222
		transform(at);
219 223
	}
220 224

  
221 225
	/**
222
	 * @see com.iver.cit.gvsig.fmap.core.IGeometry#rotate(double, double, double)
226
	 * @see com.iver.cit.gvsig.fmap.core.IGeometry#rotate(double, double,
227
	 * 		double)
223 228
	 */
224 229
	public void rotate(double r, double x, double y) {
225
		AffineTransform at=new AffineTransform();
226
		at.rotate(r,x,y);
230
		AffineTransform at = new AffineTransform();
231
		at.rotate(r, x, y);
227 232
		transform(at);
228 233
	}
234

  
235
	/**
236
	 * @see com.iver.cit.gvsig.fmap.core.IGeometry#getHandlers()
237
	 */
238
	public Handler[] getHandlers() {
239
		ArrayList handlers = new ArrayList();
240
		GeneralPathXIterator gpi = null;
241
		gpi = (GeneralPathXIterator) shp.getPathIterator(null);
242

  
243
		double[] theData = new double[6];
244

  
245
		while (!gpi.isDone()) {
246
			int theType = gpi.currentSegment(theData);
247
			//g.fillRect((int)(theData[0]-3),(int)(theData[1]-3),6,6);
248
			handlers.add(new PointHandler(theData[0], theData[1]));
249
			gpi.next();
250
		}
251

  
252
		return (Handler[]) handlers.toArray(new Handler[0]);
253
	}
254

  
255
	/**
256
	 * DOCUMENT ME!
257
	 *
258
	 * @author Vicente Caballero Navarro
259
	 */
260
	class PointHandler implements Handler {
261
		private Point2D point;
262

  
263
		/**
264
		 * Crea un nuevo PointHandler.
265
		 *
266
		 * @param x DOCUMENT ME!
267
		 * @param y DOCUMENT ME!
268
		 */
269
		public PointHandler(double x, double y) {
270
			point = new Point2D.Double(x, y);
271
		}
272

  
273
		/**
274
		 * DOCUMENT ME!
275
		 *
276
		 * @param x DOCUMENT ME!
277
		 * @param y DOCUMENT ME!
278
		 *
279
		 * @return DOCUMENT ME!
280
		 */
281
		public IGeometry move(double x, double y) {
282
			point.setLocation(point.getX() + x, point.getY() + y);
283

  
284
			return null;
285
		}
286

  
287
		/**
288
		 * @see com.iver.cit.gvsig.fmap.core.Handler#getPoint()
289
		 */
290
		public Point2D getPoint() {
291
			return point;
292
		}
293
	}
229 294
}
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/Handler.java
48 48

  
49 49

  
50 50
public interface Handler {
51
	public FGeometry move(double x, double y);
52
	
51
	public IGeometry move(double x, double y);
53 52
	public Point2D getPoint();
54 53
}

Also available in: Unified diff