Revision 4203

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/FLayoutZooms.java
44 44
 */
45 45
package com.iver.cit.gvsig.gui.layout;
46 46

  
47
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView;
48 47
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame;
49 48
import com.iver.cit.gvsig.gui.layout.fframes.IFFrameUseFMap;
50 49

  
......
61 60
 */
62 61
public class FLayoutZooms {
63 62
	private Layout layout = null;
64
	private FLayoutFunctions functions = null;
63
	private static double FACTOR=2;
65 64

  
66 65
	/**
67 66
	 * Crea un nuevo Zooms.
......
70 69
	 */
71 70
	public FLayoutZooms(Layout l) {
72 71
		layout = l;
73
		functions = new FLayoutFunctions(layout);
74 72
	}
75 73

  
76 74
	/**
......
81 79
	 * @param p2 punto final del rec?ngulo.
82 80
	 */
83 81
	public void setZoomIn(Point p1, Point p2) {
84
		/*if (p1.y != p2.y) {
85
			double points = (p2.getX() - p1.getX()) / (p2.getY() - p1.getY());
86
			double window = (double) layout.getWidth() / (double)layout.getHeight();
87

  
88
			if (points < window) {
89
				p2.x = (int) (p1.x + ((p2.x - p1.x) * window));
90
			}
91
		}
92
		*/
93
		
94 82
		if (p1.getX()>p2.getX()){
95 83
			int aux=p2.x;
96 84
			p2.x=p1.x;
......
126 114
			ymin = pSheet1.y;
127 115
			ymax = pSheet2.y;
128 116
		}
129

  
130
		Rectangle2D.Double rScreen = new Rectangle2D.Double();
131
		Rectangle2D.Double rSheet = new Rectangle2D.Double();
132
		double x = FLayoutUtilities.toSheetDistance(layout.getRect().getX(),
133
				layout.getAT());
134
		double y = FLayoutUtilities.toSheetDistance(layout.getRect().getY(),
135
				layout.getAT());
136
		double w = FLayoutUtilities.toSheetDistance(layout.getRect().getWidth(),
137
				layout.getAT());
138
		double h = FLayoutUtilities.toSheetDistance(layout.getRect().getHeight(),
139
				layout.getAT());
140

  
141 117
		if (java.lang.Math.abs(layout.getFirstPoint().x - p2.x) < 4) {
142
			double difw = 2;
143

  
144
			rSheet.x = (-pSheet2.getX() * difw) - x +
145
				FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
146
					layout.getAT());
147
			rSheet.y = (-pSheet2.getY() * difw) - y +
148
				FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
149
					layout.getAT());
150

  
151
			rSheet.width = w * difw;
152
			rSheet.height = h * difw;
153

  
154
			rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet,
155
					layout.getAT()));
156
			IFFrame[] fframes=layout.getFFrames();
157
			for (int i=0;i<fframes.length;i++){
158
				if (fframes[i] instanceof FFrameView){
159
					Point2D point1=new Point2D.Double(p2.getX()-(layout.getWidth()/2)*difw,p2.getY()-(layout.getHeight()/2)*difw);
160
					Point2D point2=new Point2D.Double(p2.getX()+(layout.getWidth()/2)*difw,p2.getY()+(layout.getHeight()/2)*difw);
161
					((FFrameView)fframes[i]).getRectView(point1,point2);
162
				}
163
			}
164
			
165
			
118
			setZoom(FACTOR,p2);
166 119
		} else {
120

  
167 121
			double wv = FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
168 122
															   .getWidth(),
169 123
					layout.getAT());
......
176 130
			double difh = hv / mh;
177 131

  
178 132
			if (difw < difh) {
179
				rSheet.x = (-xmin * difw) - x +
180
					((wv - ((pSheet2.getX() - pSheet1.getX()) * difw)) / 2);
181
				rSheet.y = (-ymin * difw) - y +
182
					((hv - ((pSheet2.getY() - pSheet1.getY()) * difw)) / 2);
183

  
184
				rSheet.width = w * difw;
185
				rSheet.height = h * difw;
133
				setZoom(difw,new Point((int)(p1.getX()+p2.getX())/2,(int)(p1.getY()+p2.getY())/2));
186 134
			} else {
187
				rSheet.x = (-xmin * difh) - x +
188
					((wv - ((pSheet2.getX() - pSheet1.getX()) * difh)) / 2);
189
				rSheet.y = (-ymin * difh) - y +
190
					((hv - ((pSheet2.getY() - pSheet1.getY()) * difh)) / 2);
191

  
192
				rSheet.width = w * difh;
193
				rSheet.height = h * difh;
135
				setZoom(difh,new Point((int)(p1.getX()+p2.getX())/2,(int)(p1.getY()+p2.getY())/2));
194 136
			}
195

  
196
			rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet,
197
					layout.getAT()));
198
			
199
			IFFrame[] fframes=layout.getFFrames();
200
			for (int i=0;i<fframes.length;i++){
201
				if (fframes[i] instanceof FFrameView){
202
					((FFrameView)fframes[i]).getRectView(p1,p2);
203
				}
204
			}
