Revision 1729

View differences:

branches/FMap_piloto_CAD_Layout_version/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/DefaultEditableFeatureSource.java
58 58
	 * @throws EditionException
59 59
	 */
60 60
	public void startEdition() throws EditionException {
61
		ofa.startEdition();
62

  
61
		if (ofa!=null){
62
			ofa.startEdition();
63
		}
63 64
		try {
64 65
			expansionFile.open();
65 66
			index = new Quadtree();
......
121 122
	 * @throws DriverIOException
122 123
	 */
123 124
	public int getGeometryCount() throws DriverIOException {
125
		if (ofa!=null)
124 126
		return ofa.getGeometryCount() + numAdd; //expansionFile.getGeometryCount() - relations.size();
127
		return numAdd;
125 128
	}
126 129

  
127 130
	/**
......
385 388
	 * @throws IOException
386 389
	 */
387 390
	public int doAddGeometry(IGeometry g) throws DriverIOException, IOException {
388
		int virtualIndex = ofa.getGeometryCount() + numAdd;
391
		int virtualIndex=0;
392
		if (ofa!=null){
393
			virtualIndex = ofa.getGeometryCount() + numAdd;
394
		}else{
395
			virtualIndex = numAdd;
396
		}
389 397
		int pos = expansionFile.addGeometry(g);
390 398
		relations.put(new Integer(virtualIndex), new Integer(pos));
391 399
		numAdd++;
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/ViewControls.java
130 130
		} else if (s.compareTo("ZOOM_IN") == 0) {
131 131
			mapCtrl.setTool("zoomIn");
132 132
		} else if (s.compareTo("ZOOM_OUT") == 0) {
133
			mapCtrl.setTool("zoomOut");
133
			mapCtrl.setTool("zoomOut");	
134 134
		} else if (s.compareTo("MEDICION") == 0) {
135 135
			mapCtrl.setTool("medicion");
136 136
		} else if (s.compareTo("AREA") == 0) {
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/LayoutControls.java
51 51
import com.iver.andami.ui.mdiManager.View;
52 52

  
53 53
import com.iver.cit.gvsig.fmap.DriverException;
54
import com.iver.cit.gvsig.fmap.edition.EditionException;
54 55
import com.iver.cit.gvsig.gui.layout.FLayoutZooms;
55 56
import com.iver.cit.gvsig.gui.layout.Layout;
56 57

  
......
94 95
		} else if (s.compareTo("SELECT") == 0) {
95 96
			layout.setTool(Layout.SELECT);
96 97
		} else if (s.compareTo("POINT") == 0) {
97
			layout.setTool(Layout.POINT);
98
			layout.setCadTool("point");
98 99
		} else if (s.compareTo("LINE") == 0) {
99
			layout.setTool(Layout.LINE);
100
			layout.setCadTool("line");
100 101
		} else if (s.compareTo("POLYLINE") == 0) {
101
			layout.setTool(Layout.POLYLINE);
102
			layout.setCadTool("polyline");
102 103
		} else if (s.compareTo("CIRCLE") == 0) {
103
			layout.setTool(Layout.CIRCLE);
104
			layout.setCadTool("circle");
104 105
		} else if (s.compareTo("RECTANGLESIMPLE") == 0) {
105 106
			layout.setCadTool("rectangle");
106 107
		} else if (s.compareTo("POLYGON") == 0) {
107
			layout.setTool(Layout.POLYGON);
108
			layout.setCadTool("polygon");
108 109
		} else if (s.compareTo("CONFIG") == 0) {
109 110
			layout.showFConfig();
110 111
		} else if (s.compareTo("PROPERTIES") == 0) {
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/FLayoutCADToolAdapter.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 com.iver.cit.gvsig.gui.layout;
42

  
43
import com.iver.cit.gvsig.fmap.ViewPort;
44
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
45
import com.iver.cit.gvsig.gui.cad.CADToolAdapter;
46

  
47
import java.awt.event.MouseEvent;
48
import java.awt.geom.Point2D;
49

  
50

  
51
/**
52
 * DOCUMENT ME!
53
 *
54
 * @author Vicente Caballero Navarro
55
 */
56
public class FLayoutCADToolAdapter extends CADToolAdapter {
57
	private Layout layout;
58

  
59
	/**
60
	 *
61
	 */
62
	public FLayoutCADToolAdapter(Layout l) {
63
		layout = l;
64
	}
65

  
66
	/**
67
	 * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
68
	 */
69
	public void mousePressed(MouseEvent e) throws BehaviorException {
70
		if (e.getButton() == MouseEvent.BUTTON1) {
71
			Point2D.Double aux = new Point2D.Double(e.getX(), e.getY());
72
			Point2D p = FLayoutUtilities.toSheetPoint(aux, layout.getAT());
73
			
74
			this.transition("punto", this.getEditableFeatureSource(), null,
75
				new double[] { p.getX(), p.getY() });
76
		}
77
	}
78
}
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/FLayoutDraw.java
45 45
package com.iver.cit.gvsig.gui.layout;
46 46

  
47 47
import com.iver.cit.gvsig.fmap.DriverException;
48
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
49
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
50
import com.iver.cit.gvsig.fmap.edition.EditableFeatureSource;
51
import com.iver.cit.gvsig.gui.cad.CadTool;
48 52
import com.iver.cit.gvsig.gui.layout.fframes.FFrame;
49 53
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView;
50 54
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame;
......
55 59
import java.awt.geom.Point2D;
56 60
import java.awt.geom.Rectangle2D;
57 61
import java.awt.image.BufferedImage;
62
import java.io.IOException;
58 63

  
59 64

  
60 65
/**
......
145 150
				((IFFrame) layout.getFFrames().get(i)).drawSymbolTag(g2);
146 151
			}
147 152
		}
148

  
153
		
149 154
		if (!layout.getFFrames().isEmpty()) {
150 155
			layout.setStatus(Layout.ACTUALIZADO);
151 156
		} else {
......
208 213

  
209 214
			g.drawRect((int) r.x, (int) r.y, (int) r.width, (int) r.height);
210 215
		}
216
		
211 217
	}
212 218

  
213
	public void drawGrid(Graphics2D g)
219
/*	public void drawGrid(Graphics2D g)
214 220
	{
215 221
		int unidadesMin = 6;
216 222
		double unidadesX = layout.getAtributes().getUnitInPixelsX();
......
260 266
		}
261 267

  
262 268
	}
269
	*/
263 270
	/**
264 271
	 * Dibuja sobre el graphics2d las reglas.
265 272
	 *
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/EventsHandler.java
44 44
 */
45 45
package com.iver.cit.gvsig.gui.layout;
46 46

  
47
import com.iver.cit.gvsig.fmap.edition.EditionException;
47 48
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
48
import com.iver.cit.gvsig.gui.cad.tools.RectangleCadTool;
49 49
import com.iver.cit.gvsig.gui.layout.fframes.FFrame;
50 50
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics;
51 51
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame;
......
88 88
		layout = l;
89 89
		events = new FLayoutFunctions(layout);
90 90
		zooms = new FLayoutZooms(layout);
91
	/*	try {
92
			layout.getCadToolAdapter().startEdition();
93
		} catch (EditionException e) {
94
			e.printStackTrace();
95
		}
96
		*/
91 97
	}
92 98

  
93 99
	/**
......
130 136
			layout.setLastPoint(e.getPoint());
131 137
			layout.repaint();
132 138
		}
139
		if (layout.getTool()==Layout.GRAPHICS || 
140
				layout.getTool()==Layout.RECTANGLEGROUP || 
141
				layout.getTool()==Layout.RECTANGLELEGEND || 
142
				layout.getTool()==Layout.RECTANGLEPICTURE || 
143
				layout.getTool()==Layout.RECTANGLESCALEBAR || 
144
				layout.getTool()==Layout.RECTANGLESYMBOL || 
145
				layout.getTool()==Layout.RECTANGLETEXT || 
146
				layout.getTool()==Layout.RECTANGLEVIEW){
147
			try {
148
				layout.getCadToolAdapter().mouseDragged(e);
149
			} catch (BehaviorException e1) {
150
				e1.printStackTrace();
151
			}
152
		}
133 153
	}
134 154

  
135 155
	/**
136 156
	 * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
137 157
	 */
138 158
	public void mouseMoved(MouseEvent E) {
139
		if (layout.getTool() == Layout.SELECT) {
159
		if (layout.getTool()==Layout.GRAPHICS){
160
			layout.setLastPoint(E.getPoint());
161
			layout.repaint();
162
			try {
163
				layout.getCadToolAdapter().mouseMoved(E);
164
			} catch (BehaviorException e) {
165
				e.printStackTrace();
166
			}
167
		}else if (layout.getTool() == Layout.SELECT) {
168
			
140 169
			Cursor cursor = null;
141 170
			Point2D.Double p = new Point2D.Double(E.getX(), E.getY());
142 171

  
......
275 304
					(layout.getTool() == Layout.RECTANGLELEGEND) ||
276 305
					(layout.getTool() == Layout.RECTANGLETEXT)) {
277 306
				layout.setStatus(Layout.RECTANGLE);
278
			} else if ((layout.getTool() == Layout.POINT) ||
279
					(layout.getTool() == Layout.LINE) ||
280
					(layout.getTool() == Layout.POLYLINE) ||
281
					(layout.getTool() == Layout.RECTANGLESIMPLE) ||
282
					(layout.getTool() == Layout.CIRCLE) ||
283
					(layout.getTool() == Layout.POLYGON)) {
284
				if (layout.getTool()== Layout.RECTANGLESIMPLE){
307
			} else if (layout.getTool()== Layout.GRAPHICS){
285 308
				try {
286
						//	if (layout.getCadTool()==null){
287 309
						layout.getCadToolAdapter().mousePressed(E);	
288
						//layout.setCadTool("rectangle");
289
							//layout.setStatus(Layout.GRAPHICS);
290
						//}
291 310
					} catch (BehaviorException e) {
292 311
						e.printStackTrace();
293 312
					}
294
				}
295
				//layout.setStatus(Layout.RECTANGLE);
313
				//}
296 314
			} else if (layout.getTool() == Layout.PAN) {
297 315
				layout.getRectOrigin().setLocation(layout.getRect().x,
298 316
					layout.getRect().y);
......
335 353
					layout.setStatus(Layout.SELECT);
336 354
					layout.repaint();
337 355
				}
338
			} else if (layout.getTool() == Layout.POINT) {
356
			} /*else if (layout.getTool() == Layout.POINT) {
339 357
				FFrameGraphics fframepoint = new FFrameGraphics();
340 358
				fframepoint.setBoundBox(FLayoutUtilities.toSheetRect(
341 359
						new Rectangle2D.Double(E.getX(), E.getY(), 20, 20),
342 360
						layout.getAT()));
343 361
				fframepoint.update(Layout.POINT, layout.getAT());
344 362
				layout.addFFrame(fframepoint, true);
345
			} else if (layout.getTool() == Layout.SET_TAG) {
363
			}*/ else if (layout.getTool() == Layout.SET_TAG) {
346 364
				m_pointSelected = new Point2D.Double(E.getX(), E.getY());
347 365

  
348 366
				for (int i = 0; i < layout.getFFrames().size(); i++) {
......
383 401
					(layout.getTool() == Layout.RECTANGLEPICTURE) ||
384 402
					(layout.getTool() == Layout.RECTANGLESCALEBAR) ||
385 403
					(layout.getTool() == Layout.RECTANGLELEGEND) ||
386
					(layout.getTool() == Layout.RECTANGLETEXT) ||
387
					(layout.getTool() == Layout.RECTANGLESIMPLE) ||
388
					(layout.getTool() == Layout.LINE) ||
389
					(layout.getTool() == Layout.POLYLINE) ||
390
					(layout.getTool() == Layout.POLYGON) ||
391
					(layout.getTool() == Layout.CIRCLE) ||
392
					(layout.getTool() == Layout.POINT)) {
404
					(layout.getTool() == Layout.RECTANGLETEXT)) {
393 405
				events.setFFrame();
394 406
			} else if (layout.getTool() == Layout.VIEW_ZOOMIN) {
395 407
				zooms.setViewZoomIn(p1, p2);
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameGraphics.java
46 46

  
47 47
import com.iver.andami.PluginServices;
48 48
import com.iver.cit.gvsig.fmap.DriverException;
49
import com.iver.cit.gvsig.fmap.core.FGeometry;
49 50
import com.iver.cit.gvsig.fmap.core.FPoint2D;
50 51
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
51 52
import com.iver.cit.gvsig.fmap.core.FPolyline2D;
52 53
import com.iver.cit.gvsig.fmap.core.FShape;
53 54
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
55
import com.iver.cit.gvsig.fmap.core.Handler;
56
import com.iver.cit.gvsig.fmap.core.IGeometry;
54 57
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
55 58
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities;
56 59
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
60
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
61
import com.iver.cit.gvsig.fmap.edition.EditableFeatureSource;
62
import com.iver.cit.gvsig.fmap.layers.SelectionSupport;
63
import com.iver.cit.gvsig.gui.cad.CADToolAdapter;
64
import com.iver.cit.gvsig.gui.cad.CadTool;
57 65
import com.iver.cit.gvsig.gui.layout.Layout;
58 66

  
59 67
import com.iver.utiles.XMLEntity;
......
62 70
import java.awt.Graphics2D;
63 71
import java.awt.geom.AffineTransform;
64 72
import java.awt.geom.Line2D;
73
import java.awt.geom.NoninvertibleTransformException;
65 74
import java.awt.geom.Point2D;
66 75
import java.awt.geom.Rectangle2D;
67 76
import java.awt.image.BufferedImage;
77
import java.io.IOException;
78
import java.util.ArrayList;
68 79

  
69 80

  
70 81
/**
71
 * FFrame para contener un gr?fico.
82
 * FFrame para contener todos los gr?ficos que se a?adan al Layout.
72 83
 *
73 84
 * @author Vicente Caballero Navarro
74 85
 */
75 86
public class FFrameGraphics extends FFrame {
76
	private int m_type = FConstant.SHAPE_TYPE_POINT;
77
	private FSymbol m_symbol = null;
78
	private Color m_color = null;
79
	private AffineTransform mT = null;
80
	private AffineTransform aT = null;
87
	private ArrayList geometries=new ArrayList();
88
	private CADToolAdapter cta;
89
	private SelectionSupport selectionSupport = new SelectionSupport();
81 90

  
82 91
	/**
83 92
	 * Crea un nuevo FFrameGraphics.
84 93
	 */
85
	public FFrameGraphics() {
94
	public FFrameGraphics(CADToolAdapter c){
95
		cta=c;
96
	}
97
	/*public FFrameGraphics() {
86 98
		mT = new AffineTransform();
87 99
		mT.setToIdentity();
100
	}*/
101
	public int getNumGeom(){
102
		return geometries.size();
88 103
	}
89

  
90
	/**
91
	 * Rellena el color que se utlizar? para dibujar el s?mbolo.
92
	 *
93
	 * @param color
94
	 */
95
	public void setColor(Color color) {
96
		m_color = color;
104
	public IGeometry[] getGeometries(){
105
		return (IGeometry[])geometries.toArray(new IGeometry[0]);
97 106
	}
98

  
99
	/**
100
	 * Actualiza el Fsymbol a partir del tipo de Gr?fico que se pase como
101
	 * par?metro.
102
	 *
103
	 * @param type tipo de gr?fico.
104
	 * @param at Transformada.
105
	 */
106
	public void update(int type, AffineTransform at) {
107
		m_type = type;
108
		aT = at;
109

  
110
		if (m_color == null) {
111
			m_color = Color.red;
112
		}
113

  
114
		switch (m_type) {
115
			case (Layout.POINT):
116
				m_symbol = new FSymbol(FConstant.SHAPE_TYPE_POINT, m_color);
117

  
118
				break;
119

  
120
			case (Layout.RECTANGLESIMPLE):
121
				m_symbol = new FSymbol(FConstant.SYMBOL_TYPE_FILL, m_color);
122
				m_symbol.setColor(null);
123

  
124
				break;
125

  
126
			case (Layout.LINE):
127
				m_symbol = new FSymbol(FConstant.SYMBOL_TYPE_LINE, m_color);
128

  
129
				break;
130

  
131
			case (Layout.POLYLINE):
132
				m_symbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT, m_color);
133

  
134
				break;
135

  
136
			case (Layout.POLYGON):
137
				m_symbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT, m_color);
138

  
139
				break;
140

  
141
			case (Layout.CIRCLE):
142
				m_symbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT, m_color);
143
				m_symbol.setStyle(FConstant.SYMBOL_STYLE_MARKER_CIRCLE);
144
				m_symbol.setOutlined(true);
145
				m_symbol.setOutlineColor(Color.red);
146
				m_symbol.setColor(null);
147

  
148
				break;
149
		}
107
	public void addGeometry(IGeometry g){
108
		geometries.add(g);
150 109
	}
151

  
152 110
	/**
153
	 * Devuelve el FSymbol que se representa.
154
	 *
155
	 * @return DOCUMENT ME!
156
	 */
157
	public FSymbol getFSymbol() {
158
		return m_symbol;
159
	}
160

  
161
	/**
162
	 * Rellena el FSymbol que se representara al dibujar.
163
	 *
164
	 * @param symbol
165
	 */
166
	public void setFSymbol(FSymbol symbol) {
167
		m_symbol = symbol;
168
	}
169

  
170
	/**
171
	 * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
172
	 * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
173
	 * de dibujar.
174
	 *
175
	 * @param g Graphics
176
	 * @param at Transformada afin.
177
	 * @param rv rect?ngulo sobre el que hacer un clip.
178
	 * @param imgBase DOCUMENT ME!
179
	 */
180
	public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv,
181
		BufferedImage imgBase) {
182
		Rectangle2D.Double rect = getBoundingBox(at);
183

  
184
		if (intersects(rv, rect)) {
185
			g.setColor(Color.black);
186

  
187
			FShape m_shape = null;
188

  
189
			switch (m_type) {
190
				case (Layout.POINT):
191

  
192
					Point2D.Double p = new Point2D.Double((int) rect.getCenterX(),
193
							(int) rect.getCenterY());
194
					m_shape = new FPoint2D(p.x, p.y);
195

  
196
					if (rect.width < rect.height) {
197
						m_symbol.setSize((int) rect.width - 10);
198
					} else {
199
						m_symbol.setSize((int) rect.height - 10);
200
					}
201

  
202
					///m_symbol = new FSymbol(FConstant.SHAPE_TYPE_POINT, Color.red);
203
					FGraphicUtilities.DrawShape(g, mT, m_shape, m_symbol);
204

  
205
					break;
206

  
207
				case (Layout.RECTANGLESIMPLE):
208

  
209
					GeneralPathX rectAux = new GeneralPathX(rect);
210
					rectAux.transform(mT);
211
					m_shape = new FPolygon2D(rectAux); //FConstant.SHAPE_TYPE_POLYLINE, rectAux);
212

  
213
					///m_symbol = new FSymbol(FConstant.SYMBOL_TYPE_LINE, Color.red);
214
					FGraphicUtilities.DrawShape(g, mT, m_shape, m_symbol);
215

  
216
					break;
217

  
218
				case (Layout.LINE):
219

  
220
					Line2D line = new Line2D.Double();
221
					line.setLine(new Point2D.Double(rect.x, rect.y),
222
						new Point2D.Double(rect.getMaxX(), rect.getMaxY()));
223

  
224
					GeneralPathX rectA = new GeneralPathX(line);
225
					rectA.transform(mT);
226
					m_shape = new FPolyline2D(rectA);
227

  
228
					///m_symbol = new FSymbol(FConstant.SYMBOL_TYPE_LINE, Color.red);
229
					FGraphicUtilities.DrawShape(g, mT, m_shape, m_symbol);
230

  
231
					//g.drawString("POLYLINE",(float)rect.getCenterX(),(float)rect.getCenterY());
232
					break;
233

  
234
				case (Layout.POLYLINE):
235
					g.drawString("POLYLINE", (float) rect.getCenterX(),
236
						(float) rect.getCenterY());
237

  
238
					break;
239

  
240
				case (Layout.POLYGON):
241
					g.drawString("POLYGON", (float) rect.getCenterX(),
242
						(float) rect.getCenterY());
243

  
244
					break;
245

  
246
				case (Layout.CIRCLE):
247

  
248
					Point2D.Double pc = new Point2D.Double((int) rect.getCenterX(),
249
							(int) rect.getCenterY());
250
					m_shape = new FPoint2D(pc.x, pc.y);
251

  
252
					if (rect.width < rect.height) {
253
						m_symbol.setSize((int) rect.width - 10);
254
					} else {
255
						m_symbol.setSize((int) rect.height - 10);
256
					}
257

  
258
					///m_symbol = new FSymbol(FConstant.SHAPE_TYPE_POINT, Color.red);
259
					FGraphicUtilities.DrawShape(g, mT, m_shape, m_symbol);
260

  
261
					break;
262
			}
263
		}
264
	}
265

  
266
	/**
267 111
	 * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
268 112
	 */
269 113
	public XMLEntity getXMLEntity() {
270 114
		XMLEntity xml = new XMLEntity();
271
		xml.putProperty("className",this.getClass().getName());
272
		xml.putProperty("m_name", m_name);
273
		xml.putProperty("x", getBoundBox().x);
274
		xml.putProperty("y", getBoundBox().y);
275
		xml.putProperty("w", getBoundBox().width);
276
		xml.putProperty("h", getBoundBox().height);
277
		xml.putProperty("m_Selected", m_Selected);
278
		xml.putProperty("type", Layout.GRAPHICS);
279

  
280
		/// xml.putProperty("m_type", m_type);
281
		xml.putProperty("tag", getTag());
282

  
283
		/// xml.addChild(m_symbol.getXMLEntity());
284 115
		return xml;
285 116
	}
286 117

  
287 118
	/**
288
	 * Crea un Objeto de esta clase a partir de la informaci?n del XMLEntity.
289
	 *
290
	 * @param xml XMLEntity
291
	 *
292
	 * @return Objeto de esta clase.
293
	 */
294
	public static FFrameGraphics createFFrameGraphics(XMLEntity xml) {
295
		FFrameGraphics fframe = new FFrameGraphics();
296

  
297
		if (xml.getIntProperty("m_Selected") != 0) {
298
			fframe.setSelected(true);
299
		} else {
300
			fframe.setSelected(false);
301
		}
302

  
303
		/// fframe.m_type = xml.getIntProperty("m_type");
304
		/// fframe.m_symbol = FSymbol.createFSymbol(xml.getChild(0));
305
		return fframe;
306
	}
307

  
308
	/**
309 119
	 * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#updateNum()
310 120
	 */
311 121
	public void updateNum() {
......
340 150
		throws DriverException {
341 151
		draw(g, at, null, null);
342 152
	}
153
	/**
154
	 * @see com.iver.cit.gvsig.gui.layout.fframes.FFrame#draw(java.awt.Graphics2D, java.awt.geom.AffineTransform, java.awt.geom.Rectangle2D, java.awt.image.BufferedImage)
155
	 */
156
	public void draw(Graphics2D g, AffineTransform at, Rectangle2D r, BufferedImage imgBase) throws DriverException {
157
		EditableFeatureSource efs=cta.getEditableFeatureSource();
158
		try {
159
			for (int i=0;i<efs.getGeometryCount();i++){
160
				try {
161
					IGeometry geometry=efs.getGeometry(i);
162
					geometry.draw(g,at,CadTool.drawingSymbol);//Cada gr?fico tendr? su propio s?mbolo.
163
					if (cta.getSelection().get(i)){
164
						Handler[] handlers=geometry.getHandlers(FGeometry.SELECTHANDLER);
165
							FGraphicUtilities.DrawHandlers((Graphics2D)g,new AffineTransform(),handlers);
166
						
167
					}
168
				} catch (IOException e1) {
169
					e1.printStackTrace();
170
				}
171
			}
172
			
173
		} catch (DriverIOException e) {
174
			e.printStackTrace();
175
		}
176
		
177
	}
178
	public void drawHandlers(Graphics2D g) {
179
		EditableFeatureSource efs=cta.getEditableFeatureSource();
180
	/*	int[] indexes = efs.getGeometriesIndexes(r);
181
		//Recorrer todas las geometrias
182
		for (int i=0;i<geometries.size();i++){
183
			//Recorrer todos los handlers y ver 
184
			//si hay alguno que se ajuste al puntero del rat?n con su tolerancia.
185
			IGeometry ig = efs.getGeometry(indexes[i]);
186
			if (ig == null) continue;
187
			if (selectionSupport.isSelected(indexes[i])){
188
				Handler[] handlers=ig.getHandlers(FGeometry.SELECTHANDLER);
189
				FGraphicUtilities.DrawHandlers((Graphics2D)g,viewPort.getAffineTransform(),handlers);
190
				ig.draw(g, at, symbol);
191
			}
192
		}*/
193
	}
343 194
}
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/dialogs/FFrameGraphicsDialog.java
78 78
	public FFrameGraphicsDialog(Layout layout, FFrameGraphics fframe) {
79 79
		m_layout = layout;
80 80
		fframegraphics = fframe;
81
		setFSymbol(fframegraphics.getFSymbol());
81
		/////setFSymbol(fframegraphics.getFSymbol());
82 82
		fillCheckBox.setSelected(false);
83 83

  
84 84
		initialize();
......
141 141
							updateControls(false); // Para que lo que haya en 
142 142
						}
143 143

  
144
						// ese momento en los controles pase al m_FSymbol
145
						///m_Renderer.setLegendType(FConstant.LEGEND_TYPE_DEFAULT);
146
						fframegraphics.setFSymbol(getFSymbol());
144
						////fframegraphics.setFSymbol(getFSymbol());
147 145

  
148
						///m_Renderer.setDefaultSymbol(m_defaultLegendPanel.getFSymbol());
149 146
						PluginServices.getMDIManager().closeView(FFrameGraphicsDialog.this);
150 147
						m_layout.refresh();
151 148
						isAcepted = true;
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/FLayoutFunctions.java
150 150
		} else if (layout.getTool() == Layout.RECTANGLETEXT) {
151 151
			fframe = new FFrameText();
152 152
			isadd = true;
153
		} else if ((layout.getTool() == Layout.RECTANGLESIMPLE) ||
154
				(layout.getTool() == Layout.LINE) ||
155
				(layout.getTool() == Layout.POLYLINE) ||
156
				(layout.getTool() == Layout.POLYGON) ||
157
				(layout.getTool() == Layout.CIRCLE) ||
158
				(layout.getTool() == Layout.POINT)) {
159
			fframe = new FFrameGraphics();
160
			isadd = true;
161
			((FFrameGraphics) fframe).update(layout.getTool(), layout.getAT());
162
		}
163

  
153
		} 
164 154
		if (isadd) {
165 155
			Rectangle2D r = new Rectangle2D.Double(); //rectOrigin.x+m_PointAnt.x,rectOrigin.y+m_PointAnt.y,m_LastPoint.x-m_PointAnt.x,m_LastPoint.y-m_PointAnt.y);
166 156
			
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/FLayoutEditable.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 com.iver.cit.gvsig.gui.layout;
42

  
43

  
44
import com.iver.cit.gvsig.fmap.core.IGeometry;
45
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
46
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame;
47

  
48
import java.awt.Image;
49
import java.awt.geom.Rectangle2D;
50

  
51
import java.io.IOException;
52

  
53

  
54
/**
55
 * DOCUMENT ME!
56
 *
57
 * @author $author$
58
 */
59
public interface FLayoutEditable {
60
    /**
61
     * M?todo invocado cuando se comienza la edici?n, para poner en marcha las
62
     * estructuras de datos necesarias para la misma
63
     *
64
     */
65
    void startEdition();
66

  
67
    /**
68
     * Invocado cuando termina la edici?n. 
69
     */
70
    void stopEdition();
71

  
72
    /**
73
     * Cancela la edici?n sin escribir los cambios
74
     *
75
     */
76
    void cancelEdition();
77

  
78
    IFFrame getFFrame(int index);
79

  
80
    /**
81
     * Devuelve el n?mero de FFrames que hay actualmente en edici?n.
82
     *
83
     * @return N?mero de FFrames.
84
     *
85
     */
86
    int getFFrameCount();
87

  
88
    /**
89
     * A?ade un FFrame al fichero de expansi?n y guarda la correspondencia
90
     * en una tabla asociada.
91
     *
92
     * @param f FFrame a guardar.
93
     *
94
     */
95
    void addFFrame(IFFrame f) ;
96

  
97
    /**
98
     * Deshace la ?ltima acci?n realizada. Si no hay m?s acciones no realiza
99
     * ninguna acci?n
100
     *
101
     */
102
    void undo();
103

  
104
    /**
105
     * Rehace la ?ltima acci?n deshecha. Si no hay m?s acciones no hace nada
106
     *
107
     */
108
    void redo();
109

  
110
    /**
111
     * Devuelve true si se puede deshacer un comando invocando undo o si por el
112
     * contrario se ha llegado al principio de la lista de comandos y ya no se
113
     * pueden deshacer m?s comandos
114
     *
115
     * @return boolean
116
     */
117
    boolean moreUndoCommands();
118

  
119
    /**
120
     * Devuelve true si se puede rehacer un comando invocando redo o si por el
121
     * contrario se est? al final de la lista de comandos y ya no se pueden
122
     * deshacer m?s comandos
123
     *
124
     * @return boolean
125
     */
126
    boolean moreRedoCommands();
127

  
128
    /**
129
     * Elimina un FFrame. 
130
     *
131
     */
132
    void removeFFrame(int index);
133

  
134
    void modifyFFrame(int index, IFFrame f);
135

  
136
  
137
    void setImage(Image i);
138
    Image getImage();
139

  
140
    /**
141
     * DOCUMENT ME!
142
     */
143
    void startComplexGeometry();
144

  
145
    /**
146
     * DOCUMENT ME!
147
     *
148
     * @throws IOException DOCUMENT ME!
149
     * @throws DriverIOException DOCUMENT ME!
150
     */
151
    void endComplexGeometry() throws IOException, DriverIOException;
152
}
153

  
0 154

  
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/Layout.java
55 55
import com.iver.cit.gvsig.fmap.DriverException;
56 56
import com.iver.cit.gvsig.fmap.ExtentEvent;
57 57
import com.iver.cit.gvsig.fmap.ViewPortListener;
58
import com.iver.cit.gvsig.fmap.edition.EditionException;
59
import com.iver.cit.gvsig.fmap.layers.FBitSet;
58 60
import com.iver.cit.gvsig.gui.cad.CADToolAdapter;
61
import com.iver.cit.gvsig.gui.cad.CadGrid;
59 62
import com.iver.cit.gvsig.gui.cad.CadTool;
60 63
import com.iver.cit.gvsig.gui.cad.tools.ArcCadTool;
61 64
import com.iver.cit.gvsig.gui.cad.tools.CircleCadTool;
......
100 103
import java.awt.event.ActionEvent;
101 104
import java.awt.event.KeyEvent;
102 105
import java.awt.geom.AffineTransform;
106
import java.awt.geom.Point2D;
103 107
import java.awt.geom.Rectangle2D;
104 108
import java.awt.image.BufferedImage;
109
import java.awt.image.MemoryImageSource;
105 110
import java.awt.print.PageFormat;
106 111
import java.awt.print.Printable;
107 112
import java.awt.print.PrinterException;
108 113
import java.awt.print.PrinterJob;
109 114

  
110 115
import java.util.ArrayList;
116
import java.util.BitSet;
111 117
import java.util.HashMap;
112 118
import java.util.Hashtable;
113 119
import java.util.Stack;
......
152 158
	public static final int RECTANGLE = 10;
153 159
	public static final int ACTUALIZADO = 11;
154 160
	public static final int SELECT = 12;
155
	public static final int POINT = 13;
156
	public static final int LINE = 14;
157
	public static final int POLYLINE = 15;
158
	public static final int RECTANGLESIMPLE = 16;
159
	public static final int CIRCLE = 17;
160
	public static final int POLYGON = 18;
161
	//public static final int POINT = 13;
162
	//public static final int LINE = 14;
163
	//public static final int POLYLINE = 15;
164
	//public static final int RECTANGLESIMPLE = 16;
165
	//public static final int CIRCLE = 17;
166
	//public static final int POLYGON = 18;
161 167
	public static final int GRAPHICS = 19;
162 168
	public static final int RECTANGLESYMBOL = 20;
163 169
	public static final int RECTANGLEGROUP = 21;
......
184 190
															   .getResource("images/CruxCursor.png")).getImage();
185 191
	public static final Image itag = new ImageIcon(Abrir.class.getClassLoader()
186 192
															  .getResource("images/tagCursor.gif")).getImage();
187
	public static final Image iPoint = new ImageIcon(Abrir.class.getClassLoader()
193
	/*public static final Image iPoint = new ImageIcon(Abrir.class.getClassLoader()
188 194
																.getResource("images/PointCursor.png")).getImage();
189 195
	public static final Image iRect = new ImageIcon(Abrir.class.getClassLoader()
190 196
															   .getResource("images/RectCursor.png")).getImage();
......
195 201
	public static final Image iCircle = new ImageIcon(Abrir.class.getClassLoader()
196 202
																 .getResource("images/CircleCursor.png")).getImage();
197 203
	public static final Image iPoligon = new ImageIcon(Abrir.class.getClassLoader()
198
																  .getResource("images/PoligonCursor.png")).getImage();
204
														  .getResource("images/PoligonCursor.png")).getImage();
205
*/
199 206
	public static Hashtable nums = new Hashtable();
200 207
	private Point origin = new Point(50, 50);
201 208
	private Point rectOrigin = new Point(origin);
......
233 240
	private PrintRequestAttributeSet att = null;
234 241
	private boolean cadtool = false;
235 242
	private HashMap namesCadTools = new HashMap();
236
	private FLayoutCADToolAdapter cadToolAdapter;
243
	private LayoutCADToolAdapter cadToolAdapter;
237 244
	private HashMap namesMapTools = new HashMap();
238 245
	private Stack toolStack = new Stack();
239 246

  
......
242 249
	 */
243 250
	public Layout() {
244 251
		this.setLayout(null);
252
		cadToolAdapter=new LayoutCADToolAdapter(this);
253
		FFrameGraphics fg=new FFrameGraphics(cadToolAdapter);
254
		addFFrame(fg,true);
245 255
		events = new EventsHandler(this);
246 256
		layoutPaint = new FLayoutDraw(this);
247
		cadToolAdapter=new FLayoutCADToolAdapter(this);
257
		getCadToolAdapter().setEditableFeatureSource(new LayoutEditableFeature(this),new FBitSet());
258
		try {
259
			getCadToolAdapter().getEditableFeatureSource().startEdition();
260
		} catch (EditionException e) {
261
			e.printStackTrace();
262
		}
248 263
		addComponentListener(events);
249 264
		addMouseMotionListener(events);
250 265
		addMouseListener(events);
......
252 267
		m_MatrizTransf.setToIdentity();
253 268
		this.initComponents();
254 269
		
270

  
255 271
	}
256 272

  
257 273
	/**
......
404 420
	 */
405 421
	private void initComponents() {
406 422
		m_attributes = new Attributes();
423
		m_attributes.setCADToolAdapter(this.getCadToolAdapter());
407 424
		m_attributes.setDistanceUnitX(rect);
408 425
		m_attributes.setDistanceUnitY(rect);
409 426
		actionDelFFrame();
......
417 434
		addCadTool("line", lineCADTool);
418 435

  
419 436
		//Herramienta de CAD de a?adir c?rculo
420
		addCadTool("circle", new CircleCadTool());
437
		CircleCadTool circleCADTool=new CircleCadTool();
438
		addCadTool("circle",circleCADTool);
421 439

  
422 440
		//Herramienta de CAD de a?adir c?rculo
423
		addCadTool("ellipse", new EllipseCadTool());
441
		EllipseCadTool ellipseCADTool=new EllipseCadTool();
442
		addCadTool("ellipse", ellipseCADTool);
424 443

  
425 444
		//Herramienta de CAD de a?adir c?rculo
426
		addCadTool("arc", new ArcCadTool());
445
		ArcCadTool arcCADTool=new ArcCadTool();
446
		addCadTool("arc",arcCADTool);
427 447

  
428 448
		//Herramienta de CAD de a?adir polyl?nea
429 449
		PolyLineCadTool polylineCADTool = new PolyLineCadTool();
......
488 508
				g.drawImage(img, 0, 0, this);
489 509

  
490 510
				g.setClip(rClip);
491
				layoutPaint.drawGrid((Graphics2D) g);
511
				cadToolAdapter.drawGrid(g);
492 512
				layoutPaint.drawRuler((Graphics2D) g, Color.black);
493 513
				g.setColor(Color.black);
494 514
				g.setXORMode(Color.white);
......
507 527
				g.drawImage(img, 0, 0, this);
508 528

  
509 529
				g.setClip(rClip);
510
				layoutPaint.drawGrid((Graphics2D) g);
530
				cadToolAdapter.drawGrid(g);
511 531
				layoutPaint.drawRuler((Graphics2D) g, Color.black);
512 532
				g.setColor(Color.black);
513 533
				g.setXORMode(Color.white);
......
522 542
				}
523 543

  
524 544
				g.drawRect(re.x, re.y, re.width, re.height);
525

  
545
			
526 546
				break;
527 547

  
528 548
			case PAN:
529 549

  
530
				/*        logger.debug("pan");
531
				   //g.setXORMode(Color.black);
550
				   logger.debug("pan");
532 551
				   rect.x = rectOrigin.x + (m_LastPoint.x - m_PointAnt.x);
533 552
				   rect.y = rectOrigin.y + (m_LastPoint.y - m_PointAnt.y);
534
				   //g.clearRect(0, 0, getWidth(), getHeight());
535 553
				   layoutPaint.drawRectangle((Graphics2D) g);
536 554
				   if (img != null) {
537 555
				           g.drawImage(img, (getLastPoint().x - getPointAnt().x),
538 556
				                   (m_LastPoint.y - m_PointAnt.y), this);
539 557
				   }
540 558
				   g.setClip(rClip);
541
				   layoutPaint.drawGrid((Graphics2D) g);
542 559
				   layoutPaint.drawRuler((Graphics2D) g, Color.black);
543
				 */
544
				if (((com.iver.cit.gvsig.gui.layout.tools.Behavior.Behavior) toolStack.peek() != null) &&
545
						(img != null)) {
546
					((com.iver.cit.gvsig.gui.layout.tools.Behavior.Behavior) toolStack.peek()).paintComponent(g);
547
					System.out.println("Pinto ACTUALIZADO");
548
				}
549

  
560
	
550 561
				break;
551 562

  
552 563
			case VIEW_PAN:
553 564

  
554
				// logger.debug("View pan");
555 565
				layoutPaint.drawRectangle((Graphics2D) g);
556 566

  
557 567
				for (int i = 0; i < getFFrames().size(); i++) {
......
562 572
							Rectangle2D.Double rec = fframe.getBoundingBox(getAT());
563 573

  
564 574
							if (img != null) {
565
								//g.drawImage(img, 0, 0, this);
566 575
								rec = (Rectangle2D.Double) rec.createIntersection(getVisibleRect());
567

  
568
								//((Graphics2D)g).clearRect((int)rec.x,(int)rec.y,(int)rec.width,(int)rec.height);
569 576
							}
570 577

  
571 578
							if (fframe.getBufferedImage() != null) {
......
574 581
								g.clipRect((int) rec.x, (int) rec.y,
575 582
									(int) rec.width, (int) rec.height);
576 583

  
577
								//g.setColor(Color.gray);
578
								//g.fillRect(0,0,getWidth(),getHeight());
579 584
								layoutPaint.drawRectangle((Graphics2D) g);
580 585
								layoutPaint.drawRuler((Graphics2D) g,
581 586
									Color.black);
......
583 588
								g.drawImage(fframe.getBufferedImage(),
584 589
									m_LastPoint.x - m_PointAnt.x,
585 590
									m_LastPoint.y - m_PointAnt.y, this);
586

  
587
								/*System.out.println(
588
								   "m_LastPoint.x - m_PointAnt.x" +
589
								   (m_LastPoint.x - m_PointAnt.x));
590
								   System.out.println(
591
								           "m_LastPoint.y - m_PointAnt.y" +
592
								           (m_LastPoint.y - m_PointAnt.y));
593
								 */
594 591
							}
595 592
						}
596 593
					}
597 594
				}
598 595

  
599 596
				g.setClip(rClip);
600
				layoutPaint.drawGrid((Graphics2D) g);
597
				cadToolAdapter.drawGrid(g);
601 598
				layoutPaint.drawRuler((Graphics2D) g, Color.black);
602

  
603
				//g.setXORMode(Color.black);
604 599
				break;
605 600

  
606 601
			case SELECT:
......
647 642
				}
648 643

  
649 644
				g.setClip(rClip);
650
				layoutPaint.drawGrid((Graphics2D) g);
645
				cadToolAdapter.drawGrid(g);
651 646
				layoutPaint.drawRuler((Graphics2D) g, Color.black);
652 647

  
653 648
				break;
654 649

  
655 650
			case GRAPHICS:
656
				layoutPaint.drawRectangle((Graphics2D) g);
657
				g.drawImage(img, 0, 0, this);
658
				g.setClip(rClip);
659
				layoutPaint.drawGrid((Graphics2D) g);
660
				layoutPaint.drawRuler((Graphics2D) g, Color.black);
661

  
662 651
				break;
663 652

  
664 653
			case DESACTUALIZADO:
......
685 674

  
686 675
				g.drawImage(img, 0, 0, this);
687 676
				g.setClip(rClip);
688
				layoutPaint.drawGrid((Graphics2D) g);
677
				cadToolAdapter.drawGrid(g);
678
				
689 679
				layoutPaint.drawHandlers((Graphics2D) g, Color.black);
690 680
				layoutPaint.drawRuler((Graphics2D) g, Color.black);
691

  
692
				if (cadtool) {
693
					getCadTool().setAT(getAT());
694
					getCadTool().drawOperation(g, null, null,
695
						m_LastPoint.getX(), m_LastPoint.getY());
681
				if (getTool()==GRAPHICS){
682
					cadToolAdapter.drawCursor(g);
696 683
				}
697

  
684
				
698 685
				break;
699 686

  
700 687
			case ACTUALIZADO:
......
703 690
				g.drawImage(img, 0, 0, this);
704 691

  
705 692
				g.setClip(rClip);
706
				layoutPaint.drawGrid((Graphics2D) g);
707

  
708 693
				layoutPaint.drawHandlers((Graphics2D) g, Color.black);
709 694
				layoutPaint.drawRuler((Graphics2D) g, Color.black);
695
				cadToolAdapter.drawGrid(g);
696
				if (getTool()==GRAPHICS){
697
					cadToolAdapter.drawCursor(g);
698
				}
699
				cadToolAdapter.paintComponent(g);
700
		
710 701
		}
711 702
	}
