Beispiel #1
0
  /**
   * The padding between the "content area" (that is, the icon rect and text rect) and the edges of
   * this button. This is a calculated value.
   */
  protected Insets getContentInsets(AbstractButton button) {
    int horizontalPosition = getHorizontalPosition(button);
    int verticalPosition = getVerticalPosition(button);

    Insets i = new Insets(0, 0, 0, 0);
    if (getFocusPainting(button) == PaintFocus.OUTSIDE
        || getFocusPainting(button) == PaintFocus.BOTH) {
      if (horizontalPosition == POS_LEFT || horizontalPosition == POS_ONLY) {
        i.left += focusSize;
      }
      if (horizontalPosition == POS_RIGHT || horizontalPosition == POS_ONLY) {
        i.right += focusSize;
      }
      if (verticalPosition == POS_TOP || verticalPosition == POS_ONLY) {
        i.top += focusSize;
      }
      if (verticalPosition == POS_BOTTOM || verticalPosition == POS_ONLY) {
        i.bottom += focusSize;
      }
    } else {
      if (fill.getShadowHighlight(button) != null
          && (verticalPosition == POS_BOTTOM || verticalPosition == POS_ONLY)) {
        i.bottom++;
      }
    }
    return i;
  }
Beispiel #2
0
 public RoundedShadowBorder() {
   insets = new Insets(0, 0, 0, 0);
   insets.bottom = bottomLeftCorner.getIconHeight() + backgroundThickness;
   insets.top = topLeftCorner.getIconHeight() + backgroundThickness;
   insets.left = topLeftCorner.getIconHeight() + backgroundThickness;
   insets.right = topRightCorner.getIconHeight() + backgroundThickness;
 }
Beispiel #3
0
 @Override
 public Insets getBorderInsets(Component c, Insets insets) {
   insets.left = 2;
   insets.top = 2;
   insets.right = insets.bottom = 3;
   return insets;
 }
Beispiel #4
0
 public Insets getBorderInsets(Component c, Insets insets) {
   insets.left = 0;
   insets.top = 0;
   insets.right = 0;
   insets.bottom = gap;
   return insets;
 }
 @Override
 public Insets getBorderInsets(Component c) {
   Dimension size = comp.getPreferredSize();
   Insets insets = border.getBorderInsets(c);
   insets.top = Math.max(insets.top, size.height);
   return insets;
 }
Beispiel #6
0
 public java.awt.Insets getBorderInsets(java.awt.Component c, java.awt.Insets insets) {
   insets.top = includeTop ? thickness : 0;
   insets.left = includeLeft ? thickness : 0;
   insets.bottom = includeBottom ? thickness : 0;
   insets.right = includeRight ? thickness : 0;
   return insets;
 }
 /**
  * returns - b.getBorderInsets(c) if border is opaque - null if border is completely non-opaque -
  * somewhere inbetween if border is compound and outside border is opaque and inside isn't
  *
  * @param b the b
  * @param c the c
  * @return the opaque insets
  */
 private static Insets getOpaqueInsets(Border b, Component c) {
   if (b == null) {
     return null;
   }
   if (b.isBorderOpaque()) {
     return b.getBorderInsets(c);
   } else if (b instanceof CompoundBorder) {
     CompoundBorder cb = (CompoundBorder) b;
     Insets iOut = getOpaqueInsets(cb.getOutsideBorder(), c);
     if (iOut != null && iOut.equals(cb.getOutsideBorder().getBorderInsets(c))) {
       // Outside border is opaque, keep looking
       Insets iIn = getOpaqueInsets(cb.getInsideBorder(), c);
       if (iIn == null) {
         // Inside is non-opaque, use outside insets
         return iOut;
       } else {
         // Found non-opaque somewhere in the inside (which is
         // also compound).
         return new Insets(
             iOut.top + iIn.top,
             iOut.left + iIn.left,
             iOut.bottom + iIn.bottom,
             iOut.right + iIn.right);
       }
     } else {
       // Outside is either all non-opaque or has non-opaque
       // border inside another compound border
       return iOut;
     }
   } else {
     return null;
   }
 }
Beispiel #8
0
 public Insets getBorderInsets(Component c, Insets newInsets) {
   newInsets.top = 3;
   newInsets.left = 1;
   newInsets.bottom = 2;
   newInsets.right = 1;
   return newInsets;
 }
