Mostly reformatting, maybe done by some automatic tools.
The reformatting does not apply to Apache SIS since the code has been reformatted again.
Contains also a typo fix (isDraging
renamed isDragging
),
but that typo was already identified in a "TODO" comment.
Command line:
svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r1091:1096 https://svn.osgeo.org/geotools/trunk/modules/extension/widgets-swing/src/main/java/org/geotools/gui/swing/MouseReshapeTracker.java
Revision 1091 | Revision 1096 |
---|---|
* } * </pre></blockquote> * * @version 1.0 * @author Martin Desruisseaux */ |
* }
* </pre></blockquote>
*
* $Id: MouseReshapeTracker.java,v 1.3 2002/07/15 15:50:34 loxnard Exp $
* @version 1.0
* @author Martin Desruisseaux
*/ |
* Indicates if the user is currently dragging the rectangle. * For this field to become <code>true</code>, the mouse must * have been over the rectangle as the user pressed the mouse button. * TODO: Replace all occurrences of "isDraging" with "isDragging". */ private transient boolean isDraging; /** * Indicates which edges the user is currently adjusting with the mouse. |
* Indicates if the user is currently dragging the rectangle.
* For this field to become <code>true</code>, the mouse must
* have been over the rectangle as the user pressed the mouse button.
*/
private transient boolean isDragging;
/**
* Indicates which edges the user is currently adjusting with the mouse. |
* in order to finish the construction of certain
* fields.
*/
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
drawnShape=logicalShape;
update();
} |
* in order to finish the construction of certain * fields. */ private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { drawnShape=logicalShape; update(); } |
tmp.x = (i&1)==0 ? drawnShape.getMinX() : drawnShape.getMaxX(); tmp.y = (i&2)==0 ? drawnShape.getMinY() : drawnShape.getMaxY(); transform.transform(tmp, tmp); if (tmp.x<xmin) xmin=tmp.x; if (tmp.x>xmax) xmax=tmp.x; if (tmp.y<ymin) ymin=tmp.y; if (tmp.y>ymax) ymax=tmp.y; } x = (int) Math.floor(xmin) -1; y = (int) Math.floor(ymin) -1; width = (int) Math.ceil (xmax-xmin) +2; |
tmp.x = (i&1)==0 ? drawnShape.getMinX() : drawnShape.getMaxX(); tmp.y = (i&2)==0 ? drawnShape.getMinY() : drawnShape.getMaxY(); transform.transform(tmp, tmp); if (tmp.x < xmin) { xmin = tmp.x; } if (tmp.x > xmax) { xmax = tmp.x; } if (tmp.y < ymin) { ymin = tmp.y; } if (tmp.y > ymax) { ymax = tmp.y; } } x = (int) Math.floor(xmin) -1; y = (int) Math.floor(ymin) -1; width = (int) Math.ceil (xmax-xmin) +2; |
* {@link #setClipMinMax setClipMinMax(...)} rather than
* <code>setClip(...)</code>.
*/
public final void setClip(final double x, final double y, final double width, final double height) {
setClipMinMax(x, x+width, y, y+height);
} |
* {@link #setClipMinMax setClipMinMax(...)} rather than * <code>setClip(...)</code>. */ public final void setClip(final double x, final double y, final double width, final double height) { setClipMinMax(x, x+width, y, y+height); } |
final double tmp=ymin; ymin=ymax; ymax=tmp; } if (!Double.isNaN(xmin)) this.xmin=xmin; if (!Double.isNaN(xmax)) this.xmax=xmax; if (!Double.isNaN(ymin)) this.ymin=ymin; if (!Double.isNaN(ymax)) this.ymax=ymax; setFrame(logicalShape.getX(), logicalShape.getY(), logicalShape.getWidth(), logicalShape.getHeight()); } /** * Method called automatically when a change in the clip is required. |
final double tmp=ymin; ymin=ymax; ymax=tmp; } if (!Double.isNaN(xmin)) { this.xmin = xmin; } if (!Double.isNaN(xmax)) { this.xmax = xmax; } if (!Double.isNaN(ymin)) { this.ymin = ymin; } if (!Double.isNaN(ymax)) { this.ymax = ymax; } setFrame(logicalShape.getX(), logicalShape.getY(), logicalShape.getWidth(), logicalShape.getHeight()); } /** * Method called automatically when a change in the clip is required. |
*/ public void setAdjustable(int side, final boolean adjustable) { side=convertSwingConstant(side); if (adjustable) adjustableSides |= side; else adjustableSides &= ~side; } /* * Converts a Swing edge constant to system used by this package. |
*/ public void setAdjustable(int side, final boolean adjustable) { side=convertSwingConstant(side); if (adjustable) { adjustableSides |= side; } else { adjustableSides &= ~side; } } /* * Converts a Swing edge constant to system used by this package. |
* one of its edges, and adjusts the mouse pointer icon accordingly.
*/
public void mouseMoved(final MouseEvent event) {
if (!isDraging) {
final Component source=event.getComponent();
if (source!=null) {
int x=event.getX(); tmp.x=x; |
* one of its edges, and adjusts the mouse pointer icon accordingly.
*/
public void mouseMoved(final MouseEvent event) {
if (!isDragging) {
final Component source=event.getComponent();
if (source!=null) {
int x=event.getX(); tmp.x=x; |
*/ final int old=adjustingSides; adjustingSides=0; if (Math.abs(x-=this.x) <=RESIZE_POS) adjustingSides |= WEST; if (Math.abs(y-=this.y) <=RESIZE_POS) adjustingSides |= NORTH; if (Math.abs(x- this.width) <=RESIZE_POS) adjustingSides |= EAST; if (Math.abs(y- this.height)<=RESIZE_POS) adjustingSides |= SOUTH; adjustingSides &= adjustableSides; if (adjustingSides!=old || mouseOverRectChanged) { |
*/ final int old=adjustingSides; adjustingSides=0; if (Math.abs(x -= this.x)<=RESIZE_POS){ adjustingSides |= WEST; } if (Math.abs(y -= this.y)<=RESIZE_POS){ adjustingSides |= NORTH; } if (Math.abs(x - this.width)<=RESIZE_POS) { adjustingSides |= EAST; } if (Math.abs(y - this.height)<=RESIZE_POS) { adjustingSides |= SOUTH; } adjustingSides &= adjustableSides; if (adjustingSides!=old || mouseOverRectChanged) { |
} } if (mouseOverRectChanged) { // Ajouter et retirer des 'listeners' marchait bien, mais avait // l'inconvénient de changer l'ordre des 'listeners'. Ca causait // problème lorsque cet ordre était important. //source.addMouseListener(this); this.mouseOverRect=mouseOverRect; |
} } if (mouseOverRectChanged) { // Adding and removing listeners worked well, but had // the disadvantage of changing the order of the // listeners. This caused problems when the order was // important. //source.addMouseListener(this); this.mouseOverRect=mouseOverRect; |
if (drawnShape.contains(transform.inverseTransform(tmp,tmp))) {
mouseDX = tmp.x-drawnShape.getX();
mouseDY = tmp.y-drawnShape.getY();
isDraging=true;
e.consume();
}
} catch (NoninvertibleTransformException exception) { |
if (drawnShape.contains(transform.inverseTransform(tmp,tmp))) {
mouseDX = tmp.x-drawnShape.getX();
mouseDY = tmp.y-drawnShape.getY();
isDragging = true;
e.consume();
}
} catch (NoninvertibleTransformException exception) { |
/** * Method called automatically during mouse drags. The default * implementation applies the mouse movement to the rectangle and notifies * the component where the event which it needs to redraw, at least in part, * came from. */ public void mouseDragged(final MouseEvent e) { if (isDraging) { final int adjustingLogicalSides=this.adjustingLogicalSides; final Component source=e.getComponent(); if (source!=null) try { |
/** * Method called automatically during mouse drags. The default * implementation applies the mouse movement to the rectangle and notifies * the component where the event which it needs to redraw, at least in * part, came from. */ public void mouseDragged(final MouseEvent e) { if (isDragging) { final int adjustingLogicalSides=this.adjustingLogicalSides; final Component source=e.getComponent(); if (source!=null) try { |
*/
switch (adjustingLogicalSides & (EAST|WEST)) {
case WEST: {
if (x0<xmin) x0=xmin;
dx += drawnShape.getX()-x0;
if (!(dx>0)) {
dx=drawnShape.getWidth(); |
*/ switch (adjustingLogicalSides & (EAST|WEST)) { case WEST: { if (x0 < xmin) { x0 = xmin; } dx += drawnShape.getX()-x0; if (!(dx>0)) { dx=drawnShape.getWidth(); |
case EAST: {
dx += x0 - (x0=drawnShape.getX());
final double limit=xmax-x0;
if (dx>limit) dx=limit;
if (!(dx>0)) {
dx=drawnShape.getWidth();
x0=drawnShape.getX(); |
case EAST: { dx += x0 - (x0=drawnShape.getX()); final double limit=xmax-x0; if (dx > limit) { dx = limit; } if (!(dx>0)) { dx=drawnShape.getWidth(); x0=drawnShape.getX(); |
}
switch (adjustingLogicalSides & (NORTH|SOUTH)) {
case NORTH: {
if (y0<ymin) y0=ymin;
dy += drawnShape.getY()-y0;
if (!(dy>0)) {
dy=drawnShape.getHeight(); |
} switch (adjustingLogicalSides & (NORTH|SOUTH)) { case NORTH: { if (y0 < ymin) { y0=ymin; } dy += drawnShape.getY()-y0; if (!(dy>0)) { dy=drawnShape.getHeight(); |
/* * Adjustment for special cases. */ if ((adjustingLogicalSides & EAST )!=0) mouseDX += (drawnShape.getWidth() -oldWidth); if ((adjustingLogicalSides & SOUTH)!=0) mouseDY += (drawnShape.getHeight()-oldHeight); } catch (NoninvertibleTransformException exception) { // Ignore. } |
/* * Adjustment for special cases. */ if ((adjustingLogicalSides & EAST) != 0) { mouseDX += (drawnShape.getWidth() - oldWidth); } if ((adjustingLogicalSides & SOUTH) != 0) { mouseDY += (drawnShape.getHeight() - oldHeight); } } catch (NoninvertibleTransformException exception) { // Ignore. } |
* that the changes are finished. */ public void mouseReleased(final MouseEvent event) { if (isDraging && (event.getModifiers() & MouseEvent.BUTTON1_MASK)!=0) { isDraging=false; final Component source=event.getComponent(); try { tmp.x=event.getX(); |
* that the changes are finished. */ public void mouseReleased(final MouseEvent event) { if (isDragging && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { isDragging = false; final Component source=event.getComponent(); try { tmp.x=event.getX(); |
if (!mouseOverRect && source!=null) source.setCursor(null); event.consume(); } catch (NoninvertibleTransformException exception) { // Ignore cette exception. } try { // Il faut que 'isDraging=false'. fireStateChanged(); } catch (RuntimeException exception) { ExceptionMonitor.show(source, exception); |
if (!mouseOverRect && source!=null) source.setCursor(null); event.consume(); } catch (NoninvertibleTransformException exception) { // Ignore this exception. } try { // It is essential that 'isDragging=false'. fireStateChanged(); } catch (RuntimeException exception) { ExceptionMonitor.show(source, exception); |
* size of the visor has changed.
*/
private void fireStateWillChange() {
stateWillChange(isDraging);
}
/** |
* size of the visor has changed.
*/
private void fireStateWillChange() {
stateWillChange(isDragging);
}
/** |
*/
private void fireStateChanged() {
updateEditors();
stateChanged(isDraging);
}
/** |
*/
private void fireStateChanged() {
updateEditors();
stateChanged(isDragging);
}
/** |
* but it will do because it is unlikely that we will ever add more
* than 4 editors.
*/
final Control control=new Control(editor, (format instanceof DateFormat), convertSwingConstant(side), toRepaint);
if (editors==null) {
editors = new Control[1];
} else { |
* but it will do because it is unlikely that we will ever add more * than 4 editors. */ final Control control = new Control(editor, (format instanceof DateFormat), convertSwingConstant(side), toRepaint); if (editors==null) { editors = new Control[1]; } else { |
* @throws IllegalArgumentException if <code>axis</code>
* isn't one of the valid codes.
*/
public void setEditorsSynchronized(final int axis, final boolean state) throws IllegalArgumentException {
switch (axis) {
case SwingConstants.HORIZONTAL: synchronizeX=state; break;
case SwingConstants.VERTICAL: synchronizeY=state; break; |
* @throws IllegalArgumentException if <code>axis</code> * isn't one of the valid codes. */ public void setEditorsSynchronized(final int axis, final boolean state) throws IllegalArgumentException { switch (axis) { case SwingConstants.HORIZONTAL: synchronizeX=state; break; case SwingConstants.VERTICAL: synchronizeY=state; break; |