712 703

  
......
929 920
			setMapCursor(izoomin);
930 921
		} else if (getTool() == ZOOM_MENOS) {
931 922
			setMapCursor(izoomout);
932
		} else if (getTool() == RECTANGLEVIEW) {
923
		} else if (getTool() == RECTANGLEVIEW || 
924
				getTool() == RECTANGLEPICTURE ||
925
				getTool() == RECTANGLESCALEBAR || 
926
				getTool() == RECTANGLELEGEND ||
927
				getTool() == RECTANGLETEXT) {
933 928
			setMapCursor(icrux);
934
		} else if (getTool() == RECTANGLEPICTURE) {
935
			setMapCursor(icrux);
936
		} else if (getTool() == RECTANGLESCALEBAR) {
937
			setMapCursor(icrux);
938
		} else if (getTool() == RECTANGLELEGEND) {
939
			setMapCursor(icrux);
940
		} else if (getTool() == RECTANGLETEXT) {
941
			setMapCursor(icrux);
942 929
		} else if (getTool() == SELECT) {
943 930
			setCursor(Cursor.getDefaultCursor());
944 931
		} else if (getTool() == SET_TAG) {
945 932
			setMapCursor(itag);
946
		} else if (getTool() == POINT) {
947
			setMapCursor(iPoint);
948
		} else if (getTool() == LINE) {
949
			setMapCursor(iRect);
950
		} else if (getTool() == RECTANGLESIMPLE) {
951
			setMapCursor(iRectangle);
952
		} else if (getTool() == POLYLINE) {
953
			setMapCursor(iLine);
954
		} else if (getTool() == POLYGON) {
955
			setMapCursor(iPoligon);
956
		} else if (getTool() == CIRCLE) {
957
			setMapCursor(iCircle);
958
		}
