Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2016-09-23 07:27:01 +0000
committerGerrit Code Review @ Eclipse.org2016-09-23 15:47:42 +0000
commita13893307ab8c9de70996e23b2d7d5fa54656192 (patch)
tree627d9ddb326d80b3ee3ee5cb943153a68035cd29
parentc8d87679b629f20088e2e442bc20d57d0cb76364 (diff)
downloadorg.eclipse.papyrus-a13893307ab8c9de70996e23b2d7d5fa54656192.tar.gz
org.eclipse.papyrus-a13893307ab8c9de70996e23b2d7d5fa54656192.tar.xz
org.eclipse.papyrus-a13893307ab8c9de70996e23b2d7d5fa54656192.zip
Bug 500999 - [Layout][Enhancement] Image should be completely displayed in the compartment
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/BorderedScalableImageFigure.java44
1 files changed, 2 insertions, 42 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/BorderedScalableImageFigure.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/BorderedScalableImageFigure.java
index 3105e38ae3b..ed60a7cad62 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/BorderedScalableImageFigure.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/figure/node/BorderedScalableImageFigure.java
@@ -19,7 +19,6 @@ import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.ScrollPane;
import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PrecisionDimension;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gmf.runtime.draw2d.ui.render.RenderedImage;
@@ -102,50 +101,11 @@ public class BorderedScalableImageFigure extends ScalableImageFigure {
// if there is aspect ratio and only one figure is set
if (isMaintainAspectRatio() && container.getParent().getChildren().size() == 1) {
- // If the ration is maintained
+ // If the ratio is maintained
ScalableCompartmentFigure scalableCompartmentFigure = FigureUtils.findParentFigureInstance(container, ScalableCompartmentFigure.class);
-
- // Get the document to calculate ratio
- ScalableImageFigure scalableImage = FigureUtils.findChildFigureInstance(getParent(), ScalableImageFigure.class);
- double ratio = 1;
- RenderedImage renderedImage = scalableImage.getRenderedImage();
- if (renderedImage instanceof org.eclipse.gmf.runtime.draw2d.ui.render.awt.internal.svg.SVGImage) {
- org.eclipse.gmf.runtime.draw2d.ui.render.awt.internal.svg.SVGImage img = (org.eclipse.gmf.runtime.draw2d.ui.render.awt.internal.svg.SVGImage) renderedImage;
- final PrecisionDimension svgDimension = getSvgDimension(img.getDocument());
- ratio = svgDimension.preciseWidth() / svgDimension.preciseHeight();
- }
-
Rectangle scalableCompartmentBounds = scalableCompartmentFigure != null ? scalableCompartmentBounds = scalableCompartmentFigure.getBounds() : container.getBounds();
- Point center = new Point(scalableCompartmentBounds.x + scalableCompartmentBounds.width / 2, scalableCompartmentBounds.y + scalableCompartmentBounds.height / 2);
-
- int width = 0;
- int height = 0;
- int y = 0;
- int x = 0;
-
- // Case width>height
- if (scalableCompartmentBounds.width > scalableCompartmentBounds.height) {
- if (scalableCompartmentBounds.width > scalableCompartmentBounds.height * ratio) {
- width = (int) (scalableCompartmentBounds.height * ratio);
- height = scalableCompartmentBounds.height;
- } else {
- width = scalableCompartmentBounds.width;
- height = (int) (scalableCompartmentBounds.width / ratio);
- }
-
- } else {// Case height>width
- if (scalableCompartmentBounds.height < scalableCompartmentBounds.width / ratio) {
- width = (int) (scalableCompartmentBounds.height * ratio);
- height = scalableCompartmentBounds.height;
- } else {
- width = scalableCompartmentBounds.width;
- height = (int) (scalableCompartmentBounds.width / ratio);
- }
- }
- y = center.y - height / 2;
- x = center.x - width / 2;
- container.setBounds(new Rectangle(x, y, width, height));
+ container.setBounds(scalableCompartmentBounds);
} else {
// Set bounds
if (scrollPaneFigure instanceof ScrollPane) {

Back to the top