Revision 27419 branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/FLayoutZooms.java
FLayoutZooms.java | ||
---|---|---|
51 | 51 |
import java.awt.geom.Rectangle2D; |
52 | 52 |
import java.util.prefs.Preferences; |
53 | 53 |
|
54 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
55 |
import org.gvsig.fmap.geom.GeometryManager; |
|
56 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
57 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
54 | 58 |
import org.gvsig.fmap.geom.util.UtilFunctions; |
55 | 59 |
import org.gvsig.fmap.mapcontext.MapContext; |
60 |
import org.slf4j.Logger; |
|
61 |
import org.slf4j.LoggerFactory; |
|
56 | 62 |
|
57 | 63 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
58 | 64 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameUseFMap; |
... | ... | |
65 | 71 |
* @author Vicente Caballero Navarro |
66 | 72 |
*/ |
67 | 73 |
public class FLayoutZooms { |
68 |
private Layout layout = null; |
|
74 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
75 |
private static final Logger logger = LoggerFactory.getLogger(FLayoutZooms.class); |
|
76 |
private Layout layout = null; |
|
69 | 77 |
|
70 |
public FLayoutZooms(Layout l) {
|
|
71 |
layout = l;
|
|
72 |
}
|
|
78 |
public FLayoutZooms(Layout l) {
|
|
79 |
layout = l;
|
|
80 |
}
|
|
73 | 81 |
|
74 |
/**
|
|
82 |
/**
|
|
75 | 83 |
* Realiza un zoom por rect?ngulo o por punto con un escalado por defecto |
76 | 84 |
* sobre el Layout que se le pasa como par?metro. |
77 | 85 |
* |
78 | 86 |
* @param p1 punto de inicio del rect?ngulo. |
79 | 87 |
* @param p2 punto final del rec?ngulo. |
80 | 88 |
*/ |
81 |
public void setZoomIn(Point p1, Point p2) {
|
|
82 |
if (java.lang.Math.abs(layout.getLayoutControl().getFirstPoint().x - p2.x) < 4) {
|
|
89 |
public void setZoomIn(Point p1, Point p2) {
|
|
90 |
if (java.lang.Math.abs(layout.getLayoutControl().getFirstPoint().x - p2.x) < 4) {
|
|
83 | 91 |
double difw = 2; |
84 | 92 |
setZoom(difw, p2); |
85 | 93 |
} else { |
... | ... | |
143 | 151 |
|
144 | 152 |
if (difw < difh) { |
145 | 153 |
rSheet.x = (-xmin * difw) |
146 |
- x
|
|
147 |
+ ((wv - ((pSheet2.getX() - pSheet1.getX()) * difw)) / 2);
|
|
154 |
- x |
|
155 |
+ ((wv - ((pSheet2.getX() - pSheet1.getX()) * difw)) / 2); |
|
148 | 156 |
rSheet.y = (-ymin * difw) |
149 |
- y
|
|
150 |
+ ((hv - ((pSheet2.getY() - pSheet1.getY()) * difw)) / 2);
|
|
157 |
- y |
|
158 |
+ ((hv - ((pSheet2.getY() - pSheet1.getY()) * difw)) / 2); |
|
151 | 159 |
|
152 | 160 |
rSheet.width = w * difw; |
153 | 161 |
rSheet.height = h * difw; |
154 | 162 |
} else { |
155 | 163 |
rSheet.x = (-xmin * difh) |
156 |
- x
|
|
157 |
+ ((wv - ((pSheet2.getX() - pSheet1.getX()) * difh)) / 2);
|
|
164 |
- x |
|
165 |
+ ((wv - ((pSheet2.getX() - pSheet1.getX()) * difh)) / 2); |
|
158 | 166 |
rSheet.y = (-ymin * difh) |
159 |
- y
|
|
160 |
+ ((hv - ((pSheet2.getY() - pSheet1.getY()) * difh)) / 2);
|
|
167 |
- y |
|
168 |
+ ((hv - ((pSheet2.getY() - pSheet1.getY()) * difh)) / 2); |
|
161 | 169 |
|
162 | 170 |
rSheet.width = w * difh; |
163 | 171 |
rSheet.height = h * difh; |
... | ... | |
169 | 177 |
layout.getLayoutControl().getRect().setRect(rScreen); |
170 | 178 |
} |
171 | 179 |
} |
172 |
}
|
|
180 |
}
|
|
173 | 181 |
|
174 |
/**
|
|
182 |
/**
|
|
175 | 183 |
* Realiza un zoom out sobre el Layout que se le pasa como par?metro. |
176 | 184 |
* |
177 | 185 |
* @param p2 punto central del rect?ngulo. |
178 | 186 |
*/ |
179 |
public void setZoomOut(Point p2) {
|
|
180 |
double difw = 0.5;
|
|
181 |
setZoom(difw,p2);
|
|
182 |
}
|
|
187 |
public void setZoomOut(Point p2) {
|
|
188 |
double difw = 0.5;
|
|
189 |
setZoom(difw,p2);
|
|
190 |
}
|
|
183 | 191 |
|
184 |
/**
|
|
192 |
/**
|
|
185 | 193 |
* Realiza un zoom out sobre el Layout que se le pasa como par?metro. |
186 | 194 |
* |
187 | 195 |
* @param dif factor. |
188 | 196 |
* @param p2 punto final del rec?ngulo. |
189 | 197 |
*/ |
190 |
public void setZoom(double dif, Point p2) {
|
|
191 |
Point2D.Double pSheet2 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
|
|
192 |
p2.getX(), p2.getY()), layout.getLayoutControl().getAT());
|
|
193 |
Rectangle2D.Double rScreen = new Rectangle2D.Double();
|
|
194 |
Rectangle2D.Double rSheet = new Rectangle2D.Double();
|
|
198 |
public void setZoom(double dif, Point p2) {
|
|
199 |
Point2D.Double pSheet2 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
|
|
200 |
p2.getX(), p2.getY()), layout.getLayoutControl().getAT());
|
|
201 |
Rectangle2D.Double rScreen = new Rectangle2D.Double();
|
|
202 |
Rectangle2D.Double rSheet = new Rectangle2D.Double();
|
|
195 | 203 |
|
196 |
double difw = dif;
|
|
204 |
double difw = dif;
|
|
197 | 205 |
|
198 |
rSheet.x = (-pSheet2.getX() * difw) -
|
|
199 |
FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect().getX(),
|
|
200 |
layout.getLayoutControl().getAT()) +
|
|
201 |
FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
|
|
202 |
layout.getLayoutControl().getAT());
|
|
203 |
rSheet.y = (-pSheet2.getY() * difw) -
|
|
204 |
FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect().getY(),
|
|
205 |
layout.getLayoutControl().getAT()) +
|
|
206 |
FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
|
|
207 |
layout.getLayoutControl().getAT());
|
|
206 |
rSheet.x = (-pSheet2.getX() * difw) -
|
|
207 |
FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect().getX(),
|
|
208 |
layout.getLayoutControl().getAT()) +
|
|
209 |
FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
|
|
210 |
layout.getLayoutControl().getAT());
|
|
211 |
rSheet.y = (-pSheet2.getY() * difw) -
|
|
212 |
FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect().getY(),
|
|
213 |
layout.getLayoutControl().getAT()) +
|
|
214 |
FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
|
|
215 |
layout.getLayoutControl().getAT());
|
|
208 | 216 |
|
209 |
rSheet.width = FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect()
|
|
210 |
.getWidth(),
|
|
211 |
layout.getLayoutControl().getAT()) * difw;
|
|
212 |
rSheet.height = FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect()
|
|
213 |
.getHeight(),
|
|
214 |
layout.getLayoutControl().getAT()) * difw;
|
|
217 |
rSheet.width = FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect()
|
|
218 |
.getWidth(),
|
|
219 |
layout.getLayoutControl().getAT()) * difw;
|
|
220 |
rSheet.height = FLayoutUtilities.toSheetDistance(layout.getLayoutControl().getRect()
|
|
221 |
.getHeight(),
|
|
222 |
layout.getLayoutControl().getAT()) * difw;
|
|
215 | 223 |
|
216 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout.getLayoutControl().getAT()));
|
|
224 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout.getLayoutControl().getAT()));
|
|
217 | 225 |
|
218 |
if (FLayoutUtilities.isPosible(rScreen)) {
|
|
219 |
layout.getLayoutControl().getRect().setRect(rScreen);
|
|
220 |
}
|
|
226 |
if (FLayoutUtilities.isPosible(rScreen)) {
|
|
227 |
layout.getLayoutControl().getRect().setRect(rScreen);
|
|
228 |
}
|
|
221 | 229 |
|
222 |
// Para realizar el zoom a partir de un punto.
|
|
223 |
Point p1 = new Point((int) (p2.getX() -
|
|
224 |
(layout.getWidth() / (difw * 2))),
|
|
225 |
(int) (p2.getY() - (layout.getHeight() / (difw * 2))));
|
|
226 |
p2 = new Point((int) (p2.getX() + (layout.getWidth() / (difw * 2))),
|
|
227 |
(int) (p2.getY() + (layout.getHeight() / (difw * 2))));
|
|
228 |
setPointsToZoom(p1, p2);
|
|
229 |
}
|
|
230 |
/**
|
|
231 |
* Introduce los puntos de control para controlar el zoom del Layout.
|
|
232 |
*/
|
|
233 |
private void setPointsToZoom(Point p1, Point p2) {
|
|
234 |
IFFrame[] fframes = layout.getLayoutContext().getFFrames();
|
|
230 |
// Para realizar el zoom a partir de un punto.
|
|
231 |
Point p1 = new Point((int) (p2.getX() -
|
|
232 |
(layout.getWidth() / (difw * 2))),
|
|
233 |
(int) (p2.getY() - (layout.getHeight() / (difw * 2))));
|
|
234 |
p2 = new Point((int) (p2.getX() + (layout.getWidth() / (difw * 2))),
|
|
235 |
(int) (p2.getY() + (layout.getHeight() / (difw * 2))));
|
|
236 |
setPointsToZoom(p1, p2);
|
|
237 |
}
|
|
238 |
/**
|
|
239 |
* Introduce los puntos de control para controlar el zoom del Layout.
|
|
240 |
*/
|
|
241 |
private void setPointsToZoom(Point p1, Point p2) {
|
|
242 |
IFFrame[] fframes = layout.getLayoutContext().getFFrames();
|
|
235 | 243 |
|
236 |
for (int i = 0; i < fframes.length; i++) {
|
|
237 |
if (fframes[i] instanceof IFFrameUseFMap) {
|
|
238 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
|
|
239 |
if (fframe.getATMap()!=null) {
|
|
240 |
Point2D px1 = FLayoutFunctions.toMapPoint(p1, fframe.getATMap());
|
|
241 |
Point2D px2 = FLayoutFunctions.toMapPoint(p2, fframe.getATMap());
|
|
242 |
fframe.setPointsToZoom(px1, px2);
|
|
243 |
}
|
|
244 |
}
|
|
245 |
}
|
|
246 |
}
|
|
244 |
for (int i = 0; i < fframes.length; i++) {
|
|
245 |
if (fframes[i] instanceof IFFrameUseFMap) {
|
|
246 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
|
|
247 |
if (fframe.getATMap()!=null) {
|
|
248 |
Point2D px1 = FLayoutFunctions.toMapPoint(p1, fframe.getATMap());
|
|
249 |
Point2D px2 = FLayoutFunctions.toMapPoint(p2, fframe.getATMap());
|
|
250 |
fframe.setPointsToZoom(px1, px2);
|
|
251 |
}
|
|
252 |
}
|
|
253 |
}
|
|
254 |
}
|
|
247 | 255 |
|
248 |
/**
|
|
249 |
* Aplica el zoom real teniendo en cuenta la resoluci?n de pantalla.
|
|
250 |
*/
|
|
251 |
public void realZoom() {
|
|
252 |
Preferences prefsResolution = Preferences.userRoot().node( "gvsig.configuration.screen" );
|
|
253 |
double cm = layout.getLayoutContext().getAttributes().getPixXCm(layout.getLayoutControl().getRect());
|
|
254 |
Toolkit kit = Toolkit.getDefaultToolkit();
|
|
255 |
double dpi = prefsResolution.getInt("dpi",kit.getScreenResolution());
|
|
256 |
double dif = (cm * Attributes.PULGADA) / dpi;
|
|
257 |
setZoom(1 / dif,
|
|
258 |
new Point(layout.getWidth() / 2, layout.getHeight() / 2));
|
|
259 |
layout.getLayoutControl().refresh();
|
|
260 |
}
|
|
256 |
/**
|
|
257 |
* Aplica el zoom real teniendo en cuenta la resoluci?n de pantalla.
|
|
258 |
*/
|
|
259 |
public void realZoom() {
|
|
260 |
Preferences prefsResolution = Preferences.userRoot().node( "gvsig.configuration.screen" );
|
|
261 |
double cm = layout.getLayoutContext().getAttributes().getPixXCm(layout.getLayoutControl().getRect());
|
|
262 |
Toolkit kit = Toolkit.getDefaultToolkit();
|
|
263 |
double dpi = prefsResolution.getInt("dpi",kit.getScreenResolution());
|
|
264 |
double dif = (cm * Attributes.PULGADA) / dpi;
|
|
265 |
setZoom(1 / dif,
|
|
266 |
new Point(layout.getWidth() / 2, layout.getHeight() / 2));
|
|
267 |
layout.getLayoutControl().refresh();
|
|
268 |
}
|
|
261 | 269 |
|
262 |
/**
|
|
263 |
* Realiza un zoom in a partir del zoom actual de la vista.
|
|
264 |
*/
|
|
265 |
public void zoomIn() {
|
|
266 |
setZoom(2, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
|
|
267 |
layout.getLayoutControl().refresh();
|
|
268 |
}
|
|
270 |
/**
|
|
271 |
* Realiza un zoom in a partir del zoom actual de la vista.
|
|
272 |
*/
|
|
273 |
public void zoomIn() {
|
|
274 |
setZoom(2, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
|
|
275 |
layout.getLayoutControl().refresh();
|
|
276 |
}
|
|
269 | 277 |
|
270 |
/**
|
|
271 |
* Realiza un zoom out a partir del zoom actual de la vista.
|
|
272 |
*/
|
|
273 |
public void zoomOut() {
|
|
274 |
setZoom(0.5, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
|
|
275 |
layout.getLayoutControl().refresh();
|
|
276 |
}
|
|
278 |
/**
|
|
279 |
* Realiza un zoom out a partir del zoom actual de la vista.
|
|
280 |
*/
|
|
281 |
public void zoomOut() {
|
|
282 |
setZoom(0.5, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
|
|
283 |
layout.getLayoutControl().refresh();
|
|
284 |
}
|
|
277 | 285 |
|
278 |
/**
|
|
286 |
/**
|
|
279 | 287 |
* Realiza un zoom a los elementos que esten seleccionados, si no hay |
280 | 288 |
* ning?n elemento seleccionado no realiza ning?n zoom |
281 | 289 |
*/ |
282 |
public void zoomSelect() {
|
|
283 |
Rectangle2D.Double recaux = null;
|
|
284 |
IFFrame[] fframes=layout.getLayoutContext().getFFrames();
|
|
285 |
for (int i = 0; i < fframes.length; i++) {
|
|
286 |
if (fframes[i].getSelected() != IFFrame.NOSELECT) {
|
|
287 |
if (recaux == null) {
|
|
288 |
recaux = fframes[i].getBoundingBox(layout.getLayoutControl().getAT());
|
|
289 |
} else {
|
|
290 |
recaux.add(fframes[i].getBoundingBox(
|
|
291 |
layout.getLayoutControl().getAT()));
|
|
292 |
}
|
|
293 |
}
|
|
294 |
}
|
|
290 |
public void zoomSelect() {
|
|
291 |
Rectangle2D.Double recaux = null;
|
|
292 |
IFFrame[] fframes=layout.getLayoutContext().getFFrames();
|
|
293 |
for (int i = 0; i < fframes.length; i++) {
|
|
294 |
if (fframes[i].getSelected() != IFFrame.NOSELECT) {
|
|
295 |
if (recaux == null) {
|
|
296 |
recaux = fframes[i].getBoundingBox(layout.getLayoutControl().getAT());
|
|
297 |
} else {
|
|
298 |
recaux.add(fframes[i].getBoundingBox(
|
|
299 |
layout.getLayoutControl().getAT()));
|
|
300 |
}
|
|
301 |
}
|
|
302 |
}
|
|
295 | 303 |
|
296 |
if (recaux != null) {
|
|
297 |
Point p1 = new Point((int) recaux.x, (int) recaux.y);
|
|
298 |
Point p2 = new Point((int) recaux.getMaxX(), (int) recaux.getMaxY());
|
|
299 |
setZoomIn(p1, p2);
|
|
300 |
layout.getLayoutControl().refresh();
|
|
301 |
}
|
|
302 |
}
|
|
303 |
/**
|
|
304 |
if (recaux != null) {
|
|
305 |
Point p1 = new Point((int) recaux.x, (int) recaux.y);
|
|
306 |
Point p2 = new Point((int) recaux.getMaxX(), (int) recaux.getMaxY());
|
|
307 |
setZoomIn(p1, p2);
|
|
308 |
layout.getLayoutControl().refresh();
|
|
309 |
}
|
|
310 |
}
|
|
311 |
/**
|
|
304 | 312 |
* Realiza un zoom a todos los elementos del layout. |
305 | 313 |
*/ |
306 |
public void zoomAllFrames() {
|
|
307 |
Rectangle2D.Double recaux = null;
|
|
308 |
IFFrame[] fframes=layout.getLayoutControl().getLayoutContext().getFFrames();
|
|
309 |
for (int i = 0; i < fframes.length; i++) {
|
|
310 |
if (recaux == null) {
|
|
311 |
recaux = fframes[i].getBoundingBox(layout.getLayoutControl().getAT());
|
|
312 |
} else {
|
|
313 |
recaux.add(fframes[i].getBoundingBox(
|
|
314 |
layout.getLayoutControl().getAT()));
|
|
315 |
}
|
|
316 |
}
|
|
314 |
public void zoomAllFrames() {
|
|
315 |
Rectangle2D.Double recaux = null;
|
|
316 |
IFFrame[] fframes=layout.getLayoutControl().getLayoutContext().getFFrames();
|
|
317 |
for (int i = 0; i < fframes.length; i++) {
|
|
318 |
if (recaux == null) {
|
|
319 |
recaux = fframes[i].getBoundingBox(layout.getLayoutControl().getAT());
|
|
320 |
} else {
|
|
321 |
recaux.add(fframes[i].getBoundingBox(
|
|
322 |
layout.getLayoutControl().getAT()));
|
|
323 |
}
|
|
324 |
}
|
|
317 | 325 |
|
318 |
if (recaux != null) {
|
|
319 |
Point p1 = new Point((int) recaux.x, (int) recaux.y);
|
|
320 |
Point p2 = new Point((int) recaux.getMaxX(), (int) recaux.getMaxY());
|
|
321 |
setZoomIn(p1, p2);
|
|
322 |
layout.getLayoutControl().refresh();
|
|
323 |
}
|
|
324 |
}
|
|
326 |
if (recaux != null) {
|
|
327 |
Point p1 = new Point((int) recaux.x, (int) recaux.y);
|
|
328 |
Point p2 = new Point((int) recaux.getMaxX(), (int) recaux.getMaxY());
|
|
329 |
setZoomIn(p1, p2);
|
|
330 |
layout.getLayoutControl().refresh();
|
|
331 |
}
|
|
332 |
}
|
|
325 | 333 |
|
326 |
/**
|
|
327 |
* Realiza un zoom in a las vista a?adidas al Layout que esten seleccionadas
|
|
328 |
*
|
|
329 |
* @param p1 Punto inicial del rect?ngulo
|
|
330 |
* @param p2 Punto final del rect?ngulo
|
|
331 |
*/
|
|
332 |
public void setViewZoomIn(Point2D p1, Point2D p2) {
|
|
333 |
IFFrame[] fframes=layout.getLayoutContext().getFFrames();
|
|
334 |
for (int i = 0; i < fframes.length; i++) {
|
|
335 |
if (fframes[i] instanceof IFFrameUseFMap) {
|
|
336 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
|
|
334 |
/**
|
|
335 |
* Realiza un zoom in a las vista a?adidas al Layout que esten seleccionadas
|
|
336 |
*
|
|
337 |
* @param p1 Punto inicial del rect?ngulo
|
|
338 |
* @param p2 Punto final del rect?ngulo
|
|
339 |
*/
|
|
340 |
public void setViewZoomIn(Point2D p1, Point2D p2) {
|
|
341 |
IFFrame[] fframes=layout.getLayoutContext().getFFrames();
|
|
342 |
for (int i = 0; i < fframes.length; i++) {
|
|
343 |
if (fframes[i] instanceof IFFrameUseFMap) {
|
|
344 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
|
|
337 | 345 |
|
338 |
if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
|
|
339 |
//IFFrameUseFMap fframeAux=(IFFrameUseFMap)((IFFrame)fframe).cloneFFrame(layout);
|
|
340 |
p1 = FLayoutFunctions.toMapPoint(p1, fframe.getATMap());
|
|
341 |
p2 = FLayoutFunctions.toMapPoint(p2, fframe.getATMap());
|
|
346 |
if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
|
|
347 |
//IFFrameUseFMap fframeAux=(IFFrameUseFMap)((IFFrame)fframe).cloneFFrame(layout);
|
|
348 |
p1 = FLayoutFunctions.toMapPoint(p1, fframe.getATMap());
|
|
349 |
p2 = FLayoutFunctions.toMapPoint(p2, fframe.getATMap());
|
|
342 | 350 |
|
343 | 351 |
|
344 |
// Borramos el anterior
|
|
345 |
layout.getLayoutControl().setStatus(LayoutControl.DESACTUALIZADO);
|
|
346 |
Rectangle2D.Double r = new Rectangle2D.Double();
|
|
352 |
// Borramos el anterior
|
|
353 |
layout.getLayoutControl().setStatus(LayoutControl.DESACTUALIZADO);
|
|
354 |
Rectangle2D.Double r = new Rectangle2D.Double();
|
|
347 | 355 |
|
348 |
if (java.lang.Math.abs(p1.getX() - p2.getX()) <= 3) {
|
|
349 |
double nuevoX;
|
|
350 |
double nuevoY;
|
|
351 |
double cX;
|
|
352 |
double cY;
|
|
356 |
if (java.lang.Math.abs(p1.getX() - p2.getX()) <= 3) {
|
|
357 |
double nuevoX;
|
|
358 |
double nuevoY;
|
|
359 |
double cX;
|
|
360 |
double cY;
|
|
353 | 361 |
|
354 |
cX = p2.getX();
|
|
355 |
cY = p2.getY();
|
|
362 |
cX = p2.getX();
|
|
363 |
cY = p2.getY();
|
|
356 | 364 |
|
357 |
double factor = 1/MapContext.ZOOMINFACTOR;
|
|
365 |
double factor = 1/MapContext.ZOOMINFACTOR;
|
|
358 | 366 |
|
359 |
Rectangle2D extent=fframe.getMapContext().getViewPort().getExtent();
|
|
360 |
if (extent!=null){
|
|
361 |
nuevoX = cX -
|
|
362 |
((extent.getWidth() * factor) / 2.0);
|
|
363 |
nuevoY = cY -
|
|
364 |
((extent.getHeight() * factor) / 2.0);
|
|
365 |
r.x = nuevoX;
|
|
366 |
r.y = nuevoY;
|
|
367 |
r.width = extent.getWidth() * factor;
|
|
368 |
r.height = extent.getHeight() * factor;
|
|
369 |
}
|
|
367 |
Rectangle2D extent=fframe.getMapContext().getViewPort().getExtent();
|
|
368 |
if (extent!=null){
|
|
369 |
nuevoX = cX -
|
|
370 |
((extent.getWidth() * factor) / 2.0);
|
|
371 |
nuevoY = cY -
|
|
372 |
((extent.getHeight() * factor) / 2.0);
|
|
373 |
r.x = nuevoX;
|
|
374 |
r.y = nuevoY;
|
|
375 |
r.width = extent.getWidth() * factor;
|
|
376 |
r.height = extent.getHeight() * factor;
|
|
377 |
}
|
|
370 | 378 |
|
371 |
//fframeAux.setNewExtent(r);
|
|
372 |
} else {
|
|
373 |
// Fijamos el nuevo extent
|
|
379 |
//fframeAux.setNewExtent(r);
|
|
380 |
} else {
|
|
381 |
// Fijamos el nuevo extent
|
|
374 | 382 |
|
375 |
r.setFrameFromDiagonal(p1, p2);
|
|
383 |
r.setFrameFromDiagonal(p1, p2);
|
|
376 | 384 |
|
377 |
//fframeAux.setNewExtent(r);
|
|
378 |
}
|
|
385 |
//fframeAux.setNewExtent(r);
|
|
386 |
}
|
|
379 | 387 |
|
380 |
/*if (fframe.getTypeScale()!=IFFrameUseFMap.AUTOMATICO) {
|
|
388 |
/*if (fframe.getTypeScale()!=IFFrameUseFMap.AUTOMATICO) {
|
|
381 | 389 |
fframeAux.setNewExtent(r); |
382 | 390 |
fframeAux.refresh(); |
383 | 391 |
layout.getEFS().modifyFFrame((IFFrame)fframe,(IFFrame)fframeAux); |
... | ... | |
385 | 393 |
layout.updateFFrames(); |
386 | 394 |
layout.setIsReSel(true); |
387 | 395 |
}else {*/ |
388 |
fframe.setNewEnvelope(UtilFunctions.createEnvelope(r.getX(),r.getY(),r.getMaxX(),r.getMaxY())); |
|
389 |
fframe.refresh(); |
|
390 |
///} |
|
391 |
// Fin del else |
|
392 |
//layout.repaint(); |
|
393 |
} |
|
394 |
} |
|
395 |
} |
|
396 |
} |
|
396 |
try { |
|
397 |
fframe.setNewEnvelope(geomManager.createEnvelope(r.getX(),r.getY(),r.getMaxX(),r.getMaxY(), SUBTYPES.GEOM2D)); |
|
398 |
} catch (CreateEnvelopeException e) { |
|
399 |
logger.error("Error creating the envelope", e); |
|
400 |
} |
|
401 |
fframe.refresh(); |
|
402 |
///} |
|
403 |
// Fin del else |
|
404 |
//layout.repaint(); |
|
405 |
} |
|
406 |
} |
|
407 |
} |
|
408 |
} |
|
397 | 409 |
|
398 |
/**
|
|
399 |
* Realiza un zoom out a las vistas a?adidas al Layout y que est?n seleccionadas
|
|
400 |
*
|
|
401 |
* @param p2 Punto central
|
|
402 |
*/
|
|
403 |
public void setViewZoomOut(Point p2) {
|
|
404 |
Point2D.Double pWorld;
|
|
405 |
IFFrame[] fframes=layout.getLayoutContext().getFFrames();
|
|
406 |
for (int i = 0; i < fframes.length; i++) {
|
|
407 |
if (fframes[i] instanceof IFFrameUseFMap) {
|
|
408 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
|
|
410 |
/**
|
|
411 |
* Realiza un zoom out a las vistas a?adidas al Layout y que est?n seleccionadas
|
|
412 |
*
|
|
413 |
* @param p2 Punto central
|
|
414 |
*/
|
|
415 |
public void setViewZoomOut(Point p2) {
|
|
416 |
Point2D.Double pWorld;
|
|
417 |
IFFrame[] fframes=layout.getLayoutContext().getFFrames();
|
|
418 |
for (int i = 0; i < fframes.length; i++) {
|
|
419 |
if (fframes[i] instanceof IFFrameUseFMap) {
|
|
420 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
|
|
409 | 421 |
|
410 |
if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
|
|
411 |
//IFFrameUseFMap fframeAux=(IFFrameUseFMap)((IFFrame)fframe).cloneFFrame(layout);
|
|
412 |
double nuevoX;
|
|
413 |
double nuevoY;
|
|
414 |
double cX;
|
|
415 |
double cY;
|
|
416 |
Point pScreen = new Point((int) p2.getX(), (int) p2.getY());
|
|
417 |
pWorld = FLayoutFunctions.toMapPoint(pScreen,
|
|
418 |
fframe.getATMap());
|
|
422 |
if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
|
|
423 |
//IFFrameUseFMap fframeAux=(IFFrameUseFMap)((IFFrame)fframe).cloneFFrame(layout);
|
|
424 |
double nuevoX;
|
|
425 |
double nuevoY;
|
|
426 |
double cX;
|
|
427 |
double cY;
|
|
428 |
Point pScreen = new Point((int) p2.getX(), (int) p2.getY());
|
|
429 |
pWorld = FLayoutFunctions.toMapPoint(pScreen,
|
|
430 |
fframe.getATMap());
|
|
419 | 431 |
|
420 |
cX = pWorld.getX();
|
|
421 |
cY = pWorld.getY();
|
|
432 |
cX = pWorld.getX();
|
|
433 |
cY = pWorld.getY();
|
|
422 | 434 |
|
423 |
double factor = 1/MapContext.ZOOMOUTFACTOR;
|
|
424 |
Rectangle2D extent = fframe.getMapContext()
|
|
425 |
.getViewPort().getExtent();
|
|
426 |
if (extent != null) {
|
|
435 |
double factor = 1/MapContext.ZOOMOUTFACTOR;
|
|
436 |
Rectangle2D extent = fframe.getMapContext()
|
|
437 |
.getViewPort().getExtent(); |
|
438 |
if (extent != null) {
|
|
427 | 439 |
nuevoX = cX - ((extent.getWidth() * factor) / 2.0); |
428 | 440 |
nuevoY = cY - ((extent.getHeight() * factor) / 2.0); |
429 | 441 |
double x = nuevoX; |
430 | 442 |
double y = nuevoY; |
431 | 443 |
double width = extent.getWidth() * factor; |
432 | 444 |
double height = extent.getHeight() * factor; |
433 |
fframe.setNewEnvelope(UtilFunctions.createEnvelope(x,y,x+width,y+height)); |
|
445 |
try { |
|
446 |
fframe.setNewEnvelope(geomManager.createEnvelope(x,y,x+width,y+height, SUBTYPES.GEOM2D)); |
|
447 |
} catch (CreateEnvelopeException e) { |
|
448 |
logger.error("Error creating the envelope", e); |
|
449 |
} |
|
434 | 450 |
fframe.refresh(); |
435 | 451 |
} |
436 |
}
|
|
437 |
}
|
|
438 |
}
|
|
439 |
}
|
|
452 |
}
|
|
453 |
}
|
|
454 |
}
|
|
455 |
}
|
|
440 | 456 |
|
441 |
/**
|
|
442 |
* Modifica los puntos de control para generar el zoom del Layout
|
|
443 |
*
|
|
444 |
* @param p1 Punto inicial
|
|
445 |
* @param p2 Punto final
|
|
446 |
*/
|
|
447 |
public void setPan(Point p1, Point p2) {
|
|
448 |
IFFrame[] fframes = layout.getLayoutContext().getFFrames();
|
|
457 |
/**
|
|
458 |
* Modifica los puntos de control para generar el zoom del Layout
|
|
459 |
*
|
|
460 |
* @param p1 Punto inicial
|
|
461 |
* @param p2 Punto final
|
|
462 |
*/
|
|
463 |
public void setPan(Point p1, Point p2) {
|
|
464 |
IFFrame[] fframes = layout.getLayoutContext().getFFrames();
|
|
449 | 465 |
|
450 |
for (int i = 0; i < fframes.length; i++) {
|
|
451 |
if (fframes[i] instanceof IFFrameUseFMap) {
|
|
452 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
|
|
453 |
AffineTransform at=fframe.getATMap();
|
|
454 |
if (at!=null) {
|
|
455 |
Point2D px1 = FLayoutFunctions.toMapPoint(p1, at);
|
|
456 |
Point2D px2 = FLayoutFunctions.toMapPoint(p2, at);
|
|
457 |
fframe.movePoints(px1, px2);
|
|
458 |
}
|
|
459 |
}
|
|
460 |
}
|
|
461 |
}
|
|
466 |
for (int i = 0; i < fframes.length; i++) {
|
|
467 |
if (fframes[i] instanceof IFFrameUseFMap) {
|
|
468 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i];
|
|
469 |
AffineTransform at=fframe.getATMap();
|
|
470 |
if (at!=null) {
|
|
471 |
Point2D px1 = FLayoutFunctions.toMapPoint(p1, at);
|
|
472 |
Point2D px2 = FLayoutFunctions.toMapPoint(p2, at);
|
|
473 |
fframe.movePoints(px1, px2);
|
|
474 |
}
|
|
475 |
}
|
|
476 |
}
|
|
477 |
}
|
|
462 | 478 |
} |
Also available in: Unified diff