How to stop resizing of image [message #225003] |
Tue, 24 October 2006 11:32 |
Eclipse User |
|
|
|
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 |
Xiang Qinxian 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
|
|
|
Powered by
FUDForum. Page generated in 0.05356 seconds