933
		}else if (getTool() == GRAPHICS) {
934
			clearMouseImage();
935
		} 
959 936
	}
960

  
937
	private void clearMouseImage(){
938
		int[] pixels = new int[16 * 16];
939
		Image image = Toolkit.getDefaultToolkit().createImage(
940
			new MemoryImageSource(16, 16, pixels, 0, 16));
941
		Cursor transparentCursor =
942
			Toolkit.getDefaultToolkit().createCustomCursor
943
			    (image, new Point(0,0), "invisiblecursor");
944
		this.setCursor(transparentCursor);
945
	}
961 946
	/**
962 947
	 * Se crean aqu? los dialogos cada vez que se necesitan.
963 948
	 *
......
1173 1158
	 */
1174 1159
	public void setIsCuadricula(boolean b) {
1175 1160
		isCuadricula = b;
1161
		getCadToolAdapter().setAdjustGrid(b);
1176 1162
	}
1177 1163

  
1178 1164
	/**
......
1231 1217
		layout.isCuadricula = xml.getBooleanProperty("isCuadricula");
1232 1218
		layout.setName(xml.getStringProperty("m_name"));
1233 1219
		layout.m_attributes = Attributes.createAtributes(xml.getChild(0));
1234

  
1220
		layout.m_attributes.setCADToolAdapter(layout.getCadToolAdapter());
1235 1221
		for (int i = 1; i < xml.getNumChild(); i++) {
1236 1222
			if (xml.getChild(i).getStringProperty("className").equals("com.iver.cit.gvsig.gui.layout.fframe.FFrameView")) {
1237 1223
				layout.addFFrame(FFrame.createFFrame(xml.getChild(i), layout, p),
......
1288 1274
	 */
