diff options
author | Mickael ADAM | 2015-11-16 16:23:15 +0000 |
---|---|---|
committer | Mickael ADAM | 2015-11-23 13:02:27 +0000 |
commit | 525fcd480677d1c9d6d5204f08ddc832b7ab0b91 (patch) | |
tree | c35b6cc3ab910eba43c4a05636ec87c5bef8b3cc | |
parent | d251c1463cf234f9f65805d8ef68bac804af36c7 (diff) | |
download | org.eclipse.papyrus-525fcd480677d1c9d6d5204f08ddc832b7ab0b91.tar.gz org.eclipse.papyrus-525fcd480677d1c9d6d5204f08ddc832b7ab0b91.tar.xz org.eclipse.papyrus-525fcd480677d1c9d6d5204f08ddc832b7ab0b91.zip |
Bug 482306 - [All Diagrams] DisplayBorder:false only hides Compartment
Lines
-modify the manage of border and shadow;
-a little fix to avoid a loop of paint.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=482306
Change-Id: Iae7c0122b9d0a5a25f10a907d111c37cf4241230
Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
2 files changed, 85 insertions, 15 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/NotVisibleBorder.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/NotVisibleBorder.java new file mode 100644 index 00000000000..ce792e9a477 --- /dev/null +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/NotVisibleBorder.java @@ -0,0 +1,39 @@ +/***************************************************************************** + * Copyright (c) 2015 CEA LIST and others. + * + * 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: + * CEA LIST - Initial API and implementation + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.gmfdiag.common.figure; + +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.LineBorder; +import org.eclipse.draw2d.geometry.Insets; + +/** + * A border which are not visible. + */ +public class NotVisibleBorder extends LineBorder { + + /** + * @see org.eclipse.draw2d.LineBorder#paint(org.eclipse.draw2d.IFigure, org.eclipse.draw2d.Graphics, org.eclipse.draw2d.geometry.Insets) + * + * @param figure + * @param graphics + * @param insets + */ + @Override + public void paint(IFigure figure, Graphics graphics, Insets insets) { + // Do nothing + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java index d128e5fa90b..6b96677d9a2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/figure/node/RoundedCompartmentFigure.java @@ -31,6 +31,7 @@ import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure; import org.eclipse.gmf.runtime.draw2d.ui.figures.RoundedRectangleBorder; import org.eclipse.gmf.runtime.draw2d.ui.graphics.ColorRegistry; import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.NotVisibleBorder; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SlidableRoundedRectangleAnchor; @@ -83,6 +84,9 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements /** set to true to define the figure as a package. */ private boolean isPackage = false; + /** set to true to define if the figure has a shadow. */ + private boolean shadow; + /** * Gets the shadow color. * @@ -155,6 +159,7 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements if (compartmentFigure != null) { createContentPane(compartmentFigure); } + setBorder(getRoundedBorder()); } /** @@ -251,7 +256,7 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements if (isPackage) { final SVGNodePlateFigure mainFigure = FigureUtils.findParentFigureInstance(this, SVGNodePlateFigure.class); // Get the connection anchor - final ConnectionAnchor connectionAnchor = mainFigure.getConnectionAnchor(""); + final ConnectionAnchor connectionAnchor = mainFigure.getConnectionAnchor(""); //$NON-NLS-1$ if (connectionAnchor instanceof SlidableRoundedRectangleAnchor) { @@ -311,12 +316,15 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements } // no used of the border of figure - if (getBorder() != null) { - setBorder(null); + if (null != getBorder() && !(getBorder() instanceof NotVisibleBorder)) { + // Set a not visible border to the figure + setBorder(new NotVisibleBorder()); } - // Draw lines - graphics.drawPolyline(polygonPoints); + if (!noBorder) { + // Draw lines + graphics.drawPolyline(polygonPoints); + } } } else { @@ -357,6 +365,7 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements setShadowTransparency(graphics, false); } + // Fill figure if (isUsingGradient()) { fillRoundedRectangleWithGradient(graphics, rectangle, cornerDimension.width, cornerDimension.height); } else { @@ -371,6 +380,15 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements if (hasHeader) { graphics.drawPolyline(getHeader()); } + + // Draw border + Border border = getBorder(); + if (border instanceof RoundedRectangleBorder) { + ((RoundedRectangleBorder) border).setArcHeight(cornerDimension.height); + ((RoundedRectangleBorder) border).setArcWidth(cornerDimension.width); + ((RoundedRectangleBorder) border).setWidth(getLineWidth()); + ((RoundedRectangleBorder) border).setStyle(borderStyle); + } } graphics.popState(); } @@ -459,10 +477,10 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements /** - * Sets the shadow backgroud color. + * Sets the shadow background color. * * @param graphics - * the new shadow backgroud color + * the new shadow background color */ private void setShadowBackgroundColor(final Graphics graphics) { @@ -520,14 +538,32 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements } } + + /** + * @see org.eclipse.papyrus.uml.diagram.common.figure.node.PapyrusNodeFigure#isShadow() + * + * @return true if has a shadow + */ + @Override + public boolean isShadow() { + return shadow; + } + /** * @see org.eclipse.papyrus.uml.diagram.common.figure.node.PapyrusNodeFigure#setShadow(boolean) * * @param shadow */ @Override - public void setShadow(final boolean shadow) { - super.setShadow(shadow); + public void setShadow(boolean shadow) { + this.shadow = shadow; + } + + /** + * @return the Rounded border used as border for this figure. + * + */ + private Border getRoundedBorder() { refreshCornerSizeWhenOval(); @@ -547,10 +583,7 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements } }; - border.setWidth(getLineWidth()); - border.setStyle(borderStyle); - setBorder(border); - setLineStyle(borderStyle); + return border; } /** @@ -562,8 +595,6 @@ public class RoundedCompartmentFigure extends NodeNamedElementFigure implements if (cornerDimension.width != getBounds().width || cornerDimension.height != getBounds().height) { cornerDimension.width = getBounds().width; cornerDimension.height = getBounds().height; - // Force to repaint the border thought setShadow() - setShadow(isShadow()); } } } |