Beispiel #9
0
 /**
  * Adds a radio button group.
  *
  * @param label group label (or null)
  * @param items radio button labels
  * @param rows number of rows
  * @param columns number of columns
  * @param defaultItem button initially selected
  */
 public void addRadioButtonGroup(
     String label, String[] items, int rows, int columns, String defaultItem) {
   Panel panel = new Panel();
   int n = items.length;
   panel.setLayout(new GridLayout(rows, columns, 0, 0));
   CheckboxGroup cg = new CheckboxGroup();
   for (int i = 0; i < n; i++) {
     Checkbox cb = new Checkbox(items[i], cg, items[i].equals(defaultItem));
     cb.addItemListener(this);
     panel.add(cb);
   }
   if (radioButtonGroups == null) radioButtonGroups = new Vector();
   radioButtonGroups.addElement(cg);
   Insets insets = getInsets(5, 10, 0, 0);
   if (label == null || label.equals("")) {
     label = "rbg" + radioButtonGroups.size();
     insets.top += 5;
   } else {
     setInsets(10, insets.left, 0);
     addMessage(label);
     insets.top = 2;
     insets.left += 10;
   }
   c.gridx = 0;
   c.gridy = y;
   c.gridwidth = 2;
   c.anchor = GridBagConstraints.WEST;
   c.insets = new Insets(insets.top, insets.left, 0, 0);
   grid.setConstraints(panel, c);
   add(panel);
   if (Recorder.record || macro) saveLabel(cg, label);
   y++;
 }
Beispiel #10
0
 public Insets getBorderInsets(Component c, Insets borderInsets) {
   borderInsets.left = insets.left;
   borderInsets.top = insets.top;
   borderInsets.right = insets.right;
   borderInsets.bottom = insets.bottom;
   return borderInsets;
 }
 /**
  * Reinitialize the insets parameter with this Border's current Insets.
  *
  * @param c the component for which this border insets value applies
  * @param insets the object to be reinitialized
  */
 public Insets getBorderInsets(Component c, Insets insets) {
   insets.left = left;
   insets.top = top;
   insets.right = right;
   insets.bottom = bottom;
   return insets;
 }
 @Override
 public Insets getBorderInsets(Component c, Insets insets) {
   insets.top = INSETS.top;
   insets.left = INSETS.left;
   insets.bottom = INSETS.bottom;
   insets.right = INSETS.right;
   return insets;
 }
 @Override
 public Insets getInsets() {
   Insets insets = super.getInsets();
   if (SystemInfo.isMac && UIUtil.isUnderAquaLookAndFeel() && isEditable) {
     insets.right += 2;
   }
   return insets;
 }
Beispiel #14
0
 public Insets getInsets() {
   Insets in = copy(getRealInsets());
   in.top += getMenuBarHeight() + getWarningWindowHeight();
   if (insLog.isLoggable(Level.FINEST)) {
     insLog.log(Level.FINEST, "Get insets returns {0}", new Object[] {String.valueOf(in)});
   }
   return in;
 }
Beispiel #15
0
 @Override
 public Insets getBorderInsets(Component c, Insets insets) {
   insets.top = 1;
   insets.left = this.calculateLeft(c.getHeight()) + 10;
   insets.bottom = 1;
   insets.right = 1;
   return insets;
 }
Beispiel #16
0
  /**
   * Reinitialize the insets parameter with this Border's current Insets.
   *
   * @param c the component for which this border insets value applies. Ignored.
   * @param insets the object to be reinitialized.
   */
  @Override
  public Insets getBorderInsets(Component c, Insets insets) {
    if (insets == null) {
      throw new IllegalArgumentException("insets");
    }
    insets.left = insets.top = insets.right = insets.bottom = 1;

    return insets;
  }
Beispiel #17
0
 @Override
 public Insets getInsets() {
   Insets insets = super.getInsets();
   if (UIUtil.isUnderGTKLookAndFeel() || UIUtil.isUnderNimbusLookAndFeel()) {
     insets.top += 1;
     insets.bottom += 2;
   }
   return insets;
 }
