/** @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent) */
 public void stateChanged(ChangeEvent e) {
   // set label according to slider which has been changed
   JSlider source = (JSlider) e.getSource();
   if (source == sliderNumberOfRetries)
     this.currentNumberOfRetries.setText(Integer.toString(source.getValue()));
   if (source == sliderIntervalBetweenRetries)
     this.currentIntervalBetweenRetries.setText(Integer.toString(source.getValue()));
 }
  public void stateChanged(ChangeEvent e) {
    JSlider source = (JSlider) e.getSource();

    if (source == unitXSlider) {
      ux = source.getValue();
      graph.setUnityX(ux);
    } else {
      uy = source.getValue();
      graph.setUnityY(uy);
    }
  }
示例#3
0
 /** Called when color slider values change. */
 public void stateChanged(ChangeEvent e) {
   JSlider slider = (JSlider) e.getSource();
   int val = slider.getValue();
   String s = "" + val;
   if (val < 100) s = "0" + s;
   if (val < 10) s = "0" + s;
   if (slider == red) redValue.setText(s);
   else if (slider == green) greenValue.setText(s);
   else if (slider == blue) blueValue.setText(s);
   Color c = new Color(red.getValue(), green.getValue(), blue.getValue());
   colorBox.setBackground(c);
 }
 /** Sets the direction of the vehicle */
 public void stateChanged(ChangeEvent event) {
   JSlider source = (JSlider) event.getSource();
   if (!source.getValueIsAdjusting()) {
     SensorInfo.getInstance().setSliderDirection(source.getValue());
     Controller.getInstance().setMotors();
   }
 }
 public void stateChanged(ChangeEvent e) {
   JSlider source = (JSlider) e.getSource();
   if (!source.getValueIsAdjusting()) {
     int delay = 1000 * (int) source.getValue();
     LifeSimulation.timer().setDelay(delay);
   }
 }
 /** Called when the speed slider was moved. */
 public void SpeedSlider_stateChanged(ChangeEvent e) {
   JSlider source = (JSlider) e.getSource();
   if (!source.getValueIsAdjusting()) {
     int speed = source.getValue();
     notifyControllerListeners(ControllerEvent.SPEED_CHANGE, new Integer(speed));
   }
 }
示例#7
0
  private void savePreferences() {
    // grab the preferences so that they can be filled in from the
    // user's selections
    ThumbMakerPreferences myPreferences = ThumbMakerPreferences.getInstance();

    // x resolution text box
    myPreferences.setStringPref(ThumbMakerPreferences.RES_WIDTH_PREF_NAME, xres.getText());

    // y resolution text box
    myPreferences.setStringPref(ThumbMakerPreferences.RES_HEIGHT_PREF_NAME, yres.getText());

    // aspect ratio checkbox
    String aspectText;
    if (aspect.isSelected()) {
      aspectText = ThumbMakerPreferences.BOOLEAN_TRUE_STRING;
    } else aspectText = ThumbMakerPreferences.BOOLEAN_FALSE_STRING;
    myPreferences.setStringPref(ThumbMakerPreferences.DO_MAINTAIN_ASPECT_PREF_NAME, aspectText);

    // red slider
    myPreferences.setIntegerPref(ThumbMakerPreferences.RED_VALUE_PREF_NAME, red.getValue());

    // green slider
    myPreferences.setIntegerPref(ThumbMakerPreferences.GREEN_VALUE_PREF_NAME, green.getValue());

    // blue slider
    myPreferences.setIntegerPref(ThumbMakerPreferences.BLUE_VALUE_PREF_NAME, blue.getValue());

    // algorithm combo box
    myPreferences.setIntegerPref(
        ThumbMakerPreferences.RESIZE_ALG_PREF_NAME, algorithm.getSelectedIndex());

    // format combo box
    myPreferences.setIntegerPref(
        ThumbMakerPreferences.THUMB_FORMAT_PREF_NAME, format.getSelectedIndex());

    // prepend field
    myPreferences.setStringPref(
        ThumbMakerPreferences.STRING_TO_PREPEND_PREF_NAME, prepend.getText());

    // append field
    myPreferences.setStringPref(ThumbMakerPreferences.STRING_TO_APPEND_PREF_NAME, append.getText());

    // output folder field
    myPreferences.setStringPref(ThumbMakerPreferences.FILE_PATH_STRING_PREF_NAME, output.getText());
  }
 public void stateChanged(ChangeEvent e) {
   if (e.getSource() == whichRadius) {
     if (!whichRadius.getValueIsAdjusting()) {
       // System.out.println(acc.length);
       if (acc != null) buildAccumulator(whichRadius.getValue());
       accumulator.setSelected(true);
     }
   }
 }
  public void stateChanged(ChangeEvent e) {
    if (e.getSource() instanceof JSlider && !isAdjusting) {

      int red = redSlider.getValue();
      int green = greenSlider.getValue();
      int blue = blueSlider.getValue();
      Color color = new Color(red, green, blue);

      getColorSelectionModel().setSelectedColor(color);
    } else if (e.getSource() instanceof JSpinner && !isAdjusting) {

      int red = ((Integer) redField.getValue()).intValue();
      int green = ((Integer) greenField.getValue()).intValue();
      int blue = ((Integer) blueField.getValue()).intValue();
      Color color = new Color(red, green, blue);

      getColorSelectionModel().setSelectedColor(color);
    }
  }
