com.intellij.util.ui.JBInsets Java Examples

The following examples show how to use com.intellij.util.ui.JBInsets. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SelectFileTemplateDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
@NotNull
private JPanel getOptionsPanel(final JPanel root) {
    JPanel options = new JPanel(new GridBagLayout());
    GridBag bag = new GridBag()
            .setDefaultInsets(new JBInsets(0, 4, 0, 4))
            .setDefaultFill(GridBagConstraints.HORIZONTAL);

    cbAddInternal = new JBCheckBox("Internal");
    cbAddJ2EE = new JBCheckBox("J2EE");

    ItemListener itemListener = e -> {
        root.remove(comboBox);
        comboBox = getSelector();
        root.add(comboBox);
        root.revalidate();
    };

    cbAddInternal.addItemListener(itemListener);
    cbAddJ2EE.addItemListener(itemListener);

    options.add(cbAddInternal, bag.nextLine().next());
    options.add(cbAddJ2EE, bag.next());
    return options;
}
 
Example #2
Source File: Breadcrumbs.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void layoutContainer(Container container) {
  if (container instanceof Breadcrumbs) {
    Breadcrumbs breadcrumbs = (Breadcrumbs)container;
    Rectangle bounds = new Rectangle(breadcrumbs.getWidth(), breadcrumbs.getHeight());
    JBInsets.removeFrom(bounds, breadcrumbs.getInsets());
    int scale = breadcrumbs.getScale();
    for (CrumbView view : breadcrumbs.views) {
      if (view.crumb != null) {
        view.update();
        view.setBounds(bounds.x, bounds.y, view.preferred.width, bounds.height, scale);
        bounds.x += view.preferred.width;
      }
    }
  }
}
 
Example #3
Source File: GlassPaneDialogWrapperPeer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void setBounds(int x, int y, int width, int height) {
  final Container p = myTransparentPane;
  if (p != null) {
    Rectangle bounds = new Rectangle(p.getWidth() - width, p.getHeight() - height);
    JBInsets.removeFrom(bounds, getInsets());

    x = bounds.width < 0 ? bounds.width / 2 : Math.min(bounds.x + bounds.width, Math.max(bounds.x, x));
    y = bounds.height < 0 ? bounds.height / 2 : Math.min(bounds.y + bounds.height, Math.max(bounds.y, y));
  }
  super.setBounds(x, y, width, height);

  if (RemoteDesktopService.isRemoteSession()) {
    shadow = null;
  }
  else if (shadow == null || shadowWidth != width || shadowHeight != height) {
    shadow = ShadowBorderPainter.createShadow(this, width, height);
    shadowWidth = width;
    shadowHeight = height;
  }
}
 
Example #4
Source File: DesktopBalloonLayoutImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void relayout() {
  final Dimension size = myLayeredPane.getSize();

  JBInsets.removeFrom(size, myInsets);

  final Rectangle layoutRec = new Rectangle(new Point(myInsets.left, myInsets.top), size);

  List<ArrayList<Balloon>> columns = createColumns(layoutRec);
  while (columns.size() > 1) {
    remove(myBalloons.get(0), true);
    columns = createColumns(layoutRec);
  }

  ToolWindowPanelImplEx pane = AWTComponentProviderUtil.findChild(myParent, ToolWindowPanelImplEx.class);
  JComponent layeredPane = pane != null ? pane.getMyLayeredPane() : null;
  int eachColumnX = (layeredPane == null ? myLayeredPane.getWidth() : layeredPane.getX() + layeredPane.getWidth()) - 4;

  doLayout(columns.get(0), eachColumnX + 4, (int)myLayeredPane.getBounds().getMaxY());
}
 
Example #5
Source File: DesktopWindowManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void showFrame() {
  final DesktopIdeFrameImpl frame = new DesktopIdeFrameImpl(myActionManager, myDataManager, ApplicationManager.getApplication());
  myProject2Frame.put(null, frame);

  if (myFrameBounds == null || !ScreenUtil.isVisible(myFrameBounds)) { //avoid situations when IdeFrame is out of all screens
    myFrameBounds = ScreenUtil.getMainScreenBounds();
    int xOff = myFrameBounds.width / 8;
    int yOff = myFrameBounds.height / 8;
    JBInsets.removeFrom(myFrameBounds, new Insets(yOff, xOff, yOff, xOff));
  }

  JFrame jWindow = (JFrame)TargetAWT.to(frame.getWindow());

  jWindow.setBounds(myFrameBounds);
  jWindow.setExtendedState(myFrameExtendedState);
  jWindow.setVisible(true);
}
 