Beispiel #18
0
 private Insets getVisualMargin(JComponent component) {
   String uid = component.getUIClassID();
   String style = null;
   if (uid == "ButtonUI" || uid == "ToggleButtonUI") {
     style = (String) component.getClientProperty("JButton.buttonType");
   } else if (uid == "ProgressBarUI") {
     style =
         (((JProgressBar) component).getOrientation() == JProgressBar.HORIZONTAL)
             ? "horizontal"
             : "vertical";
   } else if (uid == "SliderUI") {
     style =
         (((JSlider) component).getOrientation() == JProgressBar.HORIZONTAL)
             ? "horizontal"
             : "vertical";
   } else if (uid == "TabbedPaneUI") {
     switch (((JTabbedPane) component).getTabPlacement()) {
       case JTabbedPane.TOP:
         style = "top";
         break;
       case JTabbedPane.LEFT:
         style = "left";
         break;
       case JTabbedPane.BOTTOM:
         style = "bottom";
         break;
       case JTabbedPane.RIGHT:
         style = "right";
         break;
     }
   }
   Insets gap = getInsets(VISUAL_MARGINS, uid, style, 0);
   // Take into account different positions of the button icon
   if (uid == "RadioButtonUI" || uid == "CheckBoxUI") {
     switch (((AbstractButton) component).getHorizontalTextPosition()) {
       case SwingConstants.RIGHT:
         gap = new Insets(gap.top, gap.right, gap.bottom, gap.left);
         break;
       case SwingConstants.CENTER:
         gap = new Insets(gap.top, gap.right, gap.bottom, gap.right);
         break;
         /*
         case SwingConstants.LEFT :
             break;
              */
       default:
         gap = new Insets(gap.top, gap.left, gap.bottom, gap.right);
     }
     if (component.getBorder() instanceof EmptyBorder) {
       gap.left -= 2;
       gap.right -= 2;
       gap.top -= 2;
       gap.bottom -= 2;
     }
   }
   return gap;
 }
Beispiel #19
0
 private Insets getSeparatorInsets(SynthContext context, Insets insets) {
   int horizPadding = 0;
   if (context.getRegion() == Region.POPUP_MENU_SEPARATOR) {
     horizPadding = getClassSpecificIntValue(context, "horizontal-padding", 3);
   }
   insets.right = insets.left = getXThickness() + horizPadding;
   insets.top = insets.bottom = getYThickness();
   return insets;
 }
    @Override
    protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {

      final Insets insets = tabPane.getInsets();
      insets.top += 1;
      if (tabPlacement == JTabbedPane.TOP || tabPlacement == JTabbedPane.BOTTOM) {
        insets.right += 1;
      } else {
        insets.bottom += 1;
      }

      int altura = getTabAreaLength(tabPlacement);

      if (getTabCount() > 1) { // se existe mais de uma aba
        g.setColor(COR_DA_BORDA_DE_BAIXO_DAS_ABAS);
        int larguraDasTabsDaEsquerda = getLarguraDasTabs(0, getSelectedIndex() - 1);
        int larguraDaTabSelecionada = getTabBounds(tabPane, getSelectedIndex()).width;
        // int larguraDasTabsDaDireita = getLarguraDasTabs(getSelectedIndex(), getTabCount()-1);
        int largutaTotalDasTabs = getLarguraDasTabs(0, getTabCount() - 1);

        // desenha linha a esquerda da tab selecionada
        g.drawLine(insets.left, insets.top + altura, larguraDasTabsDaEsquerda, insets.top + altura);

        // desenha linha a direita da tab selecionada
        g.drawLine(
            larguraDasTabsDaEsquerda + larguraDaTabSelecionada + 2,
            insets.top + altura,
            largutaTotalDasTabs,
            insets.top + altura);

        // desenha linha na parte onde não existem tabs, esta linha vai desaparecendo

        int larguraDaLinhaTransparente = 250;
        Color cores[] = {COR_DA_BORDA_DE_BAIXO_DAS_ABAS, getBackground()};
        float distribuicaoDasCores[] = {0.1f, 0.5f};
        ((Graphics2D) g)
            .setPaint(
                new LinearGradientPaint(
                    largutaTotalDasTabs,
                    0f,
                    largutaTotalDasTabs + larguraDaLinhaTransparente,
                    2f,
                    distribuicaoDasCores,
                    cores));
        // g.setColor(new Color(0, 0, 0, 0.06f));
        g.drawLine(
            largutaTotalDasTabs,
            insets.top + altura,
            largutaTotalDasTabs + larguraDaLinhaTransparente,
            insets.top + altura);

      } else { // existe apenas a aba principal
        g.setColor(COR_DA_BORDA_DE_BAIXO_DA_ABA_PRINCIPAL);
        g.drawLine(0, insets.top + altura + 1, getWidth() - 1, insets.top + altura + 1);
      }
    }
Beispiel #21
0
  private Insets getTabbedPaneTabInsets(SynthContext context, Insets insets) {
    int xThickness = getXThickness();
    int yThickness = getYThickness();
    int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
    int pad = 2;

    insets.left = insets.right = focusSize + pad + xThickness;
    insets.top = insets.bottom = focusSize + pad + yThickness;
    return insets;
  }
Beispiel #22
0
 private Insets getMenuItemInsets(SynthContext context, Insets insets) {
   // The following calculations are derived from gtkmenuitem.c
   // (GTK+ version 2.8.20), gtk_menu_item_size_allocate() method.
   int horizPadding = getClassSpecificIntValue(context, "horizontal-padding", 3);
   int xThickness = getXThickness();
   int yThickness = getYThickness();
   insets.left = insets.right = xThickness + horizPadding;
   insets.top = insets.bottom = yThickness;
   return insets;
 }
