svn commit: r17294 - trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui
Michiel van der Wulp <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mvw
Date: 2009-08-24 22:54:34-0700
New Revision: 17294
Modified:
trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigModel.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigPackage.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigSubsystem.java
Log:
Fix the location of the symbol shown in a Model Fig and Subsystem Fig.
Make the package fig honour linewidth (except for the symbols in the Model/Subsystem).
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigModel.java?view=diff&pathrev=17294&r1=17293&r2=17294
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigModel.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigModel.java 2009-08-24 22:54:34-0700
@@ -34,21 +34,6 @@
* Class to display graphics for a UML model in a class diagram.
*/
public class FigModel extends FigPackage {
-
- private FigPoly figPoly = new FigPoly(LINE_COLOR, SOLID_FILL_COLOR);
-
- private void constructFigs() {
- int[] xpoints = {125, 130, 135, 125};
- int[] ypoints = {45, 40, 45, 45};
- Polygon polygon = new Polygon(xpoints, ypoints, 4);
- figPoly.setPolygon(polygon);
- figPoly.setFilled(false);
- addFig(figPoly);
-
- setBounds(getBounds());
-
- updateEdges();
- }
/**
* Construct a Model fig
@@ -62,20 +47,18 @@
constructFigs();
}
- /*
- * @see org.tigris.gef.presentation.Fig#setBounds(int, int, int, int)
- */
- @Override
- protected void setStandardBounds(int x, int y, int w, int h) {
-
- if (figPoly != null) {
- Rectangle oldBounds = getBounds();
- figPoly.translate((x - oldBounds.x) + (w - oldBounds.width), y
- - oldBounds.y);
+ private void constructFigs() {
+ setFigPoly(new FigPoly(LINE_COLOR, SOLID_FILL_COLOR));
+ int[] xpoints = {125, 130, 135, 125};
+ int[] ypoints = {45, 40, 45, 45};
+ Polygon polygon = new Polygon(xpoints, ypoints, 4);
+ getFigPoly().setPolygon(polygon);
+ getFigPoly().setFilled(false);
+ addFig(getFigPoly());
- }
- super.setStandardBounds(x, y, w, h);
+ setBounds(getBounds());
+
+ updateEdges();
}
-
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigPackage.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigPackage.java?view=diff&pathrev=17294&r1=17293&r2=17294
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigPackage.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigPackage.java 2009-08-24 22:54:34-0700
@@ -60,6 +60,7 @@
import org.tigris.gef.base.Globals;
import org.tigris.gef.base.LayerPerspective;
import org.tigris.gef.presentation.Fig;
+import org.tigris.gef.presentation.FigPoly;
import org.tigris.gef.presentation.FigRect;
import org.tigris.gef.presentation.FigText;
import org.tigris.gef.undo.UndoableAction;
@@ -121,6 +122,8 @@
private int tabHeight = 20;
private FigText body;
+
+ private FigPoly figPoly;
/**
* Flag that indicates if the user wants any stereotype to be shown.
@@ -203,6 +206,19 @@
return figClone;
}
+ /**
+ * @return Returns the fig for the symbol.
+ */
+ protected FigPoly getFigPoly() {
+ return figPoly;
+ }
+
+ /**
+ * @param figPoly The fig for the symbol to set.
+ */
+ protected void setFigPoly(FigPoly figPoly) {
+ this.figPoly = figPoly;
+ }
/*
* @see org.tigris.gef.presentation.Fig#setLineColor(java.awt.Color)
@@ -213,6 +229,9 @@
getStereotypeFig().setLineColor(null);
getNameFig().setLineColor(col);
body.setLineColor(col);
+ if (figPoly != null) {
+ figPoly.setLineColor(col);
+ }
}
/*
@@ -344,6 +363,17 @@
// Use "aSize" to build up the minimum size. Start with the size of the
// name fig and build up.
Dimension aSize = new Dimension(getNameFig().getMinimumSize());
+
+ if (figPoly != null) {
+ /* The figPoly is located at the right of the name text.
+ * The nameFig size is increased, so that it fits its text,
+ * and the figPoly next to the text, all within the boundaries
+ * of the nameFig. */
+ Dimension symbol = figPoly.getSize();
+ aSize.width += symbol.width;
+ aSize.height = Math.max(aSize.height, symbol.height);
+ }
+
aSize.height = Math.max(aSize.height, MIN_HEIGHT);
aSize.width = Math.max(aSize.width, MIN_WIDTH);
@@ -445,6 +475,21 @@
getBigPort().setBounds(xa, ya, newW, newH);
+ if (figPoly != null) {
+ /* The figPoly is located at the right edge of the nameFig.
+ * The nameFig size is such that it at least fits its text,
+ * and the figPoly next to the text.
+ * Making the package bigger, causes the figPoly to stick to
+ * the right edge.*/
+ Rectangle previousBounds = figPoly.getBounds();
+ Rectangle name = getNameFig().getBounds();
+ int nx = name.x + name.width - figPoly.getWidth()
+ - getLineWidth() - getNameFig().getRightMargin();
+ int ny = name.y + getLineWidth() + getNameFig().getTopMargin();
+ figPoly.translate((nx - previousBounds.x),
+ ny - previousBounds.y);
+ }
+
// Now force calculation of the bounds of the figure, update the edges
// and trigger anyone who's listening to see if the "bounds" property
// has changed.
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigSubsystem.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigSubsystem.java?view=diff&pathrev=17294&r1=17293&r2=17294
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigSubsystem.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/static_structure/ui/FigSubsystem.java 2009-08-24 22:54:34-0700
@@ -28,27 +28,13 @@
import java.awt.Rectangle;
import org.argouml.uml.diagram.DiagramSettings;
-import org.tigris.gef.graph.GraphModel;
import org.tigris.gef.presentation.FigPoly;
-/** Class to display graphics for a UML subsystem in a class diagram. */
-
+/**
+ * Class to display graphics for a UML subsystem in a class diagram.
+ */
public class FigSubsystem extends FigPackage {
- private FigPoly figPoly = new FigPoly(LINE_COLOR, SOLID_FILL_COLOR);
-
- private void constructFigs() {
- int[] xpoints = {125, 125, 130, 130, 130, 135, 135};
- int[] ypoints = {45, 40, 40, 35, 40, 40, 45};
- Polygon polygon = new Polygon(xpoints, ypoints, 7);
- figPoly.setPolygon(polygon);
- figPoly.setFilled(false);
- addFig(figPoly);
- Rectangle r = getBounds();
- setBounds(r.x, r.y, r.width, r.height);
- updateEdges();
- }
-
/**
* Construct a Subsystem fig.
*
@@ -61,21 +47,18 @@
super(owner, bounds, settings);
constructFigs();
}
-
- /*
- * @see org.tigris.gef.presentation.Fig#setBounds(int, int, int, int)
- */
- @Override
- protected void setStandardBounds(int x, int y, int w, int h) {
-
- if (figPoly != null) {
- Rectangle oldBounds = getBounds();
- figPoly.translate((x - oldBounds.x) + (w - oldBounds.width), y
- - oldBounds.y);
- }
- super.setStandardBounds(x, y, w, h);
+ private void constructFigs() {
+ setFigPoly(new FigPoly(LINE_COLOR, SOLID_FILL_COLOR));
+ int[] xpoints = {125, 125, 130, 130, 130, 135, 135};
+ int[] ypoints = {45, 40, 40, 35, 40, 40, 45};
+ Polygon polygon = new Polygon(xpoints, ypoints, 7);
+ getFigPoly().setPolygon(polygon);
+ getFigPoly().setFilled(false);
+ addFig(getFigPoly());
+ Rectangle r = getBounds();
+ setBounds(r.x, r.y, r.width, r.height);
+ updateEdges();
}
-
}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2386913
To unsubscribe from this discussion, e-mail: [[email protected]].