1289 1275
	public void setIsDrawGrid(boolean b) {
1290 1276
		isDrawCuadricula = b;
1277
		getCadToolAdapter().setGrid(b);
1291 1278
	}
1292 1279

  
1293 1280
	/**
......
1300 1287
	 * @see com.iver.andami.ui.mdiManager.ViewListener#viewClosed()
1301 1288
	 */
1302 1289
	public void viewClosed() {
1303
		///PluginServices.getMainFrame().getStatusBar().setMessage("1","");
1290
		try {
1291
			cadToolAdapter.getEditableFeatureSource().stopEdition();
1292
			///PluginServices.getMainFrame().getStatusBar().setMessage("1","");
1293
		} catch (EditionException e) {
1294
			e.printStackTrace();
1295
		}
1304 1296
	}
1305 1297

  
1306 1298
	/**
......
1361 1353

  
1362 1354
		cadToolAdapter.setCadTool(ct);
1363 1355
		cadtool = true;
1364
		setTool(RECTANGLESIMPLE);
1356
		setTool(GRAPHICS);
1365 1357

  
1366 1358
		//clearMouseImage();
1367 1359
	}
......
1372 1364
	 * @return DOCUMENT ME!
1373 1365
	 */
1374 1366
	public CADToolAdapter getCadToolAdapter() {
1375
		return cadToolAdapter;
1367
		return (CADToolAdapter)cadToolAdapter;
1376 1368
	}
