コード例 #1
0
 public void setDefaultColor(float alpha, geogebra.common.awt.GColor gc) {
   defaultColor = gc;
   if (gc != null)
     this.setIcon(
         GeoGebraIcon.createColorSwatchIcon(
             alpha, iconSize, geogebra.awt.GColorD.getAwtColor(gc), null));
   else this.setIcon(GeoGebraIcon.createNullSymbolIcon(iconSize.width, iconSize.height));
 }
コード例 #2
0
 private static ImageIcon[] getColorSwatchIcons(
     geogebra.common.awt.GColor[] colorArray, float alpha, Dimension iconSize, int colorSetType) {
   ImageIcon[] a = new ImageIcon[colorArray.length];
   for (int i = 0; i < colorArray.length; i++)
     if (colorArray[i] != null) {
       a[i] =
           GeoGebraIcon.createColorSwatchIcon(
               alpha, iconSize, geogebra.awt.GColorD.getAwtColor(colorArray[i]), null);
     } else {
       a[i] = GeoGebraIcon.createNullSymbolIcon(iconSize.width, iconSize.height);
     }
   return a;
 }
コード例 #3
0
  private static ImageIcon[] createDummyIcons(Dimension iconSize) {

    ImageIcon[] a = new ImageIcon[27];
    for (int i = 0; i < 27; i++) {
      a[i] = GeoGebraIcon.createEmptyIcon(iconSize.width, iconSize.height);
    }
    return a;
  }
コード例 #4
0
 @Override
 public ImageIcon getButtonIcon() {
   ImageIcon icon = super.getButtonIcon();
   if (icon == null && this.hasSlider) {
     icon =
         GeoGebraIcon.createColorSwatchIcon(
             getSliderValue() / 100f,
             iconSize,
             geogebra.awt.GColorD.getAwtColor(defaultColor),
             null);
   }
   return icon;
 }
コード例 #5
0
  /** Add a history popup list and an embedded popup button. See AlgebraInputBar */
  public void addHistoryPopup(boolean isDownPopup) {

    if (historyPopup == null) historyPopup = new HistoryPopup(this);

    historyPopup.setDownPopup(isDownPopup);

    ActionListener al =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String cmd = e.getActionCommand();
            if (cmd.equals(1 + BorderButton.cmdSuffix)) {

              // TODO: should up/down orientation be tied to InputBar?
              // show popup
              historyPopup.showPopup();
            }
          }
        };
    setBorderButton(1, GeoGebraIcon.createUpDownTriangleIcon(false, true), al);
    this.setBorderButtonVisible(1, false);
  }