205 137
		}
206

  
207
		if (FLayoutUtilities.isPosible(rScreen)) {
208
			layout.getRect().setRect(rScreen);
209
		}
210
		
211 138
	}
212 139

  
213 140
	/**
......
216 143
	 * @param p2 punto final del rec?ngulo.
217 144
	 */
218 145
	public void setZoomOut(Point p2) {
219
		Point2D.Double pSheet2 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
220
					p2.getX(), p2.getY()), layout.getAT());
221

  
222
		Rectangle2D.Double rScreen = new Rectangle2D.Double();
223
		Rectangle2D.Double rSheet = new Rectangle2D.Double();
224

  
225
		double difw = 0.5;
226

  
227
		rSheet.x = (-pSheet2.getX() * difw) -
228
			FLayoutUtilities.toSheetDistance(layout.getRect().getX(),
229
				layout.getAT()) +
230
			FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
231
				layout.getAT());
232
		rSheet.y = (-pSheet2.getY() * difw) -
233
			FLayoutUtilities.toSheetDistance(layout.getRect().getY(),
234
				layout.getAT()) +
235
			FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
236
				layout.getAT());
237

  
238
		rSheet.width = FLayoutUtilities.toSheetDistance(layout.getRect()
239
															  .getWidth(),
240
				layout.getAT()) * difw;
241
		rSheet.height = FLayoutUtilities.toSheetDistance(layout.getRect()
242
															   .getHeight(),
243
				layout.getAT()) * difw;
244

  
245
		rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout.getAT()));
246

  
247
		if (FLayoutUtilities.isPosible(rScreen)) {
248
			layout.getRect().setRect(rScreen);
249
		}
250
		IFFrame[] fframes=layout.getFFrames();
251
		for (int i=0;i<fframes.length;i++){
252
			if (fframes[i] instanceof FFrameView){
253
				Point2D point1=new Point2D.Double(p2.getX()-(layout.getWidth()/2)*difw,p2.getY()-(layout.getHeight()/2)*difw);
254
				Point2D point2=new Point2D.Double(p2.getX()+(layout.getWidth()/2)*difw,p2.getY()+(layout.getHeight()/2)*difw);
255
				((FFrameView)fframes[i]).getRectView(point1,point2);
256
			}
257
		}
146
		setZoom(1/FACTOR, p2);
258 147
	}
259 148

  
260 149
	/**
......
270 159
		Rectangle2D.Double rSheet = new Rectangle2D.Double();
271 160

  
272 161
		double difw = dif;
162
		double x = FLayoutUtilities.toSheetDistance(layout.getRect().getX(),
163
				layout.getAT());
164
		double y = FLayoutUtilities.toSheetDistance(layout.getRect().getY(),
165
				layout.getAT());
166
		double w = FLayoutUtilities.toSheetDistance(layout.getRect().getWidth(),
167
				layout.getAT());
168
		double h = FLayoutUtilities.toSheetDistance(layout.getRect().getHeight(),
169
				layout.getAT());
273 170

  
274
		rSheet.x = (-pSheet2.getX() * difw) -
275
			FLayoutUtilities.toSheetDistance(layout.getRect().getX(),
276
				layout.getAT()) +
171
		rSheet.x = (-pSheet2.getX() * difw) - x +
277 172
			FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
278 173
				layout.getAT());
279
		rSheet.y = (-pSheet2.getY() * difw) -
280
			FLayoutUtilities.toSheetDistance(layout.getRect().getY(),
281
				layout.getAT()) +
174
		rSheet.y = (-pSheet2.getY() * difw) - y +
282 175
			FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
283 176
				layout.getAT());
284 177

  
285
		rSheet.width = FLayoutUtilities.toSheetDistance(layout.getRect()
286
															  .getWidth(),
287
				layout.getAT()) * difw;
288
		rSheet.height = FLayoutUtilities.toSheetDistance(layout.getRect()
289
															   .getHeight(),
290
				layout.getAT()) * difw;
178
		rSheet.width = w * difw;
179
		rSheet.height = h * difw;
291 180

  
292 181
		rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout.getAT()));
293 182

  
294 183
		if (FLayoutUtilities.isPosible(rScreen)) {
295
			layout.getRect().setRect(rScreen);
184
			layout.setRect(rScreen);
296 185
		}
186
		////////////
187
		if (dif < 1)
188
			setZoomOutClip(difw,p2);
189
		else if (dif > 1)
190
			setZoomOutClip(difw,p2);
191
		/////////////
297 192
	}
298 193

  
299 194
	/**
......
314 209
	 * Realiza un zoom m?s a partir del punto central de pantalla.
315 210
	 */
