예제 #1
0
  public void initComponents() {
    GridBagLayout gridBag = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();

    JLabel label;
    JPanel panel;
    Dimension size;

    setBorder(new javax.swing.border.EtchedBorder());
    setLayout(gridBag);

    label = new JLabel(name);
    constraints.anchor = GridBagConstraints.WEST;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(label, constraints);
    add(label);

    panel = filterOptions();
    gridBag.setConstraints(panel, constraints);
    add(panel);

    sliderCutoff = new JSlider(JSlider.VERTICAL);
    sliderCutoff.setPaintTicks(true);
    sliderCutoff.setToolTipText("Cutoff Frequency");
    sliderCutoff.setMinimum(0);
    sliderCutoff.setMaximum(500);
    sliderCutoff.setMinorTickSpacing(25);
    sliderCutoff.setMajorTickSpacing(100);
    sliderCutoff.setValue(100);
    sliderCutoff.addChangeListener(new CutoffListener(filter));
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.gridwidth = 1;
    gridBag.setConstraints(sliderCutoff, constraints);
    add(sliderCutoff);

    sliderResonance = new JSlider(JSlider.VERTICAL);
    sliderResonance.setPaintTicks(true);
    sliderResonance.setToolTipText("Resonance (Pass-band Ripple)");
    sliderResonance.setMinimum(1);
    sliderResonance.setMaximum(58);
    sliderResonance.setMinorTickSpacing(3);
    sliderResonance.setMajorTickSpacing(57);
    sliderResonance.setValue(1);
    sliderResonance.addChangeListener(new ResonanceListener(filter));
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(sliderResonance, constraints);
    add(sliderResonance);

    label = new JLabel("Cutoff");
    constraints.gridwidth = 1;
    constraints.ipadx = 10;
    gridBag.setConstraints(label, constraints);
    add(label);

    label = new JLabel("Resonance");
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBag.setConstraints(label, constraints);
    add(label);
  }
예제 #2
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());
  }
예제 #3
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());
  }
예제 #4
0
  /**
   * Activate/Deactivate Rotate-Button
   *
   * @param b
   */
  public void activateRotation(boolean b) {

    if (showRotate && b) {
      rotatePanel.setVisible(b);
      rotateSlider.setValue(((ShapeItem) board.getSelectedItems()[0]).getRotation());

    } else {
      rotatePanel.setVisible(false);
    }
    rotate.setEnabled(b);
  }
예제 #5
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));
  }
 private void setFontSizeSliderSize(FontSize fontSize) {
   myIgnoreFontSizeSliderChange = true;
   try {
     FontSize[] sizes = FontSize.values();
     for (int i = 0; i < sizes.length; i++) {
       if (fontSize == sizes[i]) {
         myFontSizeSlider.setValue(i);
         break;
       }
     }
   } finally {
     myIgnoreFontSizeSliderChange = false;
   }
 }
예제 #7
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);
  }
 /** Sets the speed (int code, between 1 and NUMBER_OF_SPEED_UNTIS) */
 public void setSpeed(int speed) {
   speedSlider.setValue(speed);
   repaint();
 }
예제 #9
0
 /**
  * Sets the value of the rotate Slider
  *
  * @param degree as int
  */
 public void setRotateValue(int degree) {
   rotateSlider.setValue(degree);
 }