updated move action (uses move cursor)
This commit is contained in:
parent
323186791d
commit
2edf36f4cf
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: Visualizer2D.java,v 1.1 2006/08/21 12:13:08 fros4943 Exp $
|
* $Id: Visualizer2D.java,v 1.2 2006/09/07 09:54:37 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.plugins;
|
package se.sics.cooja.plugins;
|
||||||
|
@ -76,6 +76,7 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
|
|
||||||
private boolean moteIsBeingMoved = false;
|
private boolean moteIsBeingMoved = false;
|
||||||
private Mote moteToMove = null;
|
private Mote moteToMove = null;
|
||||||
|
private Cursor moveCursor = new Cursor(Cursor.MOVE_CURSOR);
|
||||||
|
|
||||||
private Observer simObserver = null; // Watches simulation changes
|
private Observer simObserver = null; // Watches simulation changes
|
||||||
private Observer posObserver = null; // Watches position changes
|
private Observer posObserver = null; // Watches position changes
|
||||||
|
@ -289,6 +290,7 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
private void beginMoveRequest(Mote moteToMove) {
|
private void beginMoveRequest(Mote moteToMove) {
|
||||||
moteIsBeingMoved = true;
|
moteIsBeingMoved = true;
|
||||||
this.moteToMove = moteToMove;
|
this.moteToMove = moteToMove;
|
||||||
|
canvas.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleMoveRequest(final int x, final int y,
|
private void handleMoveRequest(final int x, final int y,
|
||||||
|
@ -298,14 +300,13 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wasJustReleased) {
|
if (!wasJustReleased) {
|
||||||
visualizeSimulation(canvas.getGraphics());
|
// Still moving mote
|
||||||
canvas.paintImmediately(x - 40, y - 40, 80, 80);
|
canvas.setCursor(moveCursor);
|
||||||
canvas.getGraphics().setColor(Color.GRAY);
|
return;
|
||||||
canvas.getGraphics().drawOval(x - MOTE_RADIUS, y - MOTE_RADIUS,
|
|
||||||
2 * MOTE_RADIUS, 2 * MOTE_RADIUS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasJustReleased) {
|
// Stopped moving mote
|
||||||
|
canvas.setCursor(Cursor.getDefaultCursor());
|
||||||
moteIsBeingMoved = false;
|
moteIsBeingMoved = false;
|
||||||
|
|
||||||
Position newXYValues = transformPixelToPositon(new Point(x, y));
|
Position newXYValues = transformPixelToPositon(new Point(x, y));
|
||||||
|
@ -318,9 +319,9 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
moteToMove.getInterfaces().getPosition().setCoordinates(
|
moteToMove.getInterfaces().getPosition().setCoordinates(
|
||||||
newXYValues.getXCoordinate(), newXYValues.getYCoordinate(),
|
newXYValues.getXCoordinate(), newXYValues.getYCoordinate(),
|
||||||
moteToMove.getInterfaces().getPosition().getZCoordinate());
|
moteToMove.getInterfaces().getPosition().getZCoordinate());
|
||||||
|
}
|
||||||
|
moteToMove = null;
|
||||||
repaint();
|
repaint();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,22 +391,26 @@ public abstract class Visualizer2D extends VisPlugin {
|
||||||
int x = pixelCoord.x;
|
int x = pixelCoord.x;
|
||||||
int y = pixelCoord.y;
|
int y = pixelCoord.y;
|
||||||
|
|
||||||
if (moteColors.length >= 1) {
|
if (mote == moteToMove) {
|
||||||
|
// Don't fill mote
|
||||||
|
} else if (moteColors.length >= 2) {
|
||||||
|
g.setColor(moteColors[0]);
|
||||||
|
g.fillOval(x - MOTE_RADIUS, y - MOTE_RADIUS, 2 * MOTE_RADIUS,
|
||||||
|
2 * MOTE_RADIUS);
|
||||||
|
|
||||||
|
g.setColor(moteColors[1]);
|
||||||
|
g.fillOval(x - MOTE_RADIUS / 2, y - MOTE_RADIUS / 2, MOTE_RADIUS,
|
||||||
|
MOTE_RADIUS);
|
||||||
|
|
||||||
|
} else if (moteColors.length >= 1) {
|
||||||
g.setColor(moteColors[0]);
|
g.setColor(moteColors[0]);
|
||||||
g.fillOval(x - MOTE_RADIUS, y - MOTE_RADIUS, 2 * MOTE_RADIUS,
|
g.fillOval(x - MOTE_RADIUS, y - MOTE_RADIUS, 2 * MOTE_RADIUS,
|
||||||
2 * MOTE_RADIUS);
|
2 * MOTE_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moteColors.length >= 2) {
|
|
||||||
g.setColor(moteColors[1]);
|
|
||||||
g.fillOval(x - MOTE_RADIUS / 2, y - MOTE_RADIUS / 2, MOTE_RADIUS,
|
|
||||||
MOTE_RADIUS);
|
|
||||||
}
|
|
||||||
|
|
||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
g.drawOval(x - MOTE_RADIUS, y - MOTE_RADIUS, 2 * MOTE_RADIUS,
|
g.drawOval(x - MOTE_RADIUS, y - MOTE_RADIUS, 2 * MOTE_RADIUS,
|
||||||
2 * MOTE_RADIUS);
|
2 * MOTE_RADIUS);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue