Revision 1217
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Mon Nov 15 22:17:16 CET 2021 |
|
2 |
buildNumber=226 |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/test/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your test classes. |
|
2 |
|
|
3 |
This folder is added to the Tests classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, in this folder you can find an example of log4j configuration, |
|
7 |
prepared to log messages through the console, so logging works when you |
|
8 |
run your tests classes. |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
org.gvsig.tools packages. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.tools"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
<category name="org.gvsig.app.document.layout"> |
|
26 |
<priority value="DEBUG" /> |
|
27 |
</category> |
|
28 |
|
|
29 |
<!-- |
|
30 |
By default, show only logging messages of INFO level or higher, |
|
31 |
through the previously configured CONSOLE appender. |
|
32 |
--> |
|
33 |
<root> |
|
34 |
<priority value="INFO" /> |
|
35 |
<appender-ref ref="CONSOLE" /> |
|
36 |
</root> |
|
37 |
</log4j:configuration> |
|
0 | 38 |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
<dependencySets> |
|
26 |
|
|
27 |
<!-- |
|
28 |
<dependencySet> |
|
29 |
<useProjectArtifact>false</useProjectArtifact> |
|
30 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
31 |
<outputDirectory>lib</outputDirectory> |
|
32 |
<includes> |
|
33 |
</includes> |
|
34 |
</dependencySet> |
|
35 |
|
|
36 |
--> |
|
37 |
|
|
38 |
</dependencySets> |
|
39 |
|
|
40 |
</assembly> |
|
0 | 41 |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/LayoutAddViewListenerImpl.java | ||
---|---|---|
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 |
|
|
26 |
import org.gvsig.andami.PluginServices; |
|
27 |
import org.gvsig.app.project.documents.layout.fframes.FFrameView; |
|
28 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
29 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutAddRectangleWithDialogListener; |
|
30 |
|
|
31 |
/** |
|
32 |
* Implementaci?n de la interfaz LayoutRectangleListener como herramienta para |
|
33 |
* realizar una inserci?n por rect?ngulo. |
|
34 |
* |
|
35 |
* @author Vicente Caballero Navarro |
|
36 |
*/ |
|
37 |
public class LayoutAddViewListenerImpl extends |
|
38 |
LayoutAddRectangleWithDialogListener { |
|
39 |
|
|
40 |
private final Image img = PluginServices.getIconTheme() |
|
41 |
.get("cursor-selection-by-rectangle").getImage(); |
|
42 |
|
|
43 |
/** |
|
44 |
* Crea un nuevo LayoutAddRectangleListener. |
|
45 |
* |
|
46 |
* @param layoutPanel |
|
47 |
* Layout. |
|
48 |
*/ |
|
49 |
public LayoutAddViewListenerImpl(LayoutPanel layoutPanel) { |
|
50 |
super(layoutPanel); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getCursor() |
|
55 |
*/ |
|
56 |
public Image getImageCursor() { |
|
57 |
return img; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#cancelDrawing() |
|
62 |
*/ |
|
63 |
public boolean cancelDrawing() { |
|
64 |
return false; |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public String getFFrameName() { |
|
69 |
return FFrameView.PERSISTENCE_DEFINITION_NAME; |
|
70 |
} |
|
71 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/LayoutAddPictureListenerImpl.java | ||
---|---|---|
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 |
|
|
26 |
import org.gvsig.andami.PluginServices; |
|
27 |
import org.gvsig.app.project.documents.layout.fframes.FFramePicture; |
|
28 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
29 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutAddRectangleWithDialogListener; |
|
30 |
|
|
31 |
/** |
|
32 |
* Implementaci�n de la interfaz LayoutRectangleListener como herramienta para |
|
33 |
* realizar una inserci�n por rect�ngulo. |
|
34 |
* |
|
35 |
* @author Vicente Caballero Navarro |
|
36 |
*/ |
|
37 |
public class LayoutAddPictureListenerImpl extends |
|
38 |
LayoutAddRectangleWithDialogListener { |
|
39 |
|
|
40 |
private final Image img = PluginServices.getIconTheme() |
|
41 |
.get("cursor-selection-by-rectangle").getImage(); |
|
42 |
|
|
43 |
/** |
|
44 |
* Crea un nuevo LayoutAddRectangleListener. |
|
45 |
* |
|
46 |
* @param l |
|
47 |
* Layout. |
|
48 |
*/ |
|
49 |
public LayoutAddPictureListenerImpl(LayoutPanel l) { |
|
50 |
super(l); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getCursor() |
|
55 |
*/ |
|
56 |
public Image getImageCursor() { |
|
57 |
return img; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#cancelDrawing() |
|
62 |
*/ |
|
63 |
public boolean cancelDrawing() { |
|
64 |
return false; |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public String getFFrameName() { |
|
69 |
return FFramePicture.PERSISTENCE_DEFINITION_NAME; |
|
70 |
} |
|
71 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/behavior/LayoutMoveBehavior.java | ||
---|---|---|
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.behavior; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
import java.awt.Graphics; |
|
26 |
import java.awt.Graphics2D; |
|
27 |
import java.awt.Point; |
|
28 |
import java.awt.event.MouseEvent; |
|
29 |
import java.awt.geom.Point2D; |
|
30 |
|
|
31 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutMoveListener; |
|
32 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutToolListener; |
|
33 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
34 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
|
35 |
|
|
36 |
/** |
|
37 |
* Behaviour que espera un listener de tipo MoveListener. |
|
38 |
* |
|
39 |
* @author Vicente Caballero Navarro |
|
40 |
*/ |
|
41 |
public class LayoutMoveBehavior extends LayoutBehavior { |
|
42 |
|
|
43 |
private Point2D m_FirstPoint; |
|
44 |
private Point2D m_LastPoint; |
|
45 |
private Point2D m_PointAnt; |
|
46 |
private LayoutMoveListener listener; |
|
47 |
|
|
48 |
/** |
|
49 |
* Crea un nuevo MoveBehavior. |
|
50 |
* |
|
51 |
* @param pli |
|
52 |
* listener. |
|
53 |
*/ |
|
54 |
public LayoutMoveBehavior(LayoutMoveListener lpl) { |
|
55 |
listener = lpl; |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(java.awt.Graphics) |
|
60 |
*/ |
|
61 |
public void paintComponent(Graphics g) { |
|
62 |
m_FirstPoint = getLayoutControl().getFirstPoint(); |
|
63 |
m_LastPoint = getLayoutControl().getLastPoint(); |
|
64 |
m_PointAnt = getLayoutControl().getPointAnt(); |
|
65 |
|
|
66 |
if (getLayoutControl().getImage() != null) { |
|
67 |
if ((m_FirstPoint != null) && (m_LastPoint != null)) { |
|
68 |
if ((m_LastPoint == null) && (m_PointAnt == null)) { |
|
69 |
m_LastPoint = new Point(); |
|
70 |
m_PointAnt = new Point(); |
|
71 |
} |
|
72 |
g.drawImage(getLayoutControl().getImage(), (getLayoutControl() |
|
73 |
.getLastPoint().x - getLayoutControl().getPointAnt().x), |
|
74 |
(getLayoutControl().getLastPoint().y - getLayoutControl() |
|
75 |
.getPointAnt().y), getLayoutControl().getComponent()); |
|
76 |
|
|
77 |
getLayoutControl().getLayoutDraw().drawGrid((Graphics2D) g); |
|
78 |
getLayoutControl().getLayoutDraw().drawRuler((Graphics2D) g, |
|
79 |
Color.black); |
|
80 |
} else { |
|
81 |
super.paintComponent(g); |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* @throws BehaviorException |
|
88 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
|
89 |
*/ |
|
90 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
|
91 |
super.mousePressed(e); |
|
92 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
93 |
listener.press(event); |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* Reimplementaci?n del m?todo mouseReleased de Behavior. |
|
98 |
* |
|
99 |
* @param e |
|
100 |
* MouseEvent |
|
101 |
* |
|
102 |
* @throws BehaviorException |
|
103 |
* Excepci?n lanzada cuando el Behavior. |
|
104 |
*/ |
|
105 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
|
106 |
super.mouseReleased(e); |
|
107 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
108 |
listener.release(event); |
|
109 |
|
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* Reimplementaci?n del m?todo mouseDragged de Behavior. |
|
114 |
* |
|
115 |
* @param e |
|
116 |
* MouseEvent |
|
117 |
* @throws BehaviorException |
|
118 |
*/ |
|
119 |
public void mouseDragged(MouseEvent e) throws BehaviorException { |
|
120 |
super.mouseDragged(e); |
|
121 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
122 |
listener.drag(event); |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#setListener(com.iver.cit.gvsig.fmap.tools.ToolListener) |
|
127 |
*/ |
|
128 |
public void setListener(LayoutToolListener listener) { |
|
129 |
this.listener = (LayoutMoveListener) listener; |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#getListener() |
|
134 |
*/ |
|
135 |
public LayoutToolListener getListener() { |
|
136 |
return listener; |
|
137 |
} |
|
138 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/behavior/ILayoutBehavior.java | ||
---|---|---|
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.behavior; |
|
23 |
|
|
24 |
import java.awt.Graphics; |
|
25 |
import java.awt.Image; |
|
26 |
import java.awt.event.MouseEvent; |
|
27 |
import java.awt.event.MouseWheelEvent; |
|
28 |
|
|
29 |
import org.gvsig.app.project.documents.layout.LayoutControl; |
|
30 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutToolListener; |
|
31 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
32 |
|
|
33 |
/** |
|
34 |
* Layout behavior. |
|
35 |
* |
|
36 |
* @author Vicente Caballero Navarro |
|
37 |
*/ |
|
38 |
public interface ILayoutBehavior { |
|
39 |
|
|
40 |
/** |
|
41 |
* Devuelve el ToolListener que est? seleccionado. |
|
42 |
* |
|
43 |
* @return ToolListener seleccionado. |
|
44 |
*/ |
|
45 |
public LayoutToolListener getListener(); |
|
46 |
|
|
47 |
/** |
|
48 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(java.awt.Graphics) |
|
49 |
*/ |
|
50 |
public void paintComponent(Graphics g); |
|
51 |
|
|
52 |
/** |
|
53 |
* Inserta el Layout. |
|
54 |
* |
|
55 |
* @param lc |
|
56 |
* Layout a insertar. |
|
57 |
*/ |
|
58 |
public void setLayoutControl(LayoutControl lc); |
|
59 |
|
|
60 |
/** |
|
61 |
* Devuelve la imagen del cursor de la herrameinta. |
|
62 |
* |
|
63 |
* @return Image cursor de la herramienta. |
|
64 |
*/ |
|
65 |
public Image getImageCursor(); |
|
66 |
|
|
67 |
/** |
|
68 |
* Devuelve el Layout. |
|
69 |
* |
|
70 |
* @return Layout. |
|
71 |
*/ |
|
72 |
public LayoutControl getLayoutControl(); |
|
73 |
|
|
74 |
/** |
|
75 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) |
|
76 |
*/ |
|
77 |
public void mouseClicked(MouseEvent e) throws BehaviorException; |
|
78 |
|
|
79 |
/** |
|
80 |
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) |
|
81 |
*/ |
|
82 |
public void mouseEntered(MouseEvent e) throws BehaviorException; |
|
83 |
|
|
84 |
/** |
|
85 |
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) |
|
86 |
*/ |
|
87 |
public void mouseExited(MouseEvent e) throws BehaviorException; |
|
88 |
|
|
89 |
/** |
|
90 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
|
91 |
*/ |
|
92 |
public void mousePressed(MouseEvent e) throws BehaviorException; |
|
93 |
|
|
94 |
/** |
|
95 |
* @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) |
|
96 |
*/ |
|
97 |
public void mouseReleased(MouseEvent e) throws BehaviorException; |
|
98 |
|
|
99 |
/** |
|
100 |
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent) |
|
101 |
*/ |
|
102 |
public void mouseDragged(MouseEvent e) throws BehaviorException; |
|
103 |
|
|
104 |
/** |
|
105 |
* @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent) |
|
106 |
*/ |
|
107 |
public void mouseMoved(MouseEvent e) throws BehaviorException; |
|
108 |
|
|
109 |
/** |
|
110 |
* @see java.awt.event.MouseWheelListener#mouseWheelMoved(java.awt.event.MouseWheelEvent) |
|
111 |
*/ |
|
112 |
public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException; |
|
113 |
|
|
114 |
public boolean isAdjustable(); |
|
115 |
|
|
116 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/behavior/LayoutPointBehavior.java | ||
---|---|---|
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.behavior; |
|
23 |
|
|
24 |
import java.awt.Graphics; |
|
25 |
import java.awt.event.MouseEvent; |
|
26 |
|
|
27 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutPointListener; |
|
28 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutToolListener; |
|
29 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
30 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
|
31 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener; |
|
32 |
|
|
33 |
/** |
|
34 |
* LayoutBehaviour que espera un listener de tipo LayoutPointListener. |
|
35 |
* |
|
36 |
* @author Vicente Caballero Navarro |
|
37 |
*/ |
|
38 |
public class LayoutPointBehavior extends LayoutBehavior { |
|
39 |
|
|
40 |
private LayoutPointListener listener; |
|
41 |
private boolean doubleClick = false; |
|
42 |
|
|
43 |
/** |
|
44 |
* Crea un nuevo LayoutPointBehavior. |
|
45 |
* |
|
46 |
* @param l |
|
47 |
* listener. |
|
48 |
*/ |
|
49 |
public LayoutPointBehavior(LayoutPointListener l) { |
|
50 |
listener = l; |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* Reimplementaci?n del m?todo mousePressed de Behavior. |
|
55 |
* |
|
56 |
* @param e |
|
57 |
* MouseEvent |
|
58 |
* @throws BehaviorException |
|
59 |
*/ |
|
60 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
|
61 |
super.mousePressed(e); |
|
62 |
if (listener.cancelDrawing()) { |
|
63 |
// getMapControl().cancelDrawing(); |
|
64 |
} |
|
65 |
if (e.getClickCount() == 2) { |
|
66 |
doubleClick = true; |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(java.awt.Graphics) |
|
72 |
*/ |
|
73 |
public void paintComponent(Graphics g) { |
|
74 |
super.paintComponent(g); |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* Calls the right method from LayoutPointListener (point |
|
79 |
* and pointDoubleClick) |
|
80 |
* |
|
81 |
* @param e |
|
82 |
* MouseEvent |
|
83 |
* |
|
84 |
* @throws BehaviorException |
|
85 |
* |
|
86 |
*/ |
|
87 |
|
|
88 |
public void mouseClicked(MouseEvent e) throws BehaviorException { |
|
89 |
super.mouseClicked(e); |
|
90 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
91 |
listener.point(event); |
|
92 |
if (doubleClick) { |
|
93 |
listener.pointDoubleClick(event); |
|
94 |
doubleClick = false; |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#setListener(com.iver.cit.gvsig.fmap.tools.ToolListener) |
|
100 |
*/ |
|
101 |
public void setListener(ToolListener listener) { |
|
102 |
this.listener = (LayoutPointListener) listener; |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#getListener() |
|
107 |
*/ |
|
108 |
public LayoutToolListener getListener() { |
|
109 |
return listener; |
|
110 |
} |
|
111 |
|
|
112 |
public void mouseMoved(MouseEvent e) throws BehaviorException { |
|
113 |
super.mouseMoved(e); |
|
114 |
getLayoutControl().setGeometryAdapterPoinPosition(); |
|
115 |
} |
|
116 |
|
|
117 |
public boolean isAdjustable() { |
|
118 |
return true; |
|
119 |
} |
|
120 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/behavior/LayoutBehavior.java | ||
---|---|---|
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.behavior; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
import java.awt.Graphics; |
|
26 |
import java.awt.Graphics2D; |
|
27 |
import java.awt.Image; |
|
28 |
import java.awt.event.MouseEvent; |
|
29 |
import java.awt.event.MouseWheelEvent; |
|
30 |
|
|
31 |
import org.gvsig.app.project.documents.layout.LayoutControl; |
|
32 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutToolListener; |
|
33 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
34 |
|
|
35 |
/** |
|
36 |
* Ejecuta acciones respondiendo a eventos, por |
|
37 |
* delegaci?n desde el Layout. |
|
38 |
* |
|
39 |
* @author Vicente Caballero Navarro |
|
40 |
*/ |
|
41 |
public abstract class LayoutBehavior implements ILayoutBehavior { |
|
42 |
|
|
43 |
private LayoutControl layout; |
|
44 |
|
|
45 |
public abstract LayoutToolListener getListener(); |
|
46 |
|
|
47 |
public void paintComponent(Graphics g) { |
|
48 |
g.drawImage(getLayoutControl().getImage(), 0, 0, layout.getComponent()); |
|
49 |
|
|
50 |
getLayoutControl().getLayoutDraw().drawGrid((Graphics2D) g); |
|
51 |
getLayoutControl().getLayoutDraw().drawRuler((Graphics2D) g, |
|
52 |
Color.black); |
|
53 |
getLayoutControl().getGeometryAdapter().paint((Graphics2D) g, |
|
54 |
layout.getAT(), true); |
|
55 |
getLayoutControl().getLayoutDraw().drawHandlers((Graphics2D) g, |
|
56 |
Color.black); |
|
57 |
} |
|
58 |
|
|
59 |
public void setLayoutControl(LayoutControl lc) { |
|
60 |
layout = lc; |
|
61 |
} |
|
62 |
|
|
63 |
public Image getImageCursor() { |
|
64 |
return getListener().getImageCursor(); |
|
65 |
} |
|
66 |
|
|
67 |
public LayoutControl getLayoutControl() { |
|
68 |
return layout; |
|
69 |
} |
|
70 |
|
|
71 |
public void mouseClicked(MouseEvent e) throws BehaviorException { |
|
72 |
} |
|
73 |
|
|
74 |
public void mouseEntered(MouseEvent e) throws BehaviorException { |
|
75 |
} |
|
76 |
|
|
77 |
public void mouseExited(MouseEvent e) throws BehaviorException { |
|
78 |
} |
|
79 |
|
|
80 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
|
81 |
if (e.getButton() == MouseEvent.BUTTON1) { |
|
82 |
layout.setPointAnt(); |
|
83 |
layout.setFirstPoint(); |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
|
88 |
if (e.getButton() != MouseEvent.BUTTON3) { |
|
89 |
layout.setLastPoint(); |
|
90 |
layout.setPointAnt(); |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
public void mouseDragged(MouseEvent e) throws BehaviorException { |
|
95 |
if (e.getButton() != MouseEvent.BUTTON3) { |
|
96 |
layout.setLastPoint(); |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
public void mouseMoved(MouseEvent e) throws BehaviorException { |
|
101 |
} |
|
102 |
|
|
103 |
public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException { |
|
104 |
} |
|
105 |
|
|
106 |
public boolean isAdjustable() { |
|
107 |
return false; |
|
108 |
} |
|
109 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/behavior/LayoutSelectBehavior.java | ||
---|---|---|
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.behavior; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
import java.awt.Graphics; |
|
26 |
import java.awt.Graphics2D; |
|
27 |
import java.awt.Rectangle; |
|
28 |
import java.awt.event.MouseEvent; |
|
29 |
import java.awt.geom.Rectangle2D; |
|
30 |
|
|
31 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
32 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutMoveListener; |
|
33 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutToolListener; |
|
34 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
35 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
|
36 |
|
|
37 |
/** |
|
38 |
* Behaviour que espera un listener de tipo LayoutMoveListener. |
|
39 |
* |
|
40 |
* @author Vicente Caballero Navarro |
|
41 |
*/ |
|
42 |
public class LayoutSelectBehavior extends LayoutBehavior { |
|
43 |
|
|
44 |
private LayoutMoveListener listener; |
|
45 |
private boolean dragged = false; |
|
46 |
|
|
47 |
/** |
|
48 |
* Crea un nuevo LayoutSelectBehavior. |
|
49 |
* |
|
50 |
* @param pli |
|
51 |
* listener. |
|
52 |
*/ |
|
53 |
public LayoutSelectBehavior(LayoutMoveListener lpl) { |
|
54 |
listener = lpl; |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(java.awt.Graphics) |
|
59 |
*/ |
|
60 |
public void paintComponent(Graphics g) { |
|
61 |
getLayoutControl().getLayoutDraw().drawRectangle((Graphics2D) g); |
|
62 |
|
|
63 |
g.drawImage(getLayoutControl().getImage(), 0, 0, getLayoutControl() |
|
64 |
.getComponent()); |
|
65 |
|
|
66 |
if (getLayoutControl().isReSel()) { |
|
67 |
Rectangle reSel = getLayoutControl().getReSel(); |
|
68 |
reSel = new Rectangle(); |
|
69 |
reSel.setFrameFromDiagonal(getLayoutControl().getFirstPoint(), |
|
70 |
getLayoutControl().getLastPoint()); |
|
71 |
g.drawRect(reSel.x, reSel.y, reSel.width, reSel.height); |
|
72 |
} |
|
73 |
IFFrame[] frames = |
|
74 |
getLayoutControl().getLayoutContext().getSelectedFFrames(); |
|
75 |
for (int i = 0; i < frames.length; i++) { |
|
76 |
g.setColor(Color.black); |
|
77 |
frames[i].drawHandlers((Graphics2D) g); |
|
78 |
int difx = |
|
79 |
(getLayoutControl().getLastPoint().x - getLayoutControl() |
|
80 |
.getFirstPoint().x); |
|
81 |
int dify = |
|
82 |
(getLayoutControl().getLastPoint().y - getLayoutControl() |
|
83 |
.getFirstPoint().y); |
|
84 |
if ((Math.abs(difx) > 3) || (Math.abs(dify) > 3)) { |
|
85 |
Rectangle2D rectangle = frames[i].getMovieRect(difx, dify); |
|
86 |
if (rectangle == null) |
|
87 |
return; |
|
88 |
((Graphics2D) g).rotate( |
|
89 |
Math.toRadians(frames[i].getRotation()), rectangle.getX() |
|
90 |
+ (rectangle.getWidth() / 2), rectangle.getY() |
|
91 |
+ (rectangle.getHeight() / 2)); |
|
92 |
|
|
93 |
if (rectangle != null && dragged |
|
94 |
&& !getLayoutControl().isReSel()) { |
|
95 |
g.drawRect((int) rectangle.getMinX(), |
|
96 |
(int) rectangle.getMinY(), (int) rectangle.getWidth(), |
|
97 |
(int) rectangle.getHeight()); |
|
98 |
} |
|
99 |
|
|
100 |
((Graphics2D) g).rotate( |
|
101 |
Math.toRadians(-frames[i].getRotation()), rectangle.getX() |
|
102 |
+ (rectangle.getWidth() / 2), rectangle.getY() |
|
103 |
+ (rectangle.getHeight() / 2)); |
|
104 |
|
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
g.drawImage(getLayoutControl().getImgRuler(), 0, 0, getLayoutControl() |
|
109 |
.getComponent()); |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* @throws BehaviorException |
|
114 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
|
115 |
*/ |
|
116 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
|
117 |
super.mousePressed(e); |
|
118 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
119 |
listener.press(event); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* Reimplementaci?n del m?todo mouseReleased de Behavior. |
|
124 |
* |
|
125 |
* @param e |
|
126 |
* MouseEvent |
|
127 |
* |
|
128 |
* @throws BehaviorException |
|
129 |
* Excepci?n lanzada cuando el Behavior. |
|
130 |
*/ |
|
131 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
|
132 |
super.mouseReleased(e); |
|
133 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
134 |
listener.release(event); |
|
135 |
dragged = false; |
|
136 |
|
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* Reimplementaci?n del m?todo mouseDragged de Behavior. |
|
141 |
* |
|
142 |
* @param e |
|
143 |
* MouseEvent |
|
144 |
* @throws BehaviorException |
|
145 |
*/ |
|
146 |
public void mouseDragged(MouseEvent e) throws BehaviorException { |
|
147 |
super.mouseDragged(e); |
|
148 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
149 |
listener.drag(event); |
|
150 |
dragged = true; |
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#setListener(com.iver.cit.gvsig.fmap.tools.ToolListener) |
|
155 |
*/ |
|
156 |
public void setListener(LayoutToolListener listener) { |
|
157 |
this.listener = (LayoutMoveListener) listener; |
|
158 |
} |
|
159 |
|
|
160 |
/** |
|
161 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#getListener() |
|
162 |
*/ |
|
163 |
public LayoutToolListener getListener() { |
|
164 |
return listener; |
|
165 |
} |
|
166 |
|
|
167 |
public void mouseClicked(MouseEvent e) throws BehaviorException { |
|
168 |
super.mouseClicked(e); |
|
169 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
170 |
listener.click(event); |
|
171 |
} |
|
172 |
|
|
173 |
public void mouseMoved(MouseEvent e) throws BehaviorException { |
|
174 |
super.mouseMoved(e); |
|
175 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
176 |
listener.move(event); |
|
177 |
} |
|
178 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/behavior/LayoutViewZoomBehavior.java | ||
---|---|---|
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.behavior; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
import java.awt.Graphics; |
|
26 |
import java.awt.Graphics2D; |
|
27 |
import java.awt.Rectangle; |
|
28 |
import java.awt.event.MouseEvent; |
|
29 |
import java.awt.image.BufferedImage; |
|
30 |
|
|
31 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
32 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutMoveListener; |
|
33 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutToolListener; |
|
34 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
35 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
|
36 |
|
|
37 |
/** |
|
38 |
* Behaviour que espera un listener de tipo MoveListener. |
|
39 |
* |
|
40 |
* @author Vicente Caballero Navarro |
|
41 |
*/ |
|
42 |
public class LayoutViewZoomBehavior extends LayoutBehavior { |
|
43 |
|
|
44 |
private LayoutMoveListener listener; |
|
45 |
private boolean dragged = false; |
|
46 |
|
|
47 |
/** |
|
48 |
* Crea un nuevo MoveBehavior. |
|
49 |
* |
|
50 |
* @param pli |
|
51 |
* listener. |
|
52 |
*/ |
|
53 |
public LayoutViewZoomBehavior(LayoutMoveListener lpl) { |
|
54 |
listener = lpl; |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(java.awt.Graphics) |
|
59 |
*/ |
|
60 |
public void paintComponent(Graphics g) { |
|
61 |
BufferedImage img = getLayoutControl().getImage(); |
|
62 |
BufferedImage imgRuler = getLayoutControl().getImgRuler(); |
|
63 |
g.drawImage(img, 0, 0, getLayoutControl().getComponent()); |
|
64 |
g.drawImage(imgRuler, 0, 0, getLayoutControl().getComponent()); |
|
65 |
g.setColor(Color.black); |
|
66 |
g.setXORMode(Color.white); |
|
67 |
|
|
68 |
// Borramos el anterior |
|
69 |
Rectangle r = new Rectangle(); |
|
70 |
|
|
71 |
// Dibujamos el actual |
|
72 |
if (dragged && (getLayoutControl().getFirstPoint() != null) |
|
73 |
&& (getLayoutControl().getLastPoint() != null)) { |
|
74 |
r.setFrameFromDiagonal(getLayoutControl().getFirstPoint(), |
|
75 |
getLayoutControl().getLastPoint()); |
|
76 |
g.drawRect(r.x, r.y, r.width, r.height); |
|
77 |
} |
|
78 |
IFFrame[] frames = |
|
79 |
getLayoutControl().getLayoutContext().getSelectedFFrames(); |
|
80 |
for (int i = 0; i < frames.length; i++) { |
|
81 |
g.setColor(Color.black); |
|
82 |
frames[i].drawHandlers((Graphics2D) g); |
|
83 |
} |
|
84 |
g.setPaintMode(); |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* @throws BehaviorException |
|
89 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
|
90 |
*/ |
|
91 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
|
92 |
super.mousePressed(e); |
|
93 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
94 |
listener.press(event); |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* Reimplementaci?n del m?todo mouseReleased de Behavior. |
|
99 |
* |
|
100 |
* @param e |
|
101 |
* MouseEvent |
|
102 |
* |
|
103 |
* @throws BehaviorException |
|
104 |
* Excepci?n lanzada cuando el Behavior. |
|
105 |
*/ |
|
106 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
|
107 |
super.mouseReleased(e); |
|
108 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
109 |
listener.release(event); |
|
110 |
dragged = false; |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* Reimplementaci?n del m?todo mouseDragged de Behavior. |
|
115 |
* |
|
116 |
* @param e |
|
117 |
* MouseEvent |
|
118 |
* @throws BehaviorException |
|
119 |
*/ |
|
120 |
public void mouseDragged(MouseEvent e) throws BehaviorException { |
|
121 |
super.mouseDragged(e); |
|
122 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
123 |
listener.drag(event); |
|
124 |
dragged = true; |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#setListener(com.iver.cit.gvsig.fmap.tools.ToolListener) |
|
129 |
*/ |
|
130 |
public void setListener(LayoutToolListener listener) { |
|
131 |
this.listener = (LayoutMoveListener) listener; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#getListener() |
|
136 |
*/ |
|
137 |
public LayoutToolListener getListener() { |
|
138 |
return listener; |
|
139 |
} |
|
140 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/behavior/LayoutViewMoveBehavior.java | ||
---|---|---|
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.behavior; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
import java.awt.Graphics; |
|
26 |
import java.awt.Graphics2D; |
|
27 |
import java.awt.event.MouseEvent; |
|
28 |
import java.awt.geom.Rectangle2D; |
|
29 |
|
|
30 |
import org.gvsig.app.project.documents.layout.DefaultLayoutContext; |
|
31 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
32 |
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap; |
|
33 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutMoveListener; |
|
34 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutToolListener; |
|
35 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
36 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
|
37 |
import org.slf4j.Logger; |
|
38 |
import org.slf4j.LoggerFactory; |
|
39 |
|
|
40 |
/** |
|
41 |
* Behaviour que espera un listener de tipo MoveListener. |
|
42 |
* |
|
43 |
* @author Vicente Caballero Navarro |
|
44 |
*/ |
|
45 |
public class LayoutViewMoveBehavior extends LayoutBehavior { |
|
46 |
|
|
47 |
private LayoutMoveListener listener; |
|
48 |
|
|
49 |
/** |
|
50 |
* Crea un nuevo MoveBehavior. |
|
51 |
* |
|
52 |
* @param pli |
|
53 |
* listener. |
|
54 |
*/ |
|
55 |
public LayoutViewMoveBehavior(LayoutMoveListener lpl) { |
|
56 |
listener = lpl; |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(java.awt.Graphics) |
|
61 |
*/ |
|
62 |
public void paintComponent(Graphics g) { |
|
63 |
// save original clip area |
|
64 |
Rectangle2D origClip = g.getClipBounds(); |
|
65 |
// draw cached image |
|
66 |
g.drawImage(getLayoutControl().getImage(), 0, 0, |
|
67 |
getLayoutControl().getComponent()); |
|
68 |
|
|
69 |
IFFrameUseFMap[] fframes = getLayoutControl().getLayoutContext().getSelectedFFrames(IFFrameUseFMap.class); |
|
70 |
for (int i = 0; i < fframes.length; i++) { |
|
71 |
IFFrameUseFMap fframe = fframes[i]; |
|
72 |
Rectangle2D.Double rec = |
|
73 |
((IFFrame) fframe).getBoundingBox(getLayoutControl().getAT()); |
|
74 |
|
|
75 |
if (getLayoutControl().getImage() != null) { |
|
76 |
rec = (Rectangle2D.Double) rec |
|
77 |
.createIntersection(getLayoutControl() |
|
78 |
.getComponent().getVisibleRect()); |
|
79 |
} |
|
80 |
|
|
81 |
if (fframe.getBufferedImage() != null) { |
|
82 |
// clear the fframe rectangle |
|
83 |
Color c = g.getColor(); |
|
84 |
g.setColor(fframe.getMapContext().getViewPort().getBackColor()); |
|
85 |
g.fillRect((int) rec.x, (int) rec.y, (int) rec.width, |
|
86 |
(int) rec.height); |
|
87 |
g.setColor(c); |
|
88 |
|
|
89 |
// draw the cached image in the new position |
|
90 |
g.clipRect((int) rec.x, (int) rec.y, (int) rec.width, |
|
91 |
(int) rec.height); |
|
92 |
|
|
93 |
g.drawImage(fframe.getBufferedImage(), (int) rec.getX() |
|
94 |
+ getLayoutControl().getLastPoint().x |
|
95 |
- getLayoutControl().getPointAnt().x, |
|
96 |
(int) rec.getY() |
|
97 |
+ getLayoutControl().getLastPoint().y |
|
98 |
- getLayoutControl().getPointAnt().y, |
|
99 |
getLayoutControl().getComponent()); |
|
100 |
|
|
101 |
// force a full fframe redrawn for the next drawing cycle |
|
102 |
fframe.refresh(); |
|
103 |
} |
|
104 |
} |
|
105 |
// draw handlers and ruler |
|
106 |
g.setClip(origClip); |
|
107 |
getLayoutControl().getLayoutDraw().drawHandlers((Graphics2D) g, |
|
108 |
Color.black); |
|
109 |
g.drawImage(getLayoutControl().getImgRuler(), 0, 0, getLayoutControl() |
|
110 |
.getComponent()); |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* @throws BehaviorException |
|
115 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
|
116 |
*/ |
|
117 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
|
118 |
super.mousePressed(e); |
|
119 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
120 |
listener.press(event); |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Reimplementaci?n del m?todo mouseReleased de Behavior. |
|
125 |
* |
|
126 |
* @param e |
|
127 |
* MouseEvent |
|
128 |
* |
|
129 |
* @throws BehaviorException |
|
130 |
* Excepci?n lanzada cuando el Behavior. |
|
131 |
*/ |
|
132 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
|
133 |
super.mouseReleased(e); |
|
134 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
135 |
listener.release(event); |
|
136 |
|
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* Reimplementaci?n del m?todo mouseDragged de Behavior. |
|
141 |
* |
|
142 |
* @param e |
|
143 |
* MouseEvent |
|
144 |
* @throws BehaviorException |
|
145 |
*/ |
|
146 |
public void mouseDragged(MouseEvent e) throws BehaviorException { |
|
147 |
super.mouseDragged(e); |
|
148 |
PointEvent event = new PointEvent(e.getPoint(), e); |
|
149 |
listener.drag(event); |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#setListener(com.iver.cit.gvsig.fmap.tools.ToolListener) |
|
154 |
*/ |
|
155 |
public void setListener(LayoutToolListener listener) { |
|
156 |
this.listener = (LayoutMoveListener) listener; |
|
157 |
} |
|
158 |
|
|
159 |
/** |
|
160 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#getListener() |
|
161 |
*/ |
|
162 |
public LayoutToolListener getListener() { |
|
163 |
return listener; |
|
164 |
} |
|
165 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.207/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/behavior/LayoutRectangleBehavior.java | ||
---|---|---|
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.behavior; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
import java.awt.Graphics; |
|
26 |
import java.awt.Graphics2D; |
|
27 |
import java.awt.Point; |
|
28 |
import java.awt.Rectangle; |
|
29 |
import java.awt.event.MouseEvent; |
|
30 |
import java.awt.geom.AffineTransform; |
|
31 |
import java.awt.geom.Point2D; |
|
32 |
import java.awt.geom.Rectangle2D; |
|
33 |
import java.awt.image.BufferedImage; |
|
34 |
|
|
35 |
import org.slf4j.Logger; |
|
36 |
import org.slf4j.LoggerFactory; |
|
37 |
|
|
38 |
import org.gvsig.app.project.documents.layout.FLayoutUtilities; |
|
39 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
40 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutRectangleListener; |
|
41 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutToolListener; |
|
42 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
43 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
44 |
import org.gvsig.fmap.geom.GeometryManager; |
|
45 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
46 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
47 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
48 |
import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent; |
|
49 |
|
|
50 |
/** |
|
51 |
* Behaviour que espera un listener de tipo LayoutRectangleListener. |
|
52 |
* |
|
53 |
* @author Vicente Caballero Navarro |
|
54 |
*/ |
|
55 |
public class LayoutRectangleBehavior extends LayoutBehavior { |
|
56 |
|
|
57 |
private static final GeometryManager geomManager = GeometryLocator |
|
58 |
.getGeometryManager(); |
|
59 |
private static final Logger logger = LoggerFactory |
|
60 |
.getLogger(LayoutRectangleBehavior.class); |
|
61 |
private LayoutRectangleListener listener; |
|
62 |
private boolean dragged = false; |
|
63 |
|
|
64 |
/** |
|
65 |
* Crea un nuevo RectangleBehavior. |
|
66 |
* |
|
67 |
* @param zili |
|
68 |
* listener. |
|
69 |
*/ |
|
70 |
public LayoutRectangleBehavior(LayoutRectangleListener lrl) { |
|
71 |
listener = lrl; |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(java.awt.Graphics) |
|
76 |
*/ |
|
77 |
public void paintComponent(Graphics g) { |
|
78 |
BufferedImage img = getLayoutControl().getImage(); |
|
79 |
BufferedImage imgRuler = getLayoutControl().getImgRuler(); |
|
80 |
g.drawImage(img, 0, 0, getLayoutControl().getComponent()); |
|
81 |
g.drawImage(imgRuler, 0, 0, getLayoutControl().getComponent()); |
|
82 |
g.setColor(Color.black); |
|
83 |
g.setXORMode(Color.white); |
|
84 |
|
|
85 |
// Borramos el anterior |
|
86 |
Rectangle r = new Rectangle(); |
|
87 |
|
|
88 |
// Dibujamos el actual |
|
89 |
if (dragged && (getLayoutControl().getFirstPoint() != null) |
|
90 |
&& (getLayoutControl().getLastPoint() != null)) { |
|
91 |
r.setFrameFromDiagonal(getLayoutControl().getFirstPoint(), |
|
92 |
getLayoutControl().getLastPoint()); |
|
93 |
g.drawRect(r.x, r.y, r.width, r.height); |
|
94 |
} |
|
95 |
IFFrame[] frames = |
|
96 |
getLayoutControl().getLayoutContext().getSelectedFFrames(); |
|
97 |
for (int i = 0; i < frames.length; i++) { |
|
98 |
g.setColor(Color.black); |
|
99 |
frames[i].drawHandlers((Graphics2D) g); |
|
100 |
} |
|
101 |
g.setPaintMode(); |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* Reimplementaci?n del m?todo mousePressed de Behavior. |
|
106 |
* |
|
107 |
* @param e |
|
108 |
* MouseEvent |
|
109 |
* @throws BehaviorException |
|
110 |
*/ |
|
111 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
|
112 |
super.mousePressed(e); |
|
113 |
if (listener.cancelDrawing()) { |
|
114 |
// getLayout().cancelDrawing(); |
|
115 |
} |
|
116 |
getLayoutControl().repaint(); |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* Reimplementaci?n del m?todo mouseReleased de Behavior. |
|
121 |
* |
|
122 |
* @param e |
|
123 |
* MouseEvent |
|
124 |
* |
|
125 |
* @throws BehaviorException |
|
126 |
* Excepci?n lanzada cuando el Behavior. |
|
127 |
*/ |
|
128 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
|
129 |
super.mouseReleased(e); |
|
130 |
dragged = false; |
|
131 |
if (getLayoutControl().getFirstPoint() == null) |
|
132 |
return; |
|
133 |
Point2D p1; |
|
134 |
Point2D p2; |
Also available in: Unified diff