svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.app.document.layout.app / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / tools / LayoutAddPointListenerImpl.java @ 36648
History | View | Annotate | Download (4.16 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.app.project.documents.layout.tools; |
23 |
|
24 |
import java.awt.Image; |
25 |
import java.awt.event.MouseEvent; |
26 |
import java.awt.geom.Rectangle2D; |
27 |
|
28 |
import org.gvsig.andami.PluginServices; |
29 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGraphics; |
30 |
import org.gvsig.app.project.documents.layout.geometryadapters.GeometryAdapter; |
31 |
import org.gvsig.app.project.documents.layout.geometryadapters.PointAdapter; |
32 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
33 |
import org.gvsig.app.project.documents.layout.tools.listener.ILayoutGraphicListener; |
34 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutPointListener; |
35 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
36 |
|
37 |
/**
|
38 |
* Implementaci�n de la interfaz LayoutPointListener como herramienta para
|
39 |
* realizar
|
40 |
* un zoom menos.
|
41 |
*
|
42 |
* @author Vicente Caballero Navarro
|
43 |
*/
|
44 |
public class LayoutAddPointListenerImpl extends AbstractLayoutToolListener |
45 |
implements LayoutPointListener, ILayoutGraphicListener {
|
46 |
|
47 |
public static final Image iPoint = PluginServices.getIconTheme() |
48 |
.get("point-cursor").getImage();
|
49 |
|
50 |
/**
|
51 |
* Crea un nuevo LayoutZoomOutListenerImpl.
|
52 |
*
|
53 |
* @param mapControl
|
54 |
* MapControl.
|
55 |
*/
|
56 |
public LayoutAddPointListenerImpl(LayoutPanel layoutPanel) {
|
57 |
super(layoutPanel);
|
58 |
} |
59 |
|
60 |
/**
|
61 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.PointEvent)
|
62 |
*/
|
63 |
public void point(PointEvent event) { |
64 |
if (event.getEvent().getButton() == MouseEvent.BUTTON1) { |
65 |
endGraphic(); |
66 |
} |
67 |
} |
68 |
|
69 |
/**
|
70 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getCursor()
|
71 |
*/
|
72 |
public Image getImageCursor() { |
73 |
return iPoint;
|
74 |
} |
75 |
|
76 |
/**
|
77 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#cancelDrawing()
|
78 |
*/
|
79 |
public boolean cancelDrawing() { |
80 |
System.out.println("cancelDrawing del ZoomOutListenerImpl"); |
81 |
return true; |
82 |
} |
83 |
|
84 |
public void pointDoubleClick(PointEvent event) { |
85 |
// TODO Auto-generated method stub
|
86 |
|
87 |
} |
88 |
|
89 |
public void endGraphic() { |
90 |
layoutPanel.getLayoutControl().addGeometryAdapterPoint(); |
91 |
layoutPanel.getLayoutControl().getGeometryAdapter().end(); |
92 |
PluginServices.getMainFrame().enableControls(); |
93 |
FFrameGraphics fframe = |
94 |
(FFrameGraphics) layoutManager |
95 |
.createFrame(FFrameGraphics.PERSISTENCE_DEFINITION_NAME); |
96 |
|
97 |
// fframe.setLayout(layout);
|
98 |
fframe.setGeometryAdapter(layoutPanel.getLayoutControl() |
99 |
.getGeometryAdapter()); |
100 |
fframe.update(FFrameGraphics.POINT, layoutPanel.getLayoutControl() |
101 |
.getAT()); |
102 |
Rectangle2D r =
|
103 |
layoutPanel.getLayoutControl().getGeometryAdapter().getBounds2D(); |
104 |
double d = 0.5;// FLayoutUtilities.toSheetDistance(50,layout.getAT()); |
105 |
r = |
106 |
new Rectangle2D.Double(r.getX() - (d / 2), r.getY() - d, d * 2, |
107 |
d * 2);
|
108 |
fframe.setBoundBox(r); |
109 |
layoutPanel.getLayoutContext().addFFrame(fframe, true, true); |
110 |
layoutPanel.getLayoutControl().setGeometryAdapter(new PointAdapter());
|
111 |
layoutPanel.getLayoutControl().refresh(); |
112 |
} |
113 |
|
114 |
public GeometryAdapter createGeometryAdapter() {
|
115 |
return new PointAdapter(); |
116 |
} |
117 |
} |