Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package org.etsi.mts.tdl.graphical.sirius.figure;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.sirius.diagram.ui.tools.api.figure.IWorkspaceImageFigure;
import org.eclipse.sirius.diagram.ui.tools.api.figure.ViewNodeContainerRectangleFigureDesc;
public class ViewNodeContainerImageFigureDesc extends ViewNodeContainerRectangleFigureDesc {
public ViewNodeContainerImageFigureDesc() {
MarginBorder border = (MarginBorder) getBorder();
border.getInsets(this).top = 15;
border.getInsets(this).left = 10;
border.getInsets(this).right = 10;
}
@Override
public void setBounds(Rectangle rect) {
IWorkspaceImageFigure imgfigure = (IWorkspaceImageFigure)getParent().getChildren().get(0);
double imageAspectRatio = imgfigure.getImageAspectRatio();
final int newHeight = (int) (rect.width / imageAspectRatio);
final int newWidth = (int) (rect.height * imageAspectRatio);
Rectangle rect2 = rect.getCopy();
if (newHeight > rect.height) {
rect2.height = newHeight;
} else {
rect2.width = newWidth;
}
super.setBounds(rect2.getCopy());
imgfigure.setBounds(rect2.getCopy());
getParent().setBounds(rect2.getCopy());
getParent().getParent().setBounds(rect2.getCopy());
}
}