/** 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));
   }
 }
 /** 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();
   }
 }
예제 #3
0
  private void setComponentsEnabled(boolean enabled) {
    list.setEnabled(enabled);
    process.setEnabled(enabled);
    remove.setEnabled(enabled);
    xres.setEnabled(enabled);
    yres.setEnabled(enabled);
    aspect.setEnabled(enabled);

    boolean b = aspect.isSelected() && enabled;
    colorLabel.setEnabled(b);
    colorBox.setEnabled(b);
    redLabel.setEnabled(b);
    red.setEnabled(b);
    redValue.setEnabled(b);
    greenLabel.setEnabled(b);
    green.setEnabled(b);
    greenValue.setEnabled(b);
    blueLabel.setEnabled(b);
    blue.setEnabled(b);
    blueValue.setEnabled(b);

    format.setEnabled(enabled);
    algorithm.setEnabled(enabled);
    prepend.setEnabled(enabled);
    append.setEnabled(enabled);
    output.setEnabled(enabled);
  }
 public void stateChanged(ChangeEvent e) {
   JSlider source = (JSlider) e.getSource();
   if (!source.getValueIsAdjusting()) {
     int delay = 1000 * (int) source.getValue();
     LifeSimulation.timer().setDelay(delay);
   }
 }
 /** @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()));
 }
예제 #6
0
 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);
     }
   }
 }
예제 #7
0
  private void loadPreferences() {
    // grab the preferences so that they can be used to fill out the layout
    ThumbMakerPreferences myPreferences = ThumbMakerPreferences.getInstance();

    // x resolution text box
    xres.setText(myPreferences.getStringPref(ThumbMakerPreferences.RES_WIDTH_PREF_NAME));

    // y resolution text box
    yres.setText(myPreferences.getStringPref(ThumbMakerPreferences.RES_HEIGHT_PREF_NAME));

    // aspect ratio checkbox
    aspect.setSelected(
        myPreferences
            .getStringPref(ThumbMakerPreferences.DO_MAINTAIN_ASPECT_PREF_NAME)
            .equalsIgnoreCase(ThumbMakerPreferences.BOOLEAN_TRUE_STRING));

    // load the color values from the preferences
    int redValueNumber = myPreferences.getIntegerPref(ThumbMakerPreferences.RED_VALUE_PREF_NAME);
    int greenValueNumber =
        myPreferences.getIntegerPref(ThumbMakerPreferences.GREEN_VALUE_PREF_NAME);
    int blueValueNumber = myPreferences.getIntegerPref(ThumbMakerPreferences.BLUE_VALUE_PREF_NAME);

    // set the background color image
    colorBox.setBackground(new Color(redValueNumber, greenValueNumber, blueValueNumber));

    // red slider
    red.setValue(redValueNumber);
    redValue.setText("" + redValueNumber);

    // green slider
    green.setValue(greenValueNumber);
    greenValue.setText("" + greenValueNumber);

    // blue slider
    blue.setValue(blueValueNumber);
    blueValue.setText("" + blueValueNumber);

    // algorithm combo box
    algorithm.setSelectedIndex(
        myPreferences.getIntegerPref(ThumbMakerPreferences.RESIZE_ALG_PREF_NAME));

    // format combo box
    format.setSelectedIndex(
        myPreferences.getIntegerPref(ThumbMakerPreferences.THUMB_FORMAT_PREF_NAME));

    // prepend field
    prepend.setText(myPreferences.getStringPref(ThumbMakerPreferences.STRING_TO_PREPEND_PREF_NAME));

    // append field
    append.setText(myPreferences.getStringPref(ThumbMakerPreferences.STRING_TO_APPEND_PREF_NAME));

    // output folder field
    output.setText(
        (new File(myPreferences.getStringPref(ThumbMakerPreferences.FILE_PATH_STRING_PREF_NAME)))
            .getAbsolutePath());
  }
예제 #8
0
 public AnnotatedSlider(int minimum, int maximum, int value, SecondaryView secondaryView) {
   super(new GridBagLayout());
   _secondaryView = secondaryView;
   _minimum = minimum;
   _maximum = maximum;
   buildGUI();
   _slider.setValue(value);
   _slider.addChangeListener(new SliderListener());
   _listeners = new ArrayList();
 }
예제 #9
0
  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);
    }
  }
예제 #10
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 values of the configuration dialog to the ones specified by the given
  * WebCrawling-instance.
  *
  * @param wcCfg the WebCrawling-instance containing the values for the dialog
  */
 public void setConfig(WebCrawlingConfig wcCfg) {
   if (wcCfg != null) {
     tfSearchEngineURL.setText(wcCfg.getSearchEngineURL());
     sliderNumberOfRetries.setValue(wcCfg.getNumberOfRetries());
     sliderIntervalBetweenRetries.setValue(wcCfg.getIntervalBetweenRetries());
     tfAdditionalKeywords.setText(wcCfg.getAdditionalKeywords());
     rbAfterSearchString.setSelected(wcCfg.getAdditionalKeywordsAfterSearchString());
     rbBeforeSearchString.setSelected(!wcCfg.getAdditionalKeywordsAfterSearchString());
     jsNumberOfPages.setValue(new Integer(wcCfg.getNumberOfRequestedPages()));
     tfPathStoreRetrievedPages.setText(wcCfg.getPathStoreRetrievedPages());
     tfPathExternalCrawler.setText(wcCfg.getPathExternalCrawler());
     cbStoreURLList.setSelected(wcCfg.isStoreURLList());
   }
 }