示例#10
0
  public void stateChanged(ChangeEvent e) {

    int deepE = lSlider.getValue();
    int shallE = rSlider.getValue();
    if (shallE > deepE) {
      shallE = deepE;
    }
    if (deepE < shallE) {
      deepE = shallE;
    }
    lSlider.setValue(deepE);
    rSlider.setValue(shallE);
    drawPool(deepE, shallE, 5);

    int v = (shallE + deepE) / 2 * 5 * 20;

    deepField.setText(Integer.toString(deepE));
    shallField.setText(Integer.toString(shallE));
    areaField.setText(Integer.toString(v));
  }
  /** {@collect.stats} Sets the values of the controls to reflect the color */
  private void setColor(Color newColor) {
    int red = newColor.getRed();
    int blue = newColor.getBlue();
    int green = newColor.getGreen();

    if (redSlider.getValue() != red) {
      redSlider.setValue(red);
    }
    if (greenSlider.getValue() != green) {
      greenSlider.setValue(green);
    }
    if (blueSlider.getValue() != blue) {
      blueSlider.setValue(blue);
    }

    if (((Integer) redField.getValue()).intValue() != red) redField.setValue(new Integer(red));
    if (((Integer) greenField.getValue()).intValue() != green)
      greenField.setValue(new Integer(green));
    if (((Integer) blueField.getValue()).intValue() != blue) blueField.setValue(new Integer(blue));
  }
  public Piece pickNextPiece() {
    if (adversary.getValue() == 0 && happy.getValue() == 0) {
      adStat.setText(adversaryOff);
      adHappy.setText(happyOff);
      return (super
          .pickNextPiece()); // not to mess with the sequence of random numbers for test mode
    }

    if (adversary.getValue() != 0 && happy.getValue() != 0) {
      adversary.setValue(0);
      adversary.repaint();
    }

    if (random.nextInt(100) <= adversary.getValue()) {
      adStat.setText(adversaryOn);
      return getWorstPiece(true);
    } else {
      adStat.setText(adversaryOff);
    }
    if (random.nextInt(100) <= happy.getValue()) {
      adHappy.setText(happyOn);
      return getWorstPiece(false);
    } else {
      adHappy.setText(happyOff);
    }
    return (super.pickNextPiece());
  }
