Author: bobtarling Date: 2010-01-03 10:16:05-0800 New Revision: 17731 Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartment.java trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigUseCase.java
Log: Make the compartment separator a child of the main Fig rather than the compartment. Make sure this is the width of the classifier box. Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartment.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartment.java?view=diff&pathrev=17731&r1=17730&r2=17731 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartment.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartment.java 2010-01-03 10:16:05-0800 @@ -81,14 +81,9 @@ private static final int MIN_HEIGHT = FigNodeModelElement.NAME_FIG_HEIGHT; /** - * A separator line that has the same width as the compartment. - */ - private FigSeparator compartmentSeparator; - - /** * A separator line that may be wider than the compartment. */ - private Fig externalSeparatorFig = null; + private Fig externalSeparatorFig = new FigSeparator(X0, Y0, 11, LINE_WIDTH); /** @@ -108,15 +103,11 @@ } private void constructFigs(int x, int y, int w, int h) { - bigPort = new FigRect(x, y, w, h, LINE_COLOR, FILL_COLOR); + bigPort = new FigRect(X0, Y0, w, h, LINE_COLOR, FILL_COLOR); bigPort.setFilled(false); bigPort.setLineWidth(0); addFig(bigPort); - - compartmentSeparator = - new FigSeparator(X0, Y0, 11, LINE_WIDTH); - addFig(compartmentSeparator); // number 2 } /** @@ -133,13 +124,6 @@ } /** - * @return separator figure - */ - protected FigSeparator getSeperatorFig() { - return compartmentSeparator; - } - - /** * If a boxed compartment is set to invisible then remove all its * children. * This is to save on resources and increase efficiency as multiple @@ -214,8 +198,7 @@ minHeight += 2; // 2 Pixel padding after compartment - minHeight = Math.max(minHeight, - MIN_HEIGHT + compartmentSeparator.getHeight()); + minHeight = Math.max(minHeight, MIN_HEIGHT); return new Dimension(minWidth, minHeight); } @@ -307,7 +290,7 @@ int xpos = bigPort.getX(); int ypos = bigPort.getY(); - List<Fig> figs = getElementFigs(); + List<CompartmentFigText> figs = getElementFigs(); // We remove all of them: for (Fig f : figs) { removeFig(f); @@ -458,27 +441,24 @@ } /* Find the compartment fig for this umlObject: */ - private CompartmentFigText findCompartmentFig(List<Fig> figs, + private CompartmentFigText findCompartmentFig(List<CompartmentFigText> figs, Object umlObject) { - for (Fig fig : figs) { - if (fig instanceof CompartmentFigText) { - CompartmentFigText candidate = (CompartmentFigText) fig; - if (candidate.getOwner() == umlObject) { - return candidate; - } + for (CompartmentFigText fig : figs) { + if (fig.getOwner() == umlObject) { + return fig; } } return null; } - private List<Fig> getElementFigs() { - List<Fig> figs = new ArrayList<Fig>(getFigs()); - // TODO: This is fragile and depends on the behavior of the super class - // not changing - if (figs.size() > 1) { - // Ignore the first 2 figs: - figs.remove(1); // the separator - figs.remove(0); // the bigPort + private List<CompartmentFigText> getElementFigs() { + final List<CompartmentFigText> figs = + new ArrayList<CompartmentFigText>(getFigs().size()); + + for (Object f : getFigs()) { + if (f instanceof CompartmentFigText) { + figs.add((CompartmentFigText) f); + } } return figs; } @@ -486,41 +466,20 @@ @Override public void setLineColor(Color col) { super.setLineColor(col); - if (col != null) { - - compartmentSeparator.setFilled(true); - if (externalSeparatorFig != null) { - externalSeparatorFig.setFillColor(col); - externalSeparatorFig.setFilled(true); - compartmentSeparator.setFillColor(null); - } else { - compartmentSeparator.setFillColor(col); - } - } + externalSeparatorFig.setFillColor(col); } @Override public void setLineWidth(int w) { super.setLineWidth(0); bigPort.setLineWidth(0); - compartmentSeparator.setHeight(w); - if (externalSeparatorFig != null) { - externalSeparatorFig.setHeight(w); - } + externalSeparatorFig.setHeight(w); } @Override public void setFillColor(Color col) { super.setFillColor(col); - - compartmentSeparator.setFilled(true); - if (externalSeparatorFig != null) { - externalSeparatorFig.setFillColor(getLineColor()); - externalSeparatorFig.setFilled(true); - compartmentSeparator.setFillColor(null); - } else { - compartmentSeparator.setFillColor(getLineColor()); - } + externalSeparatorFig.setFillColor(getLineColor()); } /** @@ -529,19 +488,13 @@ * @param r the new bounds */ public void setExternalSeparatorFigBounds(Rectangle r) { - if (externalSeparatorFig != null) { - externalSeparatorFig.setBounds(r); - } + externalSeparatorFig.setBounds(r); } /** - * Create an external Fig as separator line. - * - * @return the separator Fig + * @return separator figure */ - public Fig makeExternalSeparatorFig() { - assert externalSeparatorFig == null; - externalSeparatorFig = new FigSeparator(X0, Y0, 11, LINE_WIDTH); + public Fig getSeparatorFig() { return externalSeparatorFig; } @@ -552,7 +505,7 @@ * filled with the line color, since using a FigLine would draw the line * around the start and end coordinates with a line width > 1. */ - protected static class FigSeparator extends FigRect { + private static class FigSeparator extends FigRect { /** * Constructor. * @@ -563,13 +516,19 @@ FigSeparator(int x, int y, int len, int lineWidth) { super(x, y, len, lineWidth); setLineWidth(0); - setFilled(true); + super.setFilled(true); } @Override public Dimension getMinimumSize() { return new Dimension(MIN_SIZE, getHeight()); } + + @Override + public void setFilled(boolean filled) { + // Override superclass to do nothing. + // Fill property cannot be changed. + } } } Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java?view=diff&pathrev=17731&r1=17730&r2=17731 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigCompartmentBox.java 2010-01-03 10:16:05-0800 @@ -200,6 +200,7 @@ private void addCompartment(FigCompartment c) { assert !compartments.contains(c); + addFig(c.getSeparatorFig()); compartments.add(c); } @@ -406,7 +407,13 @@ */ protected void setCompartmentBounds(FigCompartment c, Rectangle cb, Rectangle ob) { - c.setBounds(cb.x, cb.y, cb.width, cb.height); + Rectangle r = new Rectangle(); + r.y = cb.y; + r.height = getLineWidth(); + r.width = ob.width; + r.x = ob.x; + c.setExternalSeparatorFigBounds(r); + c.setBounds(cb.x, cb.y + 1, cb.width, cb.height - 1); } /* Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigUseCase.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigUseCase.java?view=diff&pathrev=17731&r1=17730&r2=17731 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigUseCase.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigUseCase.java 2010-01-03 10:16:05-0800 @@ -153,7 +153,7 @@ * This horizontal line sticks out of the box, * and touches the ellipse edge. */ - Fig separatorFig = epc.makeExternalSeparatorFig(); + Fig separatorFig = epc.getSeparatorFig(); /* TODO: This next line prevent loading a UseCase * with a stereotype to grow. Why? */ ------------------------------------------------------ http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2434415 To unsubscribe from this discussion, e-mail: [commits-unsubscr...@argouml.tigris.org].