Revision 10628 trunk/extensions/extDwg/src/com/iver/cit/gvsig/drivers/dwg/debug/DwgEntityListener.java

View differences:

DwgEntityListener.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.5  2007-02-15 16:28:36  fdiaz
48
* Revision 1.6  2007-03-06 17:27:42  caballero
49
* Exceptions
50
*
51
* Revision 1.5  2007/02/15 16:28:36  fdiaz
49 52
* Compatibilizado con branch v10
50 53
*
51 54
* Revision 1.4  2007/02/01 20:03:21  azabala
......
70 73

  
71 74
import javax.swing.JOptionPane;
72 75

  
76
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
73 77
import com.iver.cit.gvsig.drivers.dwg.DwgMemoryDriver;
74
import com.iver.cit.gvsig.fmap.DriverException;
78
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
79
import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException;
80
import com.iver.cit.gvsig.exceptions.visitors.StartVisitorException;
81
import com.iver.cit.gvsig.exceptions.visitors.VisitorException;
75 82
import com.iver.cit.gvsig.fmap.MapControl;
76 83
import com.iver.cit.gvsig.fmap.core.IGeometry;
77 84
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver;
......
79 86
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
80 87
import com.iver.cit.gvsig.fmap.layers.SingleLayerIterator;
81 88
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor;
82
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException;
83 89
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
84 90
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
85 91
import com.iver.cit.gvsig.fmap.tools.Listeners.PointListener;
......
87 93
import com.iver.cit.jdwglib.dwg.DwgObject;
88 94

  
89 95
public class DwgEntityListener implements PointListener{
90
	
91 96

  
92
	
93
		
97

  
98

  
99

  
94 100
		public static int pixelTolerance = 3;
95 101
	    private MapControl mapCtrl;
96 102
	    private Cursor cur = java.awt.Cursor.
97 103
	    		getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
98
	
104

  
99 105
	    public DwgEntityListener(MapControl mc) {
100 106
	        this.mapCtrl = mc;
101 107
	    }
102 108

  
103 109
	    public void point(PointEvent event) throws BehaviorException {
104
	        
110

  
105 111
	        Point2D pReal = mapCtrl.
106 112
	        		getMapContext().
107 113
	        		getViewPort().
108 114
	        		toMapPoint(event.getPoint());
109
	        
115

  
110 116
			SingleLayerIterator it = new SingleLayerIterator(mapCtrl.getMapContext().getLayers());
111 117
			while (it.hasNext())
112 118
			{
......
115 121
					continue;
116 122
				if(! (aux instanceof FLyrVect))
117 123
					return;
118
				
124

  
119 125
				FLyrVect vectLyr = (FLyrVect) aux;
120 126
				VectorialDriver driver = vectLyr.getSource().getDriver();
121
				
127

  
122 128
//				Class dwgMemoryDriverClass = LayerFactory.getDM().getDriverClassByName("gvSIG DWG Memory Driver");
123 129
//				if(dwgMemoryDriverClass == null){
124 130
//					System.out.println("Driver dwg no disponible???");
......
133 139
//				} catch (ClassNotFoundException e1) {
134 140
//					return;
135 141
//				}
136
				
142

  
137 143
				if(!(driver instanceof com.iver.cit.gvsig.fmap.drivers.AbstractCadMemoryDriver))
138 144
						return;
139 145
				/*
......
141 147
				 */
142 148
				if(!(driver instanceof DwgMemoryDriver)){
143 149
					JOptionPane.showConfirmDialog(null,
144
							"Esta herramienta s?lo funciona con libFMap del HEAD.\nVer comentarios en el codigo de esta clase."  
150
							"Esta herramienta s?lo funciona con libFMap del HEAD.\nVer comentarios en el codigo de esta clase."
145 151
					);
146 152
					return;
147 153
				}
148 154

  
149 155
				final com.iver.cit.gvsig.fmap.drivers.AbstractCadMemoryDriver dwgDriver = (com.iver.cit.gvsig.fmap.drivers.AbstractCadMemoryDriver)driver;
150 156
				double realTol = mapCtrl.getViewPort().toMapDistance(pixelTolerance);
151
				
157

  
152 158
					Rectangle2D recPoint = new Rectangle2D.Double(pReal.getX() - (realTol / 2),
153 159
			                pReal.getY() - (realTol / 2), realTol, realTol);
154
				
160

  
155 161
					try {
156 162
						vectLyr.process(new FeatureVisitor(){
157
							public void visit(IGeometry g, int index) throws VisitException {
158
								/* 
163
							public void visit(IGeometry g, int index) throws VisitorException {
164
								/*
159 165
								 * Cambiar la comentarizacion de las dos lineas de abajo
160 166
								 * para funcione la herramienta en libFMap del HEAD.
161 167
								 * No funciona en la v10 porque AbstractCadMemoryDriver
......
166 172
//								DwgObject dwgObj = (DwgObject) dwgDriver.getCadSource(index);
167 173
								DwgObject dwgObj = (DwgObject) ((DwgMemoryDriver)dwgDriver).getCadSource(index);
168 174

  
175

  
169 176
								DwgHandleReference handle = dwgObj.getLayerHandle();
170 177
								int lyrHdlCode = handle.getCode();
171 178
								int lyrHdl = handle.getOffset();
......
177 184
								return "";
178 185
							}
179 186

  
180
							public void stop(FLayer layer) {
187
							public void stop(FLayer layer) throws VisitorException {
181 188
							}
182 189

  
183
							public boolean start(FLayer layer) {
190
							public boolean start(FLayer layer) throws StartVisitorException {
184 191
								return true;
185 192
							}}, recPoint);
186
					} catch (VisitException e) {
193
					} catch (VisitorException e) {
187 194
						// TODO Auto-generated catch block
188 195
						e.printStackTrace();
189
					} catch (DriverException e) {
196
					} catch (ReadDriverException e) {
190 197
						// TODO Auto-generated catch block
191 198
						e.printStackTrace();
192
					}//try
193
			}//while	
199
					} catch (ExpansionFileReadException e) {
200
						// TODO Auto-generated catch block
201
						e.printStackTrace();
202
					}
203
			}//while
194 204
	    }
195 205

  
196 206
	    public Cursor getCursor() {

Also available in: Unified diff