Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Variable Diagram Size
Variable Diagram Size [message #1714508] Fri, 13 November 2015 09:59 Go to next message
md md is currently offline md mdFriend
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:
index.php/fa/23923/0/
After zoom:
index.php/fa/23924/0/

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.
index.php/fa/23925/0/

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 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 244
Registered: July 2009
Location: Lünen
Senior Member
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.
Re: Variable Diagram Size [message #1714616 is a reply to message #1714577] Sat, 14 November 2015 00:15 Go to previous messageGo to next message
md md is currently offline md mdFriend
Messages: 9
Registered: November 2015
Junior Member
But how I can achieve that the pane has a default size from (200, 200)?
Re: Variable Diagram Size [message #1714675 is a reply to message #1714616] Sun, 15 November 2015 14:50 Go to previous message
md md is currently offline md mdFriend
Messages: 9
Registered: November 2015
Junior Member
İt's possible to create or move elements outside the diagram size. Should I prevent this by commands or are their any other ways to do this?
Previous Topic:[GEF4] drag relocation, how to update the model
Next Topic:[Zest] Layout
Goto Forum:
  


Current Time: Fri Apr 19 13:58:42 GMT 2024

Powered by FUDForum. Page generated in 0.02965 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top