Example #6
Source File: DialogWrapperPeerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void validate() {
  super.validate();
  DialogWrapper wrapper = myDialogWrapper.get();
  if (wrapper != null && wrapper.isAutoAdjustable()) {
    Window window = wrapper.getWindow();
    if (window != null) {
      Dimension size = getMinimumSize();
      if (!(size == null ? myLastMinimumSize == null : size.equals(myLastMinimumSize))) {
        // update window minimum size only if root pane minimum size is changed
        if (size == null) {
          myLastMinimumSize = null;
        }
        else {
          myLastMinimumSize = new Dimension(size);
          JBInsets.addTo(size, window.getInsets());
        }
        window.setMinimumSize(size);
      }
    }
  }
}
 
Example #7
Source File: ScreenUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void moveToFit(final Rectangle rectangle, final Rectangle container, @Nullable Insets padding) {
  Rectangle move = new Rectangle(rectangle);
  JBInsets.addTo(move, padding);

  if (move.getMaxX() > container.getMaxX()) {
    move.x = (int)container.getMaxX() - move.width;
  }


  if (move.getMinX() < container.getMinX()) {
    move.x = (int)container.getMinX();
  }

  if (move.getMaxY() > container.getMaxY()) {
    move.y = (int)container.getMaxY() - move.height;
  }

  if (move.getMinY() < container.getMinY()) {
    move.y = (int)container.getMinY();
  }

  JBInsets.removeFrom(move, padding);
  rectangle.setBounds(move);
}
 
Example #8
Source File: DarculaButtonPainter.java    From consulo with Apache License 2.0 6 votes vote down vote up
public Paint getBorderPaint(Component button) {
  AbstractButton b = (AbstractButton)button;
  Color borderColor = (Color)b.getClientProperty("JButton.borderColor");
  Rectangle r = new Rectangle(b.getSize());
  JBInsets.removeFrom(r, b.getInsets());
  boolean defButton = isDefaultButton(b);

  if (button.isEnabled()) {
    if (borderColor != null) {
      return borderColor;
    }
    else {
      return button.hasFocus()
             ? JBColor.namedColor(defButton ? "Button.default.focusedBorderColor" : "Button.focusedBorderColor",
                                  JBColor.namedColor(defButton ? "Button.darcula.defaultFocusedOutlineColor" : "Button.darcula.focusedOutlineColor", 0x87afda))
             : new GradientPaint(0, 0, JBColor.namedColor(defButton ? "Button.default.startBorderColor" : "Button.startBorderColor",
                                                          JBColor.namedColor(defButton ? "Button.darcula.outlineDefaultStartColor" : "Button.darcula.outlineStartColor", 0xbfbfbf)), 0, r.height,
                                 JBColor.namedColor(defButton ? "Button.default.endBorderColor" : "Button.endBorderColor",
                                                    JBColor.namedColor(defButton ? "Button.darcula.outlineDefaultEndColor" : "Button.darcula.outlineEndColor", 0xb8b8b8)));
    }
  }
  else {
    return JBColor.namedColor("Button.disabledBorderColor", JBColor.namedColor("Button.darcula.disabledOutlineColor", 0xcfcfcf));
  }
}
 
Example #9
Source File: DarculaComboBoxUI.java    From consulo with Apache License 2.0 6 votes vote down vote up
static Shape getArrowShape(Component button) {
  Rectangle r = new Rectangle(button.getSize());
  JBInsets.removeFrom(r, JBUI.insets(1, 0, 1, 1));

  int tW = JBUIScale.scale(9);
  int tH = JBUIScale.scale(5);
  int xU = (r.width - tW) / 2 - JBUIScale.scale(1);
  int yU = (r.height - tH) / 2 + JBUIScale.scale(1);

  Path2D path = new Path2D.Float();
  path.moveTo(xU, yU);
  path.lineTo(xU + tW, yU);
  path.lineTo(xU + tW / 2.0f, yU + tH);
  path.lineTo(xU, yU);
  path.closePath();
  return path;
}
 
Example #10
Source File: DarculaEditorTextFieldUI.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public Dimension getMinimumSize(JComponent c) {
  EditorTextField editorTextField = (EditorTextField)c;

  Editor editor = editorTextField.getEditor();

  Dimension size = JBUI.size(1, 10);
  if (editor != null) {
    size.height = editor.getLineHeight();

    size.height = Math.max(size.height, JBUIScale.scale(16));

    JBInsets.addTo(size, editorTextField.getInsets());
    JBInsets.addTo(size, editor.getInsets());
  }

  return size;
}
 