316 211
	public void zoomIn() {
317
		setZoom(2, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
212
		setZoom(FACTOR, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
318 213
		layout.setStatus(Layout.DESACTUALIZADO);
319 214
		layout.repaint();
320 215
	}
......
323 218
	 * Realiza un zoom menos a partir del punto central de pantalla.
324 219
	 */
325 220
	public void zoomOut() {
326
		setZoom(0.5, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
221
		setZoom(1/FACTOR, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
327 222
		layout.setStatus(Layout.DESACTUALIZADO);
328 223
		layout.repaint();
329 224
	}
......
367 262
				IFFrameUseFMap fframe = (IFFrameUseFMap) layout.getFFrame(i);
368 263

  
369 264
				if (((IFFrame)fframe).getSelected() != IFFrame.NOSELECT) {
370
					p1 = functions.toMapPoint(p1, fframe.getATMap());
371
					p2 = functions.toMapPoint(p2, fframe.getATMap());
265
					p1 =  FLayoutFunctions.toMapPoint(p1, fframe.getATMap());
266
					p2 =  FLayoutFunctions.toMapPoint(p2, fframe.getATMap());
372 267

  
373 268
					// Borramos el anterior
374 269
					layout.setStatus(Layout.DESACTUALIZADO);
......
414 309
			}
415 310
		}
416 311
	}
312
	/**
313
	 * Realiza un zoom m?s sobre las vistas FFrameView.
314
	 *
315
	 * @param p1 punto inicial.
316
	 * @param p2 punto final.
317
	 */
318
	public void setZoomInClip(double dif,Point2D p1, Point2D p2) {
319
		double factor=1/dif;
320
		IFFrame[] fframes=layout.getFFrames();
321
		for (int i = 0; i < fframes.length; i++) {
322
			if (fframes[i] instanceof IFFrameUseFMap) {
323
				IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
324
				Rectangle2D rect=new Rectangle2D.Double();
325
				rect.setFrameFromDiagonal(p1, p2);
326
				if (p1.equals(p2)){
327
					rect.setRect(p1.getX()-(layout.getBounds().width*factor)/2,p1.getY()-(layout.getBounds().height*factor)/2,layout.getBounds().width*factor,layout.getBounds().height*factor);
328
				}
329
				if (((IFFrame)fframes[i]).getBoundingBox(layout.getAT()).intersects(rect)){
330
					p1 =  FLayoutFunctions.toMapPoint(p1, fframe.getATMap());
331
					p2 =  FLayoutFunctions.toMapPoint(p2, fframe.getATMap());
417 332

  
333
					// Borramos el anterior
334
					layout.setStatus(Layout.DESACTUALIZADO);
335

  
336
					if (java.lang.Math.abs(p1.getX() - p2.getX()) <= 3) {
337
						double nuevoX;
338
						double nuevoY;
339
						double cX;
340
						double cY;
341

  
342
						cX = p2.getX();
343
						cY = p2.getY();
344

  
345

  
346
						Rectangle2D.Double r = new Rectangle2D.Double();
347

  
348
						nuevoX = cX -
349
							((fframe.getFMap().getViewPort().getExtent()
350
									.getWidth() * factor) / 2.0);
351
						nuevoY = cY -
352
							((fframe.getFMap().getViewPort().getExtent()
353
									.getHeight() * factor) / 2.0);
354
						r.x = nuevoX;
355
						r.y = nuevoY;
356
						r.width = fframe.getFMap().getViewPort().getExtent()
357
										.getWidth() * factor;
358
						r.height = fframe.getFMap().getViewPort().getExtent()
359
										 .getHeight() * factor;
360

  
361
						fframe.setNewExtent(r);
362
					} else {
363
						//	Fijamos el nuevo extent
364
						Rectangle2D.Double r = new Rectangle2D.Double();
365

  
366
						r.setFrameFromDiagonal(p1, p2);
367

  
368
						fframe.setNewExtent(r);
369
					}
370
					fframe.refresh();
371
				}
372
			}
373
		}
374
	}
418 375
	/**
419 376
	 * Realiza un zoom menos sobre la vista del FFrameView seleccionado.
420 377
	 *
......
433 390
					double cX;
434 391
					double cY;
435 392
					Point pScreen = new Point((int) p2.getX(), (int) p2.getY());
436
					pWorld = functions.toMapPoint(pScreen, fframe.getATMap());
393
					pWorld =  FLayoutFunctions.toMapPoint(pScreen, fframe.getATMap());
437 394

  
438 395
					cX = pWorld.getX();
439 396
					cY = pWorld.getY();
......
459 416
			}
460 417
		}
461 418
	}
419
	/**
420
	 * Realiza un zoom menos sobre la vista.
421
	 *
422
	 * @param p2 Punto sobre el que realizar el zoom menos.
423
	 */
424
	public void setZoomOutClip(double dif,Point p2) {
425
		Point2D.Double pWorld;
426
		double factor=1/dif;
427
		for (int i = 0; i < layout.getFFrames().length; i++) {
428
			IFFrame[] fframes=layout.getFFrames();
429
			if (fframes[i] instanceof IFFrameUseFMap) {
430
				IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
431
				Rectangle2D rect=layout.getBounds();
432
				if (((IFFrame)fframes[i]).getBoundingBox(layout.getAT()).intersects(rect)){
433
					double nuevoX;
434
					double nuevoY;
435
					double cX;
436
					double cY;
437
					Point pScreen = new Point((int) p2.getX(), (int) p2.getY());
438
					pWorld = FLayoutFunctions.toMapPoint(pScreen, fframe.getATMap());
439

  
440
					cX = pWorld.getX();
441
					cY = pWorld.getY();
442
					Rectangle2D.Double r = new Rectangle2D.Double();
443
					nuevoX = cX -
444
						((fframe.getFMap().getViewPort().getExtent().getWidth() * factor) / 2.0);
445
					nuevoY = cY -
446
						((fframe.getFMap().getViewPort().getExtent().getHeight() * factor) / 2.0);
447
					r.x = nuevoX;
448
					r.y = nuevoY;
449
					r.width = fframe.getFMap().getViewPort().getExtent()
450
									.getWidth() * factor;
451
					r.height = fframe.getFMap().getViewPort().getExtent()
452
									 .getHeight() * factor;
453

  
454
					fframe.setNewExtent(r);
455
					fframe.refresh();
456
					///fframe.getFMap().setCancelDrawing(false);
457
				}
458
			}
459
		}
460
	}
462 461
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/FLayoutFunctions.java
131 131

  
132 132
			if (isUpdate) {
133 133
				layout.setStatus(Layout.DESACTUALIZADO);
134
				
134

  
135 135
			} else {
136 136
				layout.setStatus(Layout.ACTUALIZADO);
137 137
			}
138 138
		}
139
		
139

  
140 140
		layout.updateFFrames();
141 141
		layout.setIsReSel(true);
142 142
	}
