Exemplo n.º 1
0
    /**
     * 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) {
      Border border = getBorder();
      if (border != null) {
        if (border instanceof AbstractBorder) {
          ((AbstractBorder) border).getBorderInsets(c, insets);
        } else {
          // Can't reuse border insets because the Border interface
          // can't be enhanced.
          Insets i = border.getBorderInsets(c);
          insets.top = i.top;
          insets.right = i.right;
          insets.bottom = i.bottom;
          insets.left = i.left;
        }
      } else {
        insets.left = insets.top = insets.right = insets.bottom = 0;
      }

      insets.left += EDGE_SPACING + TEXT_SPACING;
      insets.right += EDGE_SPACING + TEXT_SPACING;
      insets.top += EDGE_SPACING + TEXT_SPACING;
      insets.bottom += EDGE_SPACING + TEXT_SPACING;

      if (c == null || label == null) {
        return insets;
      }

      insets.top += label.getHeight();

      return insets;
    }
Exemplo n.º 2
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;
  }
Exemplo n.º 3
0
    /* (non-Javadoc)
     * @see javax.swing.border.EmptyBorder#getBorderInsets(java.awt.Component, java.awt.Insets)
     */
    public Insets getBorderInsets(Component c, Insets insets) {
      insets = super.getBorderInsets(c, insets);

      Insets margin = null;
      if (c instanceof AbstractButton) {
        Insets m = ((AbstractButton) c).getMargin();
        // if this is a toolbar button then ignore getMargin()
        // and subtract the padding added by the constructor
        if (c.getParent() instanceof JToolBar
            && !(c instanceof JRadioButton)
            && !(c instanceof JCheckBox)
            && m instanceof InsetsUIResource) {
          insets.top -= 2;
          insets.left -= 2;
          insets.bottom -= 2;
          insets.right -= 2;
        } else {
          margin = m;
        }
      } else if (c instanceof JToolBar) {
        margin = ((JToolBar) c).getMargin();
      } else if (c instanceof JTextComponent) {
        margin = ((JTextComponent) c).getMargin();
      }
      if (margin != null) {
        insets.top = margin.top + 2;
        insets.left = margin.left + 2;
        insets.bottom = margin.bottom + 2;
        insets.right = margin.right + 2;
      }
      return insets;
    }
Exemplo n.º 4
0
  private Insets getScrollBarInsets(SynthContext context, Insets insets) {
    int troughBorder = getClassSpecificIntValue(context, "trough-border", 1);
    insets.left = insets.right = insets.top = insets.bottom = troughBorder;

    JComponent c = context.getComponent();
    if (c.getParent() instanceof JScrollPane) {
      // This scrollbar is part of a scrollpane; use only the
      // "scrollbar-spacing" style property to determine the padding
      // between the scrollbar and its parent scrollpane.
      int spacing = getClassSpecificIntValue(WidgetType.SCROLL_PANE, "scrollbar-spacing", 3);
      if (((JScrollBar) c).getOrientation() == JScrollBar.HORIZONTAL) {
        insets.top += spacing;
      } else {
        if (c.getComponentOrientation().isLeftToRight()) {
          insets.left += spacing;
        } else {
          insets.right += spacing;
        }
      }
    } else {
      // This is a standalone scrollbar; leave enough room for the
      // focus line in addition to the trough border.
      if (c.isFocusable()) {
        int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
        int focusPad = getClassSpecificIntValue(context, "focus-padding", 1);
        int totalFocus = focusSize + focusPad;
        insets.left += totalFocus;
        insets.right += totalFocus;
        insets.top += totalFocus;
        insets.bottom += totalFocus;
      }
    }
    return insets;
  }
Exemplo n.º 5
0
    public Insets getBorderInsets(Component c, Insets newInsets) {
      if (MetalLookAndFeel.usingOcean()) {
        newInsets.set(1, 2, 3, 2);
      } else {
        newInsets.top = newInsets.left = newInsets.bottom = newInsets.right = 2;
      }

      if (((JToolBar) c).isFloatable()) {
        if (((JToolBar) c).getOrientation() == HORIZONTAL) {
          if (c.getComponentOrientation().isLeftToRight()) {
            newInsets.left = 16;
          } else {
            newInsets.right = 16;
          }
        } else { // vertical
          newInsets.top = 16;
        }
      }

      Insets margin = ((JToolBar) c).getMargin();

      if (margin != null) {
        newInsets.left += margin.left;
        newInsets.top += margin.top;
        newInsets.right += margin.right;
        newInsets.bottom += margin.bottom;
      }

      return newInsets;
    }
Exemplo n.º 6
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;
  }
Exemplo n.º 7
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;
 }
