Revision 9392 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/FLayoutFunctions.java
FLayoutFunctions.java | ||
---|---|---|
51 | 51 |
import java.awt.geom.Point2D; |
52 | 52 |
import java.awt.geom.Rectangle2D; |
53 | 53 |
|
54 |
import com.iver.cit.gvsig.gui.layout.Layout; |
|
55 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics; |
|
56 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGroup; |
|
57 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameLegend; |
|
58 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameNorth; |
|
59 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameOverView; |
|
60 |
import com.iver.cit.gvsig.gui.layout.fframes.FFramePicture; |
|
61 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameScaleBar; |
|
62 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameTable; |
|
63 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameText; |
|
64 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView; |
|
65 | 54 |
import com.iver.cit.gvsig.project.documents.layout.commands.EditableFeatureSource; |
55 |
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameGroup; |
|
66 | 56 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
67 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameLayoutDependence; |
|
68 | 57 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameUseFMap; |
58 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
|
69 | 59 |
|
70 | 60 |
|
71 | 61 |
/** |
72 |
* Funciones utilizadas desde la clase EventsHandler.
|
|
62 |
* Funciones utilizadas desde el Layout.
|
|
73 | 63 |
* |
74 | 64 |
* @author Vicente Caballero Navarro |
75 | 65 |
*/ |
... | ... | |
91 | 81 |
public void setSelect() { |
92 | 82 |
IFFrame fframe = null; |
93 | 83 |
boolean isUpdate = false; |
94 |
layout.updateFFrames(); |
|
95 |
IFFrame[] fframes=layout.getFFrames(); |
|
96 |
EditableFeatureSource efs=layout.getEFS(); |
|
84 |
layout.getLayoutContext().updateFFrames();
|
|
85 |
IFFrame[] fframes=layout.getLayoutContext().getFFrames();
|
|
86 |
EditableFeatureSource efs=layout.getLayoutContext().getEFS();
|
|
97 | 87 |
efs.startComplexCommand(); |
98 | 88 |
for (int i = 0; i < fframes.length; i++) { |
99 | 89 |
fframe = fframes[i]; |
100 | 90 |
|
101 |
int difx = (layout.getLastPoint().x - layout.getFirstPoint().x);
|
|
102 |
int dify = (layout.getLastPoint().y - layout.getFirstPoint().y);
|
|
91 |
int difx = (layout.getLayoutControl().getLastPoint().x - layout.getLayoutControl().getFirstPoint().x);
|
|
92 |
int dify = (layout.getLayoutControl().getLastPoint().y - layout.getLayoutControl().getFirstPoint().y);
|
|
103 | 93 |
|
104 | 94 |
if (((Math.abs(difx) > 3) || (Math.abs(dify) > 3)) && |
105 | 95 |
(fframe.getSelected() != IFFrame.NOSELECT)) { |
... | ... | |
114 | 104 |
// } |
115 | 105 |
|
116 | 106 |
if (fframe instanceof FFrameGroup) { |
117 |
((FFrameGroup) fframe).setAt(layout.getAT()); |
|
107 |
((FFrameGroup) fframe).setAt(layout.getLayoutControl().getAT());
|
|
118 | 108 |
} |
119 | 109 |
|
120 | 110 |
IFFrame fframeAux=fframe.cloneFFrame(layout); |
121 | 111 |
fframeAux.setBoundBox(FLayoutUtilities.toSheetRect(rectangle, |
122 |
layout.getAT())); |
|
112 |
layout.getLayoutControl().getAT()));
|
|
123 | 113 |
if (fframeAux instanceof IFFrameUseFMap) |
124 | 114 |
((IFFrameUseFMap)fframeAux).refresh(); |
125 | 115 |
efs.modifyFFrame(fframe,fframeAux); |
126 |
fframeAux.getBoundingBox(layout.getAT()); |
|
116 |
fframeAux.getBoundingBox(layout.getLayoutControl().getAT());
|
|
127 | 117 |
|
128 | 118 |
isUpdate = true; |
129 | 119 |
} |
130 | 120 |
Rectangle rect=null; |
131 |
if (layout.getReSel()==null){ |
|
121 |
if (layout.getLayoutControl().getReSel()==null){
|
|
132 | 122 |
rect=new Rectangle(); |
133 |
rect.setFrameFromDiagonal(layout.getFirstPoint(), layout.getLastPoint());
|
|
123 |
rect.setFrameFromDiagonal(layout.getLayoutControl().getFirstPoint(), layout.getLayoutControl().getLastPoint());
|
|
134 | 124 |
}else{ |
135 |
rect=layout.getReSel(); |
|
125 |
rect=layout.getLayoutControl().getReSel();
|
|
136 | 126 |
} |
137 |
if (layout.isReSel() && |
|
127 |
if (layout.getLayoutControl().isReSel() &&
|
|
138 | 128 |
(rect.contains(fframe.getBoundingBox( |
139 |
layout.getAT())))) { |
|
129 |
layout.getLayoutControl().getAT())))) {
|
|
140 | 130 |
fframe.setSelected(true); |
141 | 131 |
} |
142 | 132 |
|
143 | 133 |
if (isUpdate) { |
144 |
layout.setStatus(Layout.DESACTUALIZADO);
|
|
134 |
layout.getLayoutControl().setStatus(LayoutControl.DESACTUALIZADO);
|
|
145 | 135 |
|
146 | 136 |
} else { |
147 |
layout.setStatus(Layout.ACTUALIZADO);
|
|
137 |
layout.getLayoutControl().setStatus(LayoutControl.ACTUALIZADO);
|
|
148 | 138 |
} |
149 | 139 |
} |
150 | 140 |
efs.endComplexCommand("move"); |
151 |
layout.updateFFrames(); |
|
152 |
layout.setIsReSel(true); |
|
141 |
layout.getLayoutContext().updateFFrames(); |
|
153 | 142 |
} |
154 | 143 |
|
155 | 144 |
/** |
... | ... | |
157 | 146 |
* para configurar las caracter?sticas. |
158 | 147 |
* @return TODO |
159 | 148 |
*/ |
160 |
public IFFrame addFFrame() { |
|
161 |
IFFrame fframe = null; |
|
162 |
boolean isadd = false; |
|
149 |
// public IFFrame addFFrame() { |
|
150 |
// IFFrame fframe = null; |
|
151 |
// boolean isadd = false; |
|
152 |
// |
|
153 |
// if (layout.getTool() == Layout.RECTANGLEVIEW) { |
|
154 |
// fframe = new FFrameView(); |
|
155 |
// isadd = true; |
|
156 |
// } else if (layout.getTool() == Layout.RECTANGLEOVERVIEW) { |
|
157 |
// fframe = new FFrameOverView(); |
|
158 |
// isadd = true; |
|
159 |
// } else if (layout.getTool() == Layout.RECTANGLEPICTURE) { |
|
160 |
// fframe = new FFramePicture(); |
|
161 |
// isadd = true; |
|
162 |
// } else if (layout.getTool() == Layout.RECTANGLESCALEBAR) { |
|
163 |
// fframe = new FFrameScaleBar(); |
|
164 |
// isadd = true; |
|
165 |
// } else if (layout.getTool() == Layout.RECTANGLELEGEND) { |
|
166 |
// fframe = new FFrameLegend(); |
|
167 |
// isadd = true; |
|
168 |
// } else if (layout.getTool() == Layout.RECTANGLETEXT) { |
|
169 |
// fframe = new FFrameText(); |
|
170 |
// isadd = true; |
|
171 |
// } else if (layout.getTool() == Layout.RECTANGLENORTH) { |
|
172 |
// fframe = new FFrameNorth(); |
|
173 |
// isadd = true; |
|
174 |
// } else if (layout.getTool() == Layout.RECTANGLEBOX) { |
|
175 |
// fframe = new FFrameTable(); |
|
176 |
// isadd = true; |
|
177 |
// } else if ((layout.getTool() == Layout.LINE) || |
|
178 |
// (layout.getTool() == Layout.POLYLINE) || |
|
179 |
// (layout.getTool() == Layout.POLYGON) || |
|
180 |
// (layout.getTool() == Layout.CIRCLE) || |
|
181 |
// (layout.getTool() == Layout.RECTANGLESIMPLE) || |
|
182 |
// (layout.getTool() == Layout.POINT)) { |
|
183 |
// fframe = new FFrameGraphics(); |
|
184 |
// ((FFrameGraphics)fframe).setGeometryAdapter(layout.getGeometryAdapter()); |
|
185 |
// isadd = false; |
|
186 |
// ((FFrameGraphics) fframe).update(layout.getTool(), layout.getAT()); |
|
187 |
// } /*else if ((layout.getTool() == Layout.POINT)){ |
|
188 |
// fframe = new FFrameGraphics(); |
|
189 |
// isadd = true; |
|
190 |
// ((FFrameGraphics) fframe).update(layout.getTool(), layout.getAT()); |
|
191 |
// }*/ |
|
192 |
// if (isadd) { |
|
193 |
// Rectangle2D r = new Rectangle2D.Double(); //rectOrigin.x+m_PointAnt.x,rectOrigin.y+m_PointAnt.y,m_LastPoint.x-m_PointAnt.x,m_LastPoint.y-m_PointAnt.y); |
|
194 |
// int tolerance=20; |
|
195 |
// r=getRectangle(tolerance); |
|
196 |
// |
|
197 |
//// if (layout.isAdjustingToGrid()) { |
|
198 |
//// //cuadrar con la cuadr?cula dibujada y despu?s en el mouseReleased guardar ese rect?ngulo de la misma forma. |
|
199 |
//// FLayoutUtilities.setRectGrid(r, |
|
200 |
//// layout.getAtributes().getUnitInPixelsX(), |
|
201 |
//// layout.getAtributes().getUnitInPixelsY(), layout.getAT()); |
|
202 |
//// } |
|
203 |
// |
|
204 |
// fframe.setBoundBox(FLayoutUtilities.toSheetRect(r, layout.getAT())); |
|
205 |
// IFFrame newFrame=layout.openFFrameDialog(fframe); |
|
206 |
// if (newFrame!=null) { |
|
207 |
// if (!layout.isEditGroup()){ |
|
208 |
// layout.addFFrame(newFrame, true,true); |
|
209 |
// } |
|
210 |
// } |
|
211 |
// }else{ |
|
212 |
// if (layout.getTool() == Layout.POINT){ |
|
213 |
// Rectangle2D r=layout.getGeometryAdapter().getBounds2D(); |
|
214 |
// double d=0.5;//FLayoutUtilities.toSheetDistance(50,layout.getAT()); |
|
215 |
// r=new Rectangle2D.Double(r.getX()-(d/2),r.getY()-d,d*2,d*2); |
|
216 |
// fframe.setBoundBox(r); |
|
217 |
// }else{ |
|
218 |
// fframe.setBoundBox(layout.getGeometryAdapter().getBounds2D()); |
|
219 |
// } |
|
220 |
// layout.addFFrame(fframe, true,true); |
|
221 |
// ///fframe.setBoundBox(FLayoutUtilities.toSheetRect(r, layout.getAT())); |
|
222 |
// } |
|
223 |
// fframe.setLayout(layout); |
|
224 |
// return fframe; |
|
225 |
// } |
|
163 | 226 |
|
164 |
if (layout.getTool() == Layout.RECTANGLEVIEW) { |
|
165 |
fframe = new FFrameView(); |
|
166 |
((IFFrameLayoutDependence)fframe).setLayout(layout); |
|
167 |
isadd = true; |
|
168 |
} else if (layout.getTool() == Layout.RECTANGLEOVERVIEW) { |
|
169 |
fframe = new FFrameOverView(); |
|
170 |
((IFFrameLayoutDependence)fframe).setLayout(layout); |
|
171 |
isadd = true; |
|
172 |
} else if (layout.getTool() == Layout.RECTANGLEPICTURE) { |
|
173 |
fframe = new FFramePicture(); |
|
174 |
isadd = true; |
|
175 |
} else if (layout.getTool() == Layout.RECTANGLESCALEBAR) { |
|
176 |
fframe = new FFrameScaleBar(); |
|
177 |
isadd = true; |
|
178 |
} else if (layout.getTool() == Layout.RECTANGLELEGEND) { |
|
179 |
fframe = new FFrameLegend(); |
|
180 |
isadd = true; |
|
181 |
} else if (layout.getTool() == Layout.RECTANGLETEXT) { |
|
182 |
fframe = new FFrameText(); |
|
183 |
isadd = true; |
|
184 |
} else if (layout.getTool() == Layout.RECTANGLENORTH) { |
|
185 |
fframe = new FFrameNorth(); |
|
186 |
isadd = true; |
|
187 |
} else if (layout.getTool() == Layout.RECTANGLEBOX) { |
|
188 |
fframe = new FFrameTable(); |
|
189 |
isadd = true; |
|
190 |
} else if ((layout.getTool() == Layout.LINE) || |
|
191 |
(layout.getTool() == Layout.POLYLINE) || |
|
192 |
(layout.getTool() == Layout.POLYGON) || |
|
193 |
(layout.getTool() == Layout.CIRCLE) || |
|
194 |
(layout.getTool() == Layout.RECTANGLESIMPLE) || |
|
195 |
(layout.getTool() == Layout.POINT)) { |
|
196 |
fframe = new FFrameGraphics(); |
|
197 |
((FFrameGraphics)fframe).setGeometryAdapter(layout.getGeometryAdapter()); |
|
198 |
isadd = false; |
|
199 |
((FFrameGraphics) fframe).update(layout.getTool(), layout.getAT()); |
|
200 |
} /*else if ((layout.getTool() == Layout.POINT)){ |
|
201 |
fframe = new FFrameGraphics(); |
|
202 |
isadd = true; |
|
203 |
((FFrameGraphics) fframe).update(layout.getTool(), layout.getAT()); |
|
204 |
}*/ |
|
205 |
if (isadd) { |
|
206 |
Rectangle2D r = new Rectangle2D.Double(); //rectOrigin.x+m_PointAnt.x,rectOrigin.y+m_PointAnt.y,m_LastPoint.x-m_PointAnt.x,m_LastPoint.y-m_PointAnt.y); |
|
207 |
int tolerance=20; |
|
208 |
r=getRectangle(tolerance); |
|
209 |
|
|
210 |
// if (layout.isAdjustingToGrid()) { |
|
211 |
// //cuadrar con la cuadr?cula dibujada y despu?s en el mouseReleased guardar ese rect?ngulo de la misma forma. |
|
212 |
// FLayoutUtilities.setRectGrid(r, |
|
213 |
// layout.getAtributes().getUnitInPixelsX(), |
|
214 |
// layout.getAtributes().getUnitInPixelsY(), layout.getAT()); |
|
227 |
// private Rectangle2D getRectangle(int tolerance) { |
|
228 |
// Rectangle2D r=new Rectangle2D.Double(); |
|
229 |
// if (isCorrectSize(tolerance,layout.getFirstPoint(),layout.getLastPoint())){ |
|
230 |
// Point2D fp=layout.getFirstPoint(); |
|
231 |
// Point2D lp=layout.getLastPoint(); |
|
232 |
// if (fp.getX()<lp.getX()){ |
|
233 |
// if (fp.getY()<lp.getY()){ |
|
234 |
// r.setRect(fp.getX(),fp.getY(),lp.getX()-fp.getX(),lp.getY()-fp.getY()); |
|
235 |
// }else{ |
|
236 |
// r.setRect(fp.getX(),lp.getY(),lp.getX()-fp.getX(),fp.getY()-lp.getY()); |
|
237 |
// } |
|
238 |
// }else{ |
|
239 |
// if (fp.getY()>lp.getY()){ |
|
240 |
// r.setRect(lp.getX(),lp.getY(),fp.getX()-lp.getX(),fp.getY()-lp.getY()); |
|
241 |
// }else{ |
|
242 |
// r.setRect(lp.getX(),fp.getY(),lp.getX()-fp.getX(),lp.getY()-fp.getY()); |
|
243 |
// } |
|
215 | 244 |
// } |
245 |
// }else{ |
|
246 |
// Point2D p1=layout.getFirstPoint(); |
|
247 |
// p1=new Point2D.Double(p1.getX()+tolerance,p1.getY()+tolerance); |
|
248 |
// r.setFrameFromDiagonal(layout.getFirstPoint(),p1); |
|
249 |
// } |
|
250 |
// return r; |
|
251 |
// } |
|
216 | 252 |
|
217 |
fframe.setBoundBox(FLayoutUtilities.toSheetRect(r, layout.getAT())); |
|
218 |
IFFrame newFrame=layout.openFFrameDialog(fframe); |
|
219 |
if (newFrame!=null) { |
|
220 |
if (!layout.isEditGroup()){ |
|
221 |
layout.addFFrame(newFrame, true,true); |
|
222 |
} |
|
223 |
} |
|
224 |
}else{ |
|
225 |
if (layout.getTool() == Layout.POINT){ |
|
226 |
Rectangle2D r=layout.getGeometryAdapter().getBounds2D(); |
|
227 |
double d=0.5;//FLayoutUtilities.toSheetDistance(50,layout.getAT()); |
|
228 |
r=new Rectangle2D.Double(r.getX()-(d/2),r.getY()-d,d*2,d*2); |
|
229 |
fframe.setBoundBox(r); |
|
230 |
}else{ |
|
231 |
fframe.setBoundBox(layout.getGeometryAdapter().getBounds2D()); |
|
232 |
} |
|
233 |
layout.addFFrame(fframe, true,true); |
|
234 |
///fframe.setBoundBox(FLayoutUtilities.toSheetRect(r, layout.getAT())); |
|
235 |
} |
|
236 |
return fframe; |
|
237 |
} |
|
238 |
|
|
239 |
private Rectangle2D getRectangle(int tolerance) { |
|
240 |
Rectangle2D r=new Rectangle2D.Double(); |
|
241 |
if (isCorrectSize(tolerance,layout.getFirstPoint(),layout.getLastPoint())){ |
|
242 |
Point2D fp=layout.getFirstPoint(); |
|
243 |
Point2D lp=layout.getLastPoint(); |
|
244 |
if (fp.getX()<lp.getX()){ |
|
245 |
if (fp.getY()<lp.getY()){ |
|
246 |
r.setRect(fp.getX(),fp.getY(),lp.getX()-fp.getX(),lp.getY()-fp.getY()); |
|
247 |
}else{ |
|
248 |
r.setRect(fp.getX(),lp.getY(),lp.getX()-fp.getX(),fp.getY()-lp.getY()); |
|
249 |
} |
|
250 |
}else{ |
|
251 |
if (fp.getY()>lp.getY()){ |
|
252 |
r.setRect(lp.getX(),lp.getY(),fp.getX()-lp.getX(),fp.getY()-lp.getY()); |
|
253 |
}else{ |
|
254 |
r.setRect(lp.getX(),fp.getY(),lp.getX()-fp.getX(),lp.getY()-fp.getY()); |
|
255 |
} |
|
256 |
} |
|
257 |
}else{ |
|
258 |
Point2D p1=layout.getFirstPoint(); |
|
259 |
p1=new Point2D.Double(p1.getX()+tolerance,p1.getY()+tolerance); |
|
260 |
r.setFrameFromDiagonal(layout.getFirstPoint(),p1); |
|
261 |
} |
|
262 |
return r; |
|
263 |
} |
|
264 |
|
|
265 | 253 |
/** |
266 | 254 |
* Pan sobre la vista del FFrameView. |
267 | 255 |
* |
... | ... | |
269 | 257 |
* @param p2 Punto final del desplazamiento. |
270 | 258 |
*/ |
271 | 259 |
public void setViewPan(Point p1, Point p2) { |
272 |
IFFrame[] fframes=layout.getFFrames(); |
|
260 |
IFFrame[] fframes=layout.getLayoutContext().getFFrames();
|
|
273 | 261 |
for (int i = 0; i < fframes.length; i++) { |
274 | 262 |
if (fframes[i] instanceof IFFrameUseFMap) { |
275 | 263 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
... | ... | |
285 | 273 |
r.width = extent.getWidth(); |
286 | 274 |
r.height = extent.getHeight(); |
287 | 275 |
fframe.getMapContext().getViewPort().setExtent(r); |
276 |
fframe.refresh(); |
|
288 | 277 |
} |
289 | 278 |
} |
290 | 279 |
} |
... | ... | |
323 | 312 |
* |
324 | 313 |
* @return True si el tama?o es correcto. |
325 | 314 |
*/ |
326 |
private boolean isCorrectSize(int tolerance, Point2D p1, Point2D p2) { |
|
327 |
if (Math.abs(p2.getX()-p1.getX())<tolerance) { |
|
328 |
return false; |
|
329 |
} else if (Math.abs(p2.getY()-p1.getY())<tolerance) { |
|
330 |
return false; |
|
331 |
} |
|
332 |
return true; |
|
333 |
} |
|
315 |
// private boolean isCorrectSize(int tolerance, Point2D p1, Point2D p2) {
|
|
316 |
// if (Math.abs(p2.getX()-p1.getX())<tolerance) {
|
|
317 |
// return false;
|
|
318 |
// } else if (Math.abs(p2.getY()-p1.getY())<tolerance) {
|
|
319 |
// return false;
|
|
320 |
// }
|
|
321 |
// return true;
|
|
322 |
// }
|
|
334 | 323 |
} |
Also available in: Unified diff