Commit 0e7029a6 authored by Nils Richerzhagen's avatar Nils Richerzhagen
Browse files

Update mouse listener

parent c1761134
......@@ -428,11 +428,17 @@ public class VisualizationTopologyView extends JFrame
private void paintNodes(Graphics2D g2) {
for (NodeInformation node : nodeInformation.values()) {
// TODO FIXME add way to provide draw() impl for nodes
if (node.clicked) {
g2.setColor(Color.MAGENTA);
g2.fillOval((int) node.position.getX() - PADDING,
(int) node.position.getY() - PADDING,
PADDING * 2 + 1, PADDING * 2 + 1);
} else {
g2.setColor(Color.BLACK);
g2.fillOval((int) node.position.getX() - PADDING,
(int) node.position.getY() - PADDING,
PADDING * 2 + 1, PADDING * 2 + 1);
}
}
}
......@@ -566,7 +572,10 @@ public class VisualizationTopologyView extends JFrame
public void eventDispatched(AWTEvent e) {
if (e instanceof MouseEvent) {
MouseEvent me = (MouseEvent) e;
if (me.getID() == MouseEvent.MOUSE_CLICKED) {
if (me.getID() == MouseEvent.MOUSE_CLICKED
|| me.getID() == MouseEvent.MOUSE_DRAGGED
|| me.getID() == MouseEvent.MOUSE_PRESSED
|| me.getID() == MouseEvent.MOUSE_RELEASED) {
// Another dirty hack until we have another graphic
// drawing system
if (((JFrame) worldPanel.getTopLevelAncestor())
......@@ -591,7 +600,32 @@ public class VisualizationTopologyView extends JFrame
.getY();
for (MouseClickListener l : mouseListeners) {
l.mouseClicked(x, y);
if (me.getID() == MouseEvent.MOUSE_CLICKED) {
l.mouseClicked(x, y);
} else {
if (l instanceof MouseListener) {
switch (me.getID()) {
case MouseEvent.MOUSE_DRAGGED:
((MouseListener) l)
.mouseDragged(x, y);
break;
case MouseEvent.MOUSE_PRESSED:
((MouseListener) l)
.mousePressed(x, y);
break;
case MouseEvent.MOUSE_RELEASED:
((MouseListener) l)
.mouseReleased(x,
y);
break;
default:
break;
}
}
}
}
}
......@@ -606,6 +640,14 @@ public class VisualizationTopologyView extends JFrame
public void mouseClicked(int x, int y);
}
public static interface MouseListener extends MouseClickListener {
public void mouseDragged(int x, int y);
public void mousePressed(int x, int y);
public void mouseReleased(int x, int y);
}
public static JComponent getWorldPanel() {
return worldPanel;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment