@Override
 public void keyTyped(KeyEvent e) {
   if (e.getKeyChar() == 's') {
     System.out.println("Writing config!");
     try {
       IOUtils.writeASCII(new File("camera.conf"), this.touchTable.cameraConfig);
       System.out.println("Camera config written");
     } catch (Exception e1) {
       System.out.println("Failed to write camera.conf: " + e1.getMessage());
     }
   } else if (e.getKeyChar() == 'c') {
     this.touchTable.clear();
   } else if (e.getKeyChar() == 'l') {
     System.out.println("Loading config!");
     try {
       TriangleCameraConfig newCC =
           IOUtils.read(new File("camera.conf"), new TriangleCameraConfig());
       this.touchTable.setCameraConfig(newCC);
       System.out.println("Read camera config");
     } catch (Exception e1) {
       System.out.println("Failed to read camera config");
     }
   } else if (e.getKeyChar() == 't') {
     if (this.touchTable.mode instanceof Mode.DRAWING_TRACKED)
       this.touchTable.mode = new Mode.DRAWING(this.touchTable);
     else this.touchTable.mode = new Mode.DRAWING_TRACKED(this.touchTable);
   } else if (e.getKeyChar() == 'm') {
     this.touchTable.mode = new Mode.SERVER(this.touchTable);
   } else if (e.getKeyChar() == 'p') {
     this.touchTable.mode = new Mode.PONG(this.touchTable);
   }
 }
Esempio n. 2
0
 @Override
 public void failedURL(URL url, String reason) {
   try {
     StringWriter writer = new StringWriter();
     if (url == null) return;
     IOUtils.writeASCII(writer, new WriteableFailedURL(url, reason));
     publisher.send("FAIL".getBytes("UTF-8"), ZMQ.SNDMORE);
     boolean sent = publisher.send(writer.toString().getBytes("UTF-8"), 0);
     if (!sent) {
       throw new IOException("Send failed");
     }
   } catch (IOException e) {
     logger.error("Unable to send failure!");
   }
 }
Esempio n. 3
0
 @Override
 public void newImageDownloaded(WriteableImageOutput written) {
   try {
     StringWriter writer = new StringWriter();
     IOUtils.writeASCII(writer, written);
     publisher.send("IMAGE".getBytes("UTF-8"), ZMQ.SNDMORE);
     boolean sent = publisher.send(writer.toString().getBytes("UTF-8"), 0);
     if (!sent) {
       throw new IOException("Send failed");
     }
   } catch (IOException e) {
     logger.error("Unable to send written image: " + written.url);
     logger.error(e.getMessage());
   }
 }