Revision 1714 trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/tools/behavior/LayoutSelectBehavior.java
LayoutSelectBehavior.java | ||
---|---|---|
22 | 22 |
package org.gvsig.app.project.documents.layout.tools.behavior; |
23 | 23 |
|
24 | 24 |
import java.awt.Color; |
25 |
import static java.awt.Event.CTRL_MASK; |
|
25 | 26 |
import java.awt.Graphics; |
26 | 27 |
import java.awt.Graphics2D; |
27 | 28 |
import java.awt.Rectangle; |
28 | 29 |
import java.awt.event.MouseEvent; |
29 | 30 |
import java.awt.geom.Rectangle2D; |
30 |
|
|
31 | 31 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
32 | 32 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutMoveListener; |
33 | 33 |
import org.gvsig.app.project.documents.layout.tools.listener.LayoutToolListener; |
... | ... | |
43 | 43 |
|
44 | 44 |
private LayoutMoveListener listener; |
45 | 45 |
private boolean dragged = false; |
46 |
private int modifiers; |
|
46 | 47 |
|
47 | 48 |
/** |
48 | 49 |
* Crea un nuevo LayoutSelectBehavior. |
... | ... | |
57 | 58 |
/** |
58 | 59 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#paintComponent(java.awt.Graphics) |
59 | 60 |
*/ |
61 |
@Override |
|
60 | 62 |
public void paintComponent(Graphics g) { |
61 | 63 |
getLayoutControl().getLayoutDraw().drawRectangle((Graphics2D) g); |
62 | 64 |
|
... | ... | |
72 | 74 |
} |
73 | 75 |
IFFrame[] frames = |
74 | 76 |
getLayoutControl().getLayoutContext().getSelectedFFrames(); |
75 |
for (int i = 0; i < frames.length; i++) {
|
|
77 |
for (IFFrame frame : frames) {
|
|
76 | 78 |
g.setColor(Color.black); |
77 |
frames[i].drawHandlers((Graphics2D) g);
|
|
79 |
frame.drawHandlers((Graphics2D) g); |
|
78 | 80 |
int difx = |
79 | 81 |
(getLayoutControl().getLastPoint().x - getLayoutControl() |
80 | 82 |
.getFirstPoint().x); |
... | ... | |
82 | 84 |
(getLayoutControl().getLastPoint().y - getLayoutControl() |
83 | 85 |
.getFirstPoint().y); |
84 | 86 |
if ((Math.abs(difx) > 3) || (Math.abs(dify) > 3)) { |
85 |
Rectangle2D rectangle = frames[i].getMovieRect(difx, dify);
|
|
87 |
Rectangle2D rectangle = frame.getMovieRect(difx, dify, !((modifiers & CTRL_MASK) != 0));
|
|
86 | 88 |
if (rectangle == null) |
87 | 89 |
return; |
88 |
((Graphics2D) g).rotate( |
|
89 |
Math.toRadians(frames[i].getRotation()), rectangle.getX() |
|
90 |
+ (rectangle.getWidth() / 2), rectangle.getY() |
|
90 |
((Graphics2D) g).rotate(Math.toRadians(frame.getRotation()), rectangle.getX() |
|
91 |
+ (rectangle.getWidth() / 2), rectangle.getY() |
|
91 | 92 |
+ (rectangle.getHeight() / 2)); |
92 |
|
|
93 |
if (rectangle != null && dragged |
|
94 |
&& !getLayoutControl().isReSel()) { |
|
93 |
if (dragged && !getLayoutControl().isReSel()) { |
|
95 | 94 |
g.drawRect((int) rectangle.getMinX(), |
96 | 95 |
(int) rectangle.getMinY(), (int) rectangle.getWidth(), |
97 | 96 |
(int) rectangle.getHeight()); |
98 | 97 |
} |
99 |
|
|
100 |
((Graphics2D) g).rotate( |
|
101 |
Math.toRadians(-frames[i].getRotation()), rectangle.getX() |
|
102 |
+ (rectangle.getWidth() / 2), rectangle.getY() |
|
98 |
((Graphics2D) g).rotate(Math.toRadians(-frame.getRotation()), rectangle.getX() |
|
99 |
+ (rectangle.getWidth() / 2), rectangle.getY() |
|
103 | 100 |
+ (rectangle.getHeight() / 2)); |
104 |
|
|
105 | 101 |
} |
106 | 102 |
} |
107 | 103 |
|
... | ... | |
113 | 109 |
* @throws BehaviorException |
114 | 110 |
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
115 | 111 |
*/ |
112 |
@Override |
|
116 | 113 |
public void mousePressed(MouseEvent e) throws BehaviorException { |
117 | 114 |
super.mousePressed(e); |
118 | 115 |
PointEvent event = new PointEvent(e.getPoint(), e); |
... | ... | |
128 | 125 |
* @throws BehaviorException |
129 | 126 |
* Excepci?n lanzada cuando el Behavior. |
130 | 127 |
*/ |
128 |
@Override |
|
131 | 129 |
public void mouseReleased(MouseEvent e) throws BehaviorException { |
132 | 130 |
super.mouseReleased(e); |
133 | 131 |
PointEvent event = new PointEvent(e.getPoint(), e); |
... | ... | |
143 | 141 |
* MouseEvent |
144 | 142 |
* @throws BehaviorException |
145 | 143 |
*/ |
144 |
@Override |
|
146 | 145 |
public void mouseDragged(MouseEvent e) throws BehaviorException { |
147 | 146 |
super.mouseDragged(e); |
148 | 147 |
PointEvent event = new PointEvent(e.getPoint(), e); |
149 | 148 |
listener.drag(event); |
150 | 149 |
dragged = true; |
150 |
modifiers = e.getModifiers(); |
|
151 | 151 |
} |
152 | 152 |
|
153 | 153 |
/** |
... | ... | |
160 | 160 |
/** |
161 | 161 |
* @see org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior#getListener() |
162 | 162 |
*/ |
163 |
@Override |
|
163 | 164 |
public LayoutToolListener getListener() { |
164 | 165 |
return listener; |
165 | 166 |
} |
166 | 167 |
|
168 |
@Override |
|
167 | 169 |
public void mouseClicked(MouseEvent e) throws BehaviorException { |
168 | 170 |
super.mouseClicked(e); |
169 | 171 |
PointEvent event = new PointEvent(e.getPoint(), e); |
170 | 172 |
listener.click(event); |
171 | 173 |
} |
172 | 174 |
|
175 |
@Override |
|
173 | 176 |
public void mouseMoved(MouseEvent e) throws BehaviorException { |
174 | 177 |
super.mouseMoved(e); |
175 | 178 |
PointEvent event = new PointEvent(e.getPoint(), e); |
Also available in: Unified diff