Revision 1846
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/EventsHandler.java | ||
---|---|---|
351 | 351 |
* @see java.awt.event.MouseListener#mouseReleassed(java.awt.event.MouseEvent) |
352 | 352 |
*/ |
353 | 353 |
public void mouseReleased(MouseEvent E) { |
354 |
if (E.getButton() != MouseEvent.BUTTON3) { |
|
355 |
layout.setLastPoint(E.getPoint()); |
|
356 |
} |
|
354 | 357 |
if (E.getButton() == MouseEvent.BUTTON1) { |
355 | 358 |
Point p1 = layout.getFirstPoint(); |
356 | 359 |
Point p2 = new Point(E.getX(), E.getY()); |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/FLayoutFunctions.java | ||
---|---|---|
163 | 163 |
|
164 | 164 |
if (isadd) { |
165 | 165 |
Rectangle2D r = new Rectangle2D.Double(); //rectOrigin.x+m_PointAnt.x,rectOrigin.y+m_PointAnt.y,m_LastPoint.x-m_PointAnt.x,m_LastPoint.y-m_PointAnt.y); |
166 |
r.setFrameFromDiagonal(layout.getFirstPoint(), layout.getLastPoint()); |
|
166 |
int tolerance=20; |
|
167 |
if (isCorrectSize(tolerance,layout.getFirstPoint(),layout.getLastPoint())){ |
|
168 |
r.setFrameFromDiagonal(layout.getFirstPoint(), layout.getLastPoint()); |
|
169 |
}else{ |
|
170 |
Point2D p1=layout.getFirstPoint(); |
|
171 |
p1=new Point2D.Double(p1.getX()+tolerance,p1.getY()+tolerance); |
|
172 |
r.setFrameFromDiagonal(layout.getFirstPoint(),p1); |
|
173 |
} |
|
167 | 174 |
|
168 | 175 |
if (layout.isCuadricula()) { |
169 | 176 |
//cuadrar con la cuadr?cula dibujada y despu?s en el mouseReleased guardar ese rect?ngulo de la misma forma. |
... | ... | |
229 | 236 |
|
230 | 237 |
return pWorld; |
231 | 238 |
} |
239 |
|
|
240 |
/** |
|
241 |
* Devuelve true si el rectangulo formado por los dos puntos que se pasan |
|
242 |
* como par?metro es superior a la tolerancia. |
|
243 |
* |
|
244 |
* @param tolerance Tolerancia |
|
245 |
* @param p1 Punto inicial del rect?ngulo. |
|
246 |
* @param p2 Punto final del rect?ngulo. |
|
247 |
* |
|
248 |
* @return True si el tama?o es correcto. |
|
249 |
*/ |
|
250 |
private boolean isCorrectSize(int tolerance, Point2D p1, Point2D p2) { |
|
251 |
if (Math.abs(p2.getX()) < (Math.abs(p1.getX()) + tolerance)) { |
|
252 |
return false; |
|
253 |
} else if (Math.abs(p2.getY()) < (Math.abs(p1.getY()) + tolerance)) { |
|
254 |
return false; |
|
255 |
} |
|
256 |
return true; |
|
257 |
} |
|
232 | 258 |
} |
Also available in: Unified diff