private void updateButtons() {
   // -----------------------------------------------------
   // update the buttons
   // note: this must always be done, even when activeGeoList is empty
   // -----------------------------------------------------
   Object[] geos = activeGeoList.toArray();
   tableText = EuclidianStyleBarStatic.updateTableText(geos, mode);
   for (int i = 0; i < popupBtnList.length; i++) {
     popupBtnList[i].update(geos);
   }
   for (int i = 0; i < toggleBtnList.length; i++) {
     toggleBtnList[i].update(geos);
   }
 }
  /**
   * *********************************************** Constructs a styleBar
   *
   * @param ev view
   */
  public EuclidianStyleBarD(EuclidianViewInterfaceCommon ev) {

    isIniting = true;

    this.ev = ev;
    ec = (EuclidianControllerD) ev.getEuclidianController();
    app = (AppD) ev.getApplication();
    cons = app.getKernel().getConstruction();

    // init handling of default geos
    defaultGeoMap = EuclidianStyleBarStatic.createDefaultMap();
    defaultGeos = new ArrayList<GeoElement>();

    // toolbar display settings
    setFloatable(false);
    Dimension d = getPreferredSize();
    d.height = iconHeight + 8;
    setPreferredSize(d);

    // init button-specific fields
    // TODO: put these in button classes
    EuclidianStyleBarStatic.pointStyleArray = EuclidianView.getPointStyles();
    pointStyleMap = new HashMap<Integer, Integer>();
    for (int i = 0; i < EuclidianStyleBarStatic.pointStyleArray.length; i++)
      pointStyleMap.put(EuclidianStyleBarStatic.pointStyleArray[i], i);

    EuclidianStyleBarStatic.lineStyleArray = EuclidianView.getLineTypes();
    lineStyleMap = new HashMap<Integer, Integer>();
    for (int i = 0; i < EuclidianStyleBarStatic.lineStyleArray.length; i++)
      lineStyleMap.put(EuclidianStyleBarStatic.lineStyleArray[i], i);

    setLabels(); // this will also init the GUI

    isIniting = false;

    setMode(ev.getMode()); // this will also update the stylebar
  }
  /**
   * process the action performed
   *
   * @param source
   * @param targetGeos
   */
  protected void processSource(Object source, ArrayList<GeoElement> targetGeos) {

    if ((source instanceof JButton)
        && (EuclidianStyleBarStatic.processSourceCommon(
            ((JButton) source).getActionCommand(), targetGeos, ev))) return;
    else if (source == btnColor) {
      if (EuclidianView.isPenMode(mode)) {
        ec.getPen().setPenColor((btnColor.getSelectedColor()));
        // btnLineStyle.setFgColor((Color)btnColor.getSelectedValue());
      } else {
        GColor color = btnColor.getSelectedColor();
        float alpha = btnColor.getSliderValue() / 100.0f;
        needUndo = EuclidianStyleBarStatic.applyColor(targetGeos, color, alpha, app);
        // btnLineStyle.setFgColor((Color)btnColor.getSelectedValue());
        // btnPointStyle.setFgColor((Color)btnColor.getSelectedValue());
      }
    } else if (source == btnBgColor) {
      if (btnBgColor.getSelectedIndex() >= 0) {
        GColor color = btnBgColor.getSelectedColor();
        float alpha = btnBgColor.getSliderValue() / 100.0f;
        needUndo = EuclidianStyleBarStatic.applyBgColor(targetGeos, color, alpha);
      }
    } else if (source == btnTextColor) {
      if (btnTextColor.getSelectedIndex() >= 0) {
        GColor color = btnTextColor.getSelectedColor();
        needUndo = EuclidianStyleBarStatic.applyTextColor(targetGeos, color);
        // btnTextColor.setFgColor((Color)btnTextColor.getSelectedValue());
        // btnItalic.setForeground((Color)btnTextColor.getSelectedValue());
        // btnBold.setForeground((Color)btnTextColor.getSelectedValue());
      }
    } else if (source == btnLineStyle) {
      if (btnLineStyle.getSelectedValue() != null) {
        if (EuclidianView.isPenMode(mode)) {
          ec.getPen()
              .setPenLineStyle(
                  EuclidianStyleBarStatic.lineStyleArray[btnLineStyle.getSelectedIndex()]);
          ec.getPen().setPenSize(btnLineStyle.getSliderValue());
        } else {
          int selectedIndex = btnLineStyle.getSelectedIndex();
          int lineSize = btnLineStyle.getSliderValue();
          needUndo = EuclidianStyleBarStatic.applyLineStyle(targetGeos, selectedIndex, lineSize);
        }
      }
    } else if (source == btnPointStyle) {
      if (btnPointStyle.getSelectedValue() != null) {
        int pointStyleSelIndex = btnPointStyle.getSelectedIndex();
        int pointSize = btnPointStyle.getSliderValue();
        needUndo =
            EuclidianStyleBarStatic.applyPointStyle(targetGeos, pointStyleSelIndex, pointSize);
      }
    } else if (source == btnBold) {
      needUndo =
          EuclidianStyleBarStatic.applyFontStyle(
              targetGeos, btnBold.isSelected() ? GFont.BOLD : GFont.PLAIN);
    } else if (source == btnItalic) {
      needUndo =
          EuclidianStyleBarStatic.applyFontStyle(
              targetGeos, btnItalic.isSelected() ? GFont.ITALIC : GFont.PLAIN);
    } else if (source == btnTextSize) {
      needUndo = EuclidianStyleBarStatic.applyTextSize(targetGeos, btnTextSize.getSelectedIndex());
    } else if (source == btnLabelStyle) {
      needUndo =
          EuclidianStyleBarStatic.applyCaptionStyle(
              targetGeos, mode, btnLabelStyle.getSelectedIndex());
    } else if (source == btnTableTextJustify
        || source == btnTableTextLinesH
        || source == btnTableTextLinesV
        || source == btnTableTextBracket) {
      EuclidianStyleBarStatic.applyTableTextFormat(
          targetGeos,
          btnTableTextJustify.getSelectedIndex(),
          btnTableTextLinesH.isSelected(),
          btnTableTextLinesV.isSelected(),
          btnTableTextBracket.getSelectedIndex(),
          app);
    } else if (source == btnDeleteSize) {
      ec.setDeleteToolSize(btnDeleteSize.getSliderValue());
    } else if (source == btnFixPosition) {
      needUndo =
          EuclidianStyleBarStatic.applyFixPosition(targetGeos, btnFixPosition.isSelected(), ev)
              != null;
    }
  }