Example #11
Source File: DarculaTextFieldUI.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void paintDarculaBackground(Graphics g, JTextComponent component) {
  Graphics2D g2 = (Graphics2D)g.create();
  Rectangle r = new Rectangle(component.getSize());
  JBInsets.removeFrom(r, DarculaUIUtil.paddings());

  try {
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);

    g2.translate(r.x, r.y);

    if (component.isEnabled() && component.isEditable()) {
      float arc = isSearchField(component) ? DarculaUIUtil.COMPONENT_ARC.getFloat() : 0.0f;
      float bw = bw();

      g2.setColor(component.getBackground());
      g2.fill(new RoundRectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2, arc, arc));
    }
  }
  finally {
    g2.dispose();
  }
}
 
Example #12
Source File: DarculaActionButtonUI.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void paintBackground(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return;

  Rectangle rect = new Rectangle(button.getSize());
  JBInsets.removeFrom(rect, button.getInsets());

  Color color = state == ActionButtonComponent.PUSHED ? JBUI.CurrentTheme.ActionButton.pressedBackground() : JBUI.CurrentTheme.ActionButton.hoverBackground();
  Graphics2D g2 = (Graphics2D)g.create();

  try {
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
    g2.setColor(color);

    float arc = DarculaUIUtil.BUTTON_ARC.getFloat();
    g2.fill(new RoundRectangle2D.Float(rect.x, rect.y, rect.width, rect.height, arc, arc));
  }
  finally {
    g2.dispose();
  }
}
 
Example #13
Source File: AbstractNavBarUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Insets getWrapperPanelInsets(Insets insets) {
  final JBInsets result = JBUI.insets(insets);
  if (shouldPaintWrapperPanel()) {
    result.top += JBUIScale.scale(1);
  }
  return result;
}
 
Example #14
Source File: ColorPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Dimension getPreferredSize() {
  if (isPreferredSizeSet()) {
    return super.getPreferredSize();
  }
  Dimension size = myTextField.getPreferredSize();
  JBInsets.addTo(size, getInsets());
  return size;
}
 
Example #15
Source File: MultiIconSimpleColoredComponent.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public MultiIconSimpleColoredComponent() {
  myFragments = new ArrayList<>(3);
  myLayouts = new ArrayList<>(3);
  myAttributes = new ArrayList<>(3);
  myIcons = new ArrayList<>(3);
  myIpad = new JBInsets(1, 2, 1, 2);
  myIconTextGap = JBUI.scale(2);
  myBorder = new MyBorder();
  myFragmentPadding = new TIntIntHashMap(10);
  myFragmentAlignment = new TIntIntHashMap(10);
  setOpaque(true);
  updateUI();
}
 
Example #16
Source File: BasicEditorTextFieldUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Dimension getMinimumSize(JComponent c) {
  EditorTextField editorTextField = (EditorTextField)c;
  Editor editor = editorTextField.getEditor();
  Dimension size = new Dimension(1, 20);
  if (editor != null) {
    size.height = editor.getLineHeight();

    JBInsets.addTo(size, editorTextField.getInsets());
    JBInsets.addTo(size, editor.getInsets());
  }

  return size;
}
 
Example #17
Source File: DarculaTextBorder.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void paintDarculaSearchArea(Graphics2D g, Rectangle r, JTextComponent c, boolean fillBackground) {
  Graphics2D g2 = (Graphics2D)g.create();
  try {
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);

    JBInsets.removeFrom(r, JBUI.insets(1));
    g2.translate(r.x, r.y);

    float arc = COMPONENT_ARC.get();
    float lw = LW.getFloat();
    float bw = BW.getFloat();
    Shape outerShape = new RoundRectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2, arc, arc);
    if (fillBackground) {
      g2.setColor(c.getBackground());
      g2.fill(outerShape);
    }

    if (c.getClientProperty("JTextField.Search.noBorderRing") != Boolean.TRUE) {
      if (c.hasFocus()) {
        paintFocusBorder(g2, r.width, r.height, arc, true);
      }
      Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
      path.append(outerShape, false);

      arc = arc > lw ? arc - lw : 0.0f;
      path.append(new RoundRectangle2D.Float(bw + lw, bw + lw, r.width - (bw + lw) * 2, r.height - (bw + lw) * 2, arc, arc), false);

      g2.setColor(DarculaUIUtil.getOutlineColor(c.isEnabled() && c.isEditable(), c.hasFocus()));
      g2.fill(path);
    }
  }
  finally {
    g2.dispose();
  }
}
 
