Revision 9392 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/FLayoutZooms.java
FLayoutZooms.java | ||
---|---|---|
51 | 51 |
import java.util.prefs.Preferences; |
52 | 52 |
|
53 | 53 |
import com.iver.cit.gvsig.fmap.MapContext; |
54 |
import com.iver.cit.gvsig.gui.layout.Attributes; |
|
55 |
import com.iver.cit.gvsig.gui.layout.Layout; |
|
56 | 54 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
57 | 55 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameUseFMap; |
56 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
|
58 | 57 |
|
59 | 58 |
|
60 | 59 |
/** |
... | ... | |
77 | 76 |
* @param p2 punto final del rec?ngulo. |
78 | 77 |
*/ |
79 | 78 |
public void setZoomIn(Point p1, Point p2) { |
80 |
if (java.lang.Math.abs(layout.getFirstPoint().x - p2.x) < 4) { |
|
79 |
if (java.lang.Math.abs(layout.getLayoutControl().getFirstPoint().x - p2.x) < 4) {
|
|
81 | 80 |
double difw = 2; |
82 | 81 |
setZoom(difw, p2); |
83 | 82 |
} else { |
... | ... | |
94 | 93 |
} |
95 | 94 |
|
96 | 95 |
Point2D.Double pSheet1 = FLayoutUtilities.toSheetPoint( |
97 |
new Point2D.Double(p1.getX(), p1.getY()), layout.getAT()); |
|
96 |
new Point2D.Double(p1.getX(), p1.getY()), layout.getLayoutControl().getAT());
|
|
98 | 97 |
Point2D.Double pSheet2 = FLayoutUtilities.toSheetPoint( |
99 |
new Point2D.Double(p2.getX(), p2.getY()), layout.getAT()); |
|
98 |
new Point2D.Double(p2.getX(), p2.getY()), layout.getLayoutControl().getAT());
|
|
100 | 99 |
|
101 | 100 |
double xmin; |
102 | 101 |
double xmax; |
... | ... | |
122 | 121 |
Rectangle2D.Double rScreen = new Rectangle2D.Double(); |
123 | 122 |
Rectangle2D.Double rSheet = new Rectangle2D.Double(); |
124 | 123 |
double x = FLayoutUtilities.toSheetDistance( |
125 |
layout.getRect().getX(), layout.getAT());
|
|
124 |
layout.getLayoutControl().getRect().getX(), layout.getLayoutControl().getAT());
|
|
126 | 125 |
double y = FLayoutUtilities.toSheetDistance( |
127 |
layout.getRect().getY(), layout.getAT());
|
|
128 |
double w = FLayoutUtilities.toSheetDistance(layout.getRect() |
|
129 |
.getWidth(), layout.getAT()); |
|
130 |
double h = FLayoutUtilities.toSheetDistance(layout.getRect() |
|
131 |
.getHeight(), layout.getAT()); |
|
126 |
layout.getLayoutControl().getRect().getY(), layout.getLayoutControl().getAT());
|
|
127 |
double w = FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect()
|
|
128 |
.getWidth(), layout.getLayoutControl().getAT());
|
|
129 |
double h = FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect()
|
|
130 |
.getHeight(), layout.getLayoutControl().getAT());
|
|
132 | 131 |
|
133 | 132 |
double wv = FLayoutUtilities.toSheetDistance(layout |
134 |
.getVisibleRect().getWidth(), layout.getAT()); |
|
133 |
.getVisibleRect().getWidth(), layout.getLayoutControl().getAT());
|
|
135 | 134 |
double hv = FLayoutUtilities.toSheetDistance(layout |
136 |
.getVisibleRect().getHeight(), layout.getAT()); |
|
135 |
.getVisibleRect().getHeight(), layout.getLayoutControl().getAT());
|
|
137 | 136 |
double mw = xmax - xmin; |
138 | 137 |
double mh = ymax - ymin; |
139 | 138 |
double difw = wv / mw; |
... | ... | |
161 | 160 |
rSheet.height = h * difh; |
162 | 161 |
} |
163 | 162 |
setPointsToZoom(p1, p2); |
164 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout |
|
163 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout.getLayoutControl()
|
|
165 | 164 |
.getAT())); |
166 | 165 |
if (FLayoutUtilities.isPosible(rScreen)) { |
167 |
layout.getRect().setRect(rScreen); |
|
166 |
layout.getLayoutControl().getRect().setRect(rScreen);
|
|
168 | 167 |
} |
169 | 168 |
} |
170 | 169 |
} |
... | ... | |
187 | 186 |
*/ |
188 | 187 |
public void setZoom(double dif, Point p2) { |
189 | 188 |
Point2D.Double pSheet2 = FLayoutUtilities.toSheetPoint(new Point2D.Double( |
190 |
p2.getX(), p2.getY()), layout.getAT()); |
|
189 |
p2.getX(), p2.getY()), layout.getLayoutControl().getAT());
|
|
191 | 190 |
Rectangle2D.Double rScreen = new Rectangle2D.Double(); |
192 | 191 |
Rectangle2D.Double rSheet = new Rectangle2D.Double(); |
193 | 192 |
|
194 | 193 |
double difw = dif; |
195 | 194 |
|
196 | 195 |
rSheet.x = (-pSheet2.getX() * difw) - |
197 |
FLayoutUtilities.toSheetDistance(layout.getRect().getX(), |
|
198 |
layout.getAT()) +
|
|
196 |
FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect().getX(),
|
|
197 |
layout.getLayoutControl().getAT()) +
|
|
199 | 198 |
FLayoutUtilities.toSheetDistance(layout.getWidth() / 2, |
200 |
layout.getAT());
|
|
199 |
layout.getLayoutControl().getAT());
|
|
201 | 200 |
rSheet.y = (-pSheet2.getY() * difw) - |
202 |
FLayoutUtilities.toSheetDistance(layout.getRect().getY(), |
|
203 |
layout.getAT()) +
|
|
201 |
FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect().getY(),
|
|
202 |
layout.getLayoutControl().getAT()) +
|
|
204 | 203 |
FLayoutUtilities.toSheetDistance(layout.getHeight() / 2, |
205 |
layout.getAT());
|
|
204 |
layout.getLayoutControl().getAT());
|
|
206 | 205 |
|
207 |
rSheet.width = FLayoutUtilities.toSheetDistance(layout.getRect() |
|
206 |
rSheet.width = FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect()
|
|
208 | 207 |
.getWidth(), |
209 |
layout.getAT()) * difw;
|
|
210 |
rSheet.height = FLayoutUtilities.toSheetDistance(layout.getRect() |
|
208 |
layout.getLayoutControl().getAT()) * difw;
|
|
209 |
rSheet.height = FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect()
|
|
211 | 210 |
.getHeight(), |
212 |
layout.getAT()) * difw;
|
|
211 |
layout.getLayoutControl().getAT()) * difw;
|
|
213 | 212 |
|
214 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout.getAT())); |
|
213 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout.getLayoutControl().getAT()));
|
|
215 | 214 |
|
216 | 215 |
if (FLayoutUtilities.isPosible(rScreen)) { |
217 |
layout.getRect().setRect(rScreen);
|
|
216 |
layout.getLayoutControl().getRect().setRect(rScreen);
|
|
218 | 217 |
} |
219 | 218 |
|
220 | 219 |
// Para realizar el zoom a partir de un punto. |
... | ... | |
229 | 228 |
* Introduce los puntos de control para controlar el zoom del Layout. |
230 | 229 |
*/ |
231 | 230 |
private void setPointsToZoom(Point p1, Point p2) { |
232 |
IFFrame[] fframes = layout.getFFrames(); |
|
231 |
IFFrame[] fframes = layout.getLayoutContext().getFFrames();
|
|
233 | 232 |
|
234 | 233 |
for (int i = 0; i < fframes.length; i++) { |
235 | 234 |
if (fframes[i] instanceof IFFrameUseFMap) { |
... | ... | |
248 | 247 |
*/ |
249 | 248 |
public void realZoom() { |
250 | 249 |
Preferences prefsResolution = Preferences.userRoot().node( "gvsig.configuration.screen" ); |
251 |
double cm = layout.getAtributes().getPixXCm(layout.getRect());
|
|
250 |
double cm = layout.getLayoutContext().getAtributes().getPixXCm(layout.getLayoutControl().getRect());
|
|
252 | 251 |
Toolkit kit = Toolkit.getDefaultToolkit(); |
253 | 252 |
double dpi = prefsResolution.getInt("dpi",kit.getScreenResolution()); |
254 | 253 |
double dif = (cm * Attributes.PULGADA) / dpi; |
255 | 254 |
setZoom(1 / dif, |
256 | 255 |
new Point(layout.getWidth() / 2, layout.getHeight() / 2)); |
257 |
layout.refresh(); |
|
256 |
layout.getLayoutControl().refresh();
|
|
258 | 257 |
} |
259 | 258 |
|
260 | 259 |
/** |
... | ... | |
262 | 261 |
*/ |
263 | 262 |
public void zoomIn() { |
264 | 263 |
setZoom(2, new Point(layout.getWidth() / 2, layout.getHeight() / 2)); |
265 |
layout.refresh();
|
|
264 |
layout.getLayoutControl().refresh();
|
|
266 | 265 |
} |
267 | 266 |
|
268 | 267 |
/** |
... | ... | |
270 | 269 |
*/ |
271 | 270 |
public void zoomOut() { |
272 | 271 |
setZoom(0.5, new Point(layout.getWidth() / 2, layout.getHeight() / 2)); |
273 |
layout.refresh();
|
|
272 |
layout.getLayoutControl().refresh();
|
|
274 | 273 |
} |
275 | 274 |
|
276 | 275 |
/** |
... | ... | |
279 | 278 |
*/ |
280 | 279 |
public void zoomSelect() { |
281 | 280 |
Rectangle2D.Double recaux = null; |
282 |
IFFrame[] fframes=layout.getFFrames(); |
|
281 |
IFFrame[] fframes=layout.getLayoutContext().getFFrames();
|
|
283 | 282 |
for (int i = 0; i < fframes.length; i++) { |
284 | 283 |
if (fframes[i].getSelected() != IFFrame.NOSELECT) { |
285 | 284 |
if (recaux == null) { |
286 |
recaux = fframes[i].getBoundingBox(layout.getAT()); |
|
285 |
recaux = fframes[i].getBoundingBox(layout.getLayoutControl().getAT());
|
|
287 | 286 |
} else { |
288 | 287 |
recaux.add(fframes[i].getBoundingBox( |
289 |
layout.getAT()));
|
|
288 |
layout.getLayoutControl().getAT()));
|
|
290 | 289 |
} |
291 | 290 |
} |
292 | 291 |
} |
... | ... | |
295 | 294 |
Point p1 = new Point((int) recaux.x, (int) recaux.y); |
296 | 295 |
Point p2 = new Point((int) recaux.getMaxX(), (int) recaux.getMaxY()); |
297 | 296 |
setZoomIn(p1, p2); |
298 |
layout.refresh(); |
|
297 |
layout.getLayoutControl().refresh();
|
|
299 | 298 |
} |
300 | 299 |
} |
301 | 300 |
/** |
... | ... | |
303 | 302 |
*/ |
304 | 303 |
public void zoomAllFrames() { |
305 | 304 |
Rectangle2D.Double recaux = null; |
306 |
IFFrame[] fframes=layout.getFFrames(); |
|
305 |
IFFrame[] fframes=layout.getLayoutControl().getLayoutContext().getFFrames();
|
|
307 | 306 |
for (int i = 0; i < fframes.length; i++) { |
308 | 307 |
if (recaux == null) { |
309 |
recaux = fframes[i].getBoundingBox(layout.getAT()); |
|
308 |
recaux = fframes[i].getBoundingBox(layout.getLayoutControl().getAT());
|
|
310 | 309 |
} else { |
311 | 310 |
recaux.add(fframes[i].getBoundingBox( |
312 |
layout.getAT()));
|
|
311 |
layout.getLayoutControl().getAT()));
|
|
313 | 312 |
} |
314 | 313 |
} |
315 | 314 |
|
... | ... | |
317 | 316 |
Point p1 = new Point((int) recaux.x, (int) recaux.y); |
318 | 317 |
Point p2 = new Point((int) recaux.getMaxX(), (int) recaux.getMaxY()); |
319 | 318 |
setZoomIn(p1, p2); |
320 |
layout.refresh(); |
|
319 |
layout.getLayoutControl().refresh();
|
|
321 | 320 |
} |
322 | 321 |
} |
323 | 322 |
|
... | ... | |
328 | 327 |
* @param p2 Punto final del rect?ngulo |
329 | 328 |
*/ |
330 | 329 |
public void setViewZoomIn(Point2D p1, Point2D p2) { |
331 |
IFFrame[] fframes=layout.getFFrames(); |
|
330 |
IFFrame[] fframes=layout.getLayoutContext().getFFrames();
|
|
332 | 331 |
for (int i = 0; i < fframes.length; i++) { |
333 | 332 |
if (fframes[i] instanceof IFFrameUseFMap) { |
334 | 333 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
... | ... | |
340 | 339 |
|
341 | 340 |
|
342 | 341 |
// Borramos el anterior |
343 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
342 |
layout.getLayoutControl().setStatus(LayoutControl.DESACTUALIZADO);
|
|
344 | 343 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
345 | 344 |
|
346 | 345 |
if (java.lang.Math.abs(p1.getX() - p2.getX()) <= 3) { |
... | ... | |
401 | 400 |
*/ |
402 | 401 |
public void setViewZoomOut(Point p2) { |
403 | 402 |
Point2D.Double pWorld; |
404 |
IFFrame[] fframes=layout.getFFrames(); |
|
403 |
IFFrame[] fframes=layout.getLayoutContext().getFFrames();
|
|
405 | 404 |
for (int i = 0; i < fframes.length; i++) { |
406 | 405 |
if (fframes[i] instanceof IFFrameUseFMap) { |
407 | 406 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
... | ... | |
457 | 456 |
* @param p2 Punto final |
458 | 457 |
*/ |
459 | 458 |
public void setPan(Point p1, Point p2) { |
460 |
IFFrame[] fframes = layout.getFFrames(); |
|
459 |
IFFrame[] fframes = layout.getLayoutContext().getFFrames();
|
|
461 | 460 |
|
462 | 461 |
for (int i = 0; i < fframes.length; i++) { |
463 | 462 |
if (fframes[i] instanceof IFFrameUseFMap) { |
Also available in: Unified diff