public void itemStateChanged(ItemEvent e) {
    Object source = e.getSource();
    if (e.getStateChange() != ItemEvent.SELECTED) return;

    if (source == ncbGridTickX) {
      double val = ncbGridTickX.getValue();
      if (val > 0) {
        double[] ticks = view.getGridDistances();
        ticks[0] = val;
        view.setGridDistances(ticks);
      }
    } else if (source == ncbGridTickY) {
      double val = ncbGridTickY.getValue();
      if (val > 0) {
        double[] ticks = view.getGridDistances();
        ticks[1] = val;
        view.setGridDistances(ticks);
      }
    } else if (source == cbGridTickAngle) {
      double val = cbGridTickAngle.getSelectedIndex();
      if (val >= 0) {
        double[] ticks = view.getGridDistances();
        // val = 4 gives  5*PI/12, skip this and go to 6*Pi/2 = Pi/2
        if (val == 4) val = 5;
        ticks[2] = (val + 1) * Math.PI / 12;
        view.setGridDistances(ticks);
      }
    }

    view.updateBackground();
    updateGUI();
  }
Ejemplo n.º 2
0
 /** Update the GUI. */
 public void updateGUI() {
   defaultsPanel.updateGUI();
   euclidianPanel.updateGUI();
   spreadsheetPanel.updateGUI();
   casPanel.updateGUI();
   advancedPanel.updateGUI();
 }
 public void setView(EuclidianViewInterface view) {
   this.view = view;
   if (!isIniting) updateGUI();
 }
  private void doActionPerformed(Object source) {
    if (source == btBackgroundColor) {
      view.setBackground(app.getGuiManager().showColorChooser(view.getBackground()));
    } else if (source == btAxesColor) {
      view.setAxesColor(app.getGuiManager().showColorChooser(view.getAxesColor()));
    } else if (source == btGridColor) {
      view.setGridColor(app.getGuiManager().showColorChooser(view.getGridColor()));
    } else if (source == cbShowAxes) {
      // view.showAxes(cbShowAxes.isSelected(), cbShowAxes.isSelected());
      view.setShowAxes(cbShowAxes.isSelected(), true);
    } else if (source == cbShowGrid) {
      view.showGrid(cbShowGrid.isSelected());
    } else if (source == cbBoldGrid) {
      view.setGridIsBold(cbBoldGrid.isSelected()); // Michael Borcherds 2008-04-11
    } else if (source == cbShowMouseCoords) {
      view.setAllowShowMouseCoords(cbShowMouseCoords.isSelected());
    } else if (source == cbGridType) {
      view.setGridType(cbGridType.getSelectedIndex());
    } else if (source == cbAxesStyle) {
      view.setAxesLineStyle(cbAxesStyle.getSelectedIndex());
    } else if (source == cbGridStyle) {
      int type = ((Integer) cbGridStyle.getSelectedItem()).intValue();
      view.setGridLineStyle(type);
    } else if (source == cbGridManualTick) {
      view.setAutomaticGridDistance(!cbGridManualTick.isSelected());
    } else if (source == tfAxesRatioX || source == tfAxesRatioY) {
      double xval = parseDouble(tfAxesRatioX.getText());
      double yval = parseDouble(tfAxesRatioY.getText());
      if (!(Double.isInfinite(xval)
          || Double.isNaN(xval)
          || Double.isInfinite(yval)
          || Double.isNaN(yval))) {
        // ratio = xval / yval
        // xscale / yscale = ratio
        // => yscale = xscale * xval/yval
        view.setCoordSystem(
            view.getXZero(), view.getYZero(), view.getXscale(), view.getXscale() * xval / yval);
      }
    } else if (source == cbView) {

      if (cbView.getSelectedIndex() == 0) setView(app.getEuclidianView());
      else setView(app.getGuiManager().getEuclidianView2());
    } else if (source == tfMinX) {
      double min = kernel.getAlgebraProcessor().evaluateToDouble(tfMinX.getText());
      double max = view.getXmax();
      if (min + Kernel.MIN_PRECISION < max) {
        view.setRealWorldCoordSystem(min, max, view.getYmin(), view.getYmax());
      }
    } else if (source == tfMaxX) {
      double min = view.getXmin();
      double max = kernel.getAlgebraProcessor().evaluateToDouble(tfMaxX.getText());
      if (min + Kernel.MIN_PRECISION < max) {
        view.setRealWorldCoordSystem(min, max, view.getYmin(), view.getYmax());
      }
    } else if (source == tfMinY) {
      double min = kernel.getAlgebraProcessor().evaluateToDouble(tfMinY.getText());
      double max = view.getYmax();
      if (min + Kernel.MIN_PRECISION < max) {
        view.setRealWorldCoordSystem(view.getXmin(), view.getXmax(), min, max);
      }
    } else if (source == tfMaxY) {
      double min = view.getYmin();
      double max = kernel.getAlgebraProcessor().evaluateToDouble(tfMaxY.getText());
      if (min + Kernel.MIN_PRECISION < max) {
        view.setRealWorldCoordSystem(view.getXmin(), view.getXmax(), min, max);
      }
    }

    view.updateBackground();
    updateGUI();
  }