Author: bobtarling Date: 2011-04-26 13:18:40-0700 New Revision: 19281 Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/DiagramElementBuilder.java trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigBaseNode.java trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigBasePresentation.java trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigCompartment.java trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigComposite.java trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedConcavePentagon.java trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedPentagon.java trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedRRect.java trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedRect.java
Log: Give more responsibility to FigComposite Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/DiagramElementBuilder.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/DiagramElementBuilder.java?view=diff&pathrev=19281&r1=19280&r2=19281 ============================================================================== --- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/DiagramElementBuilder.java (original) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/DiagramElementBuilder.java 2011-04-26 13:18:40-0700 @@ -36,6 +36,7 @@ } else if (style.equals("rect")) { fig.setDisplayState( new FigNamedRect( + owner, bounds, fig.getLineColor(), fig.getFillColor(), @@ -44,6 +45,7 @@ } else if (style.equals("rrect")) { fig.setDisplayState( new FigNamedRRect( + owner, bounds, fig.getLineColor(), fig.getFillColor(), @@ -52,6 +54,7 @@ } else if (style.equals("pentagon")) { fig.setDisplayState( new FigNamedPentagon( + owner, bounds, fig.getLineColor(), fig.getFillColor(), @@ -60,6 +63,7 @@ } else if (style.equals("concave-pentagon")) { fig.setDisplayState( new FigNamedConcavePentagon( + owner, bounds, fig.getLineColor(), fig.getFillColor(), Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigBaseNode.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigBaseNode.java?view=diff&pathrev=19281&r1=19280&r2=19281 ============================================================================== --- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigBaseNode.java (original) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigBaseNode.java 2011-04-26 13:18:40-0700 @@ -95,8 +95,6 @@ _h = h; positionChildren(); - - firePropChange("bounds", oldBounds, bounds); } protected Rectangle getBoundsImpl() { Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigBasePresentation.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigBasePresentation.java?view=diff&pathrev=19281&r1=19280&r2=19281 ============================================================================== --- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigBasePresentation.java (original) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigBasePresentation.java 2011-04-26 13:18:40-0700 @@ -20,23 +20,23 @@ import org.argouml.notation2.NotationType; import org.argouml.uml.diagram.DiagramSettings; import org.tigris.gef.presentation.Fig; -import org.tigris.gef.presentation.FigGroup; abstract class FigBasePresentation extends FigComposite implements StereotypeDisplayer, NameDisplayer { private final DiagramElement border; private final DiagramElement nameDisplay; - private Rectangle bounds; - private static final int PADDING = 2; private static final int MIN_WIDTH = 90; public FigBasePresentation( + final Object owner, final Rectangle rect, final Color lineColor, final Color fillColor, final Object modelElement, final DiagramSettings settings) { + + super(owner, rect, settings); nameDisplay = new FigNotation( modelElement, new Rectangle(0, 0, 0, 0), @@ -75,6 +75,8 @@ final int nameWidth = nameDim.width; final int nameHeight = nameDim.height; + final Rectangle bounds = getBounds(); + final int nx = bounds.x + getLeftMargin() + (bounds.width - (nameWidth + getLeftMargin() + getRightMargin())) / 2; @@ -101,110 +103,4 @@ w = Math.max(w, MIN_WIDTH); return new Dimension(w, h); } - - protected int getRightMargin() { - return PADDING; - } - - protected int getLeftMargin() { - return PADDING; - } - - protected int getTopMargin() { - return PADDING; - } - - protected int getBottomMargin() { - return PADDING; - } - - // - // !! TODO: All code below here is duplicated in FigBaseNode. The reason - // is the GEF defect - http://gef.tigris.org/issues/show_bug.cgi?id=358 - // Once we have taken a release of GEF with that fix we can remove this - // code. - // - @Override - protected void setBoundsImpl( - final int x, - final int y, - final int w, - final int h) { - - final int ww; - // Refuse to set bounds below the minimum width - final int minWidth = getMinimumSize().width; - if (w < minWidth) { - ww = minWidth; - } else { - ww = w; - } - final int hh; - final int minHeight = getMinimumSize().height; - if (h < minHeight) { - hh = minHeight; - } else { - hh = h; - } - - final Rectangle oldBounds = getBounds(); - bounds = new Rectangle(x, y, ww, hh); - - if (oldBounds.equals(bounds)) { - return; - } - - _x = x; - _y = y; - _w = ww; - _h = hh; - - positionChildren(); - - firePropChange("bounds", oldBounds, bounds); - } - - protected Rectangle getBoundsImpl() { - return bounds; - } - - - /** - * Change the position of the object from where it is to where it is plus dx - * and dy. Often called when an object is dragged. This could be very useful - * if local-coordinate systems are used because deltas need less - * transforming... maybe. Fires property "bounds". - */ - protected void translateImpl(int dx, int dy) { - if (dx ==0 || dy == 0) { - return; - } - Rectangle oldBounds = getBounds(); - Rectangle newBounds = new Rectangle( - oldBounds.x + dx, - oldBounds.y + dy, - oldBounds.width, - oldBounds.height); - setBounds(newBounds); - } - - - /** - * This is called to rearrange the contents of the Fig when a childs - * minimum size means it will no longer fit. If this group also has - * a parent and it will no longer fit that parent then control is - * delegated to that parent. - */ - public void calcBounds() { - final Dimension min = getMinimumSize(); - if (getGroup() != null - && (getBounds().height < min.height - || getBounds().width < min.width)) { - ((FigGroup) getGroup()).calcBounds(); - } else { - int maxw = Math.max(getWidth(), min.width); - int maxh = Math.max(getHeight(), min.height); - setSize(maxw, maxh); - } - } } Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigCompartment.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigCompartment.java?view=diff&pathrev=19281&r1=19280&r2=19281 ============================================================================== --- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigCompartment.java (original) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigCompartment.java 2011-04-26 13:18:40-0700 @@ -38,6 +38,9 @@ public FigCompartment(Object owner, Rectangle bounds, DiagramSettings settings, List elements) { + + super(owner, bounds, settings); + for (Object element : elements) { try { int y = bounds.y + getTopMargin(); Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigComposite.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigComposite.java?view=diff&pathrev=19281&r1=19280&r2=19281 ============================================================================== --- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigComposite.java (original) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigComposite.java 2011-04-26 13:18:40-0700 @@ -1,7 +1,9 @@ package org.argouml.activity2.diagram; +import java.awt.Dimension; import java.awt.Rectangle; +import org.argouml.uml.diagram.DiagramSettings; import org.tigris.gef.presentation.FigGroup; public class FigComposite extends FigGroup { @@ -10,6 +12,15 @@ private static final int MARGIN = 0; + public FigComposite( + final Object owner, + final Rectangle bounds, + final DiagramSettings settings) { + this.bounds = bounds; + setOwner(owner); + } + + int getRightMargin() { return MARGIN; } @@ -26,7 +37,95 @@ return MARGIN; } + protected void positionChildren() { + + } + + // + // !! TODO: All code below here is duplicated in FigBaseNode. The reason + // is the GEF defect - http://gef.tigris.org/issues/show_bug.cgi?id=358 + // Once we have taken a release of GEF with that fix we can remove this + // code. + // + @Override + protected void setBoundsImpl( + final int x, + final int y, + final int w, + final int h) { + + final int ww; + // Refuse to set bounds below the minimum width + final int minWidth = getMinimumSize().width; + if (w < minWidth) { + ww = minWidth; + } else { + ww = w; + } + final int hh; + final int minHeight = getMinimumSize().height; + if (h < minHeight) { + hh = minHeight; + } else { + hh = h; + } + + final Rectangle oldBounds = getBounds(); + bounds = new Rectangle(x, y, ww, hh); + + if (oldBounds.equals(bounds)) { + return; + } + + _x = x; + _y = y; + _w = ww; + _h = hh; + + positionChildren(); + } + protected Rectangle getBoundsImpl() { return bounds; } + + + /** + * Change the position of the object from where it is to where it is plus dx + * and dy. Often called when an object is dragged. This could be very useful + * if local-coordinate systems are used because deltas need less + * transforming... maybe. Fires property "bounds". + */ + protected void translateImpl(int dx, int dy) { + if (dx ==0 || dy == 0) { + return; + } + Rectangle oldBounds = getBounds(); + Rectangle newBounds = new Rectangle( + oldBounds.x + dx, + oldBounds.y + dy, + oldBounds.width, + oldBounds.height); + setBounds(newBounds); + } + + + /** + * This is called to rearrange the contents of the Fig when a childs + * minimum size means it will no longer fit. If this group also has + * a parent and it will no longer fit that parent then control is + * delegated to that parent. + */ + public void calcBounds() { + final Dimension min = getMinimumSize(); + if (getGroup() != null + && (getBounds().height < min.height + || getBounds().width < min.width)) { + ((FigGroup) getGroup()).calcBounds(); + } else { + int maxw = Math.max(getWidth(), min.width); + int maxh = Math.max(getHeight(), min.height); + setSize(maxw, maxh); + } + } } Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedConcavePentagon.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedConcavePentagon.java?view=diff&pathrev=19281&r1=19280&r2=19281 ============================================================================== --- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedConcavePentagon.java (original) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedConcavePentagon.java 2011-04-26 13:18:40-0700 @@ -23,9 +23,10 @@ class FigNamedConcavePentagon extends FigBasePresentation implements StereotypeDisplayer, NameDisplayer { - public FigNamedConcavePentagon(Rectangle rect, Color lineColor, + public FigNamedConcavePentagon( + final Object owner, Rectangle rect, Color lineColor, Color fillColor, Object modelElement, DiagramSettings settings) { - super(rect, lineColor, fillColor, modelElement, settings); + super(owner, rect, lineColor, fillColor, modelElement, settings); createBorder(rect, lineColor, fillColor); } Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedPentagon.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedPentagon.java?view=diff&pathrev=19281&r1=19280&r2=19281 ============================================================================== --- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedPentagon.java (original) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedPentagon.java 2011-04-26 13:18:40-0700 @@ -25,9 +25,9 @@ private static final int PADDING = 8; - public FigNamedPentagon(Rectangle rect, Color lineColor, + public FigNamedPentagon(final Object owner, Rectangle rect, Color lineColor, Color fillColor, Object modelElement, DiagramSettings settings) { - super(rect, lineColor, fillColor, modelElement, settings); + super(owner, rect, lineColor, fillColor, modelElement, settings); createBorder(rect, lineColor, fillColor); } Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedRRect.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedRRect.java?view=diff&pathrev=19281&r1=19280&r2=19281 ============================================================================== --- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedRRect.java (original) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedRRect.java 2011-04-26 13:18:40-0700 @@ -30,12 +30,13 @@ private static int RADIUS = 16; public FigNamedRRect( + final Object owner, final Rectangle rect, final Color lineColor, final Color fillColor, final Object modelElement, final DiagramSettings settings) { - super(rect, lineColor, fillColor, modelElement, settings); + super(owner, rect, lineColor, fillColor, modelElement, settings); createBorder(rect, lineColor, fillColor); } Modified: trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedRect.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedRect.java?view=diff&pathrev=19281&r1=19280&r2=19281 ============================================================================== --- trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedRect.java (original) +++ trunk/src/argouml-core-diagrams-activity2/src/org/argouml/activity2/diagram/FigNamedRect.java 2011-04-26 13:18:40-0700 @@ -25,9 +25,9 @@ private static final int PADDING = 8; public FigNamedRect( - final Rectangle rect, Color lineColor, + final Object owner, final Rectangle rect, Color lineColor, Color fillColor, Object modelElement, DiagramSettings settings) { - super(rect, lineColor, + super(owner, rect, lineColor, fillColor, modelElement, settings); createBorder(rect, lineColor, fillColor); } ------------------------------------------------------ http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2724416 To unsubscribe from this discussion, e-mail: [[email protected]].