Beispiel #23
0
 private Insets getMenuBarInsets(SynthContext context, Insets insets) {
   // The following calculations are derived from gtkmenubar.c
   // (GTK+ version 2.8.20), gtk_menu_bar_size_allocate() method.
   int internalPadding = getClassSpecificIntValue(context, "internal-padding", 1);
   int xThickness = getXThickness();
   int yThickness = getYThickness();
   insets.left = insets.right = xThickness + internalPadding;
   insets.top = insets.bottom = yThickness + internalPadding;
   return insets;
 }
 /**
  * Layout the receiver. This method set insideBounds & insets according to bounds. Insets is
  * borderWidth + spacing.
  *
  * @see updateDrawableBounds
  */
 protected void layoutComponent() {
   Insets in = (Insets) getInsets().clone();
   in.top += spacing.top;
   in.left += spacing.left;
   in.bottom += spacing.bottom;
   in.right += spacing.right;
   Dimension d = getSize();
   insideBounds.setBounds(
       in.left, in.top, d.width - in.left - in.right, d.height - in.top - in.bottom);
   updateDrawableBounds();
 }
Beispiel #25
0
 public Insets getBorderInsets(Component c, Insets newInsets) {
   if (MetalLookAndFeel.usingOcean()) {
     newInsets.set(0, 0, 2, 0);
   } else {
     newInsets.top = 1;
     newInsets.left = 0;
     newInsets.bottom = 1;
     newInsets.right = 0;
   }
   return newInsets;
 }
Beispiel #26
0
 /** Overwrites the method to increase border for the currency symbol */
 @Override
 public Insets getInsets() {
   Insets is = super.getInsets();
   String symbol = "Kes. ";
   int w = getFontMetrics(getFont()).stringWidth(symbol) + 1;
   if (leftSymbol) {
     is.left += w;
   } else {
     is.right += w;
   }
   return is;
 }
  public Insets getBorderInsets(final Component component, final Insets insets) {
    if (insets != null) {
      insets.top = 0;
      insets.left = 0;
      insets.right = 0;
      insets.bottom = 0;

      return insets;
    } else {
      return new Insets(0, 0, 0, 0);
    }
  }
  /**
   * Gets the border insets for a given component. When the toolbar is flaotable, space for for the
   * drag "dots" is also taken in the insets.
   *
   * @param c The component to get its border insets.
   * @return The toolbar border insets.
   */
  public Insets getBorderInsets(Component c) {
    Insets insets = new Insets(3, 3, 3, 3);

    if (((JToolBar) c).isFloatable()) {
      if (((JToolBar) c).getOrientation() == HORIZONTAL) {
        insets.left = 8;
      } else {
        insets.top = 8;
      }
    }

    return insets;
  }
 @Override
 public Insets getBorderInsets(Component c, Insets insets) {
   if (insets == null) {
     return new Insets(
         this.insets.top, this.insets.left,
         this.insets.bottom, this.insets.right);
   }
   insets.top = this.insets.top;
   insets.bottom = this.insets.bottom;
   insets.left = this.insets.left;
   insets.right = this.insets.left;
   return insets;
 }
Beispiel #30
0
  private Insets getButtonInsets(SynthContext context, Insets insets) {
    // The following calculations are derived from gtkbutton.c
    // (GTK+ version 2.8.20), gtk_button_size_allocate() method.
    int CHILD_SPACING = 1;
    int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
    int focusPad = getClassSpecificIntValue(context, "focus-padding", 1);
    int xThickness = getXThickness();
    int yThickness = getYThickness();
    int w = focusSize + focusPad + xThickness + CHILD_SPACING;
    int h = focusSize + focusPad + yThickness + CHILD_SPACING;
    insets.left = insets.right = w;
    insets.top = insets.bottom = h;

    Component component = context.getComponent();
    if ((component instanceof JButton)
        && !(component.getParent() instanceof JToolBar)
        && ((JButton) component).isDefaultCapable()) {
      // Include the default border insets, but only for JButtons
      // that are default capable.  Note that
      // JButton.getDefaultCapable() returns true by default, but
      // GtkToolButtons are never default capable, so we skip this
      // step if the button is contained in a toolbar.
      Insets defaultInsets =
          getClassSpecificInsetsValue(context, "default-border", BUTTON_DEFAULT_BORDER_INSETS);
      insets.left += defaultInsets.left;
      insets.right += defaultInsets.right;
      insets.top += defaultInsets.top;
      insets.bottom += defaultInsets.bottom;
    }

    return insets;
  }