public void actionPerformed(ActionEvent e) {
    if (e.getSource() instanceof TextField) {
      TextField tf = (TextField) e.getSource();
      String text = tf.getText();
      String fields[] = FILE.split(text, " ,");
      int r = 0;
      int g = 0;
      int b = 0;
      if (fields.length == 3) {
        // assumed decimal rgb values
        r = FILE.readInteger(fields[0]);
        g = FILE.readInteger(fields[1]);
        b = FILE.readInteger(fields[2]);
      } else if (fields.length == 1) {
        // assume 6 digit hex code
        int crgb = Color32.getColorFromName(fields[0]);
        r = (crgb & 0xff0000) >> 16;
        g = (crgb & 0xff00) >> 8;
        b = (crgb & 0xff);
      } else {
        Log.error("illegal colour format");
        Log.error("should be 0xabcdef or 255 0 255 or colorname");
        return;
      }

      Color c = new Color(r, g, b);

      updateColor(c, e.getSource());
    }
  }
Esempio n. 2
0
  public Processing(Box root) {
    super(null);

    Log.log("startup.processing", " processing plugin is starting up ");

    frame = new JFrame("Field/Processing");
    __applet =
        new FieldProcessingApplet(
            sizeX,
            sizeY,
            queue,
            this,
            s -> {
              if (getLastErrorOutput() != null) getLastErrorOutput().accept(new Pair<>(-1, s));
            });

    __applet.init();
    __applet.loop();
    frame.add(__applet, BorderLayout.CENTER);
    frame.setSize(sizeX, sizeY);
    frame.setVisible(true);
    frame.validate();

    applet = new FieldProcessingAppletDelgate(__applet);

    this.properties.put(P, applet);

    Log.log("startup.processing", " searching for boxes that need processing support ");

    Log.log("startup.processing", " processing plugin has finished starting up ");
  }
Esempio n. 3
0
 public HtmlViewer(String text) {
   Log.setApplicationName("HtmlViewer");
   htmlPane = new HtmlPane();
   htmlPane.setText(text);
   setTitle("HTML Viewer");
   getContentPane().add(new JScrollPane(htmlPane));
   setSize(new Dimension(640, 480));
 }
 // {{{ handleError() method
 static void handleError(Component comp, Exception e) {
   Log.log(Log.ERROR, SearchAndReplace.class, e);
   if (comp instanceof Dialog) {
     new TextAreaDialog((Dialog) comp, beanshell ? "searcherror-bsh" : "searcherror", e);
   } else {
     new TextAreaDialog((Frame) comp, beanshell ? "searcherror-bsh" : "searcherror", e);
   }
 } // }}}
  private void jMenuItemLoadLSAResultsActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItemLoadLSAResultsActionPerformed
    JFileChooser jfc = new JFileChooser();
    int fileDialogReturnVal = jfc.showOpenDialog(this);

    if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) {
      try {
        File inputFile = jfc.getSelectedFile();
        FileInputStream fis = new FileInputStream(inputFile);
        ObjectInputStream ois = new ObjectInputStream(fis);

        this.currentResults = (LSAResults) ois.readObject();
      } catch (IOException e) {
        log.log(Log.ERROR, "Failed to load LSA results\n" + e.getMessage());
      } catch (ClassNotFoundException e) {
        log.log(Log.ERROR, "Class not found : Error loading LSA results due to version mismatch");
      }

      System.out.println(currentResults == null);
    }
  } // GEN-LAST:event_jMenuItemLoadLSAResultsActionPerformed
Esempio n. 6
0
  public static File startFileChooser(Component component, File selectedFile) {
    // Create a file chooser
    final JFileChooser fc = new JFileChooser();
    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fc.setFileHidingEnabled(true);
    fc.setAcceptAllFileFilterUsed(false);
    if (selectedFile != null) fc.setSelectedFile(selectedFile);
    fc.setFileFilter(
        new FileFilter() {
          @Override
          public boolean accept(final File file) {
            if (file.isDirectory()) return true;
            String ext = Utils.getExtension(file);
            if (ext != null && ext.equals(Utils.XLS)) {
              return true;
            }
            return false;
          }

          @Override
          public String getDescription() {
            return "Excel *.xls";
          }
        });
    // In response to a button click:
    final int returnVal = fc.showOpenDialog(component);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      File file = fc.getSelectedFile();
      // This is where a real application would open the file.
      Log.d("Opening: " + file.getName() + ".");
      return file;
    } else {
      Log.d("Open command cancelled by user.");
    }
    return null;
  }