示例#13
0
 public void stateChanged(ChangeEvent e) {
   // when using these sliders use double buffering, which means
   // ignoring when DemoSurface.imageType = 'On Screen'
   if (getImageType() <= 1) {
     setImageType(2);
   }
   if (e.getSource().equals(slider1)) {
     if (opsIndex == 0) {
       thresholdOp(slider1.getValue(), high);
     } else {
       rescaleFactor = slider1.getValue();
       biop[1] = new RescaleOp((float) rescaleFactor / 128.0f, rescaleOffset, null);
     }
   } else {
     if (opsIndex == 0) {
       thresholdOp(low, slider2.getValue());
     } else {
       rescaleOffset = (float) slider2.getValue();
       biop[1] = new RescaleOp((float) rescaleFactor / 128.0f, rescaleOffset, null);
     }
   }
   repaint();
 }
示例#14
0
  public void applyProperties() {
    visible = visibleCbx.isSelected();
    float f = (float) (slider.getValue() / 100.0f);
    color = new Color3f(f, f, f);
    location =
        new Point3d(
            new Double(locationXFld.getText()).doubleValue(),
            new Double(locationYFld.getText()).doubleValue(),
            new Double(locationZFld.getText()).doubleValue());

    direction =
        new Vector3f(
            new Float(directionXFld.getText()).floatValue(),
            new Float(directionYFld.getText()).floatValue(),
            new Float(directionZFld.getText()).floatValue());

    updateLight();
  }
示例#15
0
 public void stateChanged(ChangeEvent e) {
   JSlider sliderResonance = (JSlider) e.getSource();
   int ripple = (int) sliderResonance.getValue();
   filter.setRipple((double) ripple / 2.0d);
 }
示例#16
0
 public void stateChanged(ChangeEvent e) {
   JSlider sliderCutoff = (JSlider) e.getSource();
   int cutoff = (int) sliderCutoff.getValue();
   filter.setCutoff((double) cutoff / 4000.0d);
 }
示例#17
0
 public int getValue() {
   return _slider.getValue();
 }
 /**
  * Returns the number of retries in case of a failure in accessing the Google Web API.
  *
  * @return the number of retries
  */
 public int getNumberOfRetries() {
   return sliderNumberOfRetries.getValue();
 }
 /**
  * Returns the interval between two retries of accessing the Google Web API. It is measures in
  * seconds.
  *
  * @return the interval between two retries
  */
 public int getIntervalBetweenRetries() {
   return sliderIntervalBetweenRetries.getValue();
 }
