public JPanel update(Object[] geos) {
    this.geos = geos;
    if (!checkGeos(geos)) return null;

    tfAnimStep.removeActionListener(this);

    // check if properties have same values
    GeoElement temp, geo0 = (GeoElement) geos[0];
    boolean equalStep = true;
    boolean onlyAngles = true;

    for (int i = 0; i < geos.length; i++) {
      temp = (GeoElement) geos[i];
      // same object visible value
      if (!Kernel.isEqual(geo0.getAnimationStep(), temp.getAnimationStep())) equalStep = false;
      if (!(temp.isGeoAngle())) onlyAngles = false;
    }

    // set trace visible checkbox
    // int oldDigits = kernel.getMaximumFractionDigits();
    // kernel.setMaximumFractionDigits(PropertiesDialog.TEXT_FIELD_FRACTION_DIGITS);
    StringTemplate highPrecision =
        StringTemplate.printDecimals(
            StringType.GEOGEBRA, PropertiesDialog.TEXT_FIELD_FRACTION_DIGITS, false);

    if (equalStep) {
      GeoElement stepGeo = geo0.getAnimationStepObject();
      if (onlyAngles && (stepGeo == null || (!stepGeo.isLabelSet() && stepGeo.isIndependent())))
        tfAnimStep.setText(kernel.formatAngle(geo0.getAnimationStep(), highPrecision).toString());
      else tfAnimStep.setText(stepGeo.getLabel(highPrecision));
    } else tfAnimStep.setText("");

    tfAnimStep.addActionListener(this);
    return this;
  }
Example #2
0
  @Override
  public final void update() {
    isVisible = geo.isEuclidianVisible();
    if (!isVisible) return;
    labelVisible = geo.isLabelVisible();
    updateStrokes(n);
    if (!geo.getDrawAlgorithm().equals(geo.getParentAlgorithm())) init();

    if (gp == null) gp = new GeneralPathClipped(view);
    else gp.reset();

    // init gp
    double aRW = a.getDouble();
    double bRW = b.getDouble();

    // for DrawParametricCurve.plotCurve to work with special values,
    // these changes are needed (also filter out out of screen integrals)
    // see #1234
    aRW = Math.max(aRW, view.getXmin() - EuclidianStatic.CLIP_DISTANCE);
    if (aRW > view.getXmax() + EuclidianStatic.CLIP_DISTANCE) return;

    bRW = Math.min(bRW, view.getXmax() + EuclidianStatic.CLIP_DISTANCE);
    if (bRW < view.getXmin() - EuclidianStatic.CLIP_DISTANCE) return;

    double ax = view.toScreenCoordXd(aRW);
    double bx = view.toScreenCoordXd(bRW);
    float y0 = (float) view.getyZero();

    // plot definite integral

    if (Kernel.isEqual(aRW, bRW)) {
      gp.moveTo(ax, y0);
      gp.lineTo(ax, view.toScreenCoordYd(f.evaluate(aRW)));
      gp.lineTo(ax, y0);
      return;
    }

    gp.moveTo(ax, y0);
    DrawParametricCurve.plotCurve(f, aRW, bRW, view, gp, false, DrawParametricCurve.GAP_LINE_TO);
    gp.lineTo(bx, y0);
    gp.lineTo(ax, y0);

    // gp on screen?
    if (!gp.intersects(0, 0, view.getWidth(), view.getHeight())) {
      isVisible = false;
      // don't return here to make sure that getBounds() works for
      // offscreen points too
    }

    if (labelVisible) {
      xLabel = (int) Math.round((ax + bx) / 2) - 6;
      yLabel = (int) view.getyZero() - view.getFontSize();
      labelDesc = geo.getLabelDescription();
      addLabelOffset();
    }
  }
  private void addAxesRatioItems(JMenu menu) {
    ActionListener al =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              zoomYaxis(Double.parseDouble(e.getActionCommand()));
            } catch (Exception ex) {
            }
          }
        };

    // get current axes ratio
    double scaleRatio = ((AbstractEuclidianView) app.getActiveEuclidianView()).getScaleRatio();

    JMenuItem mi;
    // int perc;
    // ImageIcon icon;
    boolean separatorAdded = false;
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < axesRatios.length; i++) {
      // build text like "1 : 2"
      sb.setLength(0);
      if (axesRatios[i] > 1.0) {
        sb.append((int) axesRatios[i]);
        sb.append(" : 1");
        if (!separatorAdded) {
          menu.addSeparator();
          separatorAdded = true;
        }

      } else { // factor
        if (axesRatios[i] == 1) menu.addSeparator();
        sb.append("1 : ");
        sb.append((int) (1.0 / axesRatios[i]));
      }

      mi = new JCheckBoxMenuItem(sb.toString());
      mi.setSelected(Kernel.isEqual(axesRatios[i], scaleRatio));
      mi.setActionCommand("" + axesRatios[i]);
      mi.addActionListener(al);
      mi.setBackground(getBackground());
      menu.add(mi);
    }
  }