Author: bobtarling Date: 2010-01-03 04:52:27-0800 New Revision: 17730 Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAttributesCompartment.java 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/ui/FigEditableCompartment.java trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEnumLiteralsCompartment.java trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigExtensionPointsCompartment.java trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigOperationsCompartment.java trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigStereotypesGroup.java trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigUseCase.java
Log: Deprecate FigEditableCompartment and remove all usage Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAttributesCompartment.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAttributesCompartment.java?view=diff&pathrev=17730&r1=17729&r2=17730 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAttributesCompartment.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAttributesCompartment.java 2010-01-03 04:52:27-0800 @@ -1,3 +1,17 @@ +/* $Id$ + ******************************************************************************* + * Copyright (c) 2009-2010 Contributors - see below + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bob Tarling + ******************************************************************************* + * + * Some portions of this file was previously release using the BSD License: + */ // $Id$ // Copyright (c) 1996-2009 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this @@ -37,7 +51,7 @@ /** * @author Bob Tarling */ -public class FigAttributesCompartment extends FigEditableCompartment { +public class FigAttributesCompartment extends FigCompartment { /** * Serial version generated by Eclipse for rev. 1.17 */ 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=17730&r1=17729&r2=17730 ============================================================================== --- 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 04:52:27-0800 @@ -1,3 +1,17 @@ +/* $Id$ + ******************************************************************************* + * Copyright (c) 2009-2010 Contributors - see below + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bob Tarling + ******************************************************************************* + * + * Some portions of this file was previously release using the BSD License: + */ // $Id$ // Copyright (c) 1996-2009 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this @@ -24,11 +38,16 @@ package org.argouml.uml.diagram.ui; +import java.awt.Color; import java.awt.Dimension; import java.awt.Rectangle; +import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.apache.log4j.Logger; +import org.argouml.model.InvalidElementException; +import org.argouml.notation.NotationProvider; import org.argouml.uml.diagram.DiagramSettings; import org.tigris.gef.presentation.Fig; import org.tigris.gef.presentation.FigRect; @@ -55,7 +74,22 @@ */ public abstract class FigCompartment extends ArgoFigGroup { + private static final Logger LOG = Logger.getLogger(FigCompartment.class); + private Fig bigPort; + + 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; + /** * The constructor. @@ -79,6 +113,10 @@ bigPort.setLineWidth(0); addFig(bigPort); + + compartmentSeparator = + new FigSeparator(X0, Y0, 11, LINE_WIDTH); + addFig(compartmentSeparator); // number 2 } /** @@ -93,6 +131,59 @@ super(owner, settings); constructFigs(bounds.x, bounds.y, bounds.width, bounds.height); } + + /** + * @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 + * figs need not exist and be resized, moved etc if they are not visible. + * If a compartment is later made visible then its child figs are rebuilt + * from the model. + * {...@inheritdoc} + */ + @Override + public void setVisible(boolean visible) { + if (isVisible() == visible) { + return; + } + super.setVisible(visible); + if (externalSeparatorFig != null) { + externalSeparatorFig.setVisible(visible); + } + if (visible) { + populate(); + } else { + for (int i = getFigs().size() - 1; i >= 0; --i) { + Fig f = getFigAt(i); + if (f instanceof CompartmentFigText) { + removeFig(f); + } + } + } + } + + @Override + public void addFig(Fig fig) { + if (fig != getBigPort() + && !(fig instanceof CompartmentFigText) + && !(fig instanceof FigSeparator)) { + LOG.error("Illegal Fig added to a FigEditableCompartment"); + throw new IllegalArgumentException( + "A FigEditableCompartment can only " + + "contain CompartmentFigTexts, " + + "received a " + fig.getClass().getName()); + } + super.addFig(fig); + } + + /** * @return the bigPort @@ -122,6 +213,10 @@ } minHeight += 2; // 2 Pixel padding after compartment + + minHeight = Math.max(minHeight, + MIN_HEIGHT + compartmentSeparator.getHeight()); + return new Dimension(minWidth, minHeight); } @@ -154,12 +249,6 @@ protected abstract void createModelElement(); @Override - public void setLineWidth(int w) { - super.setLineWidth(w); - bigPort.setLineWidth(0); - } - - @Override public void setFilled(boolean f) { // Only the bigPort may be filled super.setFilled(false); @@ -196,7 +285,291 @@ public abstract Object getCompartmentType(); /** - * The concrete Fig implements this to build all the child Figs + * @return the collection of UML objects + * on which this compartment is based + */ + protected abstract Collection getUmlCollection(); + + /** + * @return the type of the notationProvider + * used to handle the text in the compartment + */ + protected abstract int getNotationType(); + + /** + * Fills the Fig by adding all figs within. + */ + public void populate() { + if (!isVisible()) { + return; + } + + int xpos = bigPort.getX(); + int ypos = bigPort.getY(); + + List<Fig> figs = getElementFigs(); + // We remove all of them: + for (Fig f : figs) { + removeFig(f); + } + + // We are going to add the ones still valid & new ones + // in the right sequence: + FigSingleLineTextWithNotation comp = null; + try { + int acounter = -1; + for (Object umlObject : getUmlCollection()) { + comp = findCompartmentFig(figs, umlObject); + acounter++; + + // TODO: Some of these magic numbers probably assume a line + // width of 1. Replace with appropriate constants/variables. + + // If we don't have a fig for this UML object, we'll need to add + // one. We set the bounds, but they will be reset later. + if (comp == null) { + comp = createFigText(umlObject, new Rectangle( + xpos + 1 /*?LINE_WIDTH?*/, + ypos + 1 /*?LINE_WIDTH?*/ + acounter + * ROWHEIGHT, + 0, + ROWHEIGHT - 2 /*? 2*LINE_WIDTH? */), + getSettings()); + } else { + /* This one is still usable, so let's retain it, */ + /* but its position may have been changed: */ + Rectangle b = comp.getBounds(); + b.y = ypos + 1 /*?LINE_WIDTH?*/ + acounter * ROWHEIGHT; + // bounds not relevant here, but I am perfectionist... + comp.setBounds(b); + } + /* We need to set a new notationprovider, since + * the Notation language may have been changed: */ + comp.initNotationProviders(); + addFig(comp); // add it again (but now in the right sequence) + + // Now put the text in + // We must handle the case where the text is null + String ftText = comp.getNotationProvider().toString(umlObject, + comp.getNotationSettings()); + if (ftText == null) { + ftText = ""; + } + comp.setText(ftText); + + comp.setBotMargin(0); + } + } catch (InvalidElementException e) { + // TODO: It would be better here to continue the loop and try to + // build the rest of the compartment. Hence try/catch should be + // internal to the loop. + LOG.debug("Attempted to populate a FigEditableCompartment" + + " using a deleted model element - aborting", e); + } + + if (comp != null) { + comp.setBotMargin(6); // the last one needs extra space below it + } + } + + + /** + * @return null + * @deprecated for 0.27.3 by tfmorris. Subclasses must implement + * {...@link #createFigText(Object, Rectangle, DiagramSettings, + * NotationProvider)} + * which will become abstract in the future when this deprecated method is + * removed. + */ + @Deprecated + protected FigSingleLineTextWithNotation createFigText( + int x, int y, int w, int h, Fig aFig, NotationProvider np) { + // No longer abstract to allow subclasses to remove, so we provide a + // null default implementation + return null; + } + + /** + * Factory method to create a FigSingleLineTextWithNotation + * which must be implemented by all subclasses. + * It will become abstract after the release of 0.28 to + * enforce this requirement. + * + * @param owner owning UML element + * @param bounds position and size + * @param settings render settings + * @param np notation provider + * @return a FigSingleLineText which can be used to display the text. + */ + @SuppressWarnings("deprecation") + protected FigSingleLineTextWithNotation createFigText(Object owner, + Rectangle bounds, + @SuppressWarnings("unused") DiagramSettings settings, + NotationProvider np) { + + // If this is not overridden it will revert to the old behavior + // All internal subclasses have been updated, but this if for + // compatibility of non-ArgoUML extensions. + FigSingleLineTextWithNotation comp = createFigText( + bounds.x, + bounds.y, + bounds.width, + bounds.height, + this.getBigPort(), + np); + comp.setOwner(owner); + return comp; + } + + /** + * @param owner owning UML element + * @param bounds position and size + * @param settings the render settings + * @return a FigSingleLineText with notation provider + * which can be used to display the text */ - public abstract void populate(); + abstract FigSingleLineTextWithNotation createFigText(Object owner, + Rectangle bounds, + DiagramSettings settings); + + /** + * Returns the new size of the FigGroup (e.g. attributes or + * operations) after calculation new bounds for all sub-figs, + * considering their minimal sizes; FigGroup need not be + * displayed; no update event is fired.<p> + * + * This method has side effects that are sometimes used. + * + * @param x x + * @param y y + * @param w w + * @param h h + * @return the new dimension + */ + @SuppressWarnings("unused") + public Dimension updateFigGroupSize( + int x, + int y, + int w, + int h, + boolean checkSize, + int rowHeight) { + return getMinimumSize(); + } + + /* Find the compartment fig for this umlObject: */ + private CompartmentFigText findCompartmentFig(List<Fig> figs, + Object umlObject) { + for (Fig fig : figs) { + if (fig instanceof CompartmentFigText) { + CompartmentFigText candidate = (CompartmentFigText) fig; + if (candidate.getOwner() == umlObject) { + return candidate; + } + } + } + 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 + } + return figs; + } + + @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); + } + } + } + + @Override + public void setLineWidth(int w) { + super.setLineWidth(0); + bigPort.setLineWidth(0); + compartmentSeparator.setHeight(w); + if (externalSeparatorFig != null) { + 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()); + } + } + + /** + * Set new bounds for the external separator line (if it exists). + * + * @param r the new bounds + */ + public void setExternalSeparatorFigBounds(Rectangle r) { + if (externalSeparatorFig != null) { + externalSeparatorFig.setBounds(r); + } + } + + /** + * Create an external Fig as separator line. + * + * @return the separator Fig + */ + public Fig makeExternalSeparatorFig() { + assert externalSeparatorFig == null; + externalSeparatorFig = new FigSeparator(X0, Y0, 11, LINE_WIDTH); + return externalSeparatorFig; + } + + /** + * Fig representing a horizontal line separator for compartment. <p> + * + * This is a horizontal line, but implemented as a rectangle + * 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 { + /** + * Constructor. + * + * @param x coordinate + * @param y coordinate + * @param len length of the line + */ + FigSeparator(int x, int y, int len, int lineWidth) { + super(x, y, len, lineWidth); + setLineWidth(0); + setFilled(true); + } + + @Override + public Dimension getMinimumSize() { + return new Dimension(MIN_SIZE, getHeight()); + } + + } } 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=17730&r1=17729&r2=17730 ============================================================================== --- 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 04:52:27-0800 @@ -1,3 +1,18 @@ +/* $Id$ + ******************************************************************************* + * Copyright (c) 2009-2010 Contributors - see below + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bob Tarling + ******************************************************************************* + * + * Some portions of this file was previously release using the BSD License: + */ + // $Id$ // Copyright (c) 1996-2009 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this @@ -36,7 +51,6 @@ import org.apache.log4j.Logger; import org.argouml.model.AssociationChangeEvent; import org.argouml.model.AttributeChangeEvent; -import org.argouml.model.Model; import org.argouml.ui.targetmanager.TargetManager; import org.argouml.uml.diagram.DiagramSettings; import org.argouml.uml.diagram.static_structure.ui.SelectionClass; @@ -453,8 +467,8 @@ 2); Fig f = hitFig(r); - if (f instanceof FigEditableCompartment) { - FigEditableCompartment figCompartment = (FigEditableCompartment) f; + if (f instanceof FigCompartment) { + FigCompartment figCompartment = (FigCompartment) f; f = figCompartment.hitFig(r); if (f instanceof CompartmentFigText) { if (highlightedFigText != null && highlightedFigText != f) { @@ -481,9 +495,9 @@ // Search all feature compartments for a text fig to unhighlight for (int i = 1; i < getFigs().size(); i++) { fc = getFigAt(i); - if (fc instanceof FigEditableCompartment) { + if (fc instanceof FigCompartment) { CompartmentFigText ft = - unhighlight((FigEditableCompartment) fc); + unhighlight((FigCompartment) fc); if (ft != null) { return ft; } @@ -499,7 +513,8 @@ * @param fc compartment to search for highlight item * @return item that was unhighlighted or null if no action was taken */ - protected final CompartmentFigText unhighlight(FigEditableCompartment fc) { + protected final CompartmentFigText unhighlight( + FigCompartment fc) { Fig ft; for (int i = 1; i < fc.getFigs().size(); i++) { ft = fc.getFigAt(i); @@ -514,14 +529,14 @@ } protected void createContainedModelElement(FigGroup fg, InputEvent ie) { - if (!(fg instanceof FigEditableCompartment)) { + if (!(fg instanceof FigCompartment)) { return; } - ((FigEditableCompartment) fg).createModelElement(); + ((FigCompartment) fg).createModelElement(); /* Populate the compartment now, * so that we can put the last one in edit mode: * This fixes issue 5439. */ - ((FigEditableCompartment) fg).populate(); + ((FigCompartment) fg).populate(); // TODO: The above populate works but seems rather heavy here. // I can see something like this is needed though as events // won't manage this quick enough. Could we make Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEditableCompartment.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEditableCompartment.java?view=diff&pathrev=17730&r1=17729&r2=17730 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEditableCompartment.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEditableCompartment.java 2010-01-03 04:52:27-0800 @@ -1,3 +1,17 @@ +/* $Id$ + ******************************************************************************* + * Copyright (c) 2009-2010 Contributors - see below + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bob Tarling + ******************************************************************************* + * + * Some portions of this file was previously release using the BSD License: + */ // $Id$ // Copyright (c) 1996-2009 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this @@ -24,19 +38,9 @@ package org.argouml.uml.diagram.ui; -import java.awt.Color; -import java.awt.Dimension; import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import org.apache.log4j.Logger; -import org.argouml.model.InvalidElementException; -import org.argouml.notation.NotationProvider; import org.argouml.uml.diagram.DiagramSettings; -import org.tigris.gef.presentation.Fig; -import org.tigris.gef.presentation.FigRect; /** * Presentation logic for a boxed compartment, @@ -54,50 +58,11 @@ * * This FigGroup shall only contain its bigPort, * and Figs of type FigSeparator, and CompartmentFigText. + * @deprecated by Bob Tarling in 0.29.3 use {...@link FigCompartment} */ +...@deprecated public abstract class FigEditableCompartment extends FigCompartment { - private static final Logger LOG = Logger.getLogger(FigCompartment.class); - - 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; - - /** - * The constructor. <p> - * - * Two figs are added to this FigGroup: - * The bigPort (i.e. a box that encloses all compartments), - * and a separator. - * - * @param x x - * @param y y - * @param w width - * @param h height - * @deprecated for 0.27.3 by tfmorris. Use - * {...@link #FigEditableCompartment(Object, Rectangle, DiagramSettings)}. - */ - @SuppressWarnings("deprecation") - @Deprecated - public FigEditableCompartment(int x, int y, int w, int h) { - super(x, y, w, h); // This adds bigPort, i.e. number 1 - constructFigs(); - } - - private void constructFigs() { - compartmentSeparator = - new FigSeparator(X0, Y0, 11, LINE_WIDTH); - addFig(compartmentSeparator); // number 2 - } - /** * Construct a new FigGroup containing a "bigPort" or rectangle which * encloses the entire group for use in attaching edges, etc and a @@ -113,361 +78,5 @@ public FigEditableCompartment(Object owner, Rectangle bounds, DiagramSettings settings) { super(owner, bounds, settings); // This adds bigPort, i.e. number 1 - constructFigs(); - // We'd like to call populate here, but our subclasses might not be - // completely built yet, so we defer this to them - } - - /** - * @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 - * figs need not exist and be resized, moved etc if they are not visible. - * If a compartment is later made visible then its child figs are rebuilt - * from the model. - * {...@inheritdoc} - */ - @Override - public void setVisible(boolean visible) { - if (isVisible() == visible) { - return; - } - super.setVisible(visible); - if (externalSeparatorFig != null) { - externalSeparatorFig.setVisible(visible); - } - if (visible) { - populate(); - } else { - for (int i = getFigs().size() - 1; i >= 0; --i) { - Fig f = getFigAt(i); - if (f instanceof CompartmentFigText) { - removeFig(f); - } - } - } - } - - @Override - public void addFig(Fig fig) { - if (fig != getBigPort() - && !(fig instanceof CompartmentFigText) - && !(fig instanceof FigSeparator)) { - LOG.error("Illegal Fig added to a FigEditableCompartment"); - throw new IllegalArgumentException( - "A FigEditableCompartment can only " - + "contain CompartmentFigTexts, " - + "received a " + fig.getClass().getName()); - } - super.addFig(fig); - } - - /** - * @return the collection of UML objects - * on which this compartment is based - */ - protected abstract Collection getUmlCollection(); - - /** - * @return the type of the notationProvider - * used to handle the text in the compartment - */ - protected abstract int getNotationType(); - - /** - * Fills the Fig by adding all figs within. - */ - public void populate() { - if (!isVisible()) { - return; - } - - Fig bigPort = this.getBigPort(); - int xpos = bigPort.getX(); - int ypos = bigPort.getY(); - - List<Fig> figs = getElementFigs(); - // We remove all of them: - for (Fig f : figs) { - removeFig(f); - } - - // We are going to add the ones still valid & new ones - // in the right sequence: - FigSingleLineTextWithNotation comp = null; - try { - int acounter = -1; - for (Object umlObject : getUmlCollection()) { - comp = findCompartmentFig(figs, umlObject); - acounter++; - - // TODO: Some of these magic numbers probably assume a line - // width of 1. Replace with appropriate constants/variables. - - // If we don't have a fig for this UML object, we'll need to add - // one. We set the bounds, but they will be reset later. - if (comp == null) { - comp = createFigText(umlObject, new Rectangle( - xpos + 1 /*?LINE_WIDTH?*/, - ypos + 1 /*?LINE_WIDTH?*/ + acounter - * ROWHEIGHT, - 0, - ROWHEIGHT - 2 /*? 2*LINE_WIDTH? */), - getSettings()); - } else { - /* This one is still usable, so let's retain it, */ - /* but its position may have been changed: */ - Rectangle b = comp.getBounds(); - b.y = ypos + 1 /*?LINE_WIDTH?*/ + acounter * ROWHEIGHT; - // bounds not relevant here, but I am perfectionist... - comp.setBounds(b); - } - /* We need to set a new notationprovider, since - * the Notation language may have been changed: */ - comp.initNotationProviders(); - addFig(comp); // add it again (but now in the right sequence) - - // Now put the text in - // We must handle the case where the text is null - String ftText = comp.getNotationProvider().toString(umlObject, - comp.getNotationSettings()); - if (ftText == null) { - ftText = ""; - } - comp.setText(ftText); - - comp.setBotMargin(0); - } - } catch (InvalidElementException e) { - // TODO: It would be better here to continue the loop and try to - // build the rest of the compartment. Hence try/catch should be - // internal to the loop. - LOG.debug("Attempted to populate a FigEditableCompartment" - + " using a deleted model element - aborting", e); - } - - if (comp != null) { - comp.setBotMargin(6); // the last one needs extra space below it - } - } - - /* Find the compartment fig for this umlObject: */ - private CompartmentFigText findCompartmentFig(List<Fig> figs, - Object umlObject) { - for (Fig fig : figs) { - if (fig instanceof CompartmentFigText) { - CompartmentFigText candidate = (CompartmentFigText) fig; - if (candidate.getOwner() == umlObject) { - return candidate; - } - } - } - 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 - } - return figs; - } - - /** - * @return null - * @deprecated for 0.27.3 by tfmorris. Subclasses must implement - * {...@link #createFigText(Object, Rectangle, DiagramSettings, - * NotationProvider)} - * which will become abstract in the future when this deprecated method is - * removed. - */ - @Deprecated - protected FigSingleLineTextWithNotation createFigText( - int x, int y, int w, int h, Fig aFig, NotationProvider np) { - // No longer abstract to allow subclasses to remove, so we provide a - // null default implementation - return null; - } - - /** - * Factory method to create a FigSingleLineTextWithNotation - * which must be implemented by all subclasses. - * It will become abstract after the release of 0.28 to - * enforce this requirement. - * - * @param owner owning UML element - * @param bounds position and size - * @param settings render settings - * @param np notation provider - * @return a FigSingleLineText which can be used to display the text. - */ - @SuppressWarnings("deprecation") - protected FigSingleLineTextWithNotation createFigText(Object owner, - Rectangle bounds, - @SuppressWarnings("unused") DiagramSettings settings, - NotationProvider np) { - - // If this is not overridden it will revert to the old behavior - // All internal subclasses have been updated, but this if for - // compatibility of non-ArgoUML extensions. - FigSingleLineTextWithNotation comp = createFigText( - bounds.x, - bounds.y, - bounds.width, - bounds.height, - this.getBigPort(), - np); - comp.setOwner(owner); - return comp; - } - - /** - * @param owner owning UML element - * @param bounds position and size - * @param settings the render settings - * @return a FigSingleLineText with notation provider - * which can be used to display the text - */ - abstract FigSingleLineTextWithNotation createFigText(Object owner, - Rectangle bounds, - DiagramSettings settings); - - /** - * Returns the new size of the FigGroup (e.g. attributes or - * operations) after calculation new bounds for all sub-figs, - * considering their minimal sizes; FigGroup need not be - * displayed; no update event is fired.<p> - * - * This method has side effects that are sometimes used. - * - * @param x x - * @param y y - * @param w w - * @param h h - * @return the new dimension - */ - @SuppressWarnings("unused") - public Dimension updateFigGroupSize( - int x, - int y, - int w, - int h, - boolean checkSize, - int rowHeight) { - return getMinimumSize(); - } - - /** - * The minimum width is the minimum width of the widest child element. - * The minimum height is the total minimum height of all child figs but no - * less than MINIMUM_HEIGHT pixels. - * @return the minimum width - */ - @Override - public Dimension getMinimumSize() { - Dimension d = super.getMinimumSize(); - d.height = Math.max(d.height, - MIN_HEIGHT + compartmentSeparator.getHeight()); - return d; - } - - @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); - } - } - } - - @Override - public void setLineWidth(int w) { - super.setLineWidth(0); - compartmentSeparator.setHeight(w); - if (externalSeparatorFig != null) { - 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()); - } - } - - /** - * Set new bounds for the external separator line (if it exists). - * - * @param r the new bounds - */ - public void setExternalSeparatorFigBounds(Rectangle r) { - if (externalSeparatorFig != null) { - externalSeparatorFig.setBounds(r); - } - } - - /** - * Create an external Fig as separator line. - * - * @return the separator Fig - */ - public Fig makeExternalSeparatorFig() { - assert externalSeparatorFig == null; - externalSeparatorFig = new FigSeparator(X0, Y0, 11, LINE_WIDTH); - return externalSeparatorFig; - } - - /** - * Fig representing a horizontal line separator for compartment. <p> - * - * This is a horizontal line, but implemented as a rectangle - * 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 { - /** - * Constructor. - * - * @param x coordinate - * @param y coordinate - * @param len length of the line - */ - FigSeparator(int x, int y, int len, int lineWidth) { - super(x, y, len, lineWidth); - setLineWidth(0); - setFilled(true); - } - - @Override - public Dimension getMinimumSize() { - return new Dimension(MIN_SIZE, getHeight()); - } - } } Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEnumLiteralsCompartment.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEnumLiteralsCompartment.java?view=diff&pathrev=17730&r1=17729&r2=17730 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEnumLiteralsCompartment.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEnumLiteralsCompartment.java 2010-01-03 04:52:27-0800 @@ -1,3 +1,18 @@ +/* $Id$ + ******************************************************************************* + * Copyright (c) 2009-2010 Contributors - see below + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Tom Morris + * Bob Tarling + ******************************************************************************* + * + * Some portions of this file was previously release using the BSD License: + */ // $Id$ // Copyright (c) 1996-2009 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this @@ -39,7 +54,7 @@ * * @author Tom Morris */ -public class FigEnumLiteralsCompartment extends FigEditableCompartment { +public class FigEnumLiteralsCompartment extends FigCompartment { /** * Serial version for initial implementation. */ @@ -81,7 +96,7 @@ } /** - * @see org.argouml.uml.diagram.ui.FigEditableCompartment#createModelElement() + * @see org.argouml.uml.diagram.ui.FigCompartment#createModelElement() */ protected void createModelElement() { Object enumeration = getGroup().getOwner(); Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigExtensionPointsCompartment.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigExtensionPointsCompartment.java?view=diff&pathrev=17730&r1=17729&r2=17730 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigExtensionPointsCompartment.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigExtensionPointsCompartment.java 2010-01-03 04:52:27-0800 @@ -1,3 +1,19 @@ +/* $Id: FigEditableCompartment.java 17718 2010-01-02 14:06:22Z bobtarling $ + ******************************************************************************* + * Copyright (c) 2009-2010 Contributors - see below + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Michiel van der Wulp + * Bob Tarling + ******************************************************************************* + * + * Some portions of this file was previously release using the BSD License: + */ + // $Id: eclipse-argo-codetemplates.xml 11347 2006-10-26 22:37:44Z linus $ // Copyright (c) 2009 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this @@ -38,7 +54,7 @@ * * @author michiel */ -public class FigExtensionPointsCompartment extends FigEditableCompartment { +public class FigExtensionPointsCompartment extends FigCompartment { /** * The constructor. Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigOperationsCompartment.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigOperationsCompartment.java?view=diff&pathrev=17730&r1=17729&r2=17730 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigOperationsCompartment.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigOperationsCompartment.java 2010-01-03 04:52:27-0800 @@ -1,3 +1,18 @@ +/* $Id$ + ******************************************************************************* + * Copyright (c) 2009-2010 Contributors - see below + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bob Tarling + ******************************************************************************* + * + * Some portions of this file was previously release using the BSD License: + */ + // $Id$ // Copyright (c) 1996-2009 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this @@ -40,7 +55,7 @@ * * @author Bob Tarling */ -public class FigOperationsCompartment extends FigEditableCompartment { +public class FigOperationsCompartment extends FigCompartment { /** * Constructor for an Operations compartment. Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigStereotypesGroup.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigStereotypesGroup.java?view=diff&pathrev=17730&r1=17729&r2=17730 ============================================================================== --- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigStereotypesGroup.java (original) +++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigStereotypesGroup.java 2010-01-03 04:52:27-0800 @@ -1,3 +1,17 @@ +/* $Id$ + ******************************************************************************* + * Copyright (c) 2009-2010 Contributors - see below + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bob Tarling + ******************************************************************************* + * + * Some portions of this file was previously release using the BSD License: + */ // $Id$ // Copyright (c) 1996-2009 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this @@ -265,7 +279,7 @@ /** * TODO: This should become private and only called from constructor * - * @see org.argouml.uml.diagram.ui.FigEditableCompartment#populate() + * @see org.argouml.uml.diagram.ui.FigCompartment#populate() */ public void populate() { 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=17730&r1=17729&r2=17730 ============================================================================== --- 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 04:52:27-0800 @@ -1,3 +1,18 @@ +/* $Id$ + ******************************************************************************* + * Copyright (c) 2009-2010 Contributors - see below + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bob Tarling + * Michiel van der Wulp + ******************************************************************************* + * + * Some portions of this file was previously release using the BSD License: + */ // $Id$ // Copyright (c) 1996-2009 The Regents of the University of California. All // Rights Reserved. Permission to use, copy, modify, and distribute this @@ -47,7 +62,6 @@ import org.argouml.uml.diagram.ui.ActionCompartmentDisplay; import org.argouml.uml.diagram.ui.FigCompartment; import org.argouml.uml.diagram.ui.FigCompartmentBox; -import org.argouml.uml.diagram.ui.FigEditableCompartment; import org.argouml.uml.diagram.ui.FigExtensionPointsCompartment; import org.tigris.gef.base.Selection; import org.tigris.gef.presentation.Fig; @@ -100,7 +114,7 @@ * coordinates of any partition line required between use case name * and extension points.<p> * - * Finally we need to transform our coordinates, to recognize that the + * Finally we need to transform our coordinates, to recognise that the * origin is at our top left corner, and the Y coordinates are * reversed.<p> */ @@ -380,9 +394,7 @@ ob.height / 2.0 - (cb.y - ob.y)))); r.x = cb.x + cb.width / 2 - r.width / 2; - if (c instanceof FigEditableCompartment) { - ((FigEditableCompartment) c).setExternalSeparatorFigBounds(r); - } + c.setExternalSeparatorFigBounds(r); c.setBounds(cb.x, cb.y, cb.width, cb.height); } ------------------------------------------------------ http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2434375 To unsubscribe from this discussion, e-mail: [[email protected]].
