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
sirair sirair is currently offline sirair sirairFriend
Messages: 7
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 189 times)
  • Attachment: 2.PNG
    (Size: 3.54KB, Downloaded 193 times)
  • Attachment: 3.PNG
    (Size: 4.58KB, Downloaded 200 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: 235
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
sirair sirair is currently offline sirair sirairFriend
Messages: 7
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
sirair sirair is currently offline sirair sirairFriend
Messages: 7
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 MVC] concept for adding items
Next Topic:[GEF4] Tutorial first steps available
Goto Forum:
  


Current Time: Wed Sep 19 19:24:15 GMT 2018

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

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

Back to the top