コード例 #6
0
  protected void createButtons() {

    // ========================================
    // mode button

    ImageIcon[] modeArray =
        new ImageIcon[] {
          app.getImageIcon("cursor_arrow.png"),
          app.getImageIcon("applications-graphics.png"),
          app.getImageIcon("delete_small.gif"),
          app.getImageIcon("mode_point_16.gif"),
          app.getImageIcon("mode_copyvisualstyle_16.png")
        };

    // ========================================
    // pen button
    btnPen =
        new MyToggleButton(
            ((AppD) ev.getApplication()).getImageIcon("applications-graphics.png"), iconHeight) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {
            this.setVisible(
                (geos.length == 0 && mode == EuclidianConstants.MODE_MOVE)
                    || EuclidianView.isPenMode(mode));
          }
        };
    btnPen.addActionListener(this);
    // add(btnPen);

    // ========================================
    // delete button
    btnDelete =
        new MyToggleButton(
            ((AppD) ev.getApplication()).getImageIcon("delete_small.gif"), iconHeight) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {
            this.setVisible(
                (geos.length == 0 && mode == EuclidianConstants.MODE_MOVE)
                    || mode == EuclidianConstants.MODE_DELETE);
          }
        };
    btnDelete.addActionListener(this);
    add(btnDelete);

    // ========================================
    // delete-drag square size
    btnDeleteSize =
        new PopupMenuButton(app, null, 0, 0, iconDimension, 0, false, true) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {
            this.setVisible(mode == EuclidianConstants.MODE_DELETE);
          }
        };
    btnDeleteSize.getMySlider().setMinimum(10);
    btnDeleteSize.getMySlider().setMaximum(100);
    btnDeleteSize.getMySlider().setMajorTickSpacing(20);
    btnDeleteSize.getMySlider().setMinorTickSpacing(5);
    btnDeleteSize.getMySlider().setPaintTicks(true);
    btnDeleteSize.addActionListener(this);
    btnDeleteSize.setIcon(app.getImageIcon("delete_small.gif"));

    // ========================================
    // show axes button
    btnShowAxes =
        new MyToggleButton(app.getImageIcon("axes.gif"), iconHeight) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {
            // always show this button unless in pen mode
            this.setVisible(!EuclidianView.isPenMode(mode));
          }
        };

    // btnShowAxes.setPreferredSize(new Dimension(16,16));
    btnShowAxes.addActionListener(this);

    // ========================================
    // show grid button
    btnShowGrid =
        new MyToggleButton(app.getImageIcon("grid.gif"), iconHeight) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {
            // always show this button unless in pen mode
            this.setVisible(!EuclidianView.isPenMode(mode));
          }
        };
    // btnShowGrid.setPreferredSize(new Dimension(16,16));
    btnShowGrid.addActionListener(this);

    // ========================================
    // line style button

    // create line style icon array
    final Dimension lineStyleIconSize = new Dimension(80, iconHeight);
    ImageIcon[] lineStyleIcons = new ImageIcon[EuclidianStyleBarStatic.lineStyleArray.length];
    for (int i = 0; i < EuclidianStyleBarStatic.lineStyleArray.length; i++)
      lineStyleIcons[i] =
          GeoGebraIcon.createLineStyleIcon(
              EuclidianStyleBarStatic.lineStyleArray[i], 2, lineStyleIconSize, Color.BLACK, null);

    // create button
    btnLineStyle =
        new PopupMenuButton(
            app,
            lineStyleIcons,
            -1,
            1,
            lineStyleIconSize,
            geogebra.common.gui.util.SelectionTable.MODE_ICON) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {

            if (EuclidianView.isPenMode(mode)) {
              this.setVisible(true);
              setFgColor(geogebra.awt.GColorD.getAwtColor(ec.getPen().getPenColor()));
              setSliderValue(ec.getPen().getPenSize());
              setSelectedIndex(lineStyleMap.get(ec.getPen().getPenLineStyle()));
            } else {
              boolean geosOK = (geos.length > 0);
              for (int i = 0; i < geos.length; i++) {
                GeoElement geo = ((GeoElement) geos[i]).getGeoElementForPropertiesDialog();
                if (!(geo.isPath()
                    || (geo.isGeoList() ? ((GeoList) geo).showLineProperties() : false)
                    || (geo.isGeoNumeric()
                        ? (((GeoNumeric) geo).isDrawable() || ((GeoNumeric) geo).isSliderFixed())
                        : false)
                    || geo.isGeoAngle())) {
                  geosOK = false;
                  break;
                }
              }

              this.setVisible(geosOK);

              if (geosOK) {
                // setFgColor(((GeoElement)geos[0]).getObjectColor());

                setFgColor(Color.black);
                setSliderValue(((GeoElement) geos[0]).getLineThickness());

                setSelectedIndex(lineStyleMap.get(((GeoElement) geos[0]).getLineType()));

                this.setKeepVisible(mode == EuclidianConstants.MODE_MOVE);
              }
            }
          }

          @Override
          public ImageIcon getButtonIcon() {
            if (getSelectedIndex() > -1) {
              return GeoGebraIcon.createLineStyleIcon(
                  EuclidianStyleBarStatic.lineStyleArray[this.getSelectedIndex()],
                  this.getSliderValue(),
                  lineStyleIconSize,
                  Color.BLACK,
                  null);
            }
            return GeoGebraIcon.createEmptyIcon(lineStyleIconSize.width, lineStyleIconSize.height);
          }
        };

    btnLineStyle.getMySlider().setMinimum(1);
    btnLineStyle.getMySlider().setMaximum(13);
    btnLineStyle.getMySlider().setMajorTickSpacing(2);
    btnLineStyle.getMySlider().setMinorTickSpacing(1);
    btnLineStyle.getMySlider().setPaintTicks(true);
    btnLineStyle.setStandardButton(true); // popup on the whole button
    btnLineStyle.addActionListener(this);

    // ========================================
    // point style button

    // create line style icon array
    final Dimension pointStyleIconSize = new Dimension(20, iconHeight);
    ImageIcon[] pointStyleIcons = new ImageIcon[EuclidianStyleBarStatic.pointStyleArray.length];
    for (int i = 0; i < EuclidianStyleBarStatic.pointStyleArray.length; i++)
      pointStyleIcons[i] =
          GeoGebraIcon.createPointStyleIcon(
              EuclidianStyleBarStatic.pointStyleArray[i], 4, pointStyleIconSize, Color.BLACK, null);

    // create button
    btnPointStyle =
        new PopupMenuButton(
            app,
            pointStyleIcons,
            2,
            -1,
            pointStyleIconSize,
            geogebra.common.gui.util.SelectionTable.MODE_ICON) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {
            GeoElement geo;
            boolean geosOK = (geos.length > 0);
            for (int i = 0; i < geos.length; i++) {
              geo = (GeoElement) geos[i];
              if (!(geo.getGeoElementForPropertiesDialog().isGeoPoint())
                  && (!(geo.isGeoList() && ((GeoList) geo).showPointProperties()))) {
                geosOK = false;
                break;
              }
            }
            this.setVisible(geosOK);

            if (geosOK) {
              // setFgColor(((GeoElement)geos[0]).getObjectColor());
              setFgColor(Color.black);

              // if geo is a matrix, this will return a GeoNumeric...
              geo = ((GeoElement) geos[0]).getGeoElementForPropertiesDialog();

              // ... so need to check
              if (geo instanceof PointProperties) {
                setSliderValue(((PointProperties) geo).getPointSize());
                int pointStyle = ((PointProperties) geo).getPointStyle();
                if (pointStyle == -1) // global default point style
                pointStyle = EuclidianStyleConstants.POINT_STYLE_DOT;
                setSelectedIndex(pointStyleMap.get(pointStyle));
                this.setKeepVisible(mode == EuclidianConstants.MODE_MOVE);
              }
            }
          }

          @Override
          public ImageIcon getButtonIcon() {
            if (getSelectedIndex() > -1) {
              return GeoGebraIcon.createPointStyleIcon(
                  EuclidianStyleBarStatic.pointStyleArray[this.getSelectedIndex()],
                  this.getSliderValue(),
                  pointStyleIconSize,
                  Color.BLACK,
                  null);
            }
            return GeoGebraIcon.createEmptyIcon(
                pointStyleIconSize.width, pointStyleIconSize.height);
          }
        };
    btnPointStyle.getMySlider().setMinimum(1);
    btnPointStyle.getMySlider().setMaximum(9);
    btnPointStyle.getMySlider().setMajorTickSpacing(2);
    btnPointStyle.getMySlider().setMinorTickSpacing(1);
    btnPointStyle.getMySlider().setPaintTicks(true);
    btnPointStyle.setStandardButton(true); // popup on the whole button
    btnPointStyle.addActionListener(this);

    // ========================================
    // caption style button

    String[] captionArray =
        new String[] {
          app.getPlain("stylebar.Hidden"), // index
          // 4
          app.getPlain("Name"), // index 0
          app.getPlain("NameAndValue"), // index 1
          app.getPlain("Value"), // index 2
          app.getPlain("Caption") // index 3
        };

    btnLabelStyle =
        new PopupMenuButton(
            app,
            captionArray,
            -1,
            1,
            new Dimension(0, iconHeight),
            geogebra.common.gui.util.SelectionTable.MODE_TEXT) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {
            boolean geosOK = false;
            GeoElement geo = null;
            if (mode == EuclidianConstants.MODE_MOVE) {
              for (int i = 0; i < geos.length; i++) {
                if (((GeoElement) geos[i]).isLabelShowable()
                    || ((GeoElement) geos[i]).isGeoAngle()
                    || (((GeoElement) geos[i]).isGeoNumeric()
                        ? ((GeoNumeric) geos[i]).isSliderFixed()
                        : false)) {
                  geo = (GeoElement) geos[i];
                  geosOK = true;
                  break;
                }
              }
            } else if (app.getLabelingStyle() == ConstructionDefaults.LABEL_VISIBLE_ALWAYS_OFF) {
              this.setVisible(false);
              return;
            } else if (app.getLabelingStyle() == ConstructionDefaults.LABEL_VISIBLE_POINTS_ONLY) {
              for (int i = 0; i < geos.length; i++) {
                if (((GeoElement) geos[i]).isLabelShowable()
                    && ((GeoElement) geos[i]).isGeoPoint()) {
                  geo = (GeoElement) geos[i];
                  geosOK = true;
                  break;
                }
              }
            } else {
              for (int i = 0; i < geos.length; i++) {
                if (((GeoElement) geos[i]).isLabelShowable()
                    || ((GeoElement) geos[i]).isGeoAngle()
                    || (((GeoElement) geos[i]).isGeoNumeric()
                        ? ((GeoNumeric) geos[i]).isSliderFixed()
                        : false)) {
                  geo = (GeoElement) geos[i];
                  geosOK = true;
                  break;
                }
              }
            }
            this.setVisible(geosOK);

            if (geosOK) {
              if (!geo.isLabelVisible()) setSelectedIndex(0);
              else setSelectedIndex(geo.getLabelMode() + 1);
            }
          }

          @Override
          public ImageIcon getButtonIcon() {
            return (ImageIcon) this.getIcon();
          }
        };
    ImageIcon ic = app.getImageIcon("mode_showhidelabel_16.gif");
    btnLabelStyle.setIconSize(new Dimension(ic.getIconWidth(), iconHeight));
    btnLabelStyle.setIcon(ic);
    btnLabelStyle.setStandardButton(true);
    btnLabelStyle.addActionListener(this);
    btnLabelStyle.setKeepVisible(false);

    // ========================================
    // point capture button

    String[] strPointCapturing = {
      app.getMenu("Labeling.automatic"),
      app.getMenu("SnapToGrid"),
      app.getMenu("FixedToGrid"),
      app.getMenu("off")
    };

    btnPointCapture =
        new PopupMenuButton(
            app,
            strPointCapturing,
            -1,
            1,
            new Dimension(0, iconHeight),
            geogebra.common.gui.util.SelectionTable.MODE_TEXT) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {
            // always show this button unless in pen mode
            this.setVisible(!EuclidianView.isPenMode(mode));
          }

          @Override
          public ImageIcon getButtonIcon() {
            return (ImageIcon) this.getIcon();
          }
        };
    ImageIcon ptCaptureIcon = app.getImageIcon("magnet2.gif");
    btnPointCapture.setIconSize(new Dimension(ptCaptureIcon.getIconWidth(), iconHeight));
    btnPointCapture.setIcon(ptCaptureIcon);
    btnPointCapture.setStandardButton(true); // popup on the whole button
    btnPointCapture.addActionListener(this);
    btnPointCapture.setKeepVisible(false);

    // ========================================
    // fixed position button
    btnFixPosition =
        new MyToggleButton(app.getImageIcon("pin.png"), iconHeight) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {

            boolean geosOK = checkGeos(geos);

            setVisible(geosOK);
            if (geosOK) {
              if (geos[0] instanceof AbsoluteScreenLocateable
                  && !((GeoElement) geos[0]).isGeoList()) {
                AbsoluteScreenLocateable geo =
                    (AbsoluteScreenLocateable)
                        ((GeoElement) geos[0]).getGeoElementForPropertiesDialog();
                btnFixPosition.setSelected(geo.isAbsoluteScreenLocActive());
              } else if (((GeoElement) geos[0]).getParentAlgorithm()
                  instanceof AlgoAttachCopyToView) {
                btnFixPosition.setSelected(true);
              } else {
                btnFixPosition.setSelected(false);
              }
            }
          }

          private boolean checkGeos(Object[] geos) {
            if (geos.length <= 0) {
              return false;
            }

            for (int i = 0; i < geos.length; i++) {
              GeoElement geo = (GeoElement) geos[i];

              if (!geo.isPinnable()) {
                return false;
              }

              if (geo.isGeoSegment()) {
                if (geo.getParentAlgorithm() != null
                    && geo.getParentAlgorithm().getInput().length == 3) {
                  // segment is output from a Polygon
                  return false;
                }
              }
            }
            return true;
          }
        };
    btnFixPosition.addActionListener(this);
  }
