Mercurial > hg > ltpda
view src/MPipeline/src/mpipeline/MBlockNameLabel.java @ 42:f90d4f666cc7 database-connection-manager
Cleanup
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Mon, 05 Dec 2011 18:04:34 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package mpipeline; import java.awt.Point; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.io.Serializable; /** * * @author hewitson */ public class MBlockNameLabel extends MBlockLabel implements Serializable { /** * * @param s */ public MBlockNameLabel(String s) { super(s); } /** * */ public MBlockNameLabel(){ super("None"); } /** * Define the mouse events for an MBlockCore object. * * @author hewitson */ public class MBlockNameLabelMouseEvents implements Serializable, MouseListener, MouseMotionListener { /** * Create a new MBlockCoreMouseEvents listener. */ public MBlockNameLabelMouseEvents() { } public void mouseClicked(MouseEvent me) { /* Pass to canvas */ Point pt = me.getPoint(); // the point that was clicked MBlock b = (MBlock) getParent(); // get parent block MCanvas c = (MCanvas) b.getParent(); // get canvas int newX = getX() + b.getX() + pt.x; // transform to canvas coords int newY = getY() + b.getY() + pt.y; // transform to canvas coords // create a new mouse event... MouseEvent transformed = new MouseEvent(c, MouseEvent.MOUSE_CLICKED, me.getWhen(), 0, newX, newY, me.getClickCount(), false, me.getButton()); // ... and pass it to the canvas c.dispatchEvent(transformed); } public void mouseEntered(MouseEvent me) { repaint(); } public void mouseExited(MouseEvent me) { } public void mousePressed(MouseEvent me) { if (me.isPopupTrigger()) { // show context menu } else { /* Pass to block */ Point pt = me.getPoint(); // the point that was clicked MBlock b = (MBlock) getParent(); // get parent block MCanvas c = (MCanvas) b.getParent(); // get canvas int newX = getX() + b.getX() + pt.x; // transform to canvas coords int newY = getY() + b.getY() + pt.y; // transform to canvas coords // create a new mouse event... MouseEvent transformed = new MouseEvent(c, MouseEvent.MOUSE_PRESSED, me.getWhen(), 0, newX, newY, me.getClickCount(), false, me.getButton()); // ... and pass it to the canvas c.dispatchEvent(transformed); } } public void mouseReleased(MouseEvent me) { /* Pass to canvas */ Point pt = me.getPoint(); // the point that was clicked MBlock b = (MBlock) getParent(); // get parent block MCanvas c = (MCanvas) b.getParent(); // get canvas int newX = getX() + b.getX() + pt.x; // transform to canvas coords int newY = getY() + b.getY() + pt.y; // transform to canvas coords // create a new mouse event... MouseEvent transformed = new MouseEvent(c, MouseEvent.MOUSE_RELEASED, me.getWhen(), 0, newX, newY, me.getClickCount(), false, me.getButton()); // ... and pass it to the canvas c.dispatchEvent(transformed); } public void mouseDragged(MouseEvent me) { // pass this through to canvas underneath Point pt = me.getPoint(); MBlock b = (MBlock) getParent(); // get parent block MCanvas c = (MCanvas) b.getParent(); // get canvas int newX = b.getX() + getX() + pt.x; // transform to block coords int newY = b.getY() + getY() + pt.y; // transform to block coords // create a new mouse event... MouseEvent transformed = new MouseEvent(c, MouseEvent.MOUSE_DRAGGED, me.getWhen(), 0, newX, newY, me.getClickCount(), false, me.getButton()); // ... and pass it to the canvas c.dispatchEvent(transformed); } public void mouseMoved(MouseEvent me) { // pass this through to canvas underneath Point pt = me.getPoint(); MBlock b = (MBlock) getParent(); // get parent block MCanvas c = (MCanvas) b.getParent(); // get canvas int newX = b.getX() + getX() + pt.x; // transform to block coords int newY = b.getY() + getY() + pt.y; // transform to block coords // create a new mouse event... MouseEvent transformed = new MouseEvent(c, MouseEvent.MOUSE_MOVED, me.getWhen(), 0, newX, newY, me.getClickCount(), false, me.getButton()); // ... and pass it to the canvas c.dispatchEvent(transformed); } } }