rotate Figure & MouseListener [message #224443] |
Mon, 16 October 2006 12:26  |
Eclipse User |
|
|
|
Originally posted by: mouna.feki.siemens.com
Hi,
I drew a IFigur . Now my goal is the following:
If I press two times on this Figure, then she will be rotated.
My Problem is: I dŽont know how to call the graphics elements in the
method
public void mouseDoubleClicked(MouseEvent e){}
I hofe that someone me help.
Thanks in Advance
Here is my Code:
------------------------------------------------------------ ---------
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.MouseEvent;
import org.eclipse.draw2d.MouseListener;
public class CreateGleis extends Figure implements MouseListener{
protected void paintFigure(Graphics graphics)
{
graphics.pushState();
int width = getBounds().width;
int height = getBounds().height;
int x = getBounds().x;
int y = getBounds().y;
graphics.setLineWidth(3);
//horizontal line
graphics.drawLine( x , y +height/2 , x+width , y +height/2 );
addMouseListener(this);
graphics.popState();
}
public void mousePressed(MouseEvent e) {
System.out.println("mousePressed");
}
public void mouseReleased(MouseEvent e) {
System.out.println("mouseReleased");
}
public void mouseEntered(MouseEvent e) {
System.out.println("mouseEntered");
}
public void mouseExited(MouseEvent e) {
System.out.println("mouseExited");
}
public void mouseDoubleClicked(MouseEvent e) {
//graphics.rotate(45);
}
}
|
|
|
Re: rotate Figure & MouseListener [message #224476 is a reply to message #224443] |
Mon, 16 October 2006 15:42   |
Eclipse User |
|
|
|
Originally posted by: ingo.koch[nospam].sap.com
Hi Mouna,
save the angle of your figure in a variable and rotate the figure
respectively in the paint method.
you cannot access the graphics object outside the paint methods.
Regards,
Ingo
"Mouna Feki" <mouna.feki@siemens.com> wrote in message
news:34550f637f3b05fab63301e543f21f70$1@www.eclipse.org...
> Hi,
>
> I drew a IFigur . Now my goal is the following:
> If I press two times on this Figure, then she will be rotated.
> My Problem is: I d
|
|
|
Re: rotate Figure & MouseListener [message #224491 is a reply to message #224476] |
Mon, 16 October 2006 16:01   |
Eclipse User |
|
|
|
Originally posted by: mouna.feki.siemens.com
But schould be not the Transformation written in the "
mouseDoubleClicked(MouseEvent e)" Method.
If i write rotate in the paint Methode, then will be the figure rotated
(one times and without DoubleClick)
Are there another solution, to solve this Problem?
Thanks
Mouna
|
|
|
Re: rotate Figure & MouseListener [message #224553 is a reply to message #224443] |
Tue, 17 October 2006 03:32   |
Eclipse User |
|
|
|
在 2006-10-16一的 12:26 +0000,Mouna Feki写道:
> Hi,
>
> I drew a IFigur . Now my goal is the following:
> If I press two times on this Figure, then she will be rotated.
> My Problem is: I dŽont know how to call the graphics elements in the
> method
Hi,
You can refer to logic example for check out performRequest with
REQUEST_DIRECT_EDIT and handle REQUEST_OPEN. like this:
@Override
public void performRequest(Request req) {
if (req.getType() == REQ_OPEN) {
doExpandCollapse(true);
}
super.performRequest(req);
}
Regards
Qinxian
>
> public void mouseDoubleClicked(MouseEvent e){}
>
> I hofe that someone me help.
> Thanks in Advance
>
> Here is my Code:
> ------------------------------------------------------------ ---------
> import org.eclipse.draw2d.Figure;
> import org.eclipse.draw2d.Graphics;
> import org.eclipse.draw2d.MouseEvent;
> import org.eclipse.draw2d.MouseListener;
>
>
> public class CreateGleis extends Figure implements MouseListener{
>
>
> protected void paintFigure(Graphics graphics)
> {
> graphics.pushState();
> int width = getBounds().width;
> int height = getBounds().height;
> int x = getBounds().x;
> int y = getBounds().y;
>
> graphics.setLineWidth(3);
> //horizontal line
> graphics.drawLine( x , y +height/2 , x+width , y +height/2 );
> addMouseListener(this);
> graphics.popState();
> }
>
> public void mousePressed(MouseEvent e) {
> System.out.println("mousePressed");
>
> }
>
> public void mouseReleased(MouseEvent e) {
> System.out.println("mouseReleased");
> }
>
> public void mouseEntered(MouseEvent e) {
> System.out.println("mouseEntered");
> }
>
> public void mouseExited(MouseEvent e) {
> System.out.println("mouseExited");
> }
>
> public void mouseDoubleClicked(MouseEvent e) {
> //graphics.rotate(45);
>
> }
>
>
>
> }
>
>
|
|
|
Re: rotate Figure & MouseListener [message #224976 is a reply to message #224553] |
Tue, 24 October 2006 05:45   |
Eclipse User |
|
|
|
Originally posted by: geetesh.jain.gmail.com
Hi Mouna,
Even iam trying to add a rotate function for one of my element. But didnt
got any success in it.
I would really appreciate if you Can share your code if its working fine.
Thanks
Geetesh
|
|
|
|
Powered by
FUDForum. Page generated in 0.03565 seconds