예제 #12
0
  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 getPropertyComponents(List comps, final ObjectListener listener) {
    visibleCbx = new JCheckBox(getName(), visible);
    float[] rgb = color.get().getRGBComponents(null);
    slider = new JSlider(0, 100, (int) (rgb[0] * 100));

    float[] xyz = new float[3];
    direction.get(xyz);
    directionXFld = makeField("" + xyz[0], listener, "X Direction");
    directionYFld = makeField("" + xyz[1], listener, "Y Direction");
    directionZFld = makeField("" + xyz[2], listener, "Z Direction");

    double[] pxyz = new double[3];
    location.get(pxyz);
    locationXFld = makeField("" + pxyz[0], listener, "");
    locationYFld = makeField("" + pxyz[1], listener, "");
    locationZFld = makeField("" + pxyz[2], listener, "");

    List fldComps =
        Misc.newList(GuiUtils.rLabel("Direction:"), directionXFld, directionYFld, directionZFld);
    //
    // fldComps.addAll(Misc.newList(GuiUtils.rLabel("Location:"),locationXFld,locationYFld,locationZFld));

    comps.add(visibleCbx);
    GuiUtils.tmpInsets = new Insets(0, 2, 0, 0);
    comps.add(
        GuiUtils.vbox(
            slider, GuiUtils.left(GuiUtils.doLayout(fldComps, 4, GuiUtils.WT_N, GuiUtils.WT_N))));

    if (listener != null) {
      visibleCbx.addActionListener(listener);
      slider.addChangeListener(listener);
    }
  }
예제 #14
0
 private JPanel makeSlider(JLabel label, JSlider slider, JLabel value, String color) {
   JPanel p = new JPanel();
   p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
   label.setDisplayedMnemonic(label.getText().charAt(0));
   label.setLabelFor(slider);
   String tip = color + " color component slider";
   label.setToolTipText(tip);
   slider.setToolTipText(tip);
   value.setToolTipText(tip);
   p.add(label);
   slider.setMaximumSize(new Dimension(128, slider.getMaximumSize().height));
   slider.addChangeListener(this);
   p.add(slider);
   p.add(value);
   return p;
 }
예제 #15
0
 /**
  * Adds a slider to the slider panel and hooks up the listener
  *
  * @param s the slider
  * @param description the slider description
  */
 public void addSlider(JSlider s, String description) {
   s.addChangeListener(listener);
   JPanel panel = new JPanel();
   panel.add(s);
   panel.add(new JLabel(description));
   sliderPanel.add(panel);
 }
예제 #16
0
 public void setColor(Color3f value, boolean updateGui) {
   setColor(value);
   if (updateGui && slider != null) {
     float[] rgb = getColor().get().getRGBComponents(null);
     int sliderValue = (int) (100 * rgb[0]);
     slider.setValue(sliderValue);
   }
 }
예제 #17
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());
  }
예제 #18
0
 public ImageOps() {
   setBackground(Color.white);
   for (int i = 0; i < imgName.length; i++) {
     Image image = getImage(imgName[i]);
     int iw = image.getWidth(this);
     int ih = image.getHeight(this);
     img[i] = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB);
     img[i].createGraphics().drawImage(image, 0, 0, null);
   }
   slider1 = new JSlider(JSlider.VERTICAL, 0, 255, low);
   slider1.setPreferredSize(new Dimension(15, 100));
   slider1.addChangeListener(this);
   slider2 = new JSlider(JSlider.VERTICAL, 0, 255, high);
   slider2.setPreferredSize(new Dimension(15, 100));
   slider2.addChangeListener(this);
   setControls(new Component[] {new DemoControls(this), slider1, slider2});
   setConstraints(new String[] {BorderLayout.NORTH, BorderLayout.WEST, BorderLayout.EAST});
 }
예제 #19
0
 public SineWave() {
   add(sines);
   adjustCycles.addChangeListener(
       new ChangeListener() {
         public void stateChanged(ChangeEvent e) {
           sines.setCycles(((JSlider) e.getSource()).getValue());
         }
       });
   add(BorderLayout.SOUTH, adjustCycles);
 }
  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);
    }
  }