......
278 278
	 *
279 279
	 * @return Punto real.
280 280
	 */
281
	public Point2D.Double toMapPoint(Point2D pScreen, AffineTransform at1) {
281
	public static Point2D.Double toMapPoint(Point2D pScreen, AffineTransform at1) {
282 282
		Point2D.Double pWorld = new Point2D.Double();
283 283

  
284 284
		AffineTransform at;
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/Layout.java
386 386
            rect = m_attributes.getRectanglePortrait(rect, getWidth(),
387 387
                    getHeight());
388 388
        }
389

  
389
        /*IFFrame[] fframes=getFFrames();
390
        for (int i=0;i<fframes.length;i++){
391
        	fframes[i].initialize();
392
        }*/
390 393
        status = DESACTUALIZADO;
391 394
        repaint();
392 395
    }
......
1080 1083
    public Rectangle2D.Double getRect() {
1081 1084
        return rect;
1082 1085
    }
1083

  
1086
    public void setRect(Rectangle2D r){
1087
    	rect.setRect(r);
1088
    }
1084 1089
    /**
1085 1090
     * Obtiene un entero que representa la herramienta seleccionada.
1086 1091
     *
......
1361 1366
     * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
1362 1367
     */
1363 1368
    public void viewActivated() {
1369
    	//Rectangle2D r=(Rectangle2D)getRect().clone();
1370
    	fullRect();
1371
    	/*IFFrame[] fframes=getFFrames();
1372
        for (int i=0;i<fframes.length;i++){
1373
        	fframes[i].initialize();
1374
        }
1375
        setRect(r);
1376
        */
1364 1377
        repaint();
1365 1378
        PluginServices.getMainFrame().getStatusBar().setMessage("1",
1366 1379
            getAtributes().getNameUnit());
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameLegend.java
204 204
            sizefont = (float) (re.getWidth() / (m_max * 0.7));
205 205
        }
206 206

  
207
        //////Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics	
207
        //////Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics
208 208
        for (int i = layers.getLayersCount() - 1; i >= 0; i--) {
209 209
            FLayer layer = (FLayer) layers.getLayer(i);
210 210

  
......
477 477
            sizefont = (float) ((wT * N) / (m_max * 0.7));
478 478
        }
479 479

  
480
        //////	Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics	
480
        //////	Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics
481 481
        for (int i = 0; i < lays.getLayersCount(); i++) {
482 482
            FLayer layer = (FLayer) lays.getLayer(i);
483 483

  
......
683 683
            fframeview = (FFrameView) fframes[dependenceIndex];
684 684
        }
685 685
    }
686

  
687
	public void initialize() {
688
		// TODO Auto-generated method stub
689

  
690
	}
686 691
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameGraphics.java
212 212
            }
213 213

  
214 214
            geometry.draw(g, at, m_symbol);
215
            
