root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / LayoutControl.java @ 9392
History | View | Annotate | Download (22.4 KB)
1 |
package com.iver.cit.gvsig.project.documents.layout; |
---|---|
2 |
|
3 |
|
4 |
import java.awt.Color; |
5 |
import java.awt.Cursor; |
6 |
import java.awt.Graphics; |
7 |
import java.awt.Graphics2D; |
8 |
import java.awt.Image; |
9 |
import java.awt.Point; |
10 |
import java.awt.Rectangle; |
11 |
import java.awt.Toolkit; |
12 |
import java.awt.geom.AffineTransform; |
13 |
import java.awt.geom.Rectangle2D; |
14 |
import java.awt.image.BufferedImage; |
15 |
import java.awt.image.MemoryImageSource; |
16 |
import java.util.HashMap; |
17 |
|
18 |
import javax.swing.JComponent; |
19 |
|
20 |
import com.iver.cit.gvsig.fmap.DriverException; |
21 |
import com.iver.cit.gvsig.fmap.core.adapter.GeometryAdapter; |
22 |
import com.iver.cit.gvsig.fmap.core.adapter.PolyLineAdapter; |
23 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
24 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameEditableVertex; |
25 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameUseFMap; |
26 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
27 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddBoxListenerImpl; |
28 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddCircleListenerImpl; |
29 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddLegendListenerImpl; |
30 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddLineListenerImpl; |
31 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddNorthListenerImpl; |
32 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddOverViewListenerImpl; |
33 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPictureListenerImpl; |
34 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPointListenerImpl; |
35 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPolygonListenerImpl; |
36 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPolylineListenerImpl; |
37 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddRectangleListenerImpl; |
38 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddScaleListenerImpl; |
39 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddTextListenerImpl; |
40 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddViewListenerImpl; |
41 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutEditGraphicsListenerImpl; |
42 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutPanListenerImpl; |
43 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutSelectListenerImpl; |
44 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutViewPanListenerImpl; |
45 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutViewZoomInListenerImpl; |
46 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutViewZoomOutListenerImpl; |
47 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutZoomInListenerImpl; |
48 |
import com.iver.cit.gvsig.project.documents.layout.tools.LayoutZoomOutListenerImpl; |
49 |
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutBehavior; |
50 |
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutEditBehavior; |
51 |
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutMoveBehavior; |
52 |
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutPointBehavior; |
53 |
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutRectangleBehavior; |
54 |
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutSelectBehavior; |
55 |
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutViewMoveBehavior; |
56 |
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutZoomBehavior; |
57 |
import com.iver.cit.gvsig.project.documents.layout.tools.listener.ILayoutGraphicListener; |
58 |
|
59 |
/**
|
60 |
* Control del Layout.
|
61 |
*
|
62 |
* @author Vicente Caballero Navarro
|
63 |
*/
|
64 |
public class LayoutControl extends JComponent { |
65 |
public static final int DESACTUALIZADO = 4; |
66 |
public static final int ACTUALIZADO = 5; |
67 |
private int status = DESACTUALIZADO; |
68 |
private Rectangle2D rectVisible; |
69 |
private BufferedImage img = null; |
70 |
private BufferedImage imgRuler = null; |
71 |
private boolean initial = true; |
72 |
private LayoutContext layoutContext;
|
73 |
private Point origin = new Point(50, 50); |
74 |
private Point rectOrigin = new Point(origin); |
75 |
private Rectangle2D.Double rect = new Rectangle2D.Double(rectOrigin.x, |
76 |
rectOrigin.y, 400, 300); |
77 |
private FLayoutDraw layoutDraw = null; |
78 |
private FLayoutFunctions layoutFunctions = null; |
79 |
private LayoutBehavior currentLayoutTool = null; |
80 |
private Image imageCursor=null; |
81 |
private HashMap namesLayoutTools = new HashMap(); |
82 |
private Point m_FirstPoint = new Point(0, 0); |
83 |
private Point m_PointAnt = new Point(0, 0); |
84 |
private Point m_LastPoint = new Point(0, 0); |
85 |
private LayoutEvents layoutEvents;
|
86 |
private Point position; |
87 |
private AffineTransform m_MatrizTransf; |
88 |
private GeometryAdapter geometryAdapter = new PolyLineAdapter(); |
89 |
|
90 |
//private String prevTool;
|
91 |
|
92 |
private String currentTool; |
93 |
private boolean m_bCancelDrawing = false; |
94 |
private Rectangle reSel = null; |
95 |
private boolean isReSel = true; |
96 |
|
97 |
private FLayoutZooms layoutZooms;
|
98 |
private Point pointToMove=new Point(); |
99 |
|
100 |
public LayoutControl(Layout layout) {
|
101 |
layoutContext=layout.getLayoutContext(); |
102 |
layoutDraw = new FLayoutDraw(layout);
|
103 |
layoutEvents = new LayoutEvents(layout);
|
104 |
layoutZooms=new FLayoutZooms(layout);
|
105 |
layoutFunctions=new FLayoutFunctions(layout);
|
106 |
addComponentListener(layoutEvents); |
107 |
addMouseMotionListener(layoutEvents); |
108 |
addMouseListener(layoutEvents); |
109 |
m_MatrizTransf = new AffineTransform(); |
110 |
m_MatrizTransf.setToIdentity(); |
111 |
layoutContext.updateFFrames(); |
112 |
LayoutPanListenerImpl lpl = new LayoutPanListenerImpl(layout);
|
113 |
addLayoutTool("layoutpan", new LayoutMoveBehavior(lpl)); |
114 |
|
115 |
LayoutZoomInListenerImpl lzil = new LayoutZoomInListenerImpl(layout);
|
116 |
addLayoutTool("layoutzoomin", new LayoutZoomBehavior(lzil)); |
117 |
|
118 |
LayoutZoomOutListenerImpl lzol = new LayoutZoomOutListenerImpl(layout);
|
119 |
addLayoutTool("layoutzoomout", new LayoutZoomBehavior(lzol)); |
120 |
|
121 |
LayoutAddViewListenerImpl lavl = new LayoutAddViewListenerImpl(layout);
|
122 |
addLayoutTool("layoutaddview", new LayoutRectangleBehavior(lavl)); |
123 |
|
124 |
LayoutAddOverViewListenerImpl laovl = new LayoutAddOverViewListenerImpl(layout);
|
125 |
addLayoutTool("layoutaddoverview", new LayoutRectangleBehavior(laovl)); |
126 |
|
127 |
LayoutAddPictureListenerImpl lapl = new LayoutAddPictureListenerImpl(layout);
|
128 |
addLayoutTool("layoutaddpicture", new LayoutRectangleBehavior(lapl)); |
129 |
|
130 |
LayoutAddNorthListenerImpl lanorthl = new LayoutAddNorthListenerImpl(layout);
|
131 |
addLayoutTool("layoutaddnorth", new LayoutRectangleBehavior(lanorthl)); |
132 |
|
133 |
LayoutAddScaleListenerImpl lasl = new LayoutAddScaleListenerImpl(layout);
|
134 |
addLayoutTool("layoutaddscale", new LayoutRectangleBehavior(lasl)); |
135 |
|
136 |
LayoutAddLegendListenerImpl lall = new LayoutAddLegendListenerImpl(layout);
|
137 |
addLayoutTool("layoutaddlegend", new LayoutRectangleBehavior(lall)); |
138 |
|
139 |
LayoutAddTextListenerImpl latl = new LayoutAddTextListenerImpl(layout);
|
140 |
addLayoutTool("layoutaddtext", new LayoutRectangleBehavior(latl)); |
141 |
|
142 |
LayoutAddBoxListenerImpl labl = new LayoutAddBoxListenerImpl(layout);
|
143 |
addLayoutTool("layoutaddbox", new LayoutRectangleBehavior(labl)); |
144 |
|
145 |
LayoutAddPointListenerImpl lapointl = new LayoutAddPointListenerImpl(layout);
|
146 |
addLayoutTool("layoutaddpoint", new LayoutPointBehavior(lapointl)); |
147 |
|
148 |
LayoutAddLineListenerImpl lalinel = new LayoutAddLineListenerImpl(layout);
|
149 |
addLayoutTool("layoutaddline", new LayoutPointBehavior(lalinel)); |
150 |
|
151 |
LayoutAddPolygonListenerImpl lapolygonl = new LayoutAddPolygonListenerImpl(layout);
|
152 |
addLayoutTool("layoutaddpolygon", new LayoutPointBehavior(lapolygonl)); |
153 |
|
154 |
LayoutAddPolylineListenerImpl lapolylinel = new LayoutAddPolylineListenerImpl(layout);
|
155 |
addLayoutTool("layoutaddpolyline", new LayoutPointBehavior(lapolylinel)); |
156 |
|
157 |
LayoutAddCircleListenerImpl lacirclel = new LayoutAddCircleListenerImpl(layout);
|
158 |
addLayoutTool("layoutaddcircle", new LayoutPointBehavior(lacirclel)); |
159 |
|
160 |
LayoutAddRectangleListenerImpl larectanglel = new LayoutAddRectangleListenerImpl(layout);
|
161 |
addLayoutTool("layoutaddrectangle", new LayoutPointBehavior(larectanglel)); |
162 |
|
163 |
LayoutViewPanListenerImpl lvpl = new LayoutViewPanListenerImpl(layout);
|
164 |
addLayoutTool("layoutviewpan", new LayoutViewMoveBehavior(lvpl)); |
165 |
|
166 |
LayoutViewZoomInListenerImpl lvzil = new LayoutViewZoomInListenerImpl(layout);
|
167 |
addLayoutTool("layoutviewzoomin", new LayoutViewMoveBehavior(lvzil)); |
168 |
|
169 |
LayoutViewZoomOutListenerImpl lvzol = new LayoutViewZoomOutListenerImpl(layout);
|
170 |
addLayoutTool("layoutviewzoomout", new LayoutViewMoveBehavior(lvzol)); |
171 |
|
172 |
LayoutSelectListenerImpl lselectl = new LayoutSelectListenerImpl(layout);
|
173 |
addLayoutTool("layoutselect", new LayoutSelectBehavior(lselectl)); |
174 |
|
175 |
LayoutEditGraphicsListenerImpl leditl = new LayoutEditGraphicsListenerImpl(layout);
|
176 |
addLayoutTool("layoutedit", new LayoutEditBehavior(leditl)); |
177 |
|
178 |
setTool("layoutzoomin");
|
179 |
} |
180 |
/**
|
181 |
* Returns the name of the current selected tool on this Layout
|
182 |
*
|
183 |
* @return A tool name.
|
184 |
*/
|
185 |
public String getCurrentTool() { |
186 |
return currentTool;
|
187 |
} |
188 |
|
189 |
public void addLayoutTool(String name, LayoutBehavior tool) { |
190 |
namesLayoutTools.put(name, tool); |
191 |
tool.setLayoutControl(this);
|
192 |
} |
193 |
|
194 |
public void setLayoutContext(LayoutContext lc) { |
195 |
layoutContext=lc; |
196 |
} |
197 |
/**
|
198 |
* paintComponent del Layout.
|
199 |
*
|
200 |
* @param g
|
201 |
* Graphics del Layout.
|
202 |
*/
|
203 |
protected void paintComponent(Graphics g) { |
204 |
clipVisibleRect((Graphics2D) g);
|
205 |
|
206 |
Rectangle rClip = g.getClipBounds();
|
207 |
|
208 |
if (rClip == null) { |
209 |
System.err.println("clip = null"); |
210 |
} |
211 |
|
212 |
switch (status) {
|
213 |
case DESACTUALIZADO:
|
214 |
//logger.debug("desactualizado");
|
215 |
if (getWidth()==0) |
216 |
return;
|
217 |
img = new BufferedImage(getWidth(), getHeight(), |
218 |
BufferedImage.TYPE_INT_ARGB);
|
219 |
imgRuler = new BufferedImage(getWidth(), getHeight(), |
220 |
BufferedImage.TYPE_INT_ARGB);
|
221 |
Graphics gimag = img.getGraphics();
|
222 |
Graphics gimgRuler = imgRuler.getGraphics();
|
223 |
clipVisibleRect((Graphics2D) gimag);
|
224 |
|
225 |
if (initial) {
|
226 |
fullRect(); |
227 |
initial = false;
|
228 |
} |
229 |
|
230 |
try {
|
231 |
layoutDraw.drawLayout((Graphics2D) gimag, img);
|
232 |
} catch (DriverException e) {
|
233 |
e.printStackTrace(); |
234 |
} |
235 |
g.setClip(rClip); |
236 |
layoutDraw.drawRectangle((Graphics2D) g);
|
237 |
|
238 |
g.drawImage(img, 0, 0, this); |
239 |
g.setClip(rClip); |
240 |
|
241 |
layoutDraw.drawGrid((Graphics2D) gimgRuler);
|
242 |
layoutDraw.drawRuler((Graphics2D) gimgRuler, Color.black); |
243 |
setStatus(ACTUALIZADO); |
244 |
repaint(); |
245 |
break;
|
246 |
|
247 |
case ACTUALIZADO:
|
248 |
layoutDraw.drawRectangle((Graphics2D) g);
|
249 |
|
250 |
if (currentLayoutTool != null) |
251 |
currentLayoutTool.paintComponent(g); |
252 |
else {
|
253 |
g.drawImage(img, 0, 0, this); |
254 |
|
255 |
layoutDraw.drawHandlers((Graphics2D) g, Color.black); |
256 |
} |
257 |
g.setClip(rClip); |
258 |
drawCursor(g); |
259 |
} |
260 |
|
261 |
} |
262 |
|
263 |
|
264 |
public void setStatus(int s) { |
265 |
status=s; |
266 |
} |
267 |
/**
|
268 |
* Clip sobre el rect?ngulo visible.
|
269 |
*
|
270 |
* @param g2d
|
271 |
* Graphics sobre el que hacer el clip.
|
272 |
*/
|
273 |
private void clipVisibleRect(Graphics2D g2d) { |
274 |
rectVisible = this.getVisibleRect();
|
275 |
g2d.clipRect((int) rectVisible.getMinX(), (int) rectVisible.getMinY(), |
276 |
(int) rectVisible.getWidth(), (int) rectVisible.getHeight()); |
277 |
} |
278 |
public BufferedImage getImgRuler() { |
279 |
return imgRuler;
|
280 |
} |
281 |
/**
|
282 |
* Obtiene el rect que se ajusta al tama?o de la ventana, para ver el folio
|
283 |
* entero.
|
284 |
*/
|
285 |
public void fullRect() { |
286 |
rect.setRect(origin.x, origin.y, getWidth() - (origin.x * 2),
|
287 |
getHeight() - (origin.x * 2));
|
288 |
|
289 |
if (layoutContext.getAtributes().isLandSpace()) {
|
290 |
rect = layoutContext.getAtributes().getRectangleLandscape(rect, getWidth(), |
291 |
getHeight()); |
292 |
} else {
|
293 |
rect = layoutContext.getAtributes().getRectanglePortrait(rect, getWidth(), |
294 |
getHeight()); |
295 |
} |
296 |
refresh(); |
297 |
} |
298 |
|
299 |
/**
|
300 |
* Devuelve el Rectangle2D que representa en pixels al folio.
|
301 |
*
|
302 |
* @return Rectangle2D.Double
|
303 |
*/
|
304 |
public Rectangle2D.Double getRect() { |
305 |
return rect;
|
306 |
} |
307 |
|
308 |
public void setRect(Rectangle2D r) { |
309 |
rect.setRect(r); |
310 |
} |
311 |
public BufferedImage getImage() { |
312 |
return img;
|
313 |
} |
314 |
private void drawCursor(Graphics g) { |
315 |
if (imageCursor!=null && position!=null) { |
316 |
Point pAdjusted=position;
|
317 |
// if (layoutContext.isAdjustingToGrid()&&
|
318 |
// getCurrentLayoutTool().isAdjustable()){
|
319 |
// pAdjusted=FLayoutUtilities.getPointGrid(position,layoutContext.getAtributes().getUnitInPixelsX(),
|
320 |
// layoutContext.getAtributes().getUnitInPixelsY(),
|
321 |
// m_MatrizTransf);
|
322 |
// }
|
323 |
g.drawImage(imageCursor,(int)pAdjusted.getX()-16,(int)pAdjusted.getY()-16,this); |
324 |
} |
325 |
} |
326 |
/**
|
327 |
* Sustituye el puntero del rat?n por la imagen que se le pasa como
|
328 |
* par?metro.
|
329 |
*
|
330 |
* @param image
|
331 |
*/
|
332 |
public void setMapCursor(Image image) { |
333 |
imageCursor=image; |
334 |
} |
335 |
/**
|
336 |
* DOCUMENT ME!
|
337 |
*
|
338 |
* @param toolName DOCUMENT ME!
|
339 |
*/
|
340 |
public void setTool(String toolName) { |
341 |
//prevTool=getCurrentTool();
|
342 |
LayoutBehavior layoutTool = (LayoutBehavior) namesLayoutTools.get(toolName); |
343 |
currentLayoutTool = layoutTool; |
344 |
currentLayoutTool.setLayoutControl(this);
|
345 |
currentTool = toolName; |
346 |
this.setMapCursor(layoutTool.getImageCursor());
|
347 |
if (getCurrentLayoutTool().getListener() instanceof ILayoutGraphicListener) { |
348 |
geometryAdapter=((ILayoutGraphicListener)getCurrentLayoutTool().getListener()).createGeometryAdapter(); |
349 |
} |
350 |
if (getCurrentTool().equals("layoutedit")) { |
351 |
startEdit(); |
352 |
} else{
|
353 |
stopEdit(); |
354 |
} |
355 |
} |
356 |
public void startEdit() { |
357 |
IFFrame[] fframes=layoutContext.getFFrames();
|
358 |
for (int i = 0; i < fframes.length; i++) { |
359 |
IFFrame frame = fframes[i]; |
360 |
if (frame instanceof IFFrameEditableVertex) { |
361 |
if (frame.getSelected() != IFFrame.NOSELECT) {
|
362 |
((IFFrameEditableVertex) frame).startEditing(); |
363 |
} else {
|
364 |
((IFFrameEditableVertex) frame).stopEditing(); |
365 |
} |
366 |
} |
367 |
|
368 |
} |
369 |
refresh(); |
370 |
} |
371 |
|
372 |
public void stopEdit() { |
373 |
boolean refresh = false; |
374 |
IFFrame[] fframes=layoutContext.getFFrames();
|
375 |
for (int i = 0; i < fframes.length; i++) { |
376 |
IFFrame frame = fframes[i]; |
377 |
if (frame instanceof IFFrameEditableVertex) { |
378 |
if (((IFFrameEditableVertex) frame).isEditing()) {
|
379 |
((IFFrameEditableVertex) fframes[i]).stopEditing(); |
380 |
refresh = true;
|
381 |
} |
382 |
} |
383 |
} |
384 |
if (refresh)
|
385 |
refresh(); |
386 |
} |
387 |
/**
|
388 |
* Devuelve el punto que representa la esquina noroeste del mapa.
|
389 |
*
|
390 |
* @return un punto.
|
391 |
*/
|
392 |
public Point getRectOrigin() { |
393 |
return rectOrigin;
|
394 |
} |
395 |
public FLayoutDraw getLayoutDraw() {
|
396 |
return layoutDraw;
|
397 |
} |
398 |
public LayoutBehavior getCurrentLayoutTool() {
|
399 |
return currentLayoutTool;
|
400 |
} |
401 |
/**
|
402 |
* Devuelve el punto del primer click de rat?n.
|
403 |
*
|
404 |
* @return un punto.
|
405 |
*/
|
406 |
public Point getFirstPoint() { |
407 |
return m_FirstPoint;
|
408 |
} |
409 |
|
410 |
/**
|
411 |
* Devuelve el punto de click de rat?n anterior.
|
412 |
*
|
413 |
* @return un punto.
|
414 |
*/
|
415 |
public Point getPointAnt() { |
416 |
return m_PointAnt;
|
417 |
} |
418 |
|
419 |
/**
|
420 |
* Devuelve el punto donde se solt? el bot?n del rat?n.
|
421 |
*
|
422 |
* @return un punto.
|
423 |
*/
|
424 |
public Point getLastPoint() { |
425 |
return m_LastPoint;
|
426 |
} |
427 |
|
428 |
/**
|
429 |
* Rellena el primer punto de click de rat?n.
|
430 |
*
|
431 |
* @param p
|
432 |
* punto.
|
433 |
*/
|
434 |
public void setFirstPoint() { |
435 |
// if (layoutContext.isAdjustingToGrid() && getCurrentLayoutTool().isAdjustable()) {
|
436 |
// m_FirstPoint = FLayoutUtilities.getPointGrid(position,layoutContext.getAtributes().getUnitInPixelsX(),layoutContext.getAtributes().getUnitInPixelsY(),m_MatrizTransf);
|
437 |
// }else {
|
438 |
m_FirstPoint=position; |
439 |
// }
|
440 |
} |
441 |
|
442 |
/**
|
443 |
* Rellena el punto de click de rat?n anterior.
|
444 |
*
|
445 |
* @param p
|
446 |
* punto.
|
447 |
*/
|
448 |
public void setPointAnt() { |
449 |
// if (layoutContext.isAdjustingToGrid()&& getCurrentLayoutTool().isAdjustable()) {
|
450 |
// m_PointAnt = FLayoutUtilities.getPointGrid(position,layoutContext.getAtributes().getUnitInPixelsX(),layoutContext.getAtributes().getUnitInPixelsY(),m_MatrizTransf);
|
451 |
// }else {
|
452 |
m_PointAnt=position; |
453 |
// }
|
454 |
} |
455 |
|
456 |
/**
|
457 |
* Rellena el punto donde se solto el bot?n del rat?n.
|
458 |
*
|
459 |
* @param p
|
460 |
* punto.
|
461 |
*/
|
462 |
public void setLastPoint() { |
463 |
// if (layoutContext.isAdjustingToGrid()&& getCurrentLayoutTool().isAdjustable()) {
|
464 |
// m_LastPoint = FLayoutUtilities.getPointGrid(position,layoutContext.getAtributes().getUnitInPixelsX(),layoutContext.getAtributes().getUnitInPixelsY(),m_MatrizTransf);
|
465 |
// }else {
|
466 |
m_LastPoint=position; |
467 |
// }
|
468 |
} |
469 |
public void setPosition(Point point2) { |
470 |
if (layoutContext.isAdjustingToGrid()&& getCurrentLayoutTool().isAdjustable()) {
|
471 |
position = FLayoutUtilities.getPointGrid(point2,layoutContext.getAtributes().getUnitInPixelsX(),layoutContext.getAtributes().getUnitInPixelsY(),m_MatrizTransf); |
472 |
}else {
|
473 |
position=point2; |
474 |
} |
475 |
} |
476 |
public Point getPosition() { |
477 |
return position;
|
478 |
} |
479 |
/**
|
480 |
* Devuelve la Matriz transformada que se esta plicando al Layout.
|
481 |
*
|
482 |
* @return AffineTransform
|
483 |
*/
|
484 |
public AffineTransform getAT() { |
485 |
return m_MatrizTransf;
|
486 |
} |
487 |
public GeometryAdapter getGeometryAdapter() {
|
488 |
return geometryAdapter;
|
489 |
} |
490 |
public void delLastPoint() { |
491 |
getGeometryAdapter().delLastPoint(); |
492 |
} |
493 |
public int addGeometryAdapterPoint() { |
494 |
// if (layoutContext.isAdjustingToGrid() && getCurrentLayoutTool().isAdjustable()) {
|
495 |
// return getGeometryAdapter().addPoint(FLayoutUtilities.toSheetPoint(FLayoutUtilities.getPointGrid(getPosition(),layoutContext.getAtributes().getUnitInPixelsX(),layoutContext.getAtributes().getUnitInPixelsY(),getAT())
|
496 |
// , getAT()));
|
497 |
// }
|
498 |
return getGeometryAdapter().addPoint(FLayoutUtilities.toSheetPoint(getPosition(),getAT()));
|
499 |
} |
500 |
|
501 |
public void setGeometryAdapterPoinPosition() { |
502 |
// if (layoutContext.isAdjustingToGrid() && getCurrentLayoutTool().isAdjustable()) {
|
503 |
// getGeometryAdapter().pointPosition(
|
504 |
// FLayoutUtilities.toSheetPoint(FLayoutUtilities
|
505 |
// .getPointGrid(getPosition(), layoutContext.getAtributes()
|
506 |
// .getUnitInPixelsX(), layoutContext.getAtributes()
|
507 |
// .getUnitInPixelsX(), getAT()), getAT()));
|
508 |
// } else {
|
509 |
getGeometryAdapter().pointPosition(FLayoutUtilities.toSheetPoint(getPosition(),getAT())); |
510 |
// }
|
511 |
|
512 |
} |
513 |
|
514 |
public void clearMouseImage() { |
515 |
int[] pixels = new int[16 * 16]; |
516 |
Image image = Toolkit.getDefaultToolkit().createImage( |
517 |
new MemoryImageSource(16, 16, pixels, 0, 16)); |
518 |
Cursor transparentCursor = Toolkit.getDefaultToolkit() |
519 |
.createCustomCursor(image, new Point(0, 0), "invisiblecursor"); |
520 |
|
521 |
setCursor(transparentCursor); |
522 |
} |
523 |
|
524 |
public void refresh() { |
525 |
setStatus(LayoutControl.DESACTUALIZADO); |
526 |
repaint(); |
527 |
} |
528 |
/**
|
529 |
* Devuelve true si el dibujado ha sido cancelado.
|
530 |
*
|
531 |
* @return true si el dibujado ha sido cancelado.
|
532 |
*/
|
533 |
public synchronized boolean isDrawingCancelled() { |
534 |
return m_bCancelDrawing;
|
535 |
} |
536 |
|
537 |
/**
|
538 |
* Pone el dibuja a cancelado o no seg?n se quiera.
|
539 |
*
|
540 |
* @param b
|
541 |
* true si se quiere cancelar el dibujado.
|
542 |
*/
|
543 |
public synchronized void setCancelDrawing(boolean b) { |
544 |
m_bCancelDrawing = b; |
545 |
|
546 |
for (int i = 0; i < layoutContext.getFFrames().length; i++) { |
547 |
IFFrame fframe = layoutContext.getFFrame(i); |
548 |
|
549 |
if (fframe instanceof IFFrameUseFMap |
550 |
&& (((IFFrameUseFMap) fframe).getMapContext() != null)) {
|
551 |
// //TODO((FFrameView)
|
552 |
// getFFrames().get(i)).getFMap().setCancelDrawing(b);
|
553 |
} |
554 |
} |
555 |
} |
556 |
public void fullRefresh() { |
557 |
IFFrame[] fframes = layoutContext.getFFrames();
|
558 |
for (int i = 0; i < fframes.length; i++) { |
559 |
if (fframes[i] instanceof IFFrameUseFMap) { |
560 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
561 |
fframe.refresh(); |
562 |
} |
563 |
} |
564 |
refresh(); |
565 |
} |
566 |
/**
|
567 |
* Devuelve el rect?ngulo de selecci?n por rect?ngulo.
|
568 |
*
|
569 |
* @return Rect?ngulo de selecci?n.
|
570 |
*/
|
571 |
public Rectangle getReSel() { |
572 |
return reSel;
|
573 |
} |
574 |
|
575 |
/**
|
576 |
* Devuelve true si se debe dibujar el rect?ngulo de selecci?n y realizar la
|
577 |
* sellecci?n.
|
578 |
*
|
579 |
* @return true si se realiza la selecci?n por rect?ngulo.
|
580 |
*/
|
581 |
public boolean isReSel() { |
582 |
return isReSel;
|
583 |
} |
584 |
|
585 |
/**
|
586 |
* Rellena con true si se debe de dibujar y seleccionar por rect?ngulo de
|
587 |
* selecci?n.
|
588 |
*
|
589 |
* @param b
|
590 |
* boolean.
|
591 |
*/
|
592 |
public void setIsReSel(boolean b) { |
593 |
isReSel = b; |
594 |
} |
595 |
|
596 |
|
597 |
|
598 |
/**
|
599 |
* Realiza una exteni?n completa de las capas que contiene la vista del
|
600 |
* FFrameView.
|
601 |
*
|
602 |
* @throws DriverException
|
603 |
*/
|
604 |
public void viewFull() throws DriverException { |
605 |
IFFrame[] fframes = layoutContext.getFFrameSelected();
|
606 |
for (int i = 0; i < fframes.length; i++) { |
607 |
if (fframes[i] instanceof IFFrameUseFMap) { |
608 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
609 |
|
610 |
if (fframe.getMapContext() != null) { |
611 |
fframe.fullExtent(); |
612 |
} |
613 |
fframe.refresh(); |
614 |
} |
615 |
} |
616 |
refresh(); |
617 |
} |
618 |
|
619 |
public FLayoutZooms getLayoutZooms() {
|
620 |
return layoutZooms;
|
621 |
} |
622 |
|
623 |
public Point getPointToMove() { |
624 |
return pointToMove;
|
625 |
} |
626 |
public void setPointToMove(Point pointToMove) { |
627 |
this.pointToMove = pointToMove;
|
628 |
} |
629 |
public FLayoutFunctions getLayoutFunctions() {
|
630 |
return layoutFunctions;
|
631 |
} |
632 |
public LayoutContext getLayoutContext() {
|
633 |
return layoutContext;
|
634 |
} |
635 |
public void setGeometryAdapter(GeometryAdapter adapter) { |
636 |
geometryAdapter=adapter; |
637 |
|
638 |
} |
639 |
} |