Revision 12793 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/geolocation/behavior/TranslateBehavior.java
TranslateBehavior.java | ||
---|---|---|
41 | 41 |
import org.gvsig.raster.datastruct.Extent; |
42 | 42 |
|
43 | 43 |
import com.iver.andami.PluginServices; |
44 |
import com.iver.andami.messages.NotificationManager; |
|
44 | 45 |
import com.iver.cit.gvsig.fmap.MapControl; |
45 | 46 |
import com.iver.cit.gvsig.fmap.ViewPort; |
46 | 47 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
... | ... | |
190 | 191 |
} |
191 | 192 |
|
192 | 193 |
/** |
193 |
* Funci?n de pintado del canvas.Pintamos un marco a la imagen para saber |
|
194 |
* <P> |
|
195 |
* Funci?n de pintado del canvas. Pintamos un marco a la imagen para saber |
|
194 | 196 |
* donde la movemos. |
197 |
* </P> |
|
198 |
* <P> |
|
199 |
* Para dibujar el marco alrededor del raster hacemos lo mismo que para pintar el raster |
|
200 |
* rotado. En realidad dibujamos un cuadrado y luego le aplicamos las transformaciones necesarias |
|
201 |
* para que se vea con la misma forma del raster al que representa. |
|
202 |
* </P> |
|
195 | 203 |
*/ |
196 | 204 |
public void paintComponent(Graphics g) { |
197 |
if(isMoveable && lyr != null){ |
|
198 |
BufferedImage img = grBehavior.getMapControl().getImage(); |
|
199 |
|
|
200 |
ViewPort vp = grBehavior.getMapControl().getMapContext().getViewPort(); |
|
201 |
|
|
205 |
if(isMoveable && lyr != null){ |
|
202 | 206 |
try { |
207 |
ViewPort vp = grBehavior.getMapControl().getMapContext().getViewPort(); |
|
203 | 208 |
AffineTransform at = (AffineTransform)lyr.getAffineTransform().clone(); |
204 | 209 |
at.preConcatenate(vp.getAffineTransform()); |
205 |
|
|
206 | 210 |
Extent ext = lyr.getMultiRasterDataset().getExtent(); |
207 |
Point2D ini = new Point2D.Double(ptoIni.getX() , ptoIni.getY()); |
|
208 |
Point2D fin = new Point2D.Double(ptoFin.getX() , ptoFin.getY()); |
|
209 | 211 |
|
210 | 212 |
Point2D pt = new Point2D.Double(ext.getULX(), ext.getULY()); |
211 | 213 |
vp.getAffineTransform().transform(pt, pt); |
... | ... | |
215 | 217 |
vp.getAffineTransform().transform(size, size); |
216 | 218 |
at.inverseTransform(size, size); |
217 | 219 |
|
218 |
double distX = fin.getX() - ini.getX();
|
|
219 |
double distY = fin.getY() - ini.getY();
|
|
220 |
double distX = ptoFin.getX() - ptoIni.getX();
|
|
221 |
double distY = ptoFin.getY() - ptoIni.getY();
|
|
220 | 222 |
Point2D d = new Point2D.Double(ext.getULX() + distX, ext.getULY() + distY); |
221 | 223 |
vp.getAffineTransform().transform(d, d); |
222 | 224 |
at.inverseTransform(d, d); |
... | ... | |
231 | 233 |
g.drawRect((int)pt.getX() + (int)d.getX(), (int)pt.getY() + (int)d.getY(), (int)size.getX(), (int)size.getY()); |
232 | 234 |
((Graphics2D)g).transform(at.createInverse()); |
233 | 235 |
} catch (NoninvertibleTransformException e1) { |
234 |
e1.printStackTrace();
|
|
236 |
NotificationManager.addError("No se puede calcular la transformaci?n inversa de alguna esquina del raster", e1);
|
|
235 | 237 |
} |
236 | 238 |
} |
237 | 239 |
} |
Also available in: Unified diff