215

  
216 216
            if (editing) {
217 217
                g.setColor(Color.red);
218 218
            	geometry.drawVertex(g, at);
......
533 533
    public GeometryAdapter getGeometry() {
534 534
        return geometryEdit;
535 535
    }
536

  
537
	public void initialize() {
538
		// TODO Auto-generated method stub
539

  
540
	}
536 541
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameSymbol.java
199 199
    public void setFSymbol(FSymbol symbol) {
200 200
        m_Symbol = symbol;
201 201
    }
202

  
203
	public void initialize() {
204
		// TODO Auto-generated method stub
205

  
206
	}
202 207
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameView.java
101 101
    private double m_Scale = 0;
102 102
    private int m_mapUnits = 1; //Metros.
103 103

  
104
    //private int num = 0;
105 104
    private BufferedImage m_image = null;
106 105
    private AffineTransform at = null;
107 106
    private Project project = null;
108 107
    private Layout layout;
109 108
	private double scaleAnt;
110 109
	private boolean refresh=false;
111
	private FFrameView fframeAux;
112
	
110
	private boolean hasViewPort=false;
111
	private Point2D antpoint;
113 112
    /**
114 113
     * Creates a new FFrameView object.
115 114
     */
......
209 208

  
210 209
        ViewPort vp = v.getMapContext().getViewPort().cloneViewPort();
211 210

  
212
        vp.setImageSize(new Dimension((int) getBoundingBox(null).width,
211
        vp.setImageSize(new Dimension((int) getBoundingBox(getATMap()).width,
213 212
                (int) getBoundingBox(null).height));
214 213

  
215 214
        if (m_bLinked) {
......
266 265
                    e1);
267 266
            }
268 267
        }
269

  
270
        /*
271
           m_fmap = v.getMapContext();
272
        
273
           v.getMapContext().getViewPort();
274
           ViewPort vp = new ViewPort();
275
           vp.setExtent(v.getMapContext().getViewPort().getExtent());
276
           m_fmap = m_fmap.createNewFMap(vp);
277
           view = v;
278
         */
279 268
    }
280 269

  
281 270
    /**
......
300 289
        double wview = getBoundBox().getWidth();
301 290
        double hextent = (scale * hview) / 100.0;
302 291
        double wextent = (scale * wview) / 100.0;
303

  
304
        // double dif = hextent / m_fmap.getViewPort().getExtent().getHeight();
305 292
        double newx = m_fmap.getViewPort().getExtent().getCenterX() -
306 293
            (wextent / 2.0);
307 294
        double newy = m_fmap.getViewPort().getExtent().getCenterY() -
......
317 304
     *
318 305
     * @param g Graphics2D
319 306
     * @param at Transformada af?n.
320
     * @param rv rect?ngulo sobre el que hacer un clip.
307
     * @param rv rect?ngulo sobre el que hacer un clip. (el rect?ngulo visible)
321 308
     * @param imgBase Imagen para acelerar el dibujado.
322 309
     *
323 310
     * @throws com.iver.cit.gvsig.fmap.DriverException
324 311
     */
325 312
    public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv,