Esempio n. 7
0
 @SuppressWarnings("deprecation")
 public static void setTeamHead(ItemStack item, Player p) {
   if (p.isOnline() && !p.isDead()) {
     ItemStack is = p.getInventory().getHelmet();
     try {
       p.getInventory().setHelmet(item);
       if (is != null && is.getType() != Material.AIR && is.getType() != Material.WOOL) {
         InventoryUtil.addItemToInventory(p, is.clone(), is.getAmount(), true, true);
       }
       p.updateInventory();
     } catch (Exception e) {
       if (!Defaults.DEBUG_VIRTUAL) Log.printStackTrace(e);
     }
   }
 }
Esempio n. 8
0
 /**
  * Konstruktør.
  *
  * @param gameRenderer GameRendereren som eier objektet.
  * @param name Navnet til objektet. Blir default brukt som bildebasenavn
  */
 GameObject(GameRenderer gameRenderer, String name, int objectX, int objectY) {
   dead = false;
   _name = name;
   _damage = 1;
   _age = 0;
   _xSpeed = _ySpeed = 0;
   x = objectX;
   y = objectY;
   _gameRenderer = gameRenderer;
   _movie = ImageMap.getInstance().getImage(name);
   if (_movie[0] == null) {
     Log.log("Couldn't find image for GameObject. Exiting.");
     System.exit(1);
   }
   width = _movie[0].getWidth(null);
   height = _movie[0].getHeight(null);
 }
  private void jMenuItemSaveProjectActionPerformed(
      java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItemSaveProjectActionPerformed
      { // GEN-HEADEREND:event_jMenuItemSaveProjectActionPerformed
    if (this.theProject != null) {
      JFileChooser jfc = new JFileChooser();
      int fileDialogReturnVal = jfc.showSaveDialog(this);

      if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) {
        try {
          File outputFile = jfc.getSelectedFile();
          FileOutputStream fos = new FileOutputStream(outputFile);
          ObjectOutputStream oos = new ObjectOutputStream(fos);

          oos.writeObject(this.theProject);
          if (this.currentResults != null) {
            oos.writeObject(this.currentResults);
          }
        } catch (IOException e) {
          log.log(Log.ERROR, "Failed to save file\n" + e.getMessage());
        }
      }
    }
  } // GEN-LAST:event_jMenuItemSaveProjectActionPerformed
  private void jMenuItemLoadProjectActionPerformed(
      java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItemLoadProjectActionPerformed
      { // GEN-HEADEREND:event_jMenuItemLoadProjectActionPerformed
    JFileChooser jfc = new JFileChooser();
    if (lastPath != null) {
      jfc.setCurrentDirectory(lastPath);
    }
    int fileDialogReturnVal = jfc.showOpenDialog(this);

    if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) {
      try {
        File inputFile = jfc.getSelectedFile();
        FileInputStream fis = new FileInputStream(inputFile);
        ObjectInputStream ois = new ObjectInputStream(fis);

        this.theProject = (Project) ois.readObject();
        this.currentResults = (LSAResults) ois.readObject();

        lastPath = new File(jfc.getSelectedFile().getPath());
      } catch (IOException e) {
        if (this.theProject == null) {
          log.log(Log.ERROR, "Failed to load project");
        }
        if (this.currentResults == null) {
          log.log(Log.WARNING, "Failed to load results");
        }

        log.log(Log.WARNING, e.getMessage());
      } catch (ClassNotFoundException e) {
        log.log(Log.ERROR, "Class not found error, version mismatch");
      }
    }
    if (this.theProject != null) {
      jMenuItemViewDocuments.setEnabled(true);
      jMenuItemSaveProject.setEnabled(true);
      this.setTitle(theProject.getProjectName());
      log.log(Log.INFO, "Project Loaded");
    }
    if (this.currentResults != null) {
      log.log(Log.INFO, "Results loaded");
    }
  } // GEN-LAST:event_jMenuItemLoadProjectActionPerformed
Esempio n. 11
0
 private void out(String s) {
   Log.info(String.format("PrintJob@%x[%s] %s", hashCode(), jobName, s));
   // System.out.println("PrintJob@" + Integer.toHexString(hashCode()) + "[" + jobName + "] " +
   // s);
 }