Example #18
Source File: EditorTextField.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Dimension getPreferredSize() {
  if (isPreferredSizeSet()) {
    return super.getPreferredSize();
  }

  boolean toReleaseEditor = false;
  if (myEditor == null && myEnsureWillComputePreferredSize) {
    myEnsureWillComputePreferredSize = false;
    initEditor();
    toReleaseEditor = true;
  }


  Dimension size = new Dimension(100, 20);
  if (myEditor != null) {
    final Dimension preferredSize = new Dimension(myEditor.getComponent().getPreferredSize());

    if (myPreferredWidth != -1) {
      preferredSize.width = myPreferredWidth;
    }

    JBInsets.addTo(preferredSize, getInsets());
    size = preferredSize;
  }
  else if (myPassivePreferredSize != null) {
    size = myPassivePreferredSize;
  }

  if (toReleaseEditor) {
    releaseEditor(myEditor);
    myEditor = null;
    myPassivePreferredSize = size;
  }

  return size;
}
 
Example #19
Source File: DarculaPopupMenuBorder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Insets getBorderInsets(Component c) {
  if (isComboPopup(c)) {
    return JBInsets.create(1, 2).asUIResource();
  }
  else {
    return JBUI.insets("PopupMenu.borderInsets", DEFAULT_INSETS).asUIResource();
  }
}
 
Example #20
Source File: EditorComboBox.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Dimension getPreferredSize() {
  if (UIUtil.isUnderIntelliJLaF() || UIUtil.isUnderDarcula()) {
    return super.getPreferredSize();
  }
  if (myEditorField != null) {
    final Dimension preferredSize = new Dimension(myEditorField.getComponent().getPreferredSize());
    JBInsets.addTo(preferredSize, getInsets());
    return preferredSize;
  }

  //final int cbHeight = new JComboBox().getPreferredSize().height; // should be used actually
  return new Dimension(100, UIUtil.fixComboBoxHeight(20));
}
 
Example #21
Source File: ListPopupImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean isOnNextStepButton(MouseEvent e) {
  final int index = myList.getSelectedIndex();
  final Rectangle bounds = myList.getCellBounds(index, index);
  if (bounds != null) {
    JBInsets.removeFrom(bounds, UIUtil.getListCellPadding());
  }
  final Point point = e.getPoint();
  return bounds != null && point.getX() > bounds.width + bounds.getX() - AllIcons.Icons.Ide.NextStep.getIconWidth();
}
 
Example #22
Source File: BreadcrumbsComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Dimension getPreferredSize() {
  Graphics2D g2 = (Graphics2D)GraphicsUtil.safelyGetGraphics(this);
  Dimension dim = new Dimension(Integer.MAX_VALUE, g2 != null ? DEFAULT_PAINTER.getSize("DUMMY", g2.getFontMetrics(), Integer.MAX_VALUE).height + 1 : 1);
  JBInsets.addTo(dim, getInsets());
  return dim;
}
 
Example #23
Source File: SearchEverywhereUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void customizeCellRenderer(@Nonnull JList<?> list, Object value, int index, boolean selected, boolean hasFocus) {
  if (value != SearchListModel.MORE_ELEMENT) {
    throw new AssertionError(value);
  }
  setFont(UIUtil.getLabelFont().deriveFont(UIUtil.getFontSize(UIUtil.FontSize.SMALL)));
  append("... more", SMALL_LABEL_ATTRS);
  setIpad(JBInsets.create(1, 7));
  setMyBorder(null);
}
 
Example #24
Source File: TextFieldWithPopupHandlerUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void updatePreferredSize(JComponent c, Dimension size) {
  if (!isUnderComboBox(c)) {
    JBInsets.addTo(size, ((JTextComponent)c).getMargin());
    size.height = Math.max(size.height, getMinimumHeight(size.height));
    size.width = Math.max(size.width, DarculaUIUtil.MINIMUM_WIDTH.get());
  }
}
 
Example #25
Source File: NavBarBorder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Insets getBorderInsets(final Component c) {
  if (!UISettings.getInstance().SHOW_MAIN_TOOLBAR) {
    if (NavBarRootPaneExtension.runToolbarExists()) {
      return new JBInsets(1, 0, 1, 4);
    }

    return new JBInsets(0, 0, 0, 4);
  }

  return new JBInsets(1, 0, 0, 4);
}
 