326 313
        BufferedImage imgBase) throws com.iver.cit.gvsig.fmap.DriverException {
314
    	System.out.println("Tama?o del imgBase= "+ imgBase.getWidth()+","+imgBase.getHeight());
315
    	Point2D point =null;
316
    	if (getATMap()!=null){
317
    	point =functions.toMapPoint(new Point2D.Double(layout.getRect().getX(),layout.getRect().getY()), getATMap());
318
    	}
319
    	/**
320
    	 * this FFrame's BoundingBox
321
    	 */
327 322
    	Rectangle2D.Double r = getBoundingBox(at);
328
    	if (layout.getAT().getScaleX()==scaleAnt && m_image!=null && !refresh){
329
        	g.translate((int)r.getX(),(int)r.getY());
330
        	g.drawImage(m_image,0,0,layout);
331
        	g.translate(-(int)r.getX(),-(int)r.getY());
332
        	scaleAnt=layout.getAT().getScaleX();
333
        	return;
323
    	if (rv!=null && layout.getAT().getScaleX()==scaleAnt && m_image!=null && !refresh){
324
        	if (point.equals(antpoint)) {
325
				g.translate((int) r.getX(), (int) r.getY());
326
				g.drawImage(m_image, 0, 0, layout);
327
				g.translate(-(int) r.getX(), -(int) r.getY());
328
				scaleAnt = layout.getAT().getScaleX();
329
				return;
330
			}
334 331
        }
332

  
335 333
    	if (getRotation()!=0)
336 334
        g.rotate(Math.toRadians(getRotation()), r.x + (r.width / 2),
337 335
            r.y + (r.height / 2));
......
347 345
                        (int) r.getWidth(), (int) r.getHeight());
348 346

  
349 347
                    if (getQuality() == PRESENTACION) {
350
                        if (rv.intersects(r)) {
351
                        	
352
                         
348
                    	if (rv.intersects(r)) {
349
                    		ViewPort viewPort = this.getFMap().getViewPort();
350
                    		Color theBackColor = viewPort.getBackColor();
353 351

  
354
                                ViewPort viewPort = this.getFMap().getViewPort();
355
                                Color theBackColor = viewPort.getBackColor();
352
                    		if (theBackColor != null) {
353
                    			g.setColor(theBackColor);
354
                    			g.fillRect((int) r.x, (int) r.y,
355
                    					viewPort.getImageWidth(),
356
                    					viewPort.getImageHeight());
357
                    		}
358
                    		System.err.println("r : "+r);
359
                    		if (r.getWidth()>layout.getWidth() || r.getHeight()>layout.getHeight()){
360
                    			getFMap().getViewPort().setOffset(new Point2D.Double(0,0));
361
                    			if (antpoint!=null && !refresh){
362
                    			Rectangle2D extent=getFMap().getViewPort().getExtent();
363
                    			extent.setRect(extent.getX()+(antpoint.getX()-point.getX()),extent.getY()+(antpoint.getY()-point.getY()),extent.getWidth(),extent.getHeight());
364
                    			setNewExtent(extent);
365
                    			}
366
                    			//if (antViewPort==null)
367
                    			//antViewPort=getFMap().getViewPort().cloneViewPort();
368
                    			getFMap().getViewPort().setImageSize(new Dimension((int) layout.getWidth(), (int)layout.getHeight()));
369
                    			getFMap().draw(imgBase, g, getScale());
370
                    			setATMap((AffineTransform) getFMap()
371
                    				        .getViewPort()
372
                    				        .getAffineTransform()
373
                    				        .clone());
374
                    			//getFMap().setViewPort(antViewPort.cloneViewPort());
375
                    			antpoint=functions.toMapPoint(new Point2D.Double(layout.getRect().getX(),layout.getRect().getY()), getATMap());
376
                    		}else{
377
                    			if (!hasViewPort){
378
                    				saveAntViewPort();
379
                    				hasViewPort=true;
380
                    			}else{
381
                    				getFMap().setViewPort(antViewPort.cloneViewPort());
382
                    			}
383
                    			getFMap().getViewPort().setOffset(new Point2D.Double(
384
                    					r.x, r.y));
385
                    			getFMap().getViewPort().setImageSize(new Dimension(
386
                    					(int) r.width, (int) r.height));
387
                    			m_image=new BufferedImage((int)r.getWidth(),
388
                    					(int) r.getHeight(),
389
                    					BufferedImage.TYPE_INT_ARGB);
390
                    			Graphics2D gimg=(Graphics2D) m_image.getGraphics();
391
                    			gimg.translate(-((int)r.getX()),-((int)r.getY()));
392
                    			getFMap().draw(m_image,gimg, getScale());
393
                    			gimg.translate(((int)r.getX()),((int)r.getY()));
394
                    			g.drawImage(m_image,(int)r.getX(),(int)r.getY(),layout);
395
                    			setATMap((AffineTransform) getFMap()
396
                    				        .getViewPort()
397
                    				        .getAffineTransform()
398
                    				        .clone());
399
                    			 antpoint=null;
400
                    		}
401
                    		scaleAnt=layout.getAT().getScaleX();
402
                    		refresh=false;
356 403

  
357
                                if (theBackColor != null) {
358
                                    g.setColor(theBackColor);
359
                                    g.fillRect((int) r.x, (int) r.y,
360
                                        viewPort.getImageWidth(),
361
                                        viewPort.getImageHeight());
362
                                }
363
                                System.err.println("r : "+r);
364
                                if (r.getWidth()>layout.getWidth() || r.getHeight()>layout.getHeight()){
365
                                /*	TODO Este c?digo todavia no funciona bien, lo hace en el primer zoom que se realiza, pero en el siguiente se hace mal.
366
                                	getFMap().getViewPort().setClipRect(cliprectMap);
367
                                	Rectangle2D cliprectLayoutpixels=FLayoutUtilities.fromSheetRect(cliprectLayout,layout.getAT());
368
                                	this.getFMap().getViewPort().setOffset(new Point2D.Double(
369
                                            r.getX(), r.getY()));
370
                                	getFMap().getViewPort().setImageSize(new Dimension(
371
                                            (int) r.getWidth(), (int) r.getHeight()));
372
                                	
373
                                	BufferedImage image=new BufferedImage((int)cliprectLayoutpixels.getWidth(),
374
                                            (int) cliprectLayoutpixels.getHeight(),
375
                                            BufferedImage.TYPE_INT_ARGB);
376
                                    
377
                                	Graphics2D gimg=(Graphics2D) image.getGraphics();
378
                                	gimg.translate(-r.getX(),-r.getY());
379
                                	getFMap().draw(image,gimg,getScale());
380
                                	getFMap().getViewPort().setClipRect(null);
381
                                	g.drawImage(image,(int)(0),(int)(0),layout);
382
                                	m_image=null;
383
                                */
384
                                	getFMap().getViewPort().setOffset(new Point2D.Double(
385
                                            r.getX(), r.getY()));
386
                                	getFMap().getViewPort().setImageSize(new Dimension(
387
                                            (int) r.getWidth(), (int) r.getHeight()));
388
                                	getFMap().draw(imgBase,g,getScale());
389
                                }else{
390
                                	getFMap().getViewPort().setOffset(new Point2D.Double(
391
                                            r.x, r.y));
392
                                	getFMap().getViewPort().setImageSize(new Dimension(
393
                                              (int) r.width, (int) r.height));
394
                                	m_image=new BufferedImage((int)r.getWidth(),
395
                                        (int) r.getHeight(),
396
                                        BufferedImage.TYPE_INT_ARGB);
397
                                	Graphics2D gimg=(Graphics2D) m_image.getGraphics();
398
                                	gimg.translate(-((int)r.getX()),-((int)r.getY()));
399
                                	getFMap().draw(m_image,gimg, getScale());
400
                                	gimg.translate(((int)r.getX()),((int)r.getY()));
401
                                	g.drawImage(m_image,(int)r.getX(),(int)r.getY(),layout);
402
                                }
403
                                scaleAnt=layout.getAT().getScaleX();
404
                                refresh=false;
405
                        }
406
                        if (rclip != null) {
407
                            g.setClip(rclip.x, rclip.y, rclip.width,
408
                                rclip.height);
409
                        }
404
                    	}
405
                    	if (rclip != null) {
406
                    		g.setClip(rclip.x, rclip.y, rclip.width,
407
                    				rclip.height);
408
                    	}
410 409
                    } else {
411
                        drawDraft(g);
410
                    	drawDraft(g);
412 411
                    }
413 412
                } else {
414
                    printX(g, at);
413
                	printX(g, at);
414
                	setATMap((AffineTransform) getFMap()
415
    				        .getViewPort()
416
    				        .getAffineTransform()
417
    				        .clone());
415 418
                }
