Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Dialog figure
Dialog figure [message #511591] Tue, 02 February 2010 08:26 Go to next message
StefanK  is currently offline StefanK Friend
Messages: 25
Registered: July 2009
Junior Member
Hello,

I´m currently working on a gef based gui builder that needs to provice a dialog figure so that the user can place gui components like buttons into it. I was wondering if there is some kind of dialog figure available.

I checked the org.eclipse.draw2d package and google, but got no luck.

http://www.ibm.com/developerworks/opensource/library/os-ecvisual/
Figure 2 is an example for what I´m looking.

Thanks for your help.

Best regards
StefanK
Re: Dialog figure [message #511612 is a reply to message #511591] Tue, 02 February 2010 09:34 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
one of the solutions would be to capture an image of the dialog and paint the same on the figure...

off course scaling issues have to be handled...


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Dialog figure [message #511857 is a reply to message #511612] Wed, 03 February 2010 09:14 Go to previous messageGo to next message
StefanK  is currently offline StefanK Friend
Messages: 25
Registered: July 2009
Junior Member
Thanks for your reply, I´ll try it asap
Re: Dialog figure [message #517143 is a reply to message #511591] Fri, 26 February 2010 11:46 Go to previous messageGo to next message
StefanK  is currently offline StefanK Friend
Messages: 25
Registered: July 2009
Junior Member
Hi again,

I just can´t figure out how to repaint a given .gif picture if the user resizes the figure on the canvas. My gif´s size is 200*200, if I integrate it into a draw2d.Label, it is shown on the canvas, but resizing it changes only the label size, not the .gif size itself..

Are there any tutorials or code examples available?

Thanks for your help

Best regards
StefanK
Re: Dialog figure [message #517153 is a reply to message #517143] Fri, 26 February 2010 12:09 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
Use ImageFigure instead of label....

And change the scale of that figure to resize...

hope they have handled the scaled painting....

try and tell me...


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay

[Updated on: Fri, 26 February 2010 12:14]

Report message to a moderator

Re: Dialog figure [message #517520 is a reply to message #511591] Mon, 01 March 2010 06:49 Go to previous messageGo to next message
StefanK  is currently offline StefanK Friend
Messages: 25
Registered: July 2009
Junior Member
Hello vijay,

thanks for your help. I checked the ImageFigure API, but there is no method that can change the scale of the figure. I´m sorry, but this is my first project using gef.. Is it possible, that you can post a code example for "changing the scale"?

I thought there might be a method called performScale() or something..

Best regards
StefanK
Re: Dialog figure [message #517544 is a reply to message #517520] Mon, 01 March 2010 09:25 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
try this

class StrechableImageFigure extends Figure
 {
	 private Image m;

	public StrechableImageFigure(Image m) {
		super();
		this.m = m;
	}

	@Override
	public void setBounds(Rectangle rect) {
		super.setBounds(rect);
		ImageData imageData = m.getImageData();
		imageData = imageData.scaledTo(getBounds().width, getBounds().height);
		m = new Image(null, imageData);
	}

	@Override
	protected void paintFigure(Graphics graphics) {		
		graphics.drawImage(m, new Point());
	}
	
	
 }


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Dialog figure [message #517627 is a reply to message #511591] Mon, 01 March 2010 15:02 Go to previous messageGo to next message
StefanK  is currently offline StefanK Friend
Messages: 25
Registered: July 2009
Junior Member
Thanks a lot, vijay. It works just fine!
One little modification in your code:

class StrechableImageFigure extends Figure
 {
	 private Image m;

	public StrechableImageFigure(Image m) {
		super();
		this.m = m;
	}

	@Override
	public void setBounds(Rectangle rect) {
		super.setBounds(rect);
		ImageData imageData = m.getImageData();
		imageData = imageData.scaledTo(getBounds().width, getBounds().height);
		m = new Image(null, imageData);
	}

	@Override
	protected void paintFigure(Graphics graphics) {		
		graphics.drawImage(m, new Point(getBounds().x, getBounds().y));
// x and y coordinates are needed. If the Image is drawn with 0,0 coordinates, will be painted on the top left of the canvas
	}
	
	
 }


Best regards
StefanK

[Updated on: Mon, 01 March 2010 15:02]

Report message to a moderator

Re: Dialog figure [message #517801 is a reply to message #517627] Tue, 02 March 2010 08:16 Go to previous message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
There is somthing wrong here...

Can any body clearify this please....

cordinates are always relative hence Point(0,0) for a figure
will be its top left not canvas top left....

am i overriding the wrong method or somthing else is missing here or everything is correct?


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Previous Topic:[Zest] Cycle connection between two nodes
Next Topic:Gef Editor in Web
Goto Forum:
  


Current Time: Fri Mar 29 12:57:05 GMT 2024

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

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

Back to the top