Variable Diagram Size [message #1714508] |
Fri, 13 November 2015 09:59 |
md md Messages: 9 Registered: November 2015 |
Junior Member |
|
|
Hi,
I implement a graphical editing tool with GEF.
It should be possible to adjust the diagram size and it should be prevented to drag new elements outside this size.
What I do is to override the createDefaultRoot method in ScrollingGraphicalViewer and write my own ScalableLayeredPane for which I override the createScaledLayers method, see below. Their I set the bounds for now on fixed size (200,200).
@Override
protected ScalableLayeredPane createScaledLayers() {
ScalableLayeredPane layer = new ScalableLayeredPane() {
@Override
public Rectangle getBounds() {
return new Rectangle(0, 0, 200, 200);
}
@Override
public Border getBorder() {
return new SchemeBorder(SCHEMES.BUTTON);
}
@Override
public void paint(Graphics graphics) {
super.paint(graphics);
graphics.setLineWidth(5);
graphics.setForegroundColor(red);
graphics.drawRectangle(new Rectangle(getBounds()));
graphics.scale(getScale());
}
protected void paintClientArea(Graphics graphics) {
if (getChildren().isEmpty())
return;
if (scale == 1.0) {
super.paintClientArea(graphics);
} else {
ScaledGraphics g = new ScaledGraphics(graphics);
boolean optimizeClip = getBorder() == null
|| getBorder().isOpaque();
if (!optimizeClip)
g.clipRect(getBounds().getCropped(getInsets()));
g.scale(scale);
g.pushState();
paintChildren(g);
g.dispose();
graphics.restoreState();
}
}
...
The current state after I made these changes:
After zoom:
1. What I want to achieve is that the diagram size should be adjustable and
2. in case of zooming it should be not zoomed inside the diagram, the zoom should affect the whole diagram, like this.
Could so. help please!
-
Attachment: 1.PNG
(Size: 3.77KB, Downloaded 296 times) -
Attachment: 2.PNG
(Size: 3.54KB, Downloaded 309 times) -
Attachment: 3.PNG
(Size: 4.58KB, Downloaded 302 times)
|
|
|
Re: Variable Diagram Size [message #1714577 is a reply to message #1714508] |
Fri, 13 November 2015 16:35 |
|
The bounds you specify on the ScalableLayeredPane are absolute (as the pane itself is not zoomed). You would have to dynamically adjust these bounds based on the scaling that is applied by the ZoomManager.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02965 seconds