416 419
            }
417 420
        }
421

  
418 422
        if (getRotation()!=0)
419 423
        g.rotate(Math.toRadians(-getRotation()), r.x + (r.width / 2),
420 424
            r.y + (r.height / 2));
421
        
422
        setATMap((AffineTransform) getFMap()
423
        .getViewPort()
424
        .getAffineTransform()
425
        .clone());
426 425
    }
427 426

  
428 427
    /**
......
642 641
    }
643 642

  
644 643
    /**
645
     * Devuelve la MAtriz de transformaci?n utilizada por la FFrameView.
644
     * Devuelve la MAtriz de transformaci?n utilizada por la FFrameView para poder cambiar
645
     * un punto en pixels a coordenadas del mundo real.
646 646
     *
647 647
     * @return MAtriz de transformaci?n.
648 648
     */
......
691 691
        this.m_bLinked = xml.getBooleanProperty("m_bLinked");
692 692
        this.m_mapUnits = xml.getIntProperty("m_mapUnits");
693 693

  
694
        //ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
695 694
        this.m_Scale = xml.getDoubleProperty("m_Scale");
696 695

  
697 696
        int indice = xml.getIntProperty("indice");
......
742 741

  
743 742
            if (layout != null) {
744 743
                layout.setStatus(Layout.DESACTUALIZADO);
745

  
746
                //setBufferedImage(null);
747 744
            }
748 745
        }
749 746
    }
......
755 752
        if (getLinked()) {
756 753
            m_fmap.getViewPort().setBackColor(e.getNewColor());
757 754
            layout.setStatus(Layout.DESACTUALIZADO);
758

  
759
            //setBufferedImage(null);
760 755
        }
761 756
    }
762 757

  
......
777 772
    public void legendChanged(LegendChangedEvent e) {
778 773
        if (getLinked()) {
779 774
            layout.setStatus(Layout.DESACTUALIZADO);
780

  
781
            //setBufferedImage(null);
782 775
        }
783 776
    }
784 777

  
......
807 800
        this.m_bLinked = xml.getBooleanProperty("m_bLinked");
808 801
        this.m_mapUnits = xml.getIntProperty("m_mapUnits");
809 802
        setRotation(xml.getDoubleProperty("m_rotation"));
810

  
811
        //ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
812 803
        this.m_Scale = xml.getDoubleProperty("m_Scale");
813 804

  
814 805
        int indice = xml.getIntProperty("indice");
......
909 900
	public void refresh() {
910 901
		refresh=true;
911 902
	}
912
	private Rectangle2D cliprectMap;
913
	private Rectangle2D cliprectLayout;
914 903
	private FLayoutFunctions functions=new FLayoutFunctions(layout);
915
	public Rectangle2D getRectView(Point2D p1,Point2D p2){
916
		//if (cliprect==null){
917
		
918
		cliprectLayout=FLayoutUtilities.toSheetRect(new Rectangle2D.Double(p1.getX(),p1.getY(),p2.getX()-p1.getX(),p2.getY()-p1.getY()),layout.getAT());
919
		//setZoomIn(layout.getFirstPoint(),layout.getLastPoint());
920
		Point2D point1=functions.toMapPoint(new Point2D.Double(p1.getX(),p1.getY()),getATMap());
921
		Point2D point2=functions.toMapPoint(new Point2D.Double(p2.getX(),p2.getY()),getATMap());
922
		cliprectMap= new Rectangle2D.Double(point1.getX(),point1.getY()-Math.abs(point2.getY()-point1.getY()),Math.abs(point2.getX()-point1.getX()),Math.abs(point2.getY()-point1.getY()));
923
		//}
924
		return cliprectMap;
925
	}
