Esempio n. 1
0
  /** Append a downward triangle image to the right hand side of an input icon. */
  @Override
  public void setIcon(Icon icon) {

    if (isFixedIcon) {
      super.setIcon(icon);
      return;
    }

    if (iconSize == null)
      if (icon != null) iconSize = new Dimension(icon.getIconWidth(), icon.getIconHeight());
      else iconSize = new Dimension(1, 1);

    if (icon == null) {
      // icon = GeoGebraIcon.createEmptyIcon(1, iconSize.height);
    } else {
      icon = GeoGebraIcon.ensureIconSize((ImageIcon) icon, iconSize);
    }

    // add a down_triangle image to the left of the icon
    if (icon != null)
      super.setIcon(
          GeoGebraIcon.joinIcons((ImageIcon) icon, app.getImageIcon("triangle-down.png")));
    else super.setIcon(app.getImageIcon("triangle-down.png"));
  }
Esempio n. 2
0
  public ImageIcon getButtonIcon() {

    ImageIcon icon = (ImageIcon) this.getIcon();
    if (isFixedIcon) return icon;

    // draw the icon for the current table selection
    if (hasTable) {
      switch (mode) {
        case SelectionTable.MODE_TEXT:
          // Strings are converted to icons. We don't use setText so that the button size can be
          // controlled
          // regardless of the layout manager.

          icon =
              GeoGebraIcon.createStringIcon(
                  (String) data[getSelectedIndex()],
                  app.getPlainFont(),
                  false,
                  false,
                  true,
                  iconSize,
                  Color.BLACK,
                  null);

          break;

        case SelectionTable.MODE_ICON:
        case SelectionTable.MODE_LATEX:
          icon = (ImageIcon) myTable.getSelectedValue();
          break;

        default:
          icon = myTable.getDataIcon(data[getSelectedIndex()]);
      }
    }
    return icon;
  }