Revision 8943
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/AbstractSnapper.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project.documents.view.snapping; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
|
|
5 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
6 |
|
|
7 |
public abstract class AbstractSnapper implements ISnapper { |
|
8 |
|
|
9 |
// private Point2D snapPoint = null; |
|
10 |
private int sizePixels = 10; |
|
11 |
private Color color = Color.MAGENTA; |
|
12 |
private boolean enabled; |
|
13 |
// public void setSnapPoint(Point2D snapPoint) { |
|
14 |
// this.snapPoint = snapPoint; |
|
15 |
// |
|
16 |
// } |
|
17 |
|
|
18 |
|
|
19 |
public int getSizePixels() { |
|
20 |
return sizePixels; |
|
21 |
} |
|
22 |
|
|
23 |
public void setSizePixels(int sizePixels) { |
|
24 |
this.sizePixels = sizePixels; |
|
25 |
} |
|
26 |
|
|
27 |
public Color getColor() { |
|
28 |
return color; |
|
29 |
} |
|
30 |
|
|
31 |
public void setColor(Color color) { |
|
32 |
this.color = color; |
|
33 |
} |
|
34 |
|
|
35 |
public IWindow getConfigurator(){ |
|
36 |
// DefaultConfigurePanel configurePanel=new DefaultConfigurePanel(); |
|
37 |
// return configurePanel; |
|
38 |
return null; |
|
39 |
} |
|
40 |
|
|
41 |
public boolean isEnabled() { |
|
42 |
return enabled; |
|
43 |
} |
|
44 |
|
|
45 |
public void setEnabled(boolean enabled) { |
|
46 |
this.enabled = enabled; |
|
47 |
} |
|
48 |
} |
|
0 | 49 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/ISnapperGeometriesVectorial.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.project.documents.view.snapping; |
|
42 |
|
|
43 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
44 |
|
|
45 |
import java.awt.geom.Point2D; |
|
46 |
|
|
47 |
|
|
48 |
/** |
|
49 |
* Snapper vectorial with geometries. |
|
50 |
* |
|
51 |
* @author Vicente Caballero Navarro |
|
52 |
*/ |
|
53 |
public interface ISnapperGeometriesVectorial extends ISnapperVectorial { |
|
54 |
Point2D getSnapPoint(Point2D queryPoint, IGeometry geomToSnap, |
|
55 |
double tolerance, Point2D lastPointEntered); |
|
56 |
|
|
57 |
void setGeometries(IGeometry[] geoms); |
|
58 |
} |
|
0 | 59 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/Snapping.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project.documents.view.snapping; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.project.documents.view.snapping.snappers.CentralPointSnapper; |
|
4 |
import com.iver.cit.gvsig.project.documents.view.snapping.snappers.CuadrantPointSnapper; |
|
5 |
import com.iver.cit.gvsig.project.documents.view.snapping.snappers.FinalPointSnapper; |
|
6 |
import com.iver.cit.gvsig.project.documents.view.snapping.snappers.InsertPointSnapper; |
|
7 |
import com.iver.cit.gvsig.project.documents.view.snapping.snappers.IntersectionPointSnapper; |
|
8 |
import com.iver.cit.gvsig.project.documents.view.snapping.snappers.MediumPointSnapper; |
|
9 |
import com.iver.cit.gvsig.project.documents.view.snapping.snappers.NearestPointSnapper; |
|
10 |
import com.iver.cit.gvsig.project.documents.view.snapping.snappers.PerpendicularPointSnapper; |
|
11 |
import com.iver.cit.gvsig.project.documents.view.snapping.snappers.PixelSnapper; |
|
12 |
import com.iver.cit.gvsig.project.documents.view.snapping.snappers.TangentPointSnapper; |
|
13 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
|
14 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
|
15 |
|
|
16 |
/** |
|
17 |
* DOCUMENT ME! |
|
18 |
* |
|
19 |
* @author Vicente Caballero Navarro |
|
20 |
*/ |
|
21 |
public class Snapping { |
|
22 |
/** |
|
23 |
* DOCUMENT ME! |
|
24 |
*/ |
|
25 |
public static void register() { |
|
26 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
27 |
extensionPoints.add("Snapper","FinalPointSnapper", FinalPointSnapper.class); |
|
28 |
extensionPoints.add("Snapper","NearestPointSnapper", NearestPointSnapper.class); |
|
29 |
extensionPoints.add("Snapper","PixelSnapper", PixelSnapper.class); |
|
30 |
extensionPoints.add("Snapper","CentralPointSnapper", CentralPointSnapper.class); |
|
31 |
extensionPoints.add("Snapper","CuadrantPointSnapper", CuadrantPointSnapper.class); |
|
32 |
extensionPoints.add("Snapper","InsertPointSnapper", InsertPointSnapper.class); |
|
33 |
extensionPoints.add("Snapper","IntersectionPointSnapper", IntersectionPointSnapper.class); |
|
34 |
extensionPoints.add("Snapper","MediumPointSnapper", MediumPointSnapper.class); |
|
35 |
extensionPoints.add("Snapper","PerpendicularPointSnapper", PerpendicularPointSnapper.class); |
|
36 |
extensionPoints.add("Snapper","TangentPointSnapper", TangentPointSnapper.class); |
|
37 |
} |
|
38 |
} |
|
0 | 39 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/SnappingVisitor.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project.documents.view.snapping; |
|
2 |
|
|
3 |
import java.awt.geom.Point2D; |
|
4 |
|
|
5 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
6 |
import com.vividsolutions.jts.index.ItemVisitor; |
|
7 |
|
|
8 |
/** |
|
9 |
* @author fjp |
|
10 |
* |
|
11 |
* Visitor adecuado para recorrer el ?ndice espacial de JTS y no obligar |
|
12 |
* a dar 2 pasadas. En la misma pasada que se visita, se calcula la distancia |
|
13 |
* m?nima. |
|
14 |
*/ |
|
15 |
public class SnappingVisitor implements ItemVisitor { |
|
16 |
|
|
17 |
ISnapperVectorial snapper; |
|
18 |
Point2D snapPoint = null; |
|
19 |
Point2D queryPoint = null; |
|
20 |
Point2D lastPointEntered = null; |
|
21 |
|
|
22 |
double minDist = Double.MAX_VALUE; |
|
23 |
double distActual; |
|
24 |
double tolerance; |
|
25 |
|
|
26 |
public SnappingVisitor(ISnapperVectorial snapper, Point2D queryPoint, double tolerance, Point2D lastPointEntered) |
|
27 |
{ |
|
28 |
this.snapper = snapper; |
|
29 |
this.tolerance = tolerance; |
|
30 |
this.queryPoint = queryPoint; |
|
31 |
this.lastPointEntered = lastPointEntered; |
|
32 |
distActual = tolerance; |
|
33 |
// snapper.setSnapPoint(null); |
|
34 |
} |
|
35 |
|
|
36 |
public void visitItem(Object item) { |
|
37 |
IGeometry geom = (IGeometry) item; |
|
38 |
Point2D aux = snapper.getSnapPoint(queryPoint, geom, distActual, lastPointEntered); |
|
39 |
if (aux != null) |
|
40 |
{ |
|
41 |
snapPoint = aux; |
|
42 |
minDist = snapPoint.distance(queryPoint); |
|
43 |
distActual = minDist; |
|
44 |
// snapper.setSnapPoint(snapPoint); |
|
45 |
} |
|
46 |
|
|
47 |
} |
|
48 |
|
|
49 |
|
|
50 |
public Point2D getSnapPoint() |
|
51 |
{ |
|
52 |
|
|
53 |
return snapPoint; |
|
54 |
} |
|
55 |
|
|
56 |
// public double getMinDist() { |
|
57 |
// return minDist; |
|
58 |
// } |
|
59 |
|
|
60 |
} |
|
0 | 61 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/ISnapper.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project.documents.view.snapping; |
|
2 |
|
|
3 |
import java.awt.Graphics; |
|
4 |
import java.awt.geom.Point2D; |
|
5 |
|
|
6 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
7 |
|
|
8 |
/** |
|
9 |
* @author fjp |
|
10 |
* |
|
11 |
*/ |
|
12 |
public interface ISnapper { |
|
13 |
|
|
14 |
|
|
15 |
// void setSnapPoint(Point2D snapPoint); |
|
16 |
|
|
17 |
void draw(Graphics g, Point2D pPixels); |
|
18 |
|
|
19 |
String getToolTipText(); |
|
20 |
|
|
21 |
/** |
|
22 |
* Implement this if you need a Snapper more important than the others. |
|
23 |
* Default value is 0 (no prority). |
|
24 |
* @return |
|
25 |
*/ |
|
26 |
int getPriority(); |
|
27 |
|
|
28 |
boolean isEnabled(); |
|
29 |
public void setEnabled(boolean enabled); |
|
30 |
|
|
31 |
IWindow getConfigurator(); |
|
32 |
|
|
33 |
} |
|
0 | 34 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/ISnapperRaster.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.project.documents.view.snapping; |
|
42 |
|
|
43 |
import java.awt.geom.Point2D; |
|
44 |
|
|
45 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
46 |
|
|
47 |
public interface ISnapperRaster extends ISnapper { |
|
48 |
|
|
49 |
Point2D getSnapPoint(MapControl mapControl, Point2D point, double mapTolerance, Point2D lastPoint); |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
|
|
0 | 54 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/GeometriesSnappingVisitor.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project.documents.view.snapping; |
|
2 |
|
|
3 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
4 |
|
|
5 |
import com.vividsolutions.jts.geom.Coordinate; |
|
6 |
import com.vividsolutions.jts.geom.Geometry; |
|
7 |
import com.vividsolutions.jts.geom.GeometryFactory; |
|
8 |
import com.vividsolutions.jts.index.ItemVisitor; |
|
9 |
|
|
10 |
import java.awt.geom.Point2D; |
|
11 |
|
|
12 |
import java.util.ArrayList; |
|
13 |
|
|
14 |
|
|
15 |
/** |
|
16 |
* SnappingVisitor with geometries. |
|
17 |
* |
|
18 |
* @author Vicente Caballero Navarro |
|
19 |
*/ |
|
20 |
public class GeometriesSnappingVisitor extends SnappingVisitor |
|
21 |
implements ItemVisitor { |
|
22 |
private ArrayList geometries = new ArrayList(); |
|
23 |
private GeometryFactory geometryFactory = new GeometryFactory(); |
|
24 |
|
|
25 |
public GeometriesSnappingVisitor(ISnapperVectorial snapper, Point2D point, |
|
26 |
double mapTolerance, Point2D lastPointEntered) { |
|
27 |
super(snapper, point, mapTolerance, lastPointEntered); |
|
28 |
} |
|
29 |
|
|
30 |
public void visitItem(Object item) { |
|
31 |
try { |
|
32 |
IGeometry geom = (IGeometry) item; |
|
33 |
Geometry geometry = geom.toJTSGeometry(); |
|
34 |
double distance = geometry.distance(geometryFactory.createPoint( |
|
35 |
new Coordinate(queryPoint.getX(), queryPoint.getY()))); |
|
36 |
|
|
37 |
if (distance < tolerance) { |
|
38 |
geometries.add(geom); |
|
39 |
} |
|
40 |
}catch (Exception e) { |
|
41 |
} |
|
42 |
} |
|
43 |
|
|
44 |
public Point2D getSnapPoint() { |
|
45 |
if (geometries.isEmpty()) { |
|
46 |
return null; |
|
47 |
} |
|
48 |
|
|
49 |
IGeometry[] geoms = (IGeometry[]) geometries.toArray(new IGeometry[0]); |
|
50 |
((ISnapperGeometriesVectorial) snapper).setGeometries(geoms); |
|
51 |
|
|
52 |
Point2D result = null; |
|
53 |
|
|
54 |
for (int i = 0; i < geoms.length; i++) { |
|
55 |
result = snapper.getSnapPoint(queryPoint, geoms[i], tolerance, |
|
56 |
lastPointEntered); |
|
57 |
|
|
58 |
if (result != null) { |
|
59 |
return result; |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
return result; |
|
64 |
} |
|
65 |
} |
|
0 | 66 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/gui/SnapConfig.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.project.documents.view.snapping.gui; |
|
42 |
|
|
43 |
import java.awt.Component; |
|
44 |
import java.util.ArrayList; |
|
45 |
import java.util.TreeMap; |
|
46 |
|
|
47 |
import javax.swing.JButton; |
|
48 |
import javax.swing.JCheckBox; |
|
49 |
import javax.swing.JList; |
|
50 |
import javax.swing.JPanel; |
|
51 |
import javax.swing.JScrollPane; |
|
52 |
import javax.swing.JTable; |
|
53 |
import javax.swing.ListCellRenderer; |
|
54 |
import javax.swing.table.AbstractTableModel; |
|
55 |
import javax.swing.table.TableColumn; |
|
56 |
import javax.swing.table.TableModel; |
|
57 |
|
|
58 |
import com.iver.andami.PluginServices; |
|
59 |
import com.iver.cit.gvsig.project.documents.view.snapping.ISnapper; |
|
60 |
|
|
61 |
/** |
|
62 |
* @author fjp |
|
63 |
* |
|
64 |
* Necesitamos un sitio donde est?n registrados todos los snappers que |
|
65 |
* se pueden usar. ExtensionPoints es el sitio adecuado. |
|
66 |
* Este di?logo recuperar? esa lista para que el usuario marque los |
|
67 |
* snappers con los que desea trabajar. |
|
68 |
*/ |
|
69 |
public class SnapConfig extends JPanel { |
|
70 |
|
|
71 |
private JCheckBox jChkBoxRefentActive = null; |
|
72 |
private JTable jListSnappers = null; |
|
73 |
private JPanel jPanel = null; |
|
74 |
private JScrollPane jScrollPane = null; |
|
75 |
|
|
76 |
private ArrayList snappers; |
|
77 |
|
|
78 |
/** |
|
79 |
* @author fjp |
|
80 |
* primera columna editable con un check box para habilitar/deshabilitar el snapper |
|
81 |
* segunda columna con el s?mbolo del snapper |
|
82 |
* tercera con el tooltip |
|
83 |
* cuarta con un bot?n para configurar el snapper si es necesario. |
|
84 |
*/ |
|
85 |
class MyTableModel extends AbstractTableModel { |
|
86 |
|
|
87 |
public ArrayList mySnappers; |
|
88 |
|
|
89 |
public MyTableModel(ArrayList snappers) |
|
90 |
{ |
|
91 |
this.mySnappers = snappers; |
|
92 |
} |
|
93 |
|
|
94 |
public int getColumnCount() { |
|
95 |
return 5; |
|
96 |
} |
|
97 |
|
|
98 |
public int getRowCount() { |
|
99 |
return mySnappers.size(); |
|
100 |
} |
|
101 |
|
|
102 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
|
103 |
if (columnIndex == 0 || columnIndex == 4) |
|
104 |
return true; |
|
105 |
return false; |
|
106 |
} |
|
107 |
|
|
108 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
|
109 |
ISnapper snap = (ISnapper) mySnappers.get(rowIndex); |
|
110 |
switch (columnIndex) |
|
111 |
{ |
|
112 |
case 0: |
|
113 |
snap.setEnabled(((Boolean)aValue).booleanValue()); |
|
114 |
} |
|
115 |
|
|
116 |
} |
|
117 |
|
|
118 |
public Object getValueAt(int rowIndex, int columnIndex) { |
|
119 |
ISnapper snap = (ISnapper) mySnappers.get(rowIndex); |
|
120 |
switch (columnIndex) |
|
121 |
{ |
|
122 |
case 0: |
|
123 |
return new Boolean(snap.isEnabled()); |
|
124 |
case 1: |
|
125 |
return snap.getClass().getName(); |
|
126 |
case 2: |
|
127 |
return snap.getToolTipText(); |
|
128 |
case 3: |
|
129 |
return String.valueOf(snap.getPriority()); |
|
130 |
case 4: |
|
131 |
return new JButton(); |
|
132 |
} |
|
133 |
return null; |
|
134 |
} |
|
135 |
|
|
136 |
public Class getColumnClass(int columnIndex) { |
|
137 |
switch (columnIndex) |
|
138 |
{ |
|
139 |
case 0: |
|
140 |
return Boolean.class; |
|
141 |
case 1: |
|
142 |
return String.class; |
|
143 |
case 2: |
|
144 |
return String.class; |
|
145 |
case 3: |
|
146 |
return String.class; |
|
147 |
case 4: |
|
148 |
return JButton.class; |
|
149 |
} |
|
150 |
return null; |
|
151 |
} |
|
152 |
|
|
153 |
public String getColumnName(int columnIndex) { |
|
154 |
switch (columnIndex){ |
|
155 |
case 0: |
|
156 |
return PluginServices.getText(this,"aplicar"); |
|
157 |
case 1: |
|
158 |
return PluginServices.getText(this,"simbolo"); |
|
159 |
case 2: |
|
160 |
return PluginServices.getText(this,"tipo"); |
|
161 |
case 3: |
|
162 |
return PluginServices.getText(this,"prioridad"); |
|
163 |
case 4: |
|
164 |
return PluginServices.getText(this,"propiedades"); |
|
165 |
} |
|
166 |
return null; |
|
167 |
} |
|
168 |
|
|
169 |
} |
|
170 |
|
|
171 |
class MyCellRenderer extends JCheckBox implements ListCellRenderer { |
|
172 |
|
|
173 |
// This is the only method defined by ListCellRenderer. |
|
174 |
// We just reconfigure the JLabel each time we're called. |
|
175 |
|
|
176 |
public Component getListCellRendererComponent( |
|
177 |
JList list, |
|
178 |
Object value, // value to display |
|
179 |
int index, // cell index |
|
180 |
boolean isSelected, // is the cell selected |
|
181 |
boolean cellHasFocus) // the list and the cell have the focus |
|
182 |
{ |
|
183 |
ISnapper snapper = (ISnapper) value; |
|
184 |
String s = snapper.getToolTipText(); |
|
185 |
setText(s); |
|
186 |
|
|
187 |
if (isSelected) { |
|
188 |
setBackground(list.getSelectionBackground()); |
|
189 |
setForeground(list.getSelectionForeground()); |
|
190 |
} |
|
191 |
else { |
|
192 |
setBackground(list.getBackground()); |
|
193 |
setForeground(list.getForeground()); |
|
194 |
} |
|
195 |
setEnabled(list.isEnabled()); |
|
196 |
setFont(list.getFont()); |
|
197 |
setOpaque(true); |
|
198 |
return this; |
|
199 |
} |
|
200 |
|
|
201 |
public void doClick() { |
|
202 |
super.doClick(); |
|
203 |
System.out.println("Click"); |
|
204 |
} |
|
205 |
|
|
206 |
|
|
207 |
} |
|
208 |
|
|
209 |
|
|
210 |
/** |
|
211 |
* This method initializes |
|
212 |
* |
|
213 |
*/ |
|
214 |
public SnapConfig() { |
|
215 |
super(); |
|
216 |
initialize(); |
|
217 |
} |
|
218 |
|
|
219 |
/** |
|
220 |
* This method initializes this |
|
221 |
* |
|
222 |
*/ |
|
223 |
private void initialize() { |
|
224 |
this.setLayout(null); |
|
225 |
this.setSize(new java.awt.Dimension(463,239)); |
|
226 |
this.setPreferredSize(new java.awt.Dimension(463,239)); |
|
227 |
this.add(getJChkBoxRefentActive(), null); |
|
228 |
this.add(getJPanel(), null); |
|
229 |
|
|
230 |
} |
|
231 |
|
|
232 |
/** |
|
233 |
* This method initializes jChkBoxRefentActive |
|
234 |
* |
|
235 |
* @return javax.swing.JCheckBox |
|
236 |
*/ |
|
237 |
private JCheckBox getJChkBoxRefentActive() { |
|
238 |
if (jChkBoxRefentActive == null) { |
|
239 |
jChkBoxRefentActive = new JCheckBox(); |
|
240 |
jChkBoxRefentActive.setText("Referencia a Objetos Activada:"); |
|
241 |
jChkBoxRefentActive.setBounds(new java.awt.Rectangle(26,10,418,23)); |
|
242 |
} |
|
243 |
return jChkBoxRefentActive; |
|
244 |
} |
|
245 |
|
|
246 |
/** |
|
247 |
* This method initializes jListSnappers |
|
248 |
* |
|
249 |
* @return javax.swing.JList |
|
250 |
*/ |
|
251 |
private JTable getJListSnappers() { |
|
252 |
if (jListSnappers == null) { |
|
253 |
jListSnappers = new JTable(); |
|
254 |
// jListSnappers.setCellRenderer(new MyCellRenderer()); |
|
255 |
} |
|
256 |
return jListSnappers; |
|
257 |
} |
|
258 |
|
|
259 |
/** |
|
260 |
* This method initializes jPanel |
|
261 |
* |
|
262 |
* @return javax.swing.JPanel |
|
263 |
*/ |
|
264 |
private JPanel getJPanel() { |
|
265 |
if (jPanel == null) { |
|
266 |
jPanel = new JPanel(); |
|
267 |
jPanel.setLayout(null); |
|
268 |
jPanel.setBounds(new java.awt.Rectangle(19,40,423,181)); |
|
269 |
jPanel.add(getJScrollPane(), null); |
|
270 |
} |
|
271 |
return jPanel; |
|
272 |
} |
|
273 |
|
|
274 |
/** |
|
275 |
* This method initializes jScrollPane |
|
276 |
* |
|
277 |
* @return javax.swing.JScrollPane |
|
278 |
*/ |
|
279 |
private JScrollPane getJScrollPane() { |
|
280 |
if (jScrollPane == null) { |
|
281 |
jScrollPane = new JScrollPane(); |
|
282 |
jScrollPane.setBounds(new java.awt.Rectangle(9,9,402,163)); |
|
283 |
jScrollPane.setViewportView(getJListSnappers()); |
|
284 |
} |
|
285 |
return jScrollPane; |
|
286 |
} |
|
287 |
|
|
288 |
public ArrayList getSnappers() { |
|
289 |
return snappers; |
|
290 |
} |
|
291 |
|
|
292 |
public void setSnappers(ArrayList snappers) { |
|
293 |
this.snappers = snappers; |
|
294 |
MyTableModel listModel = new MyTableModel(snappers); |
|
295 |
getJListSnappers().setModel(listModel); |
|
296 |
TableColumn tc=getJListSnappers().getColumnModel().getColumn(0); |
|
297 |
setUpSymbolColumn(getJListSnappers().getColumnModel().getColumn(1)); |
|
298 |
setUpPropertyColumn(getJListSnappers().getColumnModel().getColumn(4)); |
|
299 |
getJListSnappers().setCellSelectionEnabled(false); |
|
300 |
tc.setMaxWidth(40); |
|
301 |
tc.setMinWidth(20); |
|
302 |
} |
|
303 |
public TableModel getTableModel() { |
|
304 |
return getJListSnappers().getModel(); |
|
305 |
} |
|
306 |
public boolean applySnappers() { |
|
307 |
return getJChkBoxRefentActive().isSelected(); |
|
308 |
} |
|
309 |
|
|
310 |
public void selectSnappers(TreeMap selected) { |
|
311 |
for (int i=0;i<snappers.size();i++) { |
|
312 |
Boolean b=(Boolean)selected.get(snappers.get(i)); |
|
313 |
if (b!=null) |
|
314 |
getTableModel().setValueAt(b,i,0); |
|
315 |
else |
|
316 |
getTableModel().setValueAt(new Boolean(false),i,0); |
|
317 |
} |
|
318 |
|
|
319 |
} |
|
320 |
|
|
321 |
public void setApplySnappers(boolean applySnappers) { |
|
322 |
getJChkBoxRefentActive().setSelected(applySnappers); |
|
323 |
} |
|
324 |
public void setUpSymbolColumn(TableColumn column) { |
|
325 |
DrawSnapCellRenderer symbolCellRenderer = new DrawSnapCellRenderer(snappers); |
|
326 |
column.setCellRenderer(symbolCellRenderer); |
|
327 |
} |
|
328 |
public void setUpPropertyColumn(TableColumn column) { |
|
329 |
PropertySnapCellEditor propertyeditor = new PropertySnapCellEditor(snappers); |
|
330 |
column.setCellEditor(propertyeditor); |
|
331 |
|
|
332 |
PropertySnapCellRenderer renderer = new PropertySnapCellRenderer(snappers); |
|
333 |
column.setCellRenderer(renderer); |
|
334 |
} |
|
335 |
} // @jve:decl-index=0:visual-constraint="10,10" |
|
336 |
|
|
337 |
|
|
0 | 338 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/gui/SnapConfig2.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.project.documents.view.snapping.gui; |
|
42 |
|
|
43 |
import java.awt.Component; |
|
44 |
import java.awt.Graphics2D; |
|
45 |
import java.awt.GridLayout; |
|
46 |
import java.awt.Point; |
|
47 |
import java.awt.image.BufferedImage; |
|
48 |
import java.util.ArrayList; |
|
49 |
|
|
50 |
import javax.swing.JCheckBox; |
|
51 |
import javax.swing.JList; |
|
52 |
import javax.swing.JPanel; |
|
53 |
import javax.swing.JScrollPane; |
|
54 |
import javax.swing.ListCellRenderer; |
|
55 |
|
|
56 |
import com.iver.cit.gvsig.project.documents.view.snapping.ISnapper; |
|
57 |
; |
|
58 |
|
|
59 |
public class SnapConfig2 extends JPanel { |
|
60 |
|
|
61 |
private JCheckBox jChkBoxRefentActive = null; |
|
62 |
private JPanel jPanel = null; |
|
63 |
private JScrollPane jScrollPane = null; |
|
64 |
|
|
65 |
private BufferedImage myCanvas = new BufferedImage(12, 12, BufferedImage.TYPE_INT_ARGB); |
|
66 |
|
|
67 |
private ArrayList snappers; |
|
68 |
|
|
69 |
class MyCellRenderer extends JCheckBox implements ListCellRenderer { |
|
70 |
|
|
71 |
// This is the only method defined by ListCellRenderer. |
|
72 |
// We just reconfigure the JLabel each time we're called. |
|
73 |
|
|
74 |
|
|
75 |
public Component getListCellRendererComponent( |
|
76 |
JList list, |
|
77 |
Object value, // value to display |
|
78 |
int index, // cell index |
|
79 |
boolean isSelected, // is the cell selected |
|
80 |
boolean cellHasFocus) // the list and the cell have the focus |
|
81 |
{ |
|
82 |
ISnapper snapper = (ISnapper) value; |
|
83 |
String s = snapper.getToolTipText(); |
|
84 |
setText(s); |
|
85 |
|
|
86 |
if (isSelected) { |
|
87 |
setBackground(list.getSelectionBackground()); |
|
88 |
setForeground(list.getSelectionForeground()); |
|
89 |
} |
|
90 |
else { |
|
91 |
setBackground(list.getBackground()); |
|
92 |
setForeground(list.getForeground()); |
|
93 |
} |
|
94 |
setEnabled(list.isEnabled()); |
|
95 |
setFont(list.getFont()); |
|
96 |
setOpaque(true); |
|
97 |
return this; |
|
98 |
} |
|
99 |
|
|
100 |
public void doClick() { |
|
101 |
super.doClick(); |
|
102 |
System.out.println("Click"); |
|
103 |
} |
|
104 |
|
|
105 |
|
|
106 |
} |
|
107 |
|
|
108 |
|
|
109 |
/** |
|
110 |
* This method initializes |
|
111 |
* |
|
112 |
*/ |
|
113 |
public SnapConfig2() { |
|
114 |
super(); |
|
115 |
initialize(); |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* This method initializes this |
|
120 |
* |
|
121 |
*/ |
|
122 |
private void initialize() { |
|
123 |
this.setLayout(null); |
|
124 |
this.setSize(new java.awt.Dimension(463,239)); |
|
125 |
this.setPreferredSize(new java.awt.Dimension(463,239)); |
|
126 |
this.add(getJChkBoxRefentActive(), null); |
|
127 |
this.add(getJPanel(), null); |
|
128 |
|
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* This method initializes jChkBoxRefentActive |
|
133 |
* |
|
134 |
* @return javax.swing.JCheckBox |
|
135 |
*/ |
|
136 |
private JCheckBox getJChkBoxRefentActive() { |
|
137 |
if (jChkBoxRefentActive == null) { |
|
138 |
jChkBoxRefentActive = new JCheckBox(); |
|
139 |
jChkBoxRefentActive.setText("Referencia a Objetos Activada:"); |
|
140 |
jChkBoxRefentActive.setBounds(new java.awt.Rectangle(26,10,418,23)); |
|
141 |
} |
|
142 |
return jChkBoxRefentActive; |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* This method initializes jPanel |
|
147 |
* |
|
148 |
* @return javax.swing.JPanel |
|
149 |
*/ |
|
150 |
private JPanel getJPanel() { |
|
151 |
if (jPanel == null) { |
|
152 |
jPanel = new JPanel(); |
|
153 |
jPanel.setLayout(null); |
|
154 |
jPanel.setBounds(new java.awt.Rectangle(19,40,423,181)); |
|
155 |
jPanel.add(getJScrollPane(), null); |
|
156 |
} |
|
157 |
return jPanel; |
|
158 |
} |
|
159 |
|
|
160 |
/** |
|
161 |
* This method initializes jScrollPane |
|
162 |
* |
|
163 |
* @return javax.swing.JScrollPane |
|
164 |
*/ |
|
165 |
private JScrollPane getJScrollPane() { |
|
166 |
if (jScrollPane == null) { |
|
167 |
jScrollPane = new JScrollPane(); |
|
168 |
jScrollPane.setBounds(new java.awt.Rectangle(9,9,402,163)); |
|
169 |
jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
|
170 |
jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); |
|
171 |
|
|
172 |
} |
|
173 |
return jScrollPane; |
|
174 |
} |
|
175 |
|
|
176 |
public ArrayList getSnappers() { |
|
177 |
return snappers; |
|
178 |
} |
|
179 |
|
|
180 |
public void setSnappers(ArrayList snappers) { |
|
181 |
this.snappers = snappers; |
|
182 |
JPanel newPanel = new JPanel(); |
|
183 |
GridLayout layout = new GridLayout(snappers.size()/2, 2); |
|
184 |
newPanel.setLayout(layout); |
|
185 |
newPanel.setSize(getJScrollPane().getSize()); |
|
186 |
for (int i=0; i < snappers.size(); i++) |
|
187 |
{ |
|
188 |
ISnapper s = (ISnapper) snappers.get(i); |
|
189 |
JCheckBox snapperComponent = new JCheckBox(s.getToolTipText()); |
|
190 |
// snapperComponent.setPreferredSize(new Dimension(200, 30)); |
|
191 |
Graphics2D g2 = myCanvas.createGraphics(); |
|
192 |
g2.clearRect(0,0, 12, 12); |
|
193 |
s.draw(g2, new Point(5,5)); |
|
194 |
g2.dispose(); |
|
195 |
// snapperComponent.getLabel().setIcon(new ImageIcon(myCanvas)); |
|
196 |
|
|
197 |
newPanel.add(snapperComponent); |
|
198 |
} |
|
199 |
getJScrollPane().setViewportView(newPanel); |
|
200 |
|
|
201 |
} |
|
202 |
|
|
203 |
|
|
204 |
} // @jve:decl-index=0:visual-constraint="10,10" |
|
205 |
|
|
206 |
|
|
0 | 207 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/gui/PropertySnapCellEditor.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project.documents.view.snapping.gui; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.Component; |
|
5 |
import java.awt.event.MouseEvent; |
|
6 |
import java.awt.event.MouseListener; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.EventObject; |
|
9 |
|
|
10 |
import javax.swing.JButton; |
|
11 |
import javax.swing.JPanel; |
|
12 |
import javax.swing.JTable; |
|
13 |
import javax.swing.event.CellEditorListener; |
|
14 |
import javax.swing.table.TableCellEditor; |
|
15 |
|
|
16 |
import com.iver.andami.PluginServices; |
|
17 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
18 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
19 |
import com.iver.cit.gvsig.project.documents.view.snapping.ISnapper; |
|
20 |
|
|
21 |
public class PropertySnapCellEditor extends JButton implements TableCellEditor{ |
|
22 |
private ArrayList snappers; |
|
23 |
private int row; |
|
24 |
private IWindow panel; |
|
25 |
public PropertySnapCellEditor(ArrayList snappers) { |
|
26 |
this.snappers=snappers; |
|
27 |
this.addMouseListener(new MouseListener() { |
|
28 |
|
|
29 |
public void mouseClicked(MouseEvent e) { |
|
30 |
if (e.getClickCount()==2) { |
|
31 |
if (panel!=null) |
|
32 |
openConfigurePanel(); |
|
33 |
} |
|
34 |
} |
|
35 |
|
|
36 |
public void mouseEntered(MouseEvent e) { |
|
37 |
// TODO Auto-generated method stub |
|
38 |
|
|
39 |
} |
|
40 |
|
|
41 |
public void mouseExited(MouseEvent e) { |
|
42 |
// TODO Auto-generated method stub |
|
43 |
|
|
44 |
} |
|
45 |
|
|
46 |
public void mousePressed(MouseEvent e) { |
|
47 |
// TODO Auto-generated method stub |
|
48 |
|
|
49 |
} |
|
50 |
|
|
51 |
public void mouseReleased(MouseEvent e) { |
|
52 |
// TODO Auto-generated method stub |
|
53 |
|
|
54 |
} |
|
55 |
|
|
56 |
}); |
|
57 |
} |
|
58 |
// class WinConfigure extends JPanel implements IWindow { |
|
59 |
// |
|
60 |
// private WindowInfo wi=null; |
|
61 |
// |
|
62 |
// public WindowInfo getWindowInfo() { |
|
63 |
// if (wi==null) { |
|
64 |
// wi=new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE); |
|
65 |
// wi.setWidth(panel.getWidth()); |
|
66 |
// wi.setHeight(panel.getHeight()); |
|
67 |
// wi.setTitle(PluginServices.getText(this,"propiedades")); |
|
68 |
// } |
|
69 |
// return wi; |
|
70 |
// } |
|
71 |
// } |
|
72 |
private void openConfigurePanel() { |
|
73 |
//IWindow window=new WinConfigure(); |
|
74 |
((DefaultConfigurePanel)panel).setSnapper((ISnapper)snappers.get(row)); |
|
75 |
PluginServices.getMDIManager().addWindow(panel); |
|
76 |
} |
|
77 |
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
78 |
this.row=row; |
|
79 |
panel=((ISnapper)snappers.get(row)).getConfigurator(); |
|
80 |
if (panel!=null) { |
|
81 |
this.setEnabled(true); |
|
82 |
}else { |
|
83 |
this.setEnabled(false); |
|
84 |
this.setBackground(Color.white); |
|
85 |
} |
|
86 |
return this; |
|
87 |
} |
|
88 |
|
|
89 |
public void cancelCellEditing() { |
|
90 |
// TODO Auto-generated method stub |
|
91 |
|
|
92 |
} |
|
93 |
|
|
94 |
public boolean stopCellEditing() { |
|
95 |
// TODO Auto-generated method stub |
|
96 |
return false; |
|
97 |
} |
|
98 |
|
|
99 |
public Object getCellEditorValue() { |
|
100 |
// TODO Auto-generated method stub |
|
101 |
return null; |
|
102 |
} |
|
103 |
|
|
104 |
public boolean isCellEditable(EventObject anEvent) { |
|
105 |
return true; |
|
106 |
} |
|
107 |
|
|
108 |
public boolean shouldSelectCell(EventObject anEvent) { |
|
109 |
// TODO Auto-generated method stub |
|
110 |
return false; |
|
111 |
} |
|
112 |
|
|
113 |
public void addCellEditorListener(CellEditorListener l) { |
|
114 |
// TODO Auto-generated method stub |
|
115 |
|
|
116 |
} |
|
117 |
|
|
118 |
public void removeCellEditorListener(CellEditorListener l) { |
|
119 |
// TODO Auto-generated method stub |
|
120 |
|
|
121 |
} |
|
122 |
|
|
123 |
} |
|
0 | 124 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/gui/PropertySnapCellRenderer.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project.documents.view.snapping.gui; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.Component; |
|
5 |
import java.util.ArrayList; |
|
6 |
|
|
7 |
import javax.swing.JButton; |
|
8 |
import javax.swing.JPanel; |
|
9 |
import javax.swing.JTable; |
|
10 |
import javax.swing.table.TableCellRenderer; |
|
11 |
|
|
12 |
import com.iver.cit.gvsig.project.documents.view.snapping.ISnapper; |
|
13 |
|
|
14 |
public class PropertySnapCellRenderer extends JButton implements TableCellRenderer{ |
|
15 |
private JPanel panel; |
|
16 |
private ArrayList snappers; |
|
17 |
public PropertySnapCellRenderer(ArrayList snappers) { |
|
18 |
this.snappers=snappers; |
|
19 |
this.setText("..."); |
|
20 |
} |
|
21 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
|
22 |
panel=(JPanel)((ISnapper)snappers.get(row)).getConfigurator(); |
|
23 |
if (panel!=null) { |
|
24 |
this.setEnabled(true); |
|
25 |
}else { |
|
26 |
this.setEnabled(false); |
|
27 |
this.setBackground(Color.white); |
|
28 |
} |
|
29 |
return this; |
|
30 |
} |
|
31 |
|
|
32 |
} |
|
0 | 33 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/gui/testDialog.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.project.documents.view.snapping.gui; |
|
42 |
|
|
43 |
import java.awt.JobAttributes; |
|
44 |
import java.awt.print.PageFormat; |
|
45 |
import java.awt.print.Paper; |
|
46 |
import java.awt.print.PrinterJob; |
|
47 |
import java.util.ArrayList; |
|
48 |
|
|
49 |
import javax.print.attribute.HashAttributeSet; |
|
50 |
import javax.print.attribute.HashPrintRequestAttributeSet; |
|
51 |
import javax.print.attribute.standard.MediaSize; |
|
52 |
import javax.swing.AbstractAction; |
|
53 |
import javax.swing.Action; |
|
54 |
import javax.swing.JButton; |
|
55 |
import javax.swing.JDialog; |
|
56 |
import javax.swing.LookAndFeel; |
|
57 |
import javax.swing.UIManager; |
|
58 |
import javax.swing.UnsupportedLookAndFeelException; |
|
59 |
|
|
60 |
import com.iver.cit.gvsig.project.documents.view.snapping.snappers.FinalPointSnapper; |
|
61 |
|
|
62 |
public class testDialog { |
|
63 |
public static void main(String[] args) { |
|
64 |
|
|
65 |
try { |
|
66 |
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
|
67 |
} catch (ClassNotFoundException e) { |
|
68 |
// TODO Auto-generated catch block |
|
69 |
e.printStackTrace(); |
|
70 |
} catch (InstantiationException e) { |
|
71 |
// TODO Auto-generated catch block |
|
72 |
e.printStackTrace(); |
|
73 |
} catch (IllegalAccessException e) { |
|
74 |
// TODO Auto-generated catch block |
|
75 |
e.printStackTrace(); |
|
76 |
} catch (UnsupportedLookAndFeelException e) { |
|
77 |
// TODO Auto-generated catch block |
|
78 |
e.printStackTrace(); |
|
79 |
} |
|
80 |
|
|
81 |
JDialog dlg = new JDialog(); |
|
82 |
|
|
83 |
ArrayList list = new ArrayList(); |
|
84 |
for (int i=0; i < 20; i++) |
|
85 |
list.add(new FinalPointSnapper()); |
|
86 |
SnapConfig panel = new SnapConfig(); |
|
87 |
panel.setSnappers(list); |
|
88 |
Action act = new AbstractAction(){ |
|
89 |
public void actionPerformed(java.awt.event.ActionEvent arg0) { |
|
90 |
System.out.println("HOla"); |
|
91 |
// HashPrintRequestAttributeSet att = new HashPrintRequestAttributeSet(); |
|
92 |
// |
|
93 |
// PrinterJob job = PrinterJob.getPrinterJob(); |
|
94 |
// PageFormat defaulFormat = job.defaultPage(); |
|
95 |
// // PageFormat selectedFormat = job.pageDialog(defaulFormat); |
|
96 |
// Paper paper = new Paper(); |
|
97 |
// paper.setSize(MediaSize.ISO.A5.getX(MediaSize.INCH),MediaSize.ISO.A5.getY(MediaSize.INCH)); |
|
98 |
// defaulFormat.setPaper(paper); |
|
99 |
// job.defaultPage(defaulFormat); |
|
100 |
// if (job.printDialog()) { |
|
101 |
// // System.out.println(job.) |
|
102 |
// } |
|
103 |
}; |
|
104 |
}; |
|
105 |
JButton btnPrint = new JButton(act); |
|
106 |
|
|
107 |
dlg.getContentPane().add(panel); |
|
108 |
// dlg.getContentPane().add(btnPrint); |
|
109 |
// dlg.getContentPane().setSize(panel.getSize()); |
|
110 |
dlg.pack(); |
|
111 |
dlg.show(true); |
|
112 |
} |
|
113 |
|
|
114 |
} |
|
0 | 115 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/gui/DefaultConfigurePanel.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.project.documents.view.snapping.gui; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
|
|
6 |
import javax.swing.JButton; |
|
7 |
import javax.swing.JDialog; |
|
8 |
import javax.swing.JLabel; |
|
9 |
import javax.swing.JPanel; |
|
10 |
|
|
11 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
|
12 |
|
|
13 |
import com.iver.andami.PluginServices; |
|
14 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
15 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
16 |
import com.iver.cit.gvsig.project.documents.view.snapping.AbstractSnapper; |
|
17 |
import com.iver.cit.gvsig.project.documents.view.snapping.ISnapper; |
|
18 |
|
|
19 |
public class DefaultConfigurePanel extends JPanel implements IWindow { |
|
20 |
private ISnapper snapper; |
|
21 |
private JLabel lblColor = null; |
|
22 |
private JButton bColor = null; |
|
23 |
private WindowInfo wi=null; |
|
24 |
private AcceptCancelPanel acceptCancelPanel; |
|
25 |
/** |
|
26 |
* This is the default constructor |
|
27 |
*/ |
|
28 |
public DefaultConfigurePanel() { |
|
29 |
super(); |
|
30 |
initialize(); |
|
31 |
} |
|
32 |
|
|
33 |
/** |
|
34 |
* This method initializes this |
|
35 |
* |
|
36 |
* @return void |
|
37 |
*/ |
|
38 |
private void initialize() { |
|
39 |
lblColor = new JLabel(); |
|
40 |
lblColor.setText("color"); |
|
41 |
this.setSize(269, 91); |
|
42 |
this.add(lblColor, null); |
|
43 |
this.add(getBColor(), null); |
|
44 |
this.add(getPAcceptCancel(),null); |
|
45 |
} |
|
46 |
public void setSnapper(ISnapper snapper) { |
|
47 |
this.snapper=snapper; |
|
48 |
//((AbstractSnapper)this.snapper).setColor(Color.blue); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* This method initializes bColor |
|
53 |
* |
|
54 |
* @return javax.swing.JButton |
|
55 |
*/ |
|
56 |
private JButton getBColor() { |
|
57 |
if (bColor == null) { |
|
58 |
bColor = new JButton(); |
|
59 |
bColor.setText("..."); |
|
60 |
} |
|
61 |
return bColor; |
|
62 |
} |
|
63 |
|
|
64 |
protected AcceptCancelPanel getPAcceptCancel() { |
|
65 |
if (acceptCancelPanel==null) { |
|
66 |
ActionListener okAction = new java.awt.event.ActionListener() { |
|
67 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
68 |
|
|
69 |
if (PluginServices.getMainFrame() == null) { |
|
70 |
((JDialog) (getParent().getParent().getParent() |
|
71 |
.getParent())).dispose(); |
|
72 |
} else { |
|
73 |
PluginServices.getMDIManager().closeWindow(DefaultConfigurePanel.this); |
|
74 |
} |
|
75 |
} |
|
76 |
}; |
|
77 |
ActionListener cancelAction = new java.awt.event.ActionListener() { |
|
78 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
79 |
if (PluginServices.getMainFrame() != null) { |
|
80 |
PluginServices.getMDIManager().closeWindow(DefaultConfigurePanel.this); |
|
81 |
} else { |
|
82 |
((JDialog) (getParent().getParent().getParent() |
|
83 |
.getParent())).dispose(); |
|
84 |
} |
|
85 |
} |
|
86 |
}; |
|
87 |
acceptCancelPanel=new AcceptCancelPanel(okAction,cancelAction); |
|
88 |
|
|
89 |
} |
|
90 |
return acceptCancelPanel; |
|
91 |
} |
|
92 |
|
|
93 |
public WindowInfo getWindowInfo() { |
|
94 |
if (wi==null) { |
|
95 |
wi=new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE); |
|
96 |
wi.setWidth(this.getWidth()); |
|
97 |
wi.setHeight(this.getHeight()); |
|
98 |
wi.setTitle(PluginServices.getText(this,"propiedades")); |
|
99 |
} |
|
100 |
return wi; |
|
101 |
} |
|
102 |
|
|
103 |
} // @jve:decl-index=0:visual-constraint="10,10" |
|
0 | 104 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/project/documents/view/snapping/gui/DrawSnapCellRenderer.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.project.documents.view.snapping.gui; |
|
42 |
|
|
43 |
import java.awt.Color; |
|
44 |
import java.awt.Component; |
|
45 |
import java.awt.Graphics; |
|
46 |
import java.awt.event.KeyAdapter; |
|
47 |
import java.awt.event.KeyEvent; |
|
48 |
import java.awt.event.MouseEvent; |
|
49 |
import java.awt.event.MouseListener; |
|
50 |
import java.awt.geom.Point2D; |
|
51 |
import java.util.ArrayList; |
|
52 |
import java.util.EventObject; |
|
53 |
|
|
54 |
import javax.swing.ImageIcon; |
|
55 |
import javax.swing.JPanel; |
|
56 |
import javax.swing.JTable; |
|
57 |
import javax.swing.event.CellEditorListener; |
Also available in: Unified diff