示例#20
0
 /** Return the currently selected number */
 protected int getQNumber() {
   return numSlider.getValue();
 }
 /**
  * Initializes the dialog by displaying all labels and sliders, setting title, creating buttons
  * and assigning an ActionListener. To arrange the elements of the dialog box, a GridLayout is
  * used.
  */
 private void initWebCrawlingDialog() {
   this.setTitle("Meta-Data-Related Web Crawling - Configuration");
   // assign text to buttons, set name and assign action listener
   btnStartWebCrawl.setMnemonic(KeyEvent.VK_S);
   // set "Crawl"-button as default
   this.getRootPane().setDefaultButton(btnStartWebCrawl);
   btnStartWebCrawl.setText("Start Crawling");
   btnStartWebCrawl.addActionListener(this);
   btnCancel.setText("Cancel");
   btnCancel.setMnemonic(KeyEvent.VK_C);
   btnCancel.addActionListener(this);
   // set default values for text fields
   tfSearchEngineURL.setText("http://www.google.com");
   tfAdditionalKeywords.setText("+music+review");
   tfPathExternalCrawler.setText("wget");
   // create and initialize sliders
   sliderNumberOfRetries.setMinorTickSpacing(1);
   sliderIntervalBetweenRetries.setMinorTickSpacing(1);
   // initialize labels for slider values
   currentNumberOfRetries =
       new JLabel(Integer.toString(sliderNumberOfRetries.getValue()), JLabel.CENTER);
   currentIntervalBetweenRetries =
       new JLabel(Integer.toString(sliderIntervalBetweenRetries.getValue()), JLabel.CENTER);
   // initialize button group for placement of additional keywords in search string
   panelAdditionalKeywordsPlacement.add(rbBeforeSearchString);
   panelAdditionalKeywordsPlacement.add(rbAfterSearchString);
   bgAdditionalKeywordsPlacement.add(rbBeforeSearchString);
   bgAdditionalKeywordsPlacement.add(rbAfterSearchString);
   rbBeforeSearchString.setMnemonic(KeyEvent.VK_B);
   rbAfterSearchString.setMnemonic(KeyEvent.VK_A);
   // assign change listeners
   sliderNumberOfRetries.addChangeListener(this);
   sliderIntervalBetweenRetries.addChangeListener(this);
   // init grid layout
   gridLayout.setRows(10);
   gridLayout.setVgap(0);
   // assign layout
   panel.setLayout(gridLayout);
   panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
   // add UI-elements
   getContentPane().add(panel);
   panel.add(new JLabel("URL of Search Engine"));
   panel.add(tfSearchEngineURL);
   panel.add(new JLabel());
   panel.add(new JLabel("Number of Retries"));
   panel.add(sliderNumberOfRetries);
   panel.add(currentNumberOfRetries);
   panel.add(new JLabel("Interval between Retries (sec)"));
   panel.add(sliderIntervalBetweenRetries);
   panel.add(currentIntervalBetweenRetries);
   panel.add(new JLabel("Additional Keywords"));
   panel.add(tfAdditionalKeywords);
   panel.add(panelAdditionalKeywordsPlacement);
   panel.add(new JLabel("Maximum Number of Retrieved Pages per Query"));
   panel.add(jsNumberOfPages);
   panel.add(new JLabel());
   panel.add(new JLabel("Storage Path for Retrieved Pages"));
   panel.add(tfPathStoreRetrievedPages);
   panel.add(new JLabel());
   panel.add(new JLabel("Command for External Crawler"));
   panel.add(tfPathExternalCrawler);
   panel.add(new JLabel());
   panel.add(new JLabel());
   panel.add(cbStoreURLList);
   panel.add(new JLabel());
   panel.add(new JLabel());
   panel.add(new JLabel());
   panel.add(new JLabel());
   panel.add(btnStartWebCrawl);
   panel.add(new JLabel());
   panel.add(btnCancel);
   // set default look and feel
   this.setUndecorated(true);
   this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
   this.setResizable(false);
 }
示例#22
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == b) {
      JFrame frame2 = new JFrame();
      JFileChooser chooser = new JFileChooser(".");
      int option =
          chooser.showOpenDialog(
              frame2); // parentComponent must a component like JFrame, JDialog...
      if (option == JFileChooser.APPROVE_OPTION) {
        File selectedFile = chooser.getSelectedFile();
        path = selectedFile.getAbsolutePath();
      }
      try {
        loadImage();
      } catch (IOException ioe) {
        System.out.println(ioe.getMessage());
      }
    } else if (e.getSource() == c) {

      gaussianBlur();
      // filtered = grayscale.filter(filtered, null);
      sobel();
      // thinImage();
      nonMax();
      float lowThreshold = 2.5f;
      float highThreshold = 7.5f;
      int low = Math.round(lowThreshold * MAGNITUDE_SCALE);
      int high = Math.round(highThreshold * MAGNITUDE_SCALE);
      performHysteresis(low, high);
      thresholdEdges();
      writeEdges(data);
      Hough();
      ImageIcon icon1 = new ImageIcon(res);
      lbl1.setIcon(icon1);
      ImageIcon icon2 = new ImageIcon(filtered);
      lbl2.setIcon(icon2);
      filterBtn.setSelected(true);
    }
    if (e.getSource() == findCircles) {
      try {
        accSize = Integer.parseInt(inputCircles.getText());
        res = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics g = res.getGraphics();
        g.drawImage(img, 0, 0, null);
        g.dispose();
        findMaxima();
        ImageIcon icon1 = new ImageIcon(res);
        lbl1.setIcon(icon1);
      } catch (Exception err) {
        System.out.println("Not a valid integer");
      }
    } else if (e.getSource() == filterBtn) {
      ImageIcon icon2 = new ImageIcon(filtered);
      lbl2.setIcon(icon2);
    } else if (e.getSource() == sobelBtn) {
      ImageIcon icon2 = new ImageIcon(sobel);
      lbl2.setIcon(icon2);
    } else if (e.getSource() == nonMaxBtn) {
      ImageIcon icon2 = new ImageIcon(nonMax);
      lbl2.setIcon(icon2);
    } else if (e.getSource() == accumulator) {
      buildAccumulator(whichRadius.getValue());
    }
  }