コード例 #7
0
  private void createTableTextButtons() {
    Dimension iconDimension = new Dimension(16, iconHeight);

    // ==============================
    // justification popup
    ImageIcon[] justifyIcons =
        new ImageIcon[] {
          app.getImageIcon("format-justify-left.png"),
          app.getImageIcon("format-justify-center.png"),
          app.getImageIcon("format-justify-right.png")
        };
    btnTableTextJustify =
        new PopupMenuButton(
            (AppD) ev.getApplication(),
            justifyIcons,
            1,
            -1,
            new Dimension(20, iconHeight),
            geogebra.common.gui.util.SelectionTable.MODE_ICON) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {
            if (tableText != null) {
              this.setVisible(true);
              String justification = tableText.getJustification();
              if (justification.equals("c")) btnTableTextJustify.setSelectedIndex(1);
              else if (justification.equals("r")) btnTableTextJustify.setSelectedIndex(2);
              else btnTableTextJustify.setSelectedIndex(0); // left align

            } else {
              this.setVisible(false);
            }
          }
        };

    btnTableTextJustify.addActionListener(this);
    btnTableTextJustify.setKeepVisible(false);

    // ==============================
    // bracket style popup

    ImageIcon[] bracketIcons = new ImageIcon[EuclidianStyleBarStatic.bracketArray.length];
    for (int i = 0; i < bracketIcons.length; i++) {
      bracketIcons[i] =
          GeoGebraIcon.createStringIcon(
              EuclidianStyleBarStatic.bracketArray[i],
              app.getPlainFont(),
              true,
              false,
              true,
              new Dimension(30, iconHeight),
              Color.BLACK,
              null);
    }

    btnTableTextBracket =
        new PopupMenuButton(
            (AppD) ev.getApplication(),
            bracketIcons,
            2,
            -1,
            new Dimension(30, iconHeight),
            geogebra.common.gui.util.SelectionTable.MODE_ICON) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {
            if (tableText != null) {
              this.setVisible(true);
              String s = tableText.getOpenSymbol() + " " + tableText.getCloseSymbol();
              int index = 0;
              for (int i = 0; i < EuclidianStyleBarStatic.bracketArray.length; i++) {
                if (s.equals(EuclidianStyleBarStatic.bracketArray[i])) {
                  index = i;
                  break;
                }
              }
              // System.out.println("index" + index);
              btnTableTextBracket.setSelectedIndex(index);

            } else {
              this.setVisible(false);
            }
          }
        };

    btnTableTextBracket.addActionListener(this);
    btnTableTextBracket.setKeepVisible(false);

    // ====================================
    // vertical grid lines toggle button
    btnTableTextLinesV =
        new MyToggleButton(GeoGebraIcon.createVGridIcon(iconDimension), iconHeight) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {
            if (tableText != null) {
              setVisible(true);
              setSelected(tableText.isVerticalLines());
            } else {
              setVisible(false);
            }
          }
        };
    btnTableTextLinesV.addActionListener(this);

    // ====================================
    // horizontal grid lines toggle button
    btnTableTextLinesH =
        new MyToggleButton(GeoGebraIcon.createHGridIcon(iconDimension), iconHeight) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {
            if (tableText != null) {
              setVisible(true);
              setSelected(tableText.isHorizontalLines());
            } else {
              setVisible(false);
            }
          }
        };
    btnTableTextLinesH.addActionListener(this);
  }