Example #26
Source File: DarculaPopupMenuBorder.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static Shape getBorderShape(Component c, Rectangle rect) {
  Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
  if (isComboPopup(c) && ((BasicComboPopup)c).getClientProperty("JComboBox.isCellEditor") == Boolean.TRUE) {
    JBInsets.removeFrom(rect, JBInsets.create(0, 1));
  }

  border.append(rect, false);

  Rectangle innerRect = new Rectangle(rect);
  JBInsets.removeFrom(innerRect, JBUI.insets(JBUI.getInt("PopupMenu.borderWidth", 1)));
  border.append(innerRect, false);

  return border;
}
 
Example #27
Source File: DarculaActionButtonUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void paintBorder(ActionButton button, Graphics g, Dimension size, int state) {
  if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return;

  Rectangle rect = new Rectangle(button.getSize());
  JBInsets.removeFrom(rect, button.getInsets());

  Graphics2D g2 = (Graphics2D)g.create();
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

  try {
    Color color = state == ActionButtonComponent.PUSHED ? JBUI.CurrentTheme.ActionButton.pressedBorder() : JBUI.CurrentTheme.ActionButton.hoverBorder();

    g2.setColor(color);

    float arc = DarculaUIUtil.BUTTON_ARC.getFloat();
    float lw = DarculaUIUtil.LW.getFloat();
    Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
    border.append(new RoundRectangle2D.Float(rect.x, rect.y, rect.width, rect.height, arc, arc), false);
    border.append(new RoundRectangle2D.Float(rect.x + lw, rect.y + lw, rect.width - lw * 2, rect.height - lw * 2, arc - lw, arc - lw), false);

    g2.fill(border);
  }
  finally {
    g2.dispose();
  }
}
 
Example #28
Source File: DarculaComboBoxUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void paint(Graphics g, JComponent c) {
  Container parent = c.getParent();
  if (parent != null) {
    g.setColor(DarculaUIUtil.isTableCellEditor(c) && editor != null ? editor.getBackground() : parent.getBackground());
    g.fillRect(0, 0, c.getWidth(), c.getHeight());
  }

  Graphics2D g2 = (Graphics2D)g.create();
  Rectangle r = new Rectangle(c.getSize());
  JBInsets.removeFrom(r, JBUI.insets(1));

  try {
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
    g2.translate(r.x, r.y);

    float bw = BW.getFloat();
    float arc = COMPONENT_ARC.getFloat();

    g2.setColor(getBackgroundColor());
    g2.fill(new RoundRectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2, arc, arc));
  }
  finally {
    g2.dispose();
  }

  if (!comboBox.isEditable()) {
    checkFocus();
    paintCurrentValue(g, rectangleForCurrentValue(), hasFocus);
  }
}
 
Example #29
Source File: DarculaComboBoxUI.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected Rectangle rectangleForCurrentValue() {
  Rectangle rect = new Rectangle(comboBox.getSize());
  Insets i = getInsets();

  JBInsets.removeFrom(rect, i);
  rect.width -= arrowButton != null ? (arrowButton.getWidth() - i.left) : rect.height;
  JBInsets.removeFrom(rect, padding);

  rect.width += comboBox.isEditable() ? 0 : padding.right;
  return rect;
}
 
Example #30
Source File: DarculaSpinnerBorder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  Graphics2D g2 = (Graphics2D)g.create();
  Rectangle r = new Rectangle(x, y, width, height);
  JBInsets.removeFrom(r, JBUI.insets(1));

  try {
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);

    g2.translate(r.x, r.y);

    float lw = LW.getFloat();
    float bw = BW.getFloat();
    float arc = COMPONENT_ARC.getFloat();

    Object op = ((JComponent)c).getClientProperty("JComponent.outline");
    if (c.isEnabled() && op != null) {
      paintOutlineBorder(g2, r.width, r.height, arc, true, isFocused(c), Outline.valueOf(op.toString()));
    }
    else {
      if (isFocused(c)) {
        paintFocusBorder(g2, r.width, r.height, arc, true);
      }

      Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
      border.append(new RoundRectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2, arc, arc), false);
      arc = arc > lw ? arc - lw : 0.0f;
      border.append(new RoundRectangle2D.Float(bw + lw, bw + lw, r.width - (bw + lw) * 2, r.height - (bw + lw) * 2, arc, arc), false);

      g2.setColor(getOutlineColor(c.isEnabled(), isFocused(c)));
      g2.fill(border);
    }
  }
  finally {
    g2.dispose();
  }
}