svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / layout / mapbox / tools / LayoutEditMapBoxListenerImpl.java @ 1714
History | View | Annotate | Download (3.76 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.layout.mapbox.tools; |
23 |
|
24 |
import java.awt.Image; |
25 |
import java.awt.geom.Point2D; |
26 |
import org.gvsig.andami.PluginServices; |
27 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
28 |
import org.gvsig.app.project.documents.layout.tools.*; |
29 |
import org.gvsig.layout.mapbox.fframe.FFrameMapBox; |
30 |
import org.gvsig.layout.mapbox.model.Cell; |
31 |
import static org.gvsig.layout.mapbox.model.MapBoxModel.POSITION_AT_BOTOM_OF_CELL; |
32 |
import static org.gvsig.layout.mapbox.model.MapBoxModel.POSITION_AT_TOP_OF_CELL; |
33 |
import static org.gvsig.layout.mapbox.model.MapBoxModel.POSITION_ON_LEFT_EDGE_OF_CELL; |
34 |
import static org.gvsig.layout.mapbox.model.MapBoxModel.POSITION_ON_RIGHT_EDGE_OF_CELL; |
35 |
|
36 |
/**
|
37 |
* Implementacion de la interfaz LayoutPanListener como herramienta para
|
38 |
* realizar una seleccion.
|
39 |
*
|
40 |
* @author gvSIG team
|
41 |
*/
|
42 |
public class LayoutEditMapBoxListenerImpl extends AbstractLayoutToolListener { |
43 |
|
44 |
public static final Image icrux = PluginServices.getIconTheme() |
45 |
.get("cursor-layout-graphic-edit-vertex").getImage();
|
46 |
|
47 |
/**
|
48 |
* Crea un nuevo LayoutSelectionListenerImpl.
|
49 |
*
|
50 |
* @param l
|
51 |
* Layout.
|
52 |
*/
|
53 |
public LayoutEditMapBoxListenerImpl(LayoutPanel layoutPanel) {
|
54 |
super(layoutPanel);
|
55 |
} |
56 |
|
57 |
/**
|
58 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getCursor()
|
59 |
*/
|
60 |
@Override
|
61 |
public Image getImageCursor() { |
62 |
return icrux;
|
63 |
} |
64 |
|
65 |
/**
|
66 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#cancelDrawing()
|
67 |
*/
|
68 |
@Override
|
69 |
public boolean cancelDrawing() { |
70 |
return true; |
71 |
} |
72 |
|
73 |
public void selectCell(FFrameMapBox frame, Cell cell) { |
74 |
if (frame.getSelection().getStartCell() == null) { |
75 |
frame.getSelection().add(cell); |
76 |
return;
|
77 |
} |
78 |
if (cell.equals(frame.getSelection().getStartCell())) {
|
79 |
frame.getSelection().clear(); |
80 |
return;
|
81 |
} |
82 |
frame.getSelection().add(cell); |
83 |
} |
84 |
|
85 |
public void drag(FFrameMapBox frame, Integer relativePosition, Cell cell, Point2D.Double secondPoint) { |
86 |
switch (relativePosition) {
|
87 |
case POSITION_AT_TOP_OF_CELL:
|
88 |
frame.moveHorizontalLine(cell.getY(), frame.fromSheetPointToMapBoxPoint(secondPoint).getY()); |
89 |
break;
|
90 |
case POSITION_AT_BOTOM_OF_CELL:
|
91 |
frame.moveHorizontalLine(cell.getY() + cell.getHeight(), frame.fromSheetPointToMapBoxPoint(secondPoint).getY()); |
92 |
break;
|
93 |
case POSITION_ON_LEFT_EDGE_OF_CELL:
|
94 |
frame.moveVerticalLine(cell.getX(), frame.fromSheetPointToMapBoxPoint(secondPoint).getX()); |
95 |
break;
|
96 |
|
97 |
case POSITION_ON_RIGHT_EDGE_OF_CELL:
|
98 |
frame.moveVerticalLine(cell.getX() + cell.getWidth(), frame.fromSheetPointToMapBoxPoint(secondPoint).getX()); |
99 |
break;
|
100 |
default:
|
101 |
//Do nothing
|
102 |
} |
103 |
|
104 |
} |
105 |
} |