コード例 #8
0
  private void createTextButtons() {

    // ========================
    // text color button
    final Dimension textColorIconSize = new Dimension(20, iconHeight);

    btnTextColor =
        new ColorPopupMenuButton(
            app, textColorIconSize, ColorPopupMenuButton.COLORSET_DEFAULT, false) {

          private static final long serialVersionUID = 1L;

          private Color geoColor;

          @Override
          public void update(Object[] geos) {

            boolean geosOK = checkGeoText(geos);
            setVisible(geosOK);

            if (geosOK) {
              GeoElement geo = ((GeoElement) geos[0]).getGeoElementForPropertiesDialog();
              geoColor = geogebra.awt.GColorD.getAwtColor(geo.getObjectColor());
              updateColorTable();

              // find the geoColor in the table and select it
              int index = this.getColorIndex(geoColor);
              setSelectedIndex(index);

              // if nothing was selected, set the icon to show the
              // non-standard color
              if (index == -1) {
                this.setIcon(getButtonIcon());
              }

              setFgColor(geoColor);
              setFontStyle(((TextProperties) geo).getFontStyle());
            }
          }

          @Override
          public ImageIcon getButtonIcon() {
            return GeoGebraIcon.createTextSymbolIcon(
                "A",
                app.getPlainFont(),
                textColorIconSize,
                geogebra.awt.GColorD.getAwtColor(getSelectedColor()),
                null);
          }
        };

    btnTextColor.setStandardButton(true); // popup on the whole button
    btnTextColor.addActionListener(this);

    // ========================================
    // bold text button
    ImageIcon boldIcon =
        GeoGebraIcon.createStringIcon(
            app.getPlain("Bold").substring(0, 1),
            app.getPlainFont(),
            true,
            false,
            true,
            iconDimension,
            Color.black,
            null);
    btnBold =
        new MyToggleButton(boldIcon, iconHeight) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {

            boolean geosOK = checkGeoText(geos);
            setVisible(geosOK);
            if (geosOK) {
              GeoElement geo = ((GeoElement) geos[0]).getGeoElementForPropertiesDialog();
              int style = ((TextProperties) geo).getFontStyle();
              btnBold.setSelected(style == Font.BOLD || style == (Font.BOLD + Font.ITALIC));
            }
          }
        };
    btnBold.addActionListener(this);

    // ========================================
    // italic text button
    ImageIcon italicIcon =
        GeoGebraIcon.createStringIcon(
            app.getPlain("Italic").substring(0, 1),
            app.getPlainFont(),
            false,
            true,
            true,
            iconDimension,
            Color.black,
            null);
    btnItalic =
        new MyToggleButton(italicIcon, iconHeight) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {

            boolean geosOK = checkGeoText(geos);
            setVisible(geosOK);
            this.setVisible(geosOK);
            if (geosOK) {
              GeoElement geo = ((GeoElement) geos[0]).getGeoElementForPropertiesDialog();
              int style = ((TextProperties) geo).getFontStyle();
              btnItalic.setSelected(style == Font.ITALIC || style == (Font.BOLD + Font.ITALIC));
            }
          }
        };
    btnItalic.addActionListener(this);

    // ========================================
    // text size button

    String[] textSizeArray = app.getFontSizeStrings();

    btnTextSize =
        new PopupMenuButton(
            app,
            textSizeArray,
            -1,
            1,
            new Dimension(-1, iconHeight),
            geogebra.common.gui.util.SelectionTable.MODE_TEXT) {

          private static final long serialVersionUID = 1L;

          @Override
          public void update(Object[] geos) {

            boolean geosOK = checkGeoText(geos);
            setVisible(geosOK);

            if (geosOK) {
              GeoElement geo = ((GeoElement) geos[0]).getGeoElementForPropertiesDialog();
              setSelectedIndex(
                  GeoText.getFontSizeIndex(
                      ((TextProperties) geo).getFontSizeMultiplier())); // font size ranges from
              // -4 to 4, transform
              // this to 0,1,..,4
            }
          }
        };
    btnTextSize.addActionListener(this);
    btnTextSize.setStandardButton(true); // popup on the whole button
    btnTextSize.setKeepVisible(false);
  }
