/* * ZazaMap * * Copyright (C) 2001-2003 Brian Rudy (brudyNO@SPAMpraecogito.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * ** Info ** * Authored in NetBeans 3.4.1 IDE * * Grab images of current map, and robot. Scale to * dimensions of the applet panel. Get setup info * from position server CGI (goal points). Get * robot's position and orientation from the position * server and draw (client-pull). Scale all graphics based * on zoomlevel. * * Todo- Update frequency parameter loading, exception handling!, * server-side status reports, client-side controls? * * ** Revision History ** * 0.72 10-31-2003 * Added initial support for showmap and auto-startup/shutdown. * * 0.71 3-13-2003 * Re-inserted missing tooltips, enabled iconlabel double-buffering. * * 0.70 3-8-2003 * Major code overhaul. Full Netbeans Form Editor support (yea!). The * scroll bars are now enabled in tracking mode and will no longer kill * the applet if an auto-track event occurs while scrolling. Fixed * 'background' auto-tracking graphic bug. Performance improvements with * background threaded position updating. Added magnifying glass icon to * zoom buttons for improved intelligibility. * * 0.62 5-25-2002 * Performance improvements. Added DRAWPOS option switch for applet mode. * * 0.61 3-15-2002 * Fixed bug preventing screen redraws on image update. * * 0.60 1-13-2002 * Much needed code cleanup of map rendering routines. Proper threading of * image downloads. * * 0.52 11-2-2001 * Minor UI tweaks. Still needs some work. * * 0.51 9-16-2001 * Tracking-related bug seems to have dissapeared after adding some semaphores * during screen redraws after changing zoom level. A minor bug during * auto-tracking leaves remnants of the last screen around the borders of the * animationPane after a zoom level change. * * 0.50 9-14-2001 * Added work-arounds for buffer overflow when tracking and user attempts to * scroll (remove scroll bars when tracking, should fix this), and when * changing zoom level (tracking temporarily disabled during resize). * Still has a bug related to auto-tracking. * * 0.49 9-13-2001 * Scrollbars now fully functional. Toolbar graphics enhancements. * Zoom level now fully functional. Added robot auto-tracking via Track button. * * 0.48 9-12-2001 * Basic scrollbar functionality. Updated button logic on toolbar. * Basic zoom level support (needs work). * * 0.47 8-23-2001 * Added toolbar with start/stop for position retrieval * and stubs for magnification level. Added stubs for scrollable window. * * 0.46 8-15-2001 * Added basic goal point voting. * * 0.45 8-2-2001 * Added basic target info window spawning. * * 0.44 7-31-2001 * Added stub for goal point selection. * * 0.43 7-30-2001 * Added basic goal plotting and labeling (currently disabled * for clarity). Fixed goal point parsing and array population. * Added getPos support. * * 0.42 7-28-2001 * Fixed exception handling in NetIO routines. Extended parsing. * Fixed robotImage scaling. * * 0.41 7-27-2001 * Added basic setup data retrieval and preliminary parsing. * * 0.4 7-25-2001 * Added basic NetIO framework * * 0.3 7-23-2001 * Basic image rendering using Java2D extensions for * image manipulation (rotation) * * Known Bugs- Java2D imagebuffer data not transparent when * pasted into 'g' canvas. Robot image has square borders * as a result */ import java.awt.Color; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; public class ZazaMap2 extends javax.swing.JApplet implements java.awt.event.ActionListener { /** Creates new form zazamap3 */ public ZazaMap2() { int delay = 3000; initComponents(); //b2.setBackground(Color.green); //Set up a timer that calls this object's action handler. timer = new javax.swing.Timer(delay, this); timer.setInitialDelay(0); timer.setCoalesce(true); if (!timer.isRunning()) { System.out.println("Starting timer..."); timer.start(); } } //Invoked only when run as an applet. public void init() { asApplet = true; //Get the images. bgImage = getMapImage(getParameter("MAPIMAGE")); fgImage = getMapImage(getParameter("ROBOTIMAGE")); if (getParameter("DRAWPOS").equalsIgnoreCase("yes")) { drawpos = true; } else { drawpos = false; } setup(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents jToolBar1 = new javax.swing.JToolBar(); iconlabel = new javax.swing.JLabel(); b1 = new javax.swing.JButton(); b5 = new javax.swing.JButton(); jSeparator1 = new javax.swing.JSeparator(); b2 = new javax.swing.JButton(); b3 = new javax.swing.JButton(); b4 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); mapCanvas = new javax.swing.JLabel(); jToolBar1.setBackground(new java.awt.Color(0, 0, 0)); jToolBar1.setForeground(new java.awt.Color(255, 255, 255)); iconlabel.setIcon(new javax.swing.JLabel() { public javax.swing.Icon getIcon() { try { return new javax.swing.ImageIcon( new java.net.URL("http://zazaconsole.exhibits.thetech.org/~brudy/zaza/java/images/map-title.jpg") ); } catch (java.net.MalformedURLException e) { } return null; } }.getIcon()); jToolBar1.add(iconlabel); b1.setBackground(java.awt.Color.green); b1.setText("Pos"); b1.setToolTipText("Download position information"); b1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { Pos_clicked(evt); } }); jToolBar1.add(b1); b5.setText("Track"); b5.setToolTipText("Automatically track the robot's position on the map"); b5.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { Track_clicked(evt); } }); jToolBar1.add(b5); jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL); jToolBar1.add(jSeparator1); b2.setBackground(java.awt.Color.green); b2.setIcon(new javax.swing.JLabel() { public javax.swing.Icon getIcon() { try { return new javax.swing.ImageIcon( new java.net.URL("http://zazaconsole.exhibits.thetech.org/~brudy/zaza/java/images/mag.gif") ); } catch (java.net.MalformedURLException e) { } return null; } }.getIcon()); b2.setText("1x"); b2.setToolTipText("Zoom 1x"); b2.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { OneX_clicked(evt); } }); jToolBar1.add(b2); b3.setText("2x"); b3.setToolTipText("Zoom 2x"); b3.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { TwoX_clicked(evt); } }); jToolBar1.add(b3); b4.setText("5x"); b4.setToolTipText("Zoom 5x"); b4.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { FiveX_clicked(evt); } }); jToolBar1.add(b4); getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH); mapCanvas.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); mapCanvas.setToolTipText("Click on a blue circle if you would like to visit this exhibit"); mapCanvas.setVerticalAlignment(javax.swing.SwingConstants.TOP); mapCanvas.setDoubleBuffered(true); mapCanvas.setMaximumSize(new java.awt.Dimension(395, 95)); mapCanvas.setMinimumSize(new java.awt.Dimension(395, 95)); mapCanvas.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { MapCanvas_clicked(evt); } }); jScrollPane1.setViewportView(mapCanvas); getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER); }//GEN-END:initComponents private void MapCanvas_clicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_MapCanvas_clicked boolean clickedOnGoal = goalClick(evt.getX(), evt.getY(), goalSize); // on mouseUp event over goal, do something if (clickedOnGoal) { System.out.println("You selected goal number " + String.valueOf(goalSelected) + " which is " + goals[goalSelected][2]); // Cast your vote sendGoal(goalSelected); if (asApplet) { try { URL infoURL = new URL(goals[goalSelected][3]); getAppletContext().showDocument(infoURL, "infowindow"); } catch (MalformedURLException er) { } catch (IOException er) {} } } else { System.out.println("You clicked X=" + String.valueOf(evt.getX()) + ", Y=" + String.valueOf(evt.getY()) + " but there is nothing here."); } }//GEN-LAST:event_MapCanvas_clicked private void Track_clicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Track_clicked if (trackEnabled) { b5.setBackground(Color.lightGray); trackEnabled = false; } else { b5.setBackground(Color.green); trackEnabled = true; } }//GEN-LAST:event_Track_clicked private void Pos_clicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Pos_clicked if (posEnabled) { b1.setBackground(Color.lightGray); posEnabled = false; } else { b1.setBackground(Color.green); posEnabled = true; } }//GEN-LAST:event_Pos_clicked private void FiveX_clicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_FiveX_clicked b4.setBackground(Color.green); b2.setSelected(false); b2.setBackground(Color.lightGray); b3.setSelected(false); b3.setBackground(Color.lightGray); zoomlevel = 5; updateMap(); }//GEN-LAST:event_FiveX_clicked private void TwoX_clicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TwoX_clicked b3.setBackground(Color.green); b2.setSelected(false); b2.setBackground(Color.lightGray); b4.setSelected(false); b4.setBackground(Color.lightGray); zoomlevel = 2; updateMap(); }//GEN-LAST:event_TwoX_clicked private void OneX_clicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_OneX_clicked b2.setBackground(Color.green); b3.setSelected(false); b3.setBackground(Color.lightGray); b4.setSelected(false); b4.setBackground(Color.lightGray); zoomlevel = 1; updateMap(); }//GEN-LAST:event_OneX_clicked //Invoked by a browser only. public void start() { //Start animating! if (!timer.isRunning()) { timer.start(); } } //Invoked by a browser only. public void stop() { //Stop the animating thread. if (timer.isRunning()) { timer.stop(); } } public boolean goalClick(int xposition, int yposition, int diameter) { if (isInitialized){ for(int i = 0; i < numGoals; i++){ if (((Integer.valueOf(goals[i][0]).intValue()*zoomlevel)-goalSize/2 <= xposition) && (((Integer.valueOf(goals[i][0]).intValue()*zoomlevel)-goalSize/2)+diameter >= xposition)){ if (((Integer.valueOf(goals[i][1]).intValue()*zoomlevel)-goalSize/2 <= yposition) && (((Integer.valueOf(goals[i][1]).intValue()*zoomlevel)-goalSize/2)+diameter >= yposition)){ goalSelected = i; return true; } } } } return false; } // Send goal vote (server-side tally/arbitration) public void sendGoal(int goalNum) { try { System.out.println("Sending goal number " + String.valueOf(goalNum)); String posReqStr = posServer + "?sendgoal=" + String.valueOf(goalNum); URL url = new URL(posReqStr); java.net.URLConnection connection = url.openConnection(); BufferedReader in = new BufferedReader( new java.io.InputStreamReader( connection.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) { // print it to the console // Gotta parse this somehow System.out.println("Goal request reply: " + inputLine); } in.close(); } catch (MalformedURLException e) { } catch (IOException e) { } } // Get setup info from posServer (goals) public void setup() { try { System.out.println("Getting setup info..."); String SetupStr= posServer + "?setup=yes"; System.out.println("I am getting " + SetupStr); URL url = new URL(SetupStr); java.net.URLConnection connection = url.openConnection(); BufferedReader in = new BufferedReader( new java.io.InputStreamReader( connection.getInputStream())); String inputLine; java.util.StringTokenizer dataIn; String delimiter = ","; int tokenIndex; int index = 0; while ((inputLine = in.readLine()) != null) { tokenIndex = 0; // print it to the console System.out.println("Setup data: " + inputLine); // Parse with stringTokenizer dataIn = new java.util.StringTokenizer(inputLine, delimiter, true); goals[index] = new String[4]; //create sub-array // For goal parsing. Add x,y,name to goal array // x goals[index][0] = dataIn.nextToken(); // delimiter dataIn.nextToken(); // y goals[index][1] = dataIn.nextToken(); // delimiter dataIn.nextToken(); // name goals[index][2] = dataIn.nextToken(); // delimiter dataIn.nextToken(); // URL goals[index][3] = dataIn.nextToken(); // EOL delimiters dataIn.nextToken(); dataIn.nextToken(); index++; } numGoals = index; in.close(); isInitialized = true; } catch (MalformedURLException e) { } catch (IOException e) { } } // This is called when the timer expires public void actionPerformed(java.awt.event.ActionEvent e) { if (tGetPos.activeCount() > 3) { System.out.println("tGetPos thread is still running, skipping update. " + tGetPos.activeCount() + " threads running"); } else { if (posEnabled) { //tGetPos = new Thread() { // public void run() { if ((isInitialized) && (fgImage != null) && (bgImage != null)) { getPos(); updateMap(); } else { System.out.println("Images not ready, skipping..."); } // } //}; //tGetPos.start(); if (StatusLoopCounter >= 10) { StatusLoopCounter = 0; if (getStatus() < 4) { // Robot is not running in Phase IV mode System.out.println("The robot isn't running!"); if (asApplet) { try { URL getappletURL = new URL(Server + "/cgi-bin/showmap"); getAppletContext().showDocument(getappletURL, "map"); } catch (MalformedURLException er) { } catch (IOException er) {} } else { System.out.println("The robot isn't running now, so this is going to be really boring..."); } } else { System.out.println("The robot is running."); } } else { StatusLoopCounter++; } } else { boolean threadstat = tGetPos.isAlive(); System.out.println("tGetPos=" + threadstat); } } } public void updateMap() { mapCanvas.setIcon(new javax.swing.ImageIcon(drawMap())); //tGetPos = null; } // Get position info (x,y,theta) public int getStatus() { try { System.out.println("Getting status info..."); String statReqStr= posServer + "?getstatus=yes"; URL StatRequrl = new URL(statReqStr); java.net.URLConnection Statconnection = StatRequrl.openConnection(); BufferedReader in = new BufferedReader( new java.io.InputStreamReader(Statconnection.getInputStream())); String inputLine; java.util.StringTokenizer dataIn; String delimiter = ","; int StatusMode = 0; while ((inputLine = in.readLine()) != null) { // print it to the console System.out.println("Status data: " + inputLine); // Parse with stringTokenizer dataIn = new java.util.StringTokenizer(inputLine, delimiter, true); // Status mode StatusMode = Integer.valueOf(dataIn.nextToken()).intValue(); System.out.println("Mode=" + StatusMode); // delimiter dataIn.nextToken(); // Movement status, not yet used, but needed to prevent // IO Exceptions in buggy readline routine. String movestat = dataIn.nextToken(); // EOL delimiters //dataIn.nextToken(); //dataIn.nextToken(); } in.close(); return StatusMode; } catch (MalformedURLException e) { } catch (IOException e) { System.out.println("There was an IO Exception in getStatus!"); } return 0; } // Get position info (x,y,theta) public void getPos() { try { System.out.println("Getting position info..."); String posReqStr= posServer + "?getpos=yes"; URL url = new URL(posReqStr); java.net.URLConnection connection = url.openConnection(); BufferedReader in = new BufferedReader( new java.io.InputStreamReader( connection.getInputStream())); String inputLine; java.util.StringTokenizer dataIn; String delimiter = ","; while ((inputLine = in.readLine()) != null) { // print it to the console //System.out.println("Position data: " + inputLine); // Parse with stringTokenizer dataIn = new java.util.StringTokenizer(inputLine, delimiter, true); // x PosX = Integer.valueOf(dataIn.nextToken()).intValue(); // delimiter dataIn.nextToken(); // y PosY = Integer.valueOf(dataIn.nextToken()).intValue(); // delimiter dataIn.nextToken(); // name PosTheta = Integer.valueOf(dataIn.nextToken()).intValue(); // EOL delimiters dataIn.nextToken(); dataIn.nextToken(); } in.close(); //System.out.println("Current position x=" + String.valueOf(PosX) + ", y=" + String.valueOf(PosY) + ", theta=" + String.valueOf(PosTheta)); } catch (MalformedURLException e) { } catch (IOException e) { } } public java.awt.Image getMapImage(String name) { //java.awt.Image img = getImage(getCodeBase(), name); try { //if (asApplet) { // name = getCodeBase() + name; //} System.out.println("Getting " + name); URL imURL = new URL(name); java.awt.Image img = java.awt.Toolkit.getDefaultToolkit().createImage(imURL); try { java.awt.MediaTracker tracker = new java.awt.MediaTracker(this); tracker.addImage(img, 0); tracker.waitForID(0); return img; } catch (Exception e) {} } catch (MalformedURLException er) { } catch (IOException er) {} return null; } public Graphics2D createGraphics2D(int w, int h) { Graphics2D g2 = null; if (bimg == null || bimg.getWidth() != w || bimg.getHeight() != h) { bimg = (BufferedImage) createImage(w, h); System.out.print("Resizing canvas.\n"); retrack = true; } else { retrack = false; } g2 = bimg.createGraphics(); //g2.setBackground(getBackground()); //g2.setBackground(java.awt.Color.white); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //g2.clearRect(0, 0, w, h); return g2; } public BufferedImage drawMap() { if ((bgImage != null) && (fgImage != null)) { int bgWidth = bgImage.getWidth(this) * zoomlevel; int bgHeight = bgImage.getHeight(this) * zoomlevel; if ((bgWidth > 0) && (bgHeight > 0)) { int fgWidth = 5*zoomlevel; int fgHeight = 5*zoomlevel; Graphics2D g2 = createGraphics2D(bgWidth, bgHeight); //g2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, // java.awt.RenderingHints.VALUE_ANTIALIAS_ON); BufferedImage canvasImage = new BufferedImage(bgWidth, bgHeight, BufferedImage.TYPE_INT_RGB); Graphics2D biContextcanvasImage = canvasImage.createGraphics(); biContextcanvasImage.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON); biContextcanvasImage.clearRect(0,0,bgWidth,bgHeight); int imageWidth, imageHeight; //int fgHeight = foreground.getHeight(this); //int fgHeight = 20; Color goalColor = Color.blue; Color posColor = Color.red; Color goalTextColor = Color.orange; BufferedImage bimgrob = (BufferedImage) createImage(fgWidth, fgHeight); Graphics2D grob = bimgrob.createGraphics(); grob.setBackground(Color.white); // This just chews up extra CPU cycles grob.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON); //grob.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // RenderingHints.VALUE_ANTIALIAS_OFF); grob.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); //If we have a valid width and height for the //background image, draw it. if ((bgWidth > 0) && (bgHeight > 0)) { //g2.drawImage(bgImage.getScaledInstance(bgWidth,bgHeight,java.awt.Image.SCALE_AREA_AVERAGING),0,0,bgWidth,bgHeight,this); g2.drawImage(bgImage,0,0,bgWidth,bgHeight,this); } // Draw in goal points if (isInitialized) { for (int i = 0; i < numGoals; i++) { int goalx = Integer.valueOf(goals[i][0]).intValue(); int goaly = Integer.valueOf(goals[i][1]).intValue(); g2.setColor(goalColor); g2.fillOval((goalx*zoomlevel) - goalSize/2, (goaly*zoomlevel) - goalSize/2, goalSize, goalSize); // This works, but clutters the canvas g2.setColor(goalTextColor); g2.drawString(goals[i][2], goalx*zoomlevel, (goaly*zoomlevel)-4); } } //If we have a valid width and height for the //foreground image, draw it. imageWidth = fgWidth; imageHeight = fgWidth; if ((imageWidth > 0) && (imageHeight > 0)) { grob.clearRect(0, 0, bimgrob.getWidth(this), bimgrob.getHeight(this)); grob.setBackground(getBackground()); grob.rotate(Math.toRadians(-PosTheta), bimgrob.getWidth(this)/2, bimgrob.getHeight(this)/2); grob.translate(bimgrob.getWidth(this)/2-imageWidth/2,bimgrob.getHeight(this)/2-imageHeight/2); grob.drawImage(fgImage,0,0,imageWidth,imageHeight,this); grob.dispose(); g2.drawImage(bimgrob, (PosX*zoomlevel) - imageWidth/2, (bgHeight-(PosY*zoomlevel)) - imageHeight/2,imageWidth,imageHeight, this); //System.out.println("Drawing robot at " + ((PosX*zoomlevel) - imageWidth/2) + "," + ((bgHeight-(PosY*zoomlevel)) - imageHeight/2)); // Don't scroll unless we need to if (trackEnabled) { int animx = jScrollPane1.getWidth(); int animy = jScrollPane1.getHeight(); int winstartx = (PosX*zoomlevel) - animx/2; if (winstartx < 0) { winstartx = 0; } int winstarty = bgHeight - (PosY*zoomlevel) - animy/2; if (winstarty < 0) { winstarty = 0; } mapCanvas.scrollRectToVisible(new java.awt.Rectangle(winstartx, winstarty, animx-20, animy-20)); //System.out.println("startx=" + winstartx + ", xwidth=" + animx); //System.out.println("starty=" + winstarty + ", ywidth=" + animy); // robot position text if (drawpos) { g2.setColor(posColor); g2.drawString("Theta\t=" + String.valueOf(PosTheta), winstartx+3, winstarty+animy-20); g2.drawString("Robot\tx=" + String.valueOf(PosX), winstartx+3, winstarty+animy-30); g2.drawString("Robot\ty=" + String.valueOf(PosY), winstartx+3, winstarty+animy-40); } lastPosX = PosX; lastPosY = PosY; } else { //robot position text if (drawpos) { g2.setColor(posColor); g2.drawString("Theta =" + String.valueOf(PosTheta), 2, bgHeight-4); g2.drawString("Robot x=" + String.valueOf(PosX), 2, bgHeight-14); g2.drawString("Robot y=" + String.valueOf(PosY), 2, bgHeight-24); } } } canvasImage = bimg; g2.dispose(); return canvasImage; } else { System.out.println("bgWidth/bgHeight are invalid!"); return null; } } else { System.out.println("Images are not yet loaded!"); return null; } } public static void main(java.lang.String[] args) { try { URL bgURL = new URL(ZazaMap2.bgFile); URL fgURL = new URL(ZazaMap2.fgFile); bgImage = java.awt.Toolkit.getDefaultToolkit().getImage(bgURL); fgImage = java.awt.Toolkit.getDefaultToolkit().getImage(fgURL); } catch (MalformedURLException e) { } catch (IOException e) { } javax.swing.JFrame f = new javax.swing.JFrame("ZazaMap2"); final ZazaMap2 controller = new ZazaMap2(); f.getContentPane().add(controller); controller.initComponents(); f.addWindowListener(new java.awt.event.WindowAdapter() { public void windowIconified(java.awt.event.WindowEvent e) { controller.timer.stop(); } public void windowDeiconified(java.awt.event.WindowEvent e) { controller.timer.start(); } public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); f.setSize(new java.awt.Dimension(340, 340)); f.setVisible(true); controller.setup(); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane1; private javax.swing.JButton b5; private javax.swing.JButton b1; private javax.swing.JLabel iconlabel; private javax.swing.JButton b3; private javax.swing.JToolBar jToolBar1; private javax.swing.JSeparator jSeparator1; private javax.swing.JButton b4; private javax.swing.JLabel mapCanvas; private javax.swing.JButton b2; // End of variables declaration//GEN-END:variables public boolean posEnabled = true; public boolean trackEnabled = false; public int zoomlevel = 1; static private String bgFile = "http://zazaconsole.exhibits.thetech.org/~brudy/zaza/java/images/map-ex.gif"; static private String fgFile = "http://zazaconsole.exhibits.thetech.org/~brudy/zaza/java/images/robot.gif"; static private String Server = "http://zazaconsole.exhibits.thetech.org"; static private String posServer = Server + "/cgi-bin/posServer"; public static java.awt.Image bgImage; public static java.awt.Image fgImage; private BufferedImage bimg; private boolean retrack = false; private boolean isInitialized = false; private int numGoals = 0; private String[][] goals = new String[20][]; private int goalSize = 10; public int PosX = 0; public int PosY = 0; public int PosTheta = 0; private int lastPosX; private int lastPosY; private int lastPosTheta; public boolean drawpos = true; Thread tGetPos = null; boolean frozen = false; javax.swing.Timer timer; private int goalSelected = 0; private boolean asApplet = false; private int StatusLoopCounter = 0; }