Author: bobtarling
Date: 2008-06-16 16:55:32-0700
New Revision: 14966
Modified:
trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/FigClassifierRole.java
trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/ModePlaceClassifierRole.java
trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java
Log:
Bogdan Szantos patch for issue 5121
Modified: trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/FigClassifierRole.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/FigClassifierRole.java?view=diff&rev=14966&p1=trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/FigClassifierRole.java&p2=trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/FigClassifierRole.java&r1=14965&r2=14966
==============================================================================
--- trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/FigClassifierRole.java (original)
+++ trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/FigClassifierRole.java 2008-06-16 16:55:32-0700
@@ -38,6 +38,7 @@
import org.argouml.uml.diagram.ui.FigNodeModelElement;
import org.tigris.gef.base.Geometry;
import org.tigris.gef.base.Selection;
+import org.tigris.gef.presentation.Fig;
import org.tigris.gef.presentation.FigEdge;
import org.tigris.gef.presentation.FigRect;
@@ -192,17 +193,34 @@
}
/**
- *
- * @return the
- * @see org.tigris.gef.presentation.Fig#getMinimumSize()
+ * Gets the minimum size of the CR:<br>
+ * width = the minimum width of the headFig<br>
+ * height = the minimum height of the headFig + offset (in case a create
+ * message is present).<br>
+ * An extra buffer of 10 is added to ensure lifeLine visibility.
*/
public Dimension getMinimumSize() {
- // The minimum size of the CR is the minimum size of the headFig,
- // with the offset required when a create message is received.
- // An extra buffer of 10 is added to ensure lifeLine visibility.
- return new Dimension(
- headFig.getMinimumWidth(),
- this.offset + headFig.getMinimumHeight() + 10);
+
+ List<Fig> figs = this.getEdges();
+
+ if (figs.size() > 0) {
+ // the Y position of the lower most FigMessage
+ int yMax = 0;
+
+ for (Fig fig : figs) {
+ if (fig instanceof FigMessage) {
+ if (fig.getLastPoint().y > yMax) {
+ yMax = fig.getY();
+ }
+ }
+ }
+
+ return new Dimension(headFig.getMinimumWidth(), yMax - getY() + 10);
+ } else {
+ return new Dimension(headFig.getMinimumWidth(), emptyFig
+ .getHeight()
+ + headFig.getMinimumHeight() + 10);
+ }
}
Modified: trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/ModePlaceClassifierRole.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/ModePlaceClassifierRole.java?view=diff&rev=14966&p1=trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/ModePlaceClassifierRole.java&p2=trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/ModePlaceClassifierRole.java&r1=14965&r2=14966
==============================================================================
--- trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/ModePlaceClassifierRole.java (original)
+++ trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/ModePlaceClassifierRole.java 2008-06-16 16:55:32-0700
@@ -27,13 +27,15 @@
import java.awt.event.MouseEvent;
import java.util.List;
-import org.tigris.gef.base.Layer;
import org.tigris.gef.base.ModePlace;
import org.tigris.gef.graph.GraphFactory;
import org.tigris.gef.presentation.Fig;
/**
- *
+ * Ensures that each new ClassifierRole has the same Y position and height as
+ * all the existing ones.
+ *
+ * @author bszanto
* @author penyaskito
*/
public class ModePlaceClassifierRole extends ModePlace {
Modified: trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java?view=diff&rev=14966&p1=trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java&p2=trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java&r1=14965&r2=14966
==============================================================================
--- trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java (original)
+++ trunk/src/argouml-core-diagrams-sequence2/src/org/argouml/uml/diagram/sequence2/ui/SelectionClassifierRole.java 2008-06-16 16:55:32-0700
@@ -24,6 +24,7 @@
package org.argouml.uml.diagram.sequence2.ui;
+import java.awt.Point;
import java.util.List;
import javax.swing.Icon;
@@ -52,8 +53,19 @@
}
/**
- * Make sure that the north facing handles cannot be dragged as part of a
- * resize. {@inheritDoc}
+ * Makes sure that draging on the CR keeps them all aligned and resizing
+ * doesn't force FigMessages overlaying.
+ *
+ * @param mX
+ * New X position (aka current mouse X position)
+ * @param mY
+ * New Y position (aka current mouse Y position)
+ * @param anX
+ * Old X position
+ * @param anY
+ * Old Y position
+ * @param hand
+ * The handle being dragged
*/
public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) {
@@ -63,57 +75,73 @@
List<Fig> figs = getContent().getLayer().getContents();
- // get the bounds of FigMessages
- int yMax = 65535; // this should be big enough for init
- int yMin = 0;
- for (Fig fig : figs) {
- if (fig instanceof FigMessage) {
- if (fig.getY() < yMax) {
- yMax = fig.getY();
- }
- if (fig.getY() > yMin) {
- yMin = fig.getY();
- }
- }
- }
- // a little buffer to ensure good visibility
- // yMax -= 10; // not required
- yMin += 10;
-
+ // if this is true all resizing/moving will stop
+ boolean stopResize = false;
+
// vertical resizing
switch (hand.index) {
case Handle.NORTHWEST:
case Handle.NORTH:
case Handle.NORTHEAST:
- // TODO Java 5 style for loop would be nicer
- for (Fig workOnFig : figs) {
+ final int dY = mY - getContent().getY();
/*
- * the resize will take place if the workOnFig 1. is a
- * FifClassifierRole 2. doesn't force a FigMessage to move 3.
- * doesn't violate minimum size of a CR
+ * First check if all CRs can be moved. The resize will take place
+ * if: 1. workOnFig is a FifClassifierRole that doesn't contain a
+ * Creation Message; 2. doesn't force a FigMessage to move more over
+ * another message; 3. doesn't violate minimum size of a CR
+ *
+ * TODO: take care of CRs with creation/destruction messages.
+ * Depends on issue 5130
*/
+ for (Fig workOnFig : figs) {
if (workOnFig instanceof FigClassifierRole
- && mY + workOnFig.getMinimumSize().height < yMax
- && (workOnFig.getHeight() + workOnFig.getY() - mY) > workOnFig
- .getMinimumSize().height) {
- workOnFig.setHeight(workOnFig.getHeight()
- + workOnFig.getY() - mY);
- workOnFig.setY(mY);
+ && (workOnFig.getHeight() + workOnFig.getY() - mY) < workOnFig
+ .getMinimumSize().height) {
+ stopResize = true;
+ }
+ }
+
+ // if everything is OK, go on and move CRs and FigMessages
+ if (!stopResize) {
+ for (Fig workOnFig : figs) {
+ if (workOnFig instanceof FigClassifierRole) {
+ workOnFig.setHeight(workOnFig.getHeight()
+ + workOnFig.getY() - mY);
+ workOnFig.setY(mY);
+ } else if (workOnFig instanceof FigMessage) {
+
+ // the array of points from a FigMessage
+ Point[] messagePoints = workOnFig.getPoints();
+ for (Point pt : messagePoints) {
+ pt.y = pt.y + dY;
+ workOnFig.setPoints(messagePoints);
+ }
+ }
}
}
break;
case Handle.SOUTH:
case Handle.SOUTHEAST:
case Handle.SOUTHWEST:
+ /*
+ * First check if all CRs can be moved. The resize will take place
+ * if the lower most FigMessage is not reached
+ */
for (Fig workOnFig : figs) {
- // same conditions here as above
if (workOnFig instanceof FigClassifierRole
- && mY > yMin
- && mY - workOnFig.getY()
- > workOnFig.getMinimumSize().height) {
- workOnFig.setHeight(mY - workOnFig.getY());
+ && (mY - workOnFig.getY() < workOnFig.getMinimumSize().height)) {
+ stopResize = true;
}
}
+
+ // if everything is OK, go on and move CRs and FigMessages
+ if (!stopResize) {
+ for (Fig workOnFig : figs) {
+ if (workOnFig instanceof FigClassifierRole) {
+ workOnFig.setHeight(mY - workOnFig.getY());
+ }
+ }
+ }
default:
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.