예제 #1
0
  /** Update localization */
  public void setLabels() {
    initGUI();

    btnUseAsText.setToolTipText(loc.getPlainTooltip("stylebar.UseAsText"));
    btnTextColor.setToolTipText(loc.getPlainTooltip("stylebar.TextColor"));
    btnTextSize.setToolTipText(loc.getPlainTooltip("stylebar.TextSize"));
    btnBold.setToolTipText(loc.getPlainTooltip("stylebar.Bold"));
    btnItalic.setToolTipText(loc.getPlainTooltip("stylebar.Italic"));
  }
예제 #2
0
  private void applyTextSize(ArrayList<GeoElement> geos) {

    double fontSize =
        GeoText.getRelativeFontSize(
            btnTextSize.getSelectedIndex()); // transform indices to the range -4, .. ,
    // 4

    for (int i = 0; i < geos.size(); i++) {
      GeoElement geo = geos.get(i);
      if (geo instanceof GeoCasCell
          && ((GeoCasCell) geo).getGeoText().getFontSizeMultiplier() != fontSize) {
        ((GeoCasCell) geo).setFontSizeMultiplier(fontSize);
        geo.updateRepaint();
        needUndo = true;
      }
    }
  }
예제 #3
0
  private void createTextButtons() {

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

    btnTextColor =
        new ColorPopupMenuButton(
            app, textColoriconHeight, 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 =
                  org.geogebra.desktop.awt.GColorD.getAwtColor(((GeoCasCell) geo).getFontColor());
              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(),
                textColoriconHeight,
                org.geogebra.desktop.awt.GColorD.getAwtColor(getSelectedColor()),
                null);
          }
        };

    btnTextColor.addActionListener(this);

    // ========================================
    // use as text button
    ImageIcon useAsTextIcon =
        GeoGebraIcon.createStringIcon(
            app.getPlain("Text").substring(0, 1),
            app.getPlainFont(),
            true,
            false,
            true,
            iconDimension,
            Color.black,
            null);
    btnUseAsText =
        new MyToggleButton(useAsTextIcon, iconHeight) {

          private static final long serialVersionUID = 1L;

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

            setVisible(true);
            btnUseAsText.setSelected(checkGeoText(geos));
          }
        };
    btnUseAsText.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 = ((GeoCasCell) geo).getGeoText().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 = ((GeoCasCell) geo).getGeoText().getFontStyle();
              btnItalic.setSelected(style == Font.ITALIC || style == (Font.BOLD + Font.ITALIC));
            }
          }
        };
    btnItalic.addActionListener(this);

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

    String[] textSizeArray = app.getLocalization().getFontSizeStrings();

    btnTextSize =
        new PopupMenuButton(
            app,
            textSizeArray,
            -1,
            1,
            new Dimension(-1, iconHeight),
            org.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]);
              setSelectedIndex(
                  GeoText.getFontSizeIndex(
                      ((GeoCasCell) geo).getFontSizeMultiplier())); // font size
              // ranges from
              // -4 to 4, transform
              // this to 0,1,..,4
            }
          }
        };
    btnTextSize.addActionListener(this);
    btnTextSize.setKeepVisible(false);
  }