Revision 1074 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/FLayoutZooms.java
FLayoutZooms.java | ||
---|---|---|
1 | 1 |
/* |
2 | 2 |
* Created on 17-sep-2004 |
3 | 3 |
* |
4 |
* To change the template for this generated file go to |
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments |
|
6 | 4 |
*/ |
7 | 5 |
package com.iver.cit.gvsig.gui.layout; |
8 | 6 |
|
... | ... | |
22 | 20 |
* @author Vicente Caballero Navarro |
23 | 21 |
*/ |
24 | 22 |
public class FLayoutZooms { |
25 |
private Layout layout = null;
|
|
26 |
private FLayoutFunctions functions=null;
|
|
23 |
private Layout layout = null;
|
|
24 |
private FLayoutFunctions functions = null;
|
|
27 | 25 |
|
28 |
/**
|
|
29 |
* Crea un nuevo Zooms.
|
|
30 |
*
|
|
31 |
* @param l Mapa sobre el que se actua.
|
|
32 |
*/
|
|
33 |
public FLayoutZooms(Layout l) {
|
|
34 |
layout = l;
|
|
35 |
functions=new FLayoutFunctions(layout);
|
|
36 |
}
|
|
26 |
/**
|
|
27 |
* Crea un nuevo Zooms.
|
|
28 |
*
|
|
29 |
* @param l Mapa sobre el que se actua.
|
|
30 |
*/
|
|
31 |
public FLayoutZooms(Layout l) {
|
|
32 |
layout = l;
|
|
33 |
functions = new FLayoutFunctions(layout);
|
|
34 |
}
|
|
37 | 35 |
|
38 |
/**
|
|
39 |
* Realiza un zoom por rect?ngulo o por punto con un escalado por defecto
|
|
40 |
* sobre el Layout que se le pasa como par?metro.
|
|
41 |
*
|
|
42 |
* @param p1 punto de inicio del rect?ngulo.
|
|
43 |
* @param p2 punto final del rec?ngulo.
|
|
44 |
*/
|
|
45 |
public void setZoomIn(Point p1, Point p2) {
|
|
46 |
if (p1.y != p2.y) {
|
|
47 |
double points = (p2.x - p1.x) / (p2.y - p1.y);
|
|
48 |
double window = (double) layout.getWidth() / layout.getHeight();
|
|
36 |
/**
|
|
37 |
* Realiza un zoom por rect?ngulo o por punto con un escalado por defecto
|
|
38 |
* sobre el Layout que se le pasa como par?metro.
|
|
39 |
*
|
|
40 |
* @param p1 punto de inicio del rect?ngulo.
|
|
41 |
* @param p2 punto final del rec?ngulo.
|
|
42 |
*/
|
|
43 |
public void setZoomIn(Point p1, Point p2) {
|
|
44 |
if (p1.y != p2.y) {
|
|
45 |
double points = (p2.x - p1.x) / (p2.y - p1.y);
|
|
46 |
double window = (double) layout.getWidth() / layout.getHeight();
|
|
49 | 47 |
|
50 |
if (points < window) {
|
|
51 |
p2.x = (int) (p1.x + ((p2.x - p1.x) * window));
|
|
52 |
}
|
|
53 |
}
|
|
48 |
if (points < window) {
|
|
49 |
p2.x = (int) (p1.x + ((p2.x - p1.x) * window));
|
|
50 |
}
|
|
51 |
}
|
|
54 | 52 |
|
55 |
Point2D.Double pSheet1 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
|
|
56 |
p1.getX(), p1.getY()), layout.getAT());
|
|
57 |
Point2D.Double pSheet2 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
|
|
58 |
p2.getX(), p2.getY()), layout.getAT());
|
|
53 |
Point2D.Double pSheet1 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
|
|
54 |
p1.getX(), p1.getY()), layout.getAT());
|
|
55 |
Point2D.Double pSheet2 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
|
|
56 |
p2.getX(), p2.getY()), layout.getAT());
|
|
59 | 57 |
|
60 |
double xmin = 0;
|
|
61 |
double xmax = 0;
|
|
62 |
double ymin = 0;
|
|
58 |
double xmin = 0;
|
|
59 |
double xmax = 0;
|
|
60 |
double ymin = 0;
|
|
63 | 61 |
|
64 |
if (pSheet1.x > pSheet2.x) {
|
|
65 |
xmin = pSheet2.x;
|
|
66 |
xmax = pSheet1.x;
|
|
67 |
} else {
|
|
68 |
xmin = pSheet1.x;
|
|
69 |
xmax = pSheet2.x;
|
|
70 |
}
|
|
62 |
if (pSheet1.x > pSheet2.x) {
|
|
63 |
xmin = pSheet2.x;
|
|
64 |
xmax = pSheet1.x;
|
|
65 |
} else {
|
|
66 |
xmin = pSheet1.x;
|
|
67 |
xmax = pSheet2.x;
|
|
68 |
}
|
|
71 | 69 |
|
72 |
if (pSheet1.y > pSheet2.y) {
|
|
73 |
ymin = pSheet2.y;
|
|
74 |
} else {
|
|
75 |
ymin = pSheet1.y;
|
|
76 |
}
|
|
70 |
if (pSheet1.y > pSheet2.y) {
|
|
71 |
ymin = pSheet2.y;
|
|
72 |
} else {
|
|
73 |
ymin = pSheet1.y;
|
|
74 |
}
|
|
77 | 75 |
|
78 |
Rectangle2D.Double rScreen = new Rectangle2D.Double();
|
|
79 |
Rectangle2D.Double rSheet = new Rectangle2D.Double();
|
|
76 |
Rectangle2D.Double rScreen = new Rectangle2D.Double();
|
|
77 |
Rectangle2D.Double rSheet = new Rectangle2D.Double();
|
|
80 | 78 |
|
81 |
if (java.lang.Math.abs(layout.getFirstPoint().x - p2.x) < 4) {
|
|
82 |
double w = FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
|
|
83 |
.getWidth(),
|
|
84 |
layout.getAT());
|
|
85 |
double difw = 2;
|
|
79 |
if (java.lang.Math.abs(layout.getFirstPoint().x - p2.x) < 4) {
|
|
80 |
double w = FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
|
|
81 |
.getWidth(),
|
|
82 |
layout.getAT());
|
|
83 |
double difw = 2;
|
|
86 | 84 |
|
87 |
rSheet.x = (-pSheet2.getX() * difw) -
|
|
88 |
FLayoutUtilities.toSheetDistance(layout.getRect().getX(),
|
|
89 |
layout.getAT()) +
|
|
90 |
FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
|
|
91 |
layout.getAT());
|
|
92 |
rSheet.y = (-pSheet2.getY() * difw) -
|
|
93 |
FLayoutUtilities.toSheetDistance(layout.getRect().getY(),
|
|
94 |
layout.getAT()) +
|
|
95 |
FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
|
|
96 |
layout.getAT());
|
|
85 |
rSheet.x = (-pSheet2.getX() * difw) -
|
|
86 |
FLayoutUtilities.toSheetDistance(layout.getRect().getX(),
|
|
87 |
layout.getAT()) +
|
|
88 |
FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
|
|
89 |
layout.getAT());
|
|
90 |
rSheet.y = (-pSheet2.getY() * difw) -
|
|
91 |
FLayoutUtilities.toSheetDistance(layout.getRect().getY(),
|
|
92 |
layout.getAT()) +
|
|
93 |
FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
|
|
94 |
layout.getAT());
|
|
97 | 95 |
|
98 |
rSheet.width = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
99 |
.getWidth(),
|
|
100 |
layout.getAT()) * difw;
|
|
101 |
rSheet.height = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
102 |
.getHeight(),
|
|
103 |
layout.getAT()) * difw;
|
|
96 |
rSheet.width = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
97 |
.getWidth(),
|
|
98 |
layout.getAT()) * difw;
|
|
99 |
rSheet.height = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
100 |
.getHeight(),
|
|
101 |
layout.getAT()) * difw;
|
|
104 | 102 |
|
105 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet,
|
|
106 |
layout.getAT()));
|
|
107 |
} else {
|
|
108 |
double w = FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
|
|
109 |
.getWidth(),
|
|
110 |
layout.getAT());
|
|
111 |
double mw = xmax - xmin;
|
|
112 |
double difw = w / mw;
|
|
103 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet,
|
|
104 |
layout.getAT()));
|
|
105 |
} else {
|
|
106 |
double w = FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
|
|
107 |
.getWidth(),
|
|
108 |
layout.getAT());
|
|
109 |
double mw = xmax - xmin;
|
|
110 |
double difw = w / mw;
|
|
113 | 111 |
|
114 |
rSheet.x = (-xmin * difw) -
|
|
115 |
FLayoutUtilities.toSheetDistance(layout.getRect().getX(),
|
|
116 |
layout.getAT());
|
|
117 |
rSheet.y = (-ymin * difw) -
|
|
118 |
FLayoutUtilities.toSheetDistance(layout.getRect().getY(),
|
|
119 |
layout.getAT());
|
|
112 |
rSheet.x = (-xmin * difw) -
|
|
113 |
FLayoutUtilities.toSheetDistance(layout.getRect().getX(),
|
|
114 |
layout.getAT());
|
|
115 |
rSheet.y = (-ymin * difw) -
|
|
116 |
FLayoutUtilities.toSheetDistance(layout.getRect().getY(),
|
|
117 |
layout.getAT());
|
|
120 | 118 |
|
121 |
rSheet.width = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
122 |
.getWidth(),
|
|
123 |
layout.getAT()) * difw;
|
|
124 |
rSheet.height = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
125 |
.getHeight(),
|
|
126 |
layout.getAT()) * difw;
|
|
119 |
rSheet.width = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
120 |
.getWidth(),
|
|
121 |
layout.getAT()) * difw;
|
|
122 |
rSheet.height = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
123 |
.getHeight(),
|
|
124 |
layout.getAT()) * difw;
|
|
127 | 125 |
|
128 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet,
|
|
129 |
layout.getAT()));
|
|
130 |
}
|
|
126 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet,
|
|
127 |
layout.getAT()));
|
|
128 |
}
|
|
131 | 129 |
|
132 |
if (FLayoutUtilities.isPosible(rScreen)) {
|
|
133 |
layout.getRect().setRect(rScreen);
|
|
134 |
}
|
|
135 |
}
|
|
130 |
if (FLayoutUtilities.isPosible(rScreen)) {
|
|
131 |
layout.getRect().setRect(rScreen);
|
|
132 |
}
|
|
133 |
}
|
|
136 | 134 |
|
137 |
/**
|
|
138 |
* Realiza un zoom out sobre el Layout que se le pasa como par?metro.
|
|
139 |
*
|
|
140 |
* @param p2 punto final del rec?ngulo.
|
|
141 |
*/
|
|
142 |
public void setZoomOut(Point p2) {
|
|
143 |
Point2D.Double pSheet2 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
|
|
144 |
p2.getX(), p2.getY()), layout.getAT());
|
|
135 |
/**
|
|
136 |
* Realiza un zoom out sobre el Layout que se le pasa como par?metro.
|
|
137 |
*
|
|
138 |
* @param p2 punto final del rec?ngulo.
|
|
139 |
*/
|
|
140 |
public void setZoomOut(Point p2) {
|
|
141 |
Point2D.Double pSheet2 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
|
|
142 |
p2.getX(), p2.getY()), layout.getAT());
|
|
145 | 143 |
|
146 |
Rectangle2D.Double rScreen = new Rectangle2D.Double();
|
|
147 |
Rectangle2D.Double rSheet = new Rectangle2D.Double();
|
|
144 |
Rectangle2D.Double rScreen = new Rectangle2D.Double();
|
|
145 |
Rectangle2D.Double rSheet = new Rectangle2D.Double();
|
|
148 | 146 |
|
149 |
double w = FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
|
|
150 |
.getWidth(),
|
|
151 |
layout.getAT());
|
|
152 |
double difw = 0.5;
|
|
147 |
double w = FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
|
|
148 |
.getWidth(),
|
|
149 |
layout.getAT());
|
|
150 |
double difw = 0.5;
|
|
153 | 151 |
|
154 |
rSheet.x = (-pSheet2.getX() * difw) -
|
|
155 |
FLayoutUtilities.toSheetDistance(layout.getRect().getX(),
|
|
156 |
layout.getAT()) +
|
|
157 |
FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
|
|
158 |
layout.getAT());
|
|
159 |
rSheet.y = (-pSheet2.getY() * difw) -
|
|
160 |
FLayoutUtilities.toSheetDistance(layout.getRect().getY(),
|
|
161 |
layout.getAT()) +
|
|
162 |
FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
|
|
163 |
layout.getAT());
|
|
152 |
rSheet.x = (-pSheet2.getX() * difw) -
|
|
153 |
FLayoutUtilities.toSheetDistance(layout.getRect().getX(),
|
|
154 |
layout.getAT()) +
|
|
155 |
FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
|
|
156 |
layout.getAT());
|
|
157 |
rSheet.y = (-pSheet2.getY() * difw) -
|
|
158 |
FLayoutUtilities.toSheetDistance(layout.getRect().getY(),
|
|
159 |
layout.getAT()) +
|
|
160 |
FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
|
|
161 |
layout.getAT());
|
|
164 | 162 |
|
165 |
rSheet.width = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
166 |
.getWidth(),
|
|
167 |
layout.getAT()) * difw;
|
|
168 |
rSheet.height = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
169 |
.getHeight(),
|
|
170 |
layout.getAT()) * difw;
|
|
163 |
rSheet.width = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
164 |
.getWidth(),
|
|
165 |
layout.getAT()) * difw;
|
|
166 |
rSheet.height = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
167 |
.getHeight(),
|
|
168 |
layout.getAT()) * difw;
|
|
171 | 169 |
|
172 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout.getAT()));
|
|
170 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout.getAT()));
|
|
173 | 171 |
|
174 |
if (FLayoutUtilities.isPosible(rScreen)) {
|
|
175 |
layout.getRect().setRect(rScreen);
|
|
176 |
}
|
|
177 |
}
|
|
172 |
if (FLayoutUtilities.isPosible(rScreen)) {
|
|
173 |
layout.getRect().setRect(rScreen);
|
|
174 |
}
|
|
175 |
}
|
|
178 | 176 |
|
179 |
/**
|
|
180 |
* Realiza un zoom out sobre el Layout que se le pasa como par?metro.
|
|
181 |
*
|
|
182 |
* @param dif punto de inicio del rect?ngulo.
|
|
183 |
* @param p2 punto final del rec?ngulo.
|
|
184 |
*/
|
|
185 |
public void setZoom(double dif, Point p2) {
|
|
186 |
Point2D.Double pSheet2 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
|
|
187 |
p2.getX(), p2.getY()), layout.getAT());
|
|
188 |
Rectangle2D.Double rScreen = new Rectangle2D.Double();
|
|
189 |
Rectangle2D.Double rSheet = new Rectangle2D.Double();
|
|
177 |
/**
|
|
178 |
* Realiza un zoom out sobre el Layout que se le pasa como par?metro.
|
|
179 |
*
|
|
180 |
* @param dif punto de inicio del rect?ngulo.
|
|
181 |
* @param p2 punto final del rec?ngulo.
|
|
182 |
*/
|
|
183 |
public void setZoom(double dif, Point p2) {
|
|
184 |
Point2D.Double pSheet2 = FLayoutUtilities.toSheetPoint(new Point2D.Double(
|
|
185 |
p2.getX(), p2.getY()), layout.getAT());
|
|
186 |
Rectangle2D.Double rScreen = new Rectangle2D.Double();
|
|
187 |
Rectangle2D.Double rSheet = new Rectangle2D.Double();
|
|
190 | 188 |
|
191 |
double w = FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
|
|
192 |
.getWidth(),
|
|
193 |
layout.getAT());
|
|
194 |
double difw = dif;
|
|
189 |
double w = FLayoutUtilities.toSheetDistance(layout.getVisibleRect()
|
|
190 |
.getWidth(),
|
|
191 |
layout.getAT());
|
|
192 |
double difw = dif;
|
|
195 | 193 |
|
196 |
rSheet.x = (-pSheet2.getX() * difw) -
|
|
197 |
FLayoutUtilities.toSheetDistance(layout.getRect().getX(),
|
|
198 |
layout.getAT()) +
|
|
199 |
FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
|
|
200 |
layout.getAT());
|
|
201 |
rSheet.y = (-pSheet2.getY() * difw) -
|
|
202 |
FLayoutUtilities.toSheetDistance(layout.getRect().getY(),
|
|
203 |
layout.getAT()) +
|
|
204 |
FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
|
|
205 |
layout.getAT());
|
|
194 |
rSheet.x = (-pSheet2.getX() * difw) -
|
|
195 |
FLayoutUtilities.toSheetDistance(layout.getRect().getX(),
|
|
196 |
layout.getAT()) +
|
|
197 |
FLayoutUtilities.toSheetDistance(layout.getWidth() / 2,
|
|
198 |
layout.getAT());
|
|
199 |
rSheet.y = (-pSheet2.getY() * difw) -
|
|
200 |
FLayoutUtilities.toSheetDistance(layout.getRect().getY(),
|
|
201 |
layout.getAT()) +
|
|
202 |
FLayoutUtilities.toSheetDistance(layout.getHeight() / 2,
|
|
203 |
layout.getAT());
|
|
206 | 204 |
|
207 |
rSheet.width = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
208 |
.getWidth(),
|
|
209 |
layout.getAT()) * difw;
|
|
210 |
rSheet.height = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
211 |
.getHeight(),
|
|
212 |
layout.getAT()) * difw;
|
|
205 |
rSheet.width = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
206 |
.getWidth(),
|
|
207 |
layout.getAT()) * difw;
|
|
208 |
rSheet.height = FLayoutUtilities.toSheetDistance(layout.getRect()
|
|
209 |
.getHeight(),
|
|
210 |
layout.getAT()) * difw;
|
|
213 | 211 |
|
214 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout.getAT()));
|
|
212 |
rScreen.setRect(FLayoutUtilities.fromSheetRect(rSheet, layout.getAT()));
|
|
215 | 213 |
|
216 |
if (FLayoutUtilities.isPosible(rScreen)) {
|
|
217 |
layout.getRect().setRect(rScreen);
|
|
218 |
}
|
|
219 |
}
|
|
214 |
if (FLayoutUtilities.isPosible(rScreen)) {
|
|
215 |
layout.getRect().setRect(rScreen);
|
|
216 |
}
|
|
217 |
}
|
|
220 | 218 |
|
221 |
/**
|
|
222 |
* Realiza un zoom a escala 1:1.
|
|
223 |
*/
|
|
224 |
public void realZoom() {
|
|
225 |
double cm = layout.getAtributes().getPixXCm(layout.getRect());
|
|
226 |
Toolkit kit = Toolkit.getDefaultToolkit();
|
|
227 |
int resolution = kit.getScreenResolution();
|
|
228 |
double dif = (cm * Attributes.PULGADA) / resolution;
|
|
229 |
setZoom(1 / dif,
|
|
230 |
new Point(layout.getWidth() / 2, layout.getHeight() / 2));
|
|
231 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
232 |
layout.repaint();
|
|
233 |
}
|
|
219 |
/**
|
|
220 |
* Realiza un zoom a escala 1:1.
|
|
221 |
*/
|
|
222 |
public void realZoom() {
|
|
223 |
double cm = layout.getAtributes().getPixXCm(layout.getRect());
|
|
224 |
Toolkit kit = Toolkit.getDefaultToolkit();
|
|
225 |
int resolution = kit.getScreenResolution();
|
|
226 |
double dif = (cm * Attributes.PULGADA) / resolution;
|
|
227 |
setZoom(1 / dif,
|
|
228 |
new Point(layout.getWidth() / 2, layout.getHeight() / 2));
|
|
229 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
230 |
layout.repaint();
|
|
231 |
}
|
|
234 | 232 |
|
235 |
/**
|
|
236 |
* Realiza un zoom m?s a partir del punto central de pantalla.
|
|
237 |
*/
|
|
238 |
public void zoomIn() {
|
|
239 |
setZoom(2, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
|
|
240 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
241 |
layout.repaint();
|
|
242 |
}
|
|
233 |
/**
|
|
234 |
* Realiza un zoom m?s a partir del punto central de pantalla.
|
|
235 |
*/
|
|
236 |
public void zoomIn() {
|
|
237 |
setZoom(2, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
|
|
238 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
239 |
layout.repaint();
|
|
240 |
}
|
|
243 | 241 |
|
244 |
/**
|
|
245 |
* Realiza un zoom menos a partir del punto central de pantalla.
|
|
246 |
*/
|
|
247 |
public void zoomOut() {
|
|
248 |
setZoom(0.5, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
|
|
249 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
250 |
layout.repaint();
|
|
251 |
}
|
|
242 |
/**
|
|
243 |
* Realiza un zoom menos a partir del punto central de pantalla.
|
|
244 |
*/
|
|
245 |
public void zoomOut() {
|
|
246 |
setZoom(0.5, new Point(layout.getWidth() / 2, layout.getHeight() / 2));
|
|
247 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
248 |
layout.repaint();
|
|
249 |
}
|
|
252 | 250 |
|
253 |
/**
|
|
254 |
* Realiza un zoom a los elementos que esten seleccionados, si no hay
|
|
255 |
* ning?n elemento seleccionado no realiza ning?n zoom
|
|
256 |
*/
|
|
257 |
public void zoomSelect() {
|
|
258 |
Rectangle2D.Double recaux = null;
|
|
251 |
/**
|
|
252 |
* Realiza un zoom a los elementos que esten seleccionados, si no hay
|
|
253 |
* ning?n elemento seleccionado no realiza ning?n zoom
|
|
254 |
*/
|
|
255 |
public void zoomSelect() {
|
|
256 |
Rectangle2D.Double recaux = null;
|
|
259 | 257 |
|
260 |
for (int i = 0; i < layout.getFFrames().size(); i++) {
|
|
261 |
if (((IFFrame) layout.getFFrames().get(i)).getSelected() != FFrame.NOSELECT) {
|
|
262 |
if (recaux == null) {
|
|
263 |
recaux = ((IFFrame) layout.getFFrames().get(i)).getBoundingBox(layout.getAT());
|
|
264 |
} else {
|
|
265 |
recaux.add(((IFFrame) layout.getFFrames().get(i)).getBoundingBox(
|
|
266 |
layout.getAT()));
|
|
267 |
}
|
|
268 |
}
|
|
269 |
}
|
|
258 |
for (int i = 0; i < layout.getFFrames().size(); i++) {
|
|
259 |
if (((IFFrame) layout.getFFrames().get(i)).getSelected() != FFrame.NOSELECT) {
|
|
260 |
if (recaux == null) {
|
|
261 |
recaux = ((IFFrame) layout.getFFrames().get(i)).getBoundingBox(layout.getAT());
|
|
262 |
} else {
|
|
263 |
recaux.add(((IFFrame) layout.getFFrames().get(i)).getBoundingBox(
|
|
264 |
layout.getAT()));
|
|
265 |
}
|
|
266 |
}
|
|
267 |
}
|
|
270 | 268 |
|
271 |
if (recaux != null) {
|
|
272 |
Point p1 = new Point((int) recaux.x, (int) recaux.y);
|
|
273 |
Point p2 = new Point((int) recaux.getMaxX(), (int) recaux.getMaxY());
|
|
274 |
setZoomIn(p1, p2);
|
|
275 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
276 |
layout.repaint();
|
|
277 |
}
|
|
278 |
}
|
|
269 |
if (recaux != null) {
|
|
270 |
Point p1 = new Point((int) recaux.x, (int) recaux.y);
|
|
271 |
Point p2 = new Point((int) recaux.getMaxX(), (int) recaux.getMaxY());
|
|
272 |
setZoomIn(p1, p2);
|
|
273 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
274 |
layout.repaint();
|
|
275 |
}
|
|
276 |
}
|
|
279 | 277 |
|
280 |
/** |
|
281 |
* DOCUMENT ME! |
|
282 |
* |
|
283 |
* @param p1 DOCUMENT ME! |
|
284 |
* @param p2 DOCUMENT ME! |
|
285 |
*/ |
|
286 |
public void setViewZoomIn(Point2D p1, Point2D p2) { |
|
287 |
//Point2D.Double p1; |
|
288 |
//Point2D.Double p2; |
|
289 |
//Point pScreen = new Point(E.getX(), E.getY()); |
|
290 |
for (int i = 0; i < layout.getFFrames().size(); i++) { |
|
291 |
if (layout.getFFrames().get(i) instanceof FFrameView) { |
|
292 |
FFrameView fframe = (FFrameView) layout.getFFrames().get(i); |
|
278 |
/** |
|
279 |
* Realiza un zoom m?s sobre la vista del FFrameView seleccionado. |
|
280 |
* |
|
281 |
* @param p1 punto inicial. |
|
282 |
* @param p2 punto final. |
|
283 |
*/ |
|
284 |
public void setViewZoomIn(Point2D p1, Point2D p2) { |
|
285 |
for (int i = 0; i < layout.getFFrames().size(); i++) { |
|
286 |
if (layout.getFFrames().get(i) instanceof FFrameView) { |
|
287 |
FFrameView fframe = (FFrameView) layout.getFFrames().get(i); |
|
293 | 288 |
|
294 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
|
295 |
p1 = functions.toMapPoint(p1,fframe.getAt());
|
|
296 |
p2 = functions.toMapPoint(p2,fframe.getAt());
|
|
289 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
|
290 |
p1 = functions.toMapPoint(p1, fframe.getAt());
|
|
291 |
p2 = functions.toMapPoint(p2, fframe.getAt());
|
|
297 | 292 |
|
298 |
// Borramos el anterior
|
|
299 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
293 |
// Borramos el anterior
|
|
294 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
300 | 295 |
|
301 |
if (java.lang.Math.abs(p1.getX() - p2.getX()) <= 3) {
|
|
302 |
double nuevoX;
|
|
303 |
double nuevoY;
|
|
304 |
double cX;
|
|
305 |
double cY;
|
|
296 |
if (java.lang.Math.abs(p1.getX() - p2.getX()) <= 3) {
|
|
297 |
double nuevoX;
|
|
298 |
double nuevoY;
|
|
299 |
double cX;
|
|
300 |
double cY;
|
|
306 | 301 |
|
307 |
cX = p2.getX();
|
|
308 |
cY = p2.getY();
|
|
302 |
cX = p2.getX();
|
|
303 |
cY = p2.getY();
|
|
309 | 304 |
|
310 |
double factor = 0.6;
|
|
311 |
Rectangle2D.Double r = new Rectangle2D.Double();
|
|
305 |
double factor = 0.6;
|
|
306 |
Rectangle2D.Double r = new Rectangle2D.Double();
|
|
312 | 307 |
|
313 |
nuevoX = cX - |
|
314 |
((fframe.getFMap().getViewPort().getExtent().getWidth() * factor) / 2.0); |
|
315 |
nuevoY = cY - |
|
316 |
((fframe.getFMap().getViewPort().getExtent().getHeight() * factor) / 2.0); |
|
317 |
r.x = nuevoX; |
|
318 |
r.y = nuevoY; |
|
319 |
r.width = fframe.getFMap().getViewPort().getExtent().getWidth() * factor; |
|
320 |
r.height = fframe.getFMap().getViewPort().getExtent().getHeight() * factor; |
|
308 |
nuevoX = cX - |
|
309 |
((fframe.getFMap().getViewPort().getExtent() |
|
310 |
.getWidth() * factor) / 2.0); |
|
311 |
nuevoY = cY - |
|
312 |
((fframe.getFMap().getViewPort().getExtent() |
|
313 |
.getHeight() * factor) / 2.0); |
|
314 |
r.x = nuevoX; |
|
315 |
r.y = nuevoY; |
|
316 |
r.width = fframe.getFMap().getViewPort().getExtent() |
|
317 |
.getWidth() * factor; |
|
318 |
r.height = fframe.getFMap().getViewPort().getExtent() |
|
319 |
.getHeight() * factor; |
|
321 | 320 |
|
322 | 321 |
fframe.setNewExtent(r); |
323 |
} else {
|
|
324 |
// Fijamos el nuevo extent
|
|
325 |
Rectangle2D.Double r = new Rectangle2D.Double();
|
|
322 |
} else {
|
|
323 |
// Fijamos el nuevo extent
|
|
324 |
Rectangle2D.Double r = new Rectangle2D.Double();
|
|
326 | 325 |
|
327 |
r.setFrameFromDiagonal(p1, p2);
|
|
326 |
r.setFrameFromDiagonal(p1, p2);
|
|
328 | 327 |
|
329 |
fframe.setNewExtent(r);
|
|
330 |
}
|
|
328 |
fframe.setNewExtent(r);
|
|
329 |
}
|
|
331 | 330 |
|
332 |
// Fin del else
|
|
333 |
layout.repaint();
|
|
334 |
}
|
|
335 |
}
|
|
336 |
}
|
|
337 |
}
|
|
331 |
// Fin del else
|
|
332 |
layout.repaint();
|
|
333 |
}
|
|
334 |
}
|
|
335 |
}
|
|
336 |
}
|
|
338 | 337 |
|
339 |
/**
|
|
340 |
* DOCUMENT ME!
|
|
341 |
*
|
|
342 |
* @param p2 DOCUMENT ME!
|
|
343 |
*/
|
|
344 |
public void setViewZoomOut(Point p2) {
|
|
345 |
Point2D.Double pWorld;
|
|
338 |
/**
|
|
339 |
* Realiza un zoom menos sobre la vista del FFrameView seleccionado.
|
|
340 |
*
|
|
341 |
* @param p2 Punto sobre el que realizar el zoom menos.
|
|
342 |
*/
|
|
343 |
public void setViewZoomOut(Point p2) {
|
|
344 |
Point2D.Double pWorld;
|
|
346 | 345 |
|
347 |
for (int i = 0; i < layout.getFFrames().size(); i++) {
|
|
348 |
if (layout.getFFrames().get(i) instanceof FFrameView) {
|
|
349 |
FFrameView fframe = (FFrameView) layout.getFFrames().get(i);
|
|
346 |
for (int i = 0; i < layout.getFFrames().size(); i++) {
|
|
347 |
if (layout.getFFrames().get(i) instanceof FFrameView) {
|
|
348 |
FFrameView fframe = (FFrameView) layout.getFFrames().get(i);
|
|
350 | 349 |
|
351 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
|
352 |
double nuevoX;
|
|
353 |
double nuevoY;
|
|
354 |
double cX;
|
|
355 |
double cY;
|
|
356 |
Point pScreen = new Point((int) p2.getX(), (int) p2.getY());
|
|
357 |
pWorld = functions.toMapPoint(pScreen,fframe.getAt());
|
|
350 |
if (fframe.getSelected() != FFrame.NOSELECT) {
|
|
351 |
double nuevoX;
|
|
352 |
double nuevoY;
|
|
353 |
double cX;
|
|
354 |
double cY;
|
|
355 |
Point pScreen = new Point((int) p2.getX(), (int) p2.getY());
|
|
356 |
pWorld = functions.toMapPoint(pScreen, fframe.getAt());
|
|
358 | 357 |
|
359 |
cX = pWorld.getX();
|
|
360 |
cY = pWorld.getY();
|
|
358 |
cX = pWorld.getX();
|
|
359 |
cY = pWorld.getY();
|
|
361 | 360 |
|
362 |
double factor = 1.8;
|
|
363 |
Rectangle2D.Double r = new Rectangle2D.Double();
|
|
361 |
double factor = 1.8;
|
|
362 |
Rectangle2D.Double r = new Rectangle2D.Double();
|
|
364 | 363 |
|
365 |
nuevoX = cX - |
|
366 |
((fframe.getFMap().getViewPort().getExtent().getWidth() * factor) / 2.0); |
|
367 |
nuevoY = cY - |
|
368 |
((fframe.getFMap().getViewPort().getExtent().getHeight() * factor) / 2.0); |
|
369 |
r.x = nuevoX; |
|
370 |
r.y = nuevoY; |
|
371 |
r.width = fframe.getFMap().getViewPort().getExtent().getWidth() * factor; |
|
372 |
r.height = fframe.getFMap().getViewPort().getExtent().getHeight() * factor; |
|
364 |
nuevoX = cX - |
|
365 |
((fframe.getFMap().getViewPort().getExtent().getWidth() * factor) / 2.0); |
|
366 |
nuevoY = cY - |
|
367 |
((fframe.getFMap().getViewPort().getExtent().getHeight() * factor) / 2.0); |
|
368 |
r.x = nuevoX; |
|
369 |
r.y = nuevoY; |
|
370 |
r.width = fframe.getFMap().getViewPort().getExtent() |
|
371 |
.getWidth() * factor; |
|
372 |
r.height = fframe.getFMap().getViewPort().getExtent() |
|
373 |
.getHeight() * factor; |
|
373 | 374 |
|
374 | 375 |
fframe.setNewExtent(r); |
375 |
///fframe.getFMap().setCancelDrawing(false); |
|
376 |
} |
|
377 |
} |
|
378 |
} |
|
379 |
} |
|
376 |
|
|
377 |
///fframe.getFMap().setCancelDrawing(false); |
|
378 |
} |
|
379 |
} |
|
380 |
} |
|
381 |
} |
|
380 | 382 |
} |
Also available in: Unified diff