示例#23
0
  private void process() {
    int width = Integer.parseInt(xres.getText());
    int height = Integer.parseInt(yres.getText());
    boolean preserveAspect = aspect.isSelected();
    Color bg = new Color(red.getValue(), green.getValue(), blue.getValue());

    String outDir = output.getText();
    String suffix = ((String) format.getSelectedItem()).toLowerCase();
    String preText = prepend.getText();
    String appText = append.getText();

    int scaleType = -1;
    String alg = (String) algorithm.getSelectedItem();
    if (alg.equals("Smooth")) scaleType = Image.SCALE_SMOOTH;
    else if (alg.equals("Standard")) scaleType = Image.SCALE_DEFAULT;
    else if (alg.equals("Fast")) scaleType = Image.SCALE_FAST;
    else if (alg.equals("Replicate")) scaleType = Image.SCALE_REPLICATE;
    else if (alg.equals("Area averaging")) {
      scaleType = Image.SCALE_AREA_AVERAGING;
    }

    DefaultListModel model = (DefaultListModel) list.getModel();
    int size = model.size();
    progress.setValue(0);
    progress.setMaximum(4 * size);

    for (int i = 0; i < size; i++) {
      ThumbFile tf = (ThumbFile) model.elementAt(i);
      list.setSelectedValue(tf, true);
      String tail = " (" + (i + 1) + " of " + size + ")";

      progress.setValue(4 * i);
      progress.setString("Reading" + tail);

      // construct input and output filenames
      String inFile = tf.getPath();
      String outFile = outDir + SLASH + tf.getName();
      int ndx = outFile.lastIndexOf(SLASH);
      String s1 = outFile.substring(0, ndx + SLASH.length());
      String s2 = outFile.substring(ndx + SLASH.length());
      int dot_ndx = s2.lastIndexOf(".");
      if (dot_ndx >= 0) s2 = s2.substring(0, dot_ndx);

      // make the thumbnail file name
      outFile = s1 + preText + s2 + appText + "." + suffix;

      // read in the file to an image
      BufferedImage image = null;
      try {
        image = ImageIO.read(new File(inFile));
      } catch (IOException exc) {
        exc.printStackTrace();
      }

      progress.setValue(4 * i + 1);
      progress.setString("Resizing" + tail);

      // resize image
      int w, h;
      if (preserveAspect) {
        int ow = image.getWidth();
        int oh = image.getHeight();
        double oasp = (double) ow / oh;
        double tasp = (double) width / height;
        if (oasp > tasp) {
          w = width;
          h = (int) (w / oasp);
        } else {
          h = height;
          w = (int) (oasp * h);
        }
      } else {
        w = width;
        h = height;
      }
      Image resized = image.getScaledInstance(w, h, scaleType);

      progress.setValue(4 * i + 2);
      progress.setString("Painting" + tail);

      // create thumbnail
      BufferedImage thumb = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
      Graphics2D g2d = thumb.createGraphics();
      g2d.setColor(bg);
      g2d.fillRect(0, 0, width, height);
      g2d.drawImage(resized, (width - w) / 2, (height - h) / 2, this);
      g2d.dispose();

      progress.setValue(4 * i + 3);
      progress.setString("Writing" + tail);

      // save thumbnail to disk
      File out = new File(outFile);
      File parent = out.getParentFile();
      if (parent != null && !parent.exists()) parent.mkdirs();
      try {
        ImageIO.write(thumb, suffix, out);
      } catch (IOException exc) {
        exc.printStackTrace();
      }
    }

    list.setSelectedIndices(new int[0]);
    progress.setValue(4 * size);
    progress.setString("Complete");
  }