Exemplo n.º 8
0
 /**
  * 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;
 }
Exemplo n.º 9
0
 public Insets getBorderInsets(Component c, Insets insets) {
   insets.left = 0;
   insets.top = 0;
   insets.right = 0;
   insets.bottom = gap;
   return insets;
 }
Exemplo n.º 10
0
 @Override
 public Insets getBorderInsets(Component c, Insets insets) {
   insets.left = 2;
   insets.top = 2;
   insets.right = insets.bottom = 3;
   return insets;
 }
Exemplo n.º 11
0
 public Insets getBorderInsets(Component c, Insets newInsets) {
   newInsets.top = 3;
   newInsets.left = 1;
   newInsets.bottom = 2;
   newInsets.right = 1;
   return newInsets;
 }
Exemplo n.º 12
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;
 }
Exemplo n.º 13
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;
 }
 @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;
 }
Exemplo n.º 15
0
 @Override
 public Insets getBorderInsets(Component c, final Insets insets) {
   insets.top +=
       getTitledSeparator(c).getPreferredSize().getHeight()
           - TitledSeparator.TOP_INSET
           - TitledSeparator.BOTTOM_INSET;
   insets.top += UIUtil.DEFAULT_VGAP;
   insets.top += insideInsets.top;
   insets.left += insideInsets.left;
   insets.bottom += insideInsets.bottom;
   insets.right += insideInsets.right;
   insets.top += outsideInsets.top;
   insets.left += outsideInsets.left;
   insets.bottom += outsideInsets.bottom;
   insets.right += outsideInsets.right;
   return insets;
 }
  private void updateTabBorder() {
    if (!myProject.isOpen()) return;

    ToolWindowManagerEx mgr = (ToolWindowManagerEx) ToolWindowManager.getInstance(myProject);

    String[] ids = mgr.getToolWindowIds();

    Insets border = new Insets(0, 0, 0, 0);

    UISettings uiSettings = UISettings.getInstance();

    List<String> topIds = mgr.getIdsOn(ToolWindowAnchor.TOP);
    List<String> bottom = mgr.getIdsOn(ToolWindowAnchor.BOTTOM);
    List<String> rightIds = mgr.getIdsOn(ToolWindowAnchor.RIGHT);
    List<String> leftIds = mgr.getIdsOn(ToolWindowAnchor.LEFT);

    if (!uiSettings.HIDE_TOOL_STRIPES) {
      border.top = topIds.size() > 0 ? 1 : 0;
      border.bottom = bottom.size() > 0 ? 1 : 0;
      border.left = leftIds.size() > 0 ? 1 : 0;
      border.right = rightIds.size() > 0 ? 1 : 0;
    }

    for (String each : ids) {
      ToolWindow eachWnd = mgr.getToolWindow(each);
      if (!eachWnd.isAvailable()) continue;

      if (eachWnd.isVisible() && eachWnd.getType() == ToolWindowType.DOCKED) {
        ToolWindowAnchor eachAnchor = eachWnd.getAnchor();
        if (eachAnchor == ToolWindowAnchor.TOP) {
          border.top = 0;
        } else if (eachAnchor == ToolWindowAnchor.BOTTOM) {
          border.bottom = 0;
        } else if (eachAnchor == ToolWindowAnchor.LEFT) {
          border.left = 0;
        } else if (eachAnchor == ToolWindowAnchor.RIGHT) {
          border.right = 0;
        }
      }
    }

    myTabs
        .getPresentation()
        .setPaintBorder(border.top, border.left, border.right, border.bottom)
        .setTabSidePaintBorder(5);
  }
Exemplo n.º 17
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;
 }
Exemplo n.º 18
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;
  }
Exemplo n.º 19
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;
 }
Exemplo n.º 20
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;
 }
Exemplo n.º 21
0
 @Override
 public Insets getInsets() {
   Insets insets = super.getInsets();
   if (UIUtil.isUnderGTKLookAndFeel() || UIUtil.isUnderNimbusLookAndFeel()) {
     insets.top += 1;
     insets.bottom += 2;
   }
   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);
      }
    }
Exemplo n.º 23
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;
  }
Exemplo n.º 24
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;
 }
Exemplo n.º 25
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;
 }
Exemplo n.º 26
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;
 }
Exemplo n.º 27
0
 /**
  * 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();
 }
Exemplo n.º 28
0
    public Insets getBorderInsets(Component c, Insets insets) {
      Insets borderInsets;
      if (border != null) {
        borderInsets = border.getBorderInsets(c);
      } else {
        borderInsets = new Insets(0, 0, 0, 0);
      }
      insets.top = EDGE_SPACING + TEXT_SPACING + borderInsets.top;
      insets.right = EDGE_SPACING + TEXT_SPACING + borderInsets.right;
      insets.bottom = EDGE_SPACING + TEXT_SPACING + borderInsets.bottom;
      insets.left = EDGE_SPACING + TEXT_SPACING + borderInsets.left;

      if (c == null || component == null) {
        return insets;
      }

      int compHeight = component.getPreferredSize().height;

      switch (titlePosition) {
        case ABOVE_TOP:
          insets.top += compHeight + TEXT_SPACING;
          break;
        case TOP:
        case DEFAULT_POSITION:
          insets.top += Math.max(compHeight, borderInsets.top) - borderInsets.top;
          break;
        case BELOW_TOP:
          insets.top += compHeight + TEXT_SPACING;
          break;
        case ABOVE_BOTTOM:
          insets.bottom += compHeight + TEXT_SPACING;
          break;
        case BOTTOM:
          insets.bottom += Math.max(compHeight, borderInsets.bottom) - borderInsets.bottom;
          break;
        case BELOW_BOTTOM:
          insets.bottom += compHeight + TEXT_SPACING;
          break;
      }
      return insets;
    }
  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);
    }
  }
Exemplo n.º 30
0
    public Insets getBorderInsets(Component c, Insets insets) {
      Insets margin = null;

      if (c instanceof AbstractButton) {
        margin = ((AbstractButton) c).getMargin();
      }
      if (margin == null || margin instanceof UIResource) {
        // default margin so replace
        insets.left = left;
        insets.top = top;
        insets.right = right;
        insets.bottom = bottom;
      } else {
        // Margin which has been explicitly set by the user.
        insets.left = margin.left;
        insets.top = margin.top;
        insets.right = margin.right;
        insets.bottom = margin.bottom;
      }
      return insets;
    }