Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
0e7029a6
Commit
0e7029a6
authored
Sep 13, 2016
by
Nils Richerzhagen
Browse files
Update mouse listener
parent
c1761134
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/topology/views/VisualizationTopologyView.java
View file @
0e7029a6
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment