rotate Figure & MouseListener [message #224443] |
Mon, 16 October 2006 08: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);
}
}
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.24299 seconds