예제 #21
0
  public java.awt.Container createControlPanel() {
    java.awt.Container panel2 = Box.createVerticalBox();
    panel2 = super.createControlPanel();

    brainPlay = new JCheckBox("Brain Play", false);
    if (testMode) brainPlay.setSelected(true);
    panel2.add(brainPlay);

    JPanel row2 = new JPanel();

    // ADVERSARY slider
    row2.add(Box.createVerticalStrut(12));
    row2.add(new JLabel("Adversary:"));

    adversary = new JSlider(0, 100, 0); // min, max, current
    adversary.setPreferredSize(new Dimension(100, 15));
    row2.add(adversary);

    JPanel text = new JPanel();
    text.add(adStat = new JLabel(adversaryOff));
    panel2.add(text);

    panel2.add(row2);

    JPanel row3 = new JPanel();

    // Mr. Happy slider
    row3.add(Box.createVerticalStrut(12));
    row3.add(new JLabel("CELAB"));

    happy = new JSlider(0, 100, 0); // min, max, current
    happy.setPreferredSize(new Dimension(100, 15));
    row3.add(happy);

    JPanel text2 = new JPanel();
    text2.add(adHappy = new JLabel(happyOff));
    panel2.add(text2);

    panel2.add(row3);

    return (panel2);
  }
예제 #22
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));
  }
예제 #23
0
파일: SineWave.java 프로젝트: haomen/refs
 public void init() {
   Container cp = getContentPane();
   cp.add(sines);
   cycles.addChangeListener(
       new ChangeListener() {
         public void stateChanged(ChangeEvent e) {
           sines.setCycles(((JSlider) e.getSource()).getValue());
         }
       });
   cp.add(BorderLayout.SOUTH, cycles);
 }
예제 #24
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();
 }
예제 #25
0
  private void createGUI() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    Container window = getContentPane();
    window.setLayout(new FlowLayout());

    lSlider = new JSlider(JSlider.VERTICAL, 1, 6, 1);
    window.add(lSlider);
    lSlider.addChangeListener(this);

    panel = new JPanel();
    panel.setPreferredSize(new Dimension(200, 175));
    panel.setBackground(Color.WHITE);
    window.add(panel);

    rSlider = new JSlider(JSlider.VERTICAL, 1, 6, 1);
    window.add(rSlider);
    rSlider.addChangeListener(this);

    deepLabel = new JLabel("Deep end: ");
    window.add(deepLabel);

    deepField = new JTextField(4);
    window.add(deepField);

    shallLabel = new JLabel("Shall end: ");
    window.add(shallLabel);

    shallField = new JTextField(4);
    window.add(shallField);

    areaLabel = new JLabel("Area of the swimming pool: ");
    window.add(areaLabel);

    areaField = new JTextField(4);
    window.add(areaField);
  }
예제 #26
0
  /** Change the view to display a given question number (1-origin) */
  protected void setQNumber(int nn) {
    String userShowNumber = Integer.toString(nn);

    System.out.println("setQNumber(" + userShowNumber + ");");

    // notify the model
    //	TODO -- if necessary!

    // update the view
    numTF.setText(userShowNumber);
    numSlider.setValue(nn);

    // show the right question
    myCardLayout.show(questionsPanel, userShowNumber);
  }
예제 #27
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();
  }
  TimerControls(ControlBar creator) {
    parent = creator;
    super.setPreferredSize(new Dimension(200, 172));
    setLayout(new BorderLayout());

    pausePlay = new JButton("Play");
    speed = makeJSlider();

    pausePlay.addActionListener(this);
    speed.addChangeListener(this);

    super.add(pausePlay, BorderLayout.WEST);
    super.add(speed, BorderLayout.EAST);
    super.add(new JLabel(" Simulation Speed Controls"), BorderLayout.NORTH);

    super.repaint();
    super.setVisible(true);
  }
  private JSlider makeJSlider() {

    JSlider slider = new JSlider(JSlider.VERTICAL, 0, 10, 1);
    slider.setMajorTickSpacing(1);
    slider.setPaintTicks(true);
    slider.setSnapToTicks(true);

    Hashtable labelTable = new Hashtable();
    for (int i = 0; i <= 10; i += 2) {
      labelTable.put(new Integer(i), new JLabel(i + " Seconds"));
    }
    slider.setLabelTable(labelTable);
    slider.setPaintLabels(true);
    return slider;
  }
예제 #30
0
 public void loadImage() throws IOException {
   nonMax = ImageIO.read(new File(path));
   width = nonMax.getWidth();
   height = nonMax.getHeight();
   rmax = width > height ? height / 2 : width / 2;
   accRMax = (rmax + offset - 1) / offset;
   whichRadius.setMaximum(accRMax);
   img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
   Graphics g = img.getGraphics();
   g.drawImage(nonMax, 0, 0, null);
   g.dispose();
   res = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
   g = res.getGraphics();
   g.drawImage(img, 0, 0, null);
   g.dispose();
   greyScale = copyImage(nonMax);
   ImageIcon icon = new ImageIcon(img);
   ImageIcon icon2 = new ImageIcon(greyScale);
   lbl1.setIcon(icon);
   lbl2.setIcon(icon2);
 }