コード例 #9
0
  public void dragGestureRecognized(DragGestureEvent dge) {

    if (geoLabelList == null) geoLabelList = new ArrayList<String>();
    else geoLabelList.clear();

    for (GeoElement geo : selection.getSelectedGeos()) {
      geoLabelList.add(geo.getLabel(StringTemplate.defaultTemplate));
    }

    // if we have something ... do the drag!
    if (geoLabelList.size() > 0) {

      String latex;

      boolean showJustFirstGeoInDrag = false;

      if (selection.getSelectedGeos().size() == 1) {
        showJustFirstGeoInDrag = true;
      } else {

        // workaround for http://forge.scilab.org/index.php/p/jlatexmath/issues/749/#preview
        for (GeoElement geo : selection.getSelectedGeos()) {
          if (geo.isGeoCurveCartesian()) {
            showJustFirstGeoInDrag = true;
            break;
          }
        }
      }

      if (showJustFirstGeoInDrag) {
        latex =
            selection
                .getSelectedGeos()
                .get(0)
                .getLaTeXAlgebraDescription(true, StringTemplate.latexTemplate);
      } else {

        // create drag image
        StringBuilder sb = new StringBuilder();
        sb.append("\\fbox{\\begin{array}{l}");
        for (GeoElement geo : selection.getSelectedGeos()) {
          sb.append(geo.getLaTeXAlgebraDescription(true, StringTemplate.latexTemplate));
          sb.append("\\\\");
        }
        sb.append("\\end{array}}");
        latex = sb.toString();
      }
      ImageIcon ic =
          GeoGebraIcon.createLatexIcon(
              (AppD) app, latex, ((AppD) app).getPlainFont(), false, Color.DARK_GRAY, null);

      // start drag
      ds.startDrag(
          dge,
          DragSource.DefaultCopyDrop,
          ic.getImage(),
          new Point(-5, -30),
          new TransferableAlgebraView(geoLabelList),
          this);
    }
  }