Commit a37f4e8d authored by Leigh B. Stoller's avatar Leigh B. Stoller

Fix a few input bugs that might have been causing crashes. Also remove a

bunch of "static" declarations cause they were wrong to use in the first
place (now that I understand what static means in a class definition).
parent 5d74fed7
...@@ -25,12 +25,12 @@ import java.text.DecimalFormat; ...@@ -25,12 +25,12 @@ import java.text.DecimalFormat;
* Draw the floormap and put little dots on it. * Draw the floormap and put little dots on it.
*/ */
public class RoboTrack extends JApplet { public class RoboTrack extends JApplet {
static Map map; Map map;
static JTable maptable; JTable maptable;
static JPopupMenu MenuPopup; JPopupMenu MenuPopup;
static JMenuItem CancelMenuItem, SubmitMenuItem; JMenuItem CancelMenuItem, SubmitMenuItem;
static Image floorimage; Image floorimage;
static double pixels_per_meter = 1.0; double pixels_per_meter = 1.0;
boolean frozen = false; boolean frozen = false;
static final DecimalFormat FORMATTER = new DecimalFormat("0.00"); static final DecimalFormat FORMATTER = new DecimalFormat("0.00");
String uid, auth; String uid, auth;
...@@ -40,7 +40,7 @@ public class RoboTrack extends JApplet { ...@@ -40,7 +40,7 @@ public class RoboTrack extends JApplet {
* The connection to boss that will provide robot location info. * The connection to boss that will provide robot location info.
* When run interactively (from main) it is set to stdin (see below). * When run interactively (from main) it is set to stdin (see below).
*/ */
static InputStream is; InputStream is;
public void init() { public void init() {
try try
...@@ -124,14 +124,17 @@ public class RoboTrack extends JApplet { ...@@ -124,14 +124,17 @@ public class RoboTrack extends JApplet {
* Create the popup menu that will be used to fire off * Create the popup menu that will be used to fire off
* robot moves. We use the mouseadaptor for this too. * robot moves. We use the mouseadaptor for this too.
*/ */
MenuPopup = new JPopupMenu("dd"); MenuPopup = new JPopupMenu("Tracker");
JMenuItem menuitem = new JMenuItem(" Motion Menu ");
menuitem.addActionListener(mymouser);
MenuPopup.add(menuitem);
SubmitMenuItem = new JMenuItem("Submit All Moves"); SubmitMenuItem = new JMenuItem("Submit All Moves");
SubmitMenuItem.addActionListener(mymouser); SubmitMenuItem.addActionListener(mymouser);
MenuPopup.add(SubmitMenuItem); MenuPopup.add(SubmitMenuItem);
CancelMenuItem = new JMenuItem("Cancel All Moves"); CancelMenuItem = new JMenuItem("Cancel All Moves");
CancelMenuItem.addActionListener(mymouser); CancelMenuItem.addActionListener(mymouser);
MenuPopup.add(CancelMenuItem); MenuPopup.add(CancelMenuItem);
JMenuItem menuitem = new JMenuItem("Close This Menu"); menuitem = new JMenuItem("Close This Menu");
menuitem.addActionListener(mymouser); menuitem.addActionListener(mymouser);
MenuPopup.add(menuitem); MenuPopup.add(menuitem);
MenuPopup.setBorder(BorderFactory.createLineBorder(Color.black)); MenuPopup.setBorder(BorderFactory.createLineBorder(Color.black));
...@@ -161,7 +164,7 @@ public class RoboTrack extends JApplet { ...@@ -161,7 +164,7 @@ public class RoboTrack extends JApplet {
/* /*
* A container for coordinate information. * A container for coordinate information.
*/ */
static class Robot { private class Robot {
int x, y; // Current x,y coords in pixels int x, y; // Current x,y coords in pixels
double z; // Current z in meters double z; // Current z in meters
double or = 500.0; // Current orientation double or = 500.0; // Current orientation
...@@ -195,12 +198,12 @@ public class RoboTrack extends JApplet { ...@@ -195,12 +198,12 @@ public class RoboTrack extends JApplet {
int index; int index;
} }
// Indexed by the robot physical name, points Robot struct above. // Indexed by the robot physical name, points Robot struct above.
static Dictionary robots = new Hashtable(); Dictionary robots = new Hashtable();
// Map from integer index to a Robot struct. // Map from integer index to a Robot struct.
static Vector robotmap = new Vector(10, 10);; Vector robotmap = new Vector(10, 10);;
static int robotcount = 0; int robotcount = 0;
static class Map extends JPanel implements Runnable { private class Map extends JPanel implements Runnable {
private Thread thread; private Thread thread;
private BufferedImage bimg; private BufferedImage bimg;
private Graphics2D G2 = null; private Graphics2D G2 = null;
...@@ -376,9 +379,9 @@ public class RoboTrack extends JApplet { ...@@ -376,9 +379,9 @@ public class RoboTrack extends JApplet {
* Draw a robot, which is either the real one, a destination one, * Draw a robot, which is either the real one, a destination one,
* or a shadow one being dragged around. * or a shadow one being dragged around.
*/ */
static int DRAWROBOT_LOC = 1; private int DRAWROBOT_LOC = 1;
static int DRAWROBOT_DST = 2; private int DRAWROBOT_DST = 2;
static int DRAWROBOT_DRAG = 3; private int DRAWROBOT_DRAG = 3;
public void drawRobot(Graphics2D g2, public void drawRobot(Graphics2D g2,
int x, int y, double or, int x, int y, double or,
...@@ -683,7 +686,20 @@ public class RoboTrack extends JApplet { ...@@ -683,7 +686,20 @@ public class RoboTrack extends JApplet {
if ((robbie.dragging && (col >= 6 && col <= 8)) || if ((robbie.dragging && (col >= 6 && col <= 8)) ||
(!robbie.gotdest && col == 8)) { (!robbie.gotdest && col == 8)) {
String stmp = value.toString().trim(); String stmp = value.toString().trim();
double dtmp = Double.parseDouble(stmp); double dtmp;
if (stmp.length() == 0)
return;
try
{
dtmp = Double.parseDouble(stmp);
}
catch(Throwable th)
{
// Must not be a float.
return;
}
switch (col) { switch (col) {
case 6: case 6:
...@@ -771,7 +787,7 @@ public class RoboTrack extends JApplet { ...@@ -771,7 +787,7 @@ public class RoboTrack extends JApplet {
* orientation. * orientation.
*/ */
if (!robbie.dragging) { if (!robbie.dragging) {
robbie.drag_or = robbie.dor; robbie.drag_or = robbie.or;
// For the table. // For the table.
robbie.dragor_string = robbie.or_string; robbie.dragor_string = robbie.or_string;
} }
......
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