Skip to main content



      Home
Home » Eclipse Projects » GEF » Variable Diagram Size
Variable Diagram Size [message #1714508] Fri, 13 November 2015 04:59 Go to next message
Eclipse UserFriend
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 360 times)
  • Attachment: 2.PNG
    (Size: 3.54KB, Downloaded 367 times)
  • Attachment: 3.PNG
    (Size: 4.58KB, Downloaded 356 times)
Re: Variable Diagram Size [message #1714577 is a reply to message #1714508] Fri, 13 November 2015 11:35 Go to previous messageGo to next message
Eclipse UserFriend
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] Fri, 13 November 2015 19:15 Go to previous messageGo to next message
Eclipse UserFriend
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 09:50 Go to previous message
Eclipse UserFriend
İ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: Wed Jul 23 06:34:51 EDT 2025

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

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

Back to the top