926
	/*
927
	public void setZoomIn(Point p1, Point p2) {
928
		if (p1.getX()>p2.getX()){
929
			int aux=p2.x;
930
			p2.x=p1.x;
931
			p1.x=aux;
932
		}
933
		if (p1.getY()>p2.getY()){
934
			int aux=p2.y;
935
			p2.y=p1.y;
936
			p1.y=aux;
937
		}
938
		Point2D.Double pSheet1 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
939
					p1.getX(), p1.getY()), layout.getAT());
940
		Point2D.Double pSheet2 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
941
					p2.getX(), p2.getY()), layout.getAT());
904
	private ViewPort antViewPort;
942 905

  
943
		double xmin;
944
		double xmax;
945
		double ymin;
946
		double ymax = 0;
906
	public void saveAntViewPort() {
907
		antViewPort=getFMap().getViewPort().cloneViewPort();
947 908

  
948
		if (pSheet1.x > pSheet2.x) {
949
			xmin = pSheet2.x;
950
			xmax = pSheet1.x;
951
		} else {
952
			xmin = pSheet1.x;
953
			xmax = pSheet2.x;
954
		}
909
	}
955 910

  
956
		if (pSheet1.y > pSheet2.y) {
957
			ymin = pSheet2.y;
958
			ymax = pSheet1.y;
959
		} else {
960
			ymin = pSheet1.y;
961
			ymax = pSheet2.y;
962
		}
963

  
964
		Rectangle2D.Double rScreen = new Rectangle2D.Double();
965
		Rectangle2D.Double rSheet = new Rectangle2D.Double();
966
		double x = cliprectLayout.getX();
967
		double y = cliprectLayout.getY();
968
		double w = cliprectLayout.getWidth();
969
		double h = cliprectLayout.getHeight();
970

  
971
		if (java.lang.Math.abs(layout.getFirstPoint().x - p2.x) < 4) {
972
			double difw = 2;
973

  
974
			rSheet.x = (-pSheet2.getX() * difw) - x +
975
				FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
976
					layout.getAT());
977
			rSheet.y = (-pSheet2.getY() * difw) - y +
978
				FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
979
					layout.getAT());
980

  
981
			rSheet.width = w * difw;
982
			rSheet.height = h * difw;
983

  
984
			rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet,
985
					layout.getAT()));
986
		} else {
987
			double wv = FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
988
															   .getWidth(),
989
					layout.getAT());
990
			double hv = FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
991
															   .getHeight(),
992
					layout.getAT());
993
			double mw = xmax - xmin;
994
			double mh = ymax - ymin;
995
			double difw = wv / mw;
996
			double difh = hv / mh;
997

  
998
			if (difw < difh) {
999
				rSheet.x = (-xmin * difw) - x +
1000
					((wv - ((pSheet2.getX() - pSheet1.getX()) * difw)) / 2);
1001
				rSheet.y = (-ymin * difw) - y +
1002
					((hv - ((pSheet2.getY() - pSheet1.getY()) * difw)) / 2);
1003

  
1004
				rSheet.width = w * difw;
1005
				rSheet.height = h * difw;
1006
			} else {
1007
				rSheet.x = (-xmin * difh) - x +
1008
					((wv - ((pSheet2.getX() - pSheet1.getX()) * difh)) / 2);
1009
				rSheet.y = (-ymin * difh) - y +
1010
					((hv - ((pSheet2.getY() - pSheet1.getY()) * difh)) / 2);
1011

  
1012
				rSheet.width = w * difh;
1013
				rSheet.height = h * difh;
1014
			}
1015

  
1016
			rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet,
1017
					layout.getAT()));
1018
		}
1019
		cliprectLayoutpixels=rScreen;
1020
		
1021
	}*/
911
	public void initialize() {
912
		setView(view);
913
	}
1022 914
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFramePicture.java
452 452
        throws DriverException {
453 453
        draw(g, at, null, null);
454 454
    }
455

  
456
	public void initialize() {
457
		// TODO Auto-generated method stub
458

  
459
	}
455 460
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameScaleBar.java
1238 1238
    public void setNumDec(int numDec) {
1239 1239
        this.numDec = numDec;
1240 1240
    }
1241

  
1242
	public void initialize() {
1243
		// TODO Auto-generated method stub
1244

  
1245
	}
1241 1246
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameText.java
82 82

  
83 83
    //jaume
84 84
    private boolean surrounded = false; // The text field is surrounded by a rectangle
85
    private double cellPadding = 0; // The gap between the the text field and the surrounding rectangle 
85
    private double cellPadding = 0; // The gap between the the text field and the surrounding rectangle
86 86
    private boolean fixedFontSize = false; // The text field font size is constant fixed to the folio's size
87 87
    private int fontSize; // Text field's font size
88 88
    private boolean hasTitle; // The text field has title
......
759 759
    public void clearText() {
760 760
        m_text.clear();
761 761
    }
762

  
763
	public void initialize() {
764
		// TODO Auto-generated method stub
765

  
766
	}
762 767
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/IFFrame.java
334 334
     */
335 335
    public void setLevel(int l);
336 336
    public IFFrame cloneFFrame(Layout layout);
337

  
338
	public void initialize();
337 339
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameGroup.java
345 345
            }
346 346
        }
347 347
    }
348

  
349
	public void initialize() {
350
		// TODO Auto-generated method stub
351

  
352
	}
348 353
}

Also available in: Unified diff