1369
	public FFrameGraphics getFFrameGraphics(){
1370
		return (FFrameGraphics)getFFrames().get(0);
1371
	}
1377 1372
}
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/LayoutOriginalFeature.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 com.iver.cit.gvsig.gui.layout;
42

  
43
import java.io.IOException;
44

  
45
import com.iver.cit.gvsig.fmap.core.IGeometry;
46
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
47
import com.iver.cit.gvsig.fmap.edition.EditableFeatureSource;
48
import com.iver.cit.gvsig.fmap.edition.EditionException;
49
import com.iver.cit.gvsig.fmap.edition.OriginalFeatureAdapter;
50

  
51

  
52
/**
53
 * DOCUMENT ME!
54
 *
55
 * @author Vicente Caballero Navarro
56
 */
57
public class LayoutOriginalFeature implements OriginalFeatureAdapter {
58
	private Layout layout;
59

  
60
	/**
61
	 * Crea un nuevo LayoutOriginalFeature.
62
	 *
63
	 * @param l DOCUMENT ME!
64
	 */
65
	public LayoutOriginalFeature(Layout l) {
66
		layout = l;
67
	}
68

  
69
	/**
70
	 * @see com.iver.cit.gvsig.fmap.edition.OriginalFeatureAdapter#getGeometryCount()
71
	 */
72
	public int getGeometryCount() throws DriverIOException {
73
		return layout.getFFrameGraphics().getNumGeom();
74
	}
75

  
76
	/**
77
	 * @see com.iver.cit.gvsig.fmap.edition.OriginalFeatureAdapter#startEdition()
78
	 */
79
	public void startEdition() throws EditionException {
80
	}
81

  
82
	/**
83
	 * @see com.iver.cit.gvsig.fmap.edition.OriginalFeatureAdapter#stopEdition(com.iver.cit.gvsig.fmap.edition.EditableFeatureSource)
84
	 */
85
	public void stopEdition(EditableFeatureSource editedSource)
86
		throws EditionException {
87
		try {
88
			for (int i=0;i<editedSource.getGeometryCount();i++){
89
				try {
90
					layout.getFFrameGraphics().addGeometry(editedSource.getGeometry(i));
91
				} catch (IOException e1) {
92
					e1.printStackTrace();
93
				}
94
			}
95
		} catch (DriverIOException e) {
96
			e.printStackTrace();
97
		}
98
	}
99

  
100
	/**
101
	 * @see com.iver.cit.gvsig.fmap.edition.OriginalFeatureAdapter#getGeometry(int)
102
	 */
103
	public IGeometry getGeometry(int index) throws DriverIOException {
104
		return null;
105
	}
106
}
0 107

  
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/FLayoutUtilities.java
129 129
	 *
130 130
	 * @return Point2D en coordenadas de folio.
131 131
	 */
132
	public static Point2D.Double toSheetPoint(Point2D.Double pScreen,
132
	public static Point2D.Double toSheetPoint(Point2D pScreen,
133 133
		AffineTransform at) {
134 134
		Point2D.Double pWorld = new Point2D.Double();
135 135
		AffineTransform at1;
......
174 174
	 *
175 175
	 * @return Point2D en pixels.
176 176
	 */
177
	public static Point2D.Double fromSheetPoint(Point2D.Double pSheet,
177
	public static Point2D.Double fromSheetPoint(Point2D pSheet,
178 178
		AffineTransform at) {
179 179
		Point2D.Double pScreen = new Point2D.Double();
180 180

  
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/LayoutEditableFeature.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 com.iver.cit.gvsig.gui.layout;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff