svn-document-layout / tags / 2059 / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / tools / LayoutAddPointListenerImpl.java @ 46
History | View | Annotate | Download (4.21 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.geom.Geometry; |
36 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
37 |
|
38 |
/**
|
39 |
* Implementaci�n de la interfaz LayoutPointListener como herramienta para
|
40 |
* realizar
|
41 |
* un zoom menos.
|
42 |
*
|
43 |
* @author Vicente Caballero Navarro
|
44 |
*/
|
45 |
public class LayoutAddPointListenerImpl extends AbstractLayoutToolListener |
46 |
implements LayoutPointListener, ILayoutGraphicListener {
|
47 |
|
48 |
public static final Image iPoint = PluginServices.getIconTheme() |
49 |
.get("cursor-layout-insert-point").getImage();
|
50 |
|
51 |
/**
|
52 |
* Crea un nuevo LayoutZoomOutListenerImpl.
|
53 |
*
|
54 |
* @param mapControl
|
55 |
* MapControl.
|
56 |
*/
|
57 |
public LayoutAddPointListenerImpl(LayoutPanel layoutPanel) {
|
58 |
super(layoutPanel);
|
59 |
} |
60 |
|
61 |
/**
|
62 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.PointEvent)
|
63 |
*/
|
64 |
public void point(PointEvent event) { |
65 |
if (event.getEvent().getButton() == MouseEvent.BUTTON1) { |
66 |
endGraphic(); |
67 |
} |
68 |
} |
69 |
|
70 |
/**
|
71 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getCursor()
|
72 |
*/
|
73 |
public Image getImageCursor() { |
74 |
return iPoint;
|
75 |
} |
76 |
|
77 |
/**
|
78 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#cancelDrawing()
|
79 |
*/
|
80 |
public boolean cancelDrawing() { |
81 |
System.out.println("cancelDrawing del ZoomOutListenerImpl"); |
82 |
return true; |
83 |
} |
84 |
|
85 |
public void pointDoubleClick(PointEvent event) { |
86 |
// TODO Auto-generated method stub
|
87 |
|
88 |
} |
89 |
|
90 |
public void endGraphic() { |
91 |
layoutPanel.getLayoutControl().addGeometryAdapterPoint(); |
92 |
layoutPanel.getLayoutControl().getGeometryAdapter().end(); |
93 |
PluginServices.getMainFrame().enableControls(); |
94 |
FFrameGraphics fframe = |
95 |
(FFrameGraphics) layoutManager |
96 |
.createFrame(FFrameGraphics.PERSISTENCE_DEFINITION_NAME); |
97 |
|
98 |
// fframe.setLayout(layout);
|
99 |
fframe.setGeometryAdapter(layoutPanel.getLayoutControl() |
100 |
.getGeometryAdapter()); |
101 |
fframe.update(Geometry.TYPES.POINT, layoutPanel.getLayoutControl() |
102 |
.getAT()); |
103 |
Rectangle2D r =
|
104 |
layoutPanel.getLayoutControl().getGeometryAdapter().getBounds2D(); |
105 |
double d = 0.5;// FLayoutUtilities.toSheetDistance(50,layout.getAT()); |
106 |
r = |
107 |
new Rectangle2D.Double(r.getX() - (d / 2), r.getY() - d, d * 2, |
108 |
d * 2);
|
109 |
fframe.setBoundBox(r); |
110 |
layoutPanel.getLayoutContext().addFFrame(fframe, true, true); |
111 |
layoutPanel.getLayoutControl().setGeometryAdapter(new PointAdapter());
|
112 |
layoutPanel.getLayoutControl().refresh(); |
113 |
} |
114 |
|
115 |
public GeometryAdapter createGeometryAdapter() {
|
116 |
return new PointAdapter(); |
117 |
} |
118 |
} |