Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to stop resizing of image
How to stop resizing of image [message #225003] Tue, 24 October 2006 11:32 Go to next message
Eclipse UserFriend
Originally posted by: digvijaysrana.gmail.com

I have a figure called Cool.gif which i can drop on my Editor. Although i
have written "setBounds(new Rectangle(r.x,r.y,33,33))" assuming that it
would stop resizing , whcih infact it did.
But i dont know why it stopped working...
Can any one help me how can i can retain the original shape of the Figure
!!

Thx
DigVijay

---------------------Code---------------------------------
public class MyFigureClass extends Figure{

protected void paintFigure(Graphics g) {
super.paintFigure(g);

Rectangle r = getBounds();
g.drawImage(MyImages.getImage("Cool"), r.x, r.y);

setBounds(new Rectangle(r.x,r.y,33,33));
}

public void setBounds(Rectangle rect) {
super.setBounds(rect);
}

public void setConstraint(IFigure child, Object constraint) {
super.setConstraint(child, constraint);
}
}
---------------------Code-----------------------------------
Re: How to stop resizing of image [message #225034 is a reply to message #225003] Tue, 24 October 2006 14:16 Go to previous message
Xiang Qinxian is currently offline Xiang QinxianFriend
Messages: 119
Registered: July 2009
Senior Member
在 2006-10-24二的 11:32 +0000,DigVijay S 写道:
>
> I have a figure called Cool.gif which i can drop on my Editor. Although i
> have written "setBounds(new Rectangle(r.x,r.y,33,33))" assuming that it
> would stop resizing , whcih infact it did.
> But i dont know why it stopped working...
> Can any one help me how can i can retain the original shape of the Figure
> !!
>
> Thx
> DigVijay
>
> ---------------------Code---------------------------------
> public class MyFigureClass extends Figure{
>
> protected void paintFigure(Graphics g) {
> super.paintFigure(g);
>
> Rectangle r = getBounds();
> g.drawImage(MyImages.getImage("Cool"), r.x, r.y);
>
> setBounds(new Rectangle(r.x,r.y,33,33));
> }
Hi, according to requirment above, should call :
g.drawImae(myImage, 0, 0, 33, 33, r.x, r.y, 33, 33);
given w,h, clip it, else internal GC do as myImage.width and
image.height;

>
> public void setBounds(Rectangle rect) {
> super.setBounds(rect);
> }
>
> public void setConstraint(IFigure child, Object constraint) {
> super.setConstraint(child, constraint);
> }
> }
> ---------------------Code-----------------------------------
>
Regards,

Qinxian
Previous Topic:Tooltip for the list of Actions in the context menu
Next Topic:To slow scrolling with ScrollPane
Goto Forum:
  


Current Time: Fri Apr 26 01:22:37 GMT 2024

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

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

Back to the top