Java 类com.intellij.util.ui.JBInsets 实例源码

项目:PackageTemplates    文件:SelectFileTemplateDialog.java   
@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;
}
项目:intellij-ce-playground    文件:ConfigurationErrorsComponent.java   
@Override
public void paint(final Graphics g) {
  Rectangle bounds = new Rectangle(getWidth(), getHeight());
  JBInsets.removeFrom(bounds, getInsets());

  bounds.x += (bounds.width - myIcon.getIconWidth()) / 2;
  bounds.y += (bounds.height - myIcon.getIconHeight()) / 2;

  if (myBehavior.isHovered()) {
    // todo
  }

  if (myBehavior.isPressedByMouse()) {
    bounds.x++;
    bounds.y++;
  }

  myIcon.paintIcon(this, g, bounds.x, bounds.y);
}
项目:intellij-ce-playground    文件:WizardArrowUI.java   
private String layout(AbstractButton b, FontMetrics fm,
                      int width, int height) {
  viewRect.setBounds(0, 0, width, height);
  JBInsets.removeFrom(viewRect, b.getInsets());

  textRect.x = textRect.y = textRect.width = textRect.height = 0;
  iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0;

  // layout the text and icon
  return SwingUtilities.layoutCompoundLabel(
    b, fm, b.getText(), b.getIcon(),
    b.getVerticalAlignment(), b.getHorizontalAlignment(),
    b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
    viewRect, iconRect, textRect,
    b.getText() == null ? 0 : b.getIconTextGap());
}
项目:intellij-ce-playground    文件:ScreenUtil.java   
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);
}
项目:intellij-ce-playground    文件:WindowManagerImpl.java   
public void showFrame() {
  final IdeFrameImpl frame = new IdeFrameImpl(ApplicationInfoEx.getInstanceEx(),
                                              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));
  }

  fixForOracleBug8007219(frame);

  frame.setBounds(myFrameBounds);
  frame.setExtendedState(myFrameExtendedState);
  frame.setVisible(true);

}
项目:intellij-ce-playground    文件:DialogWrapperPeerImpl.java   
@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);
      }
    }
  }
}
项目:intellij-ce-playground    文件:ActionButtonWithText.java   
public void paintComponent(Graphics g) {
  Icon icon = getIcon();
  FontMetrics fm = getFontMetrics(getFont());
  Rectangle viewRect = new Rectangle(getSize());
  JBInsets.removeFrom(viewRect, getInsets());

  Rectangle iconRect = new Rectangle();
  Rectangle textRect = new Rectangle();
  String text = SwingUtilities.layoutCompoundLabel(this, fm, getText(), icon,
                                                   SwingConstants.CENTER, horizontalTextAlignment(),
                                                   SwingConstants.CENTER, horizontalTextPosition(),
                                                   viewRect, iconRect, textRect, iconTextSpace());
  ActionButtonLook look = ActionButtonLook.IDEA_LOOK;
  look.paintBackground(g, this);
  look.paintIconAt(g, this, icon, iconRect.x, iconRect.y);
  look.paintBorder(g, this);

  UISettings.setupAntialiasing(g);
  g.setColor(isButtonEnabled() ? getForeground() : getInactiveTextColor());
  SwingUtilities2.drawStringUnderlineCharAt(this, g, text,
                                            getMnemonicCharIndex(text),
                                            textRect.x,
                                            textRect.y + fm.getAscent());
}
项目:intellij-ce-playground    文件:EditorTextField.java   
@Override
public Dimension getMinimumSize() {
  if (super.isMinimumSizeSet()) {
    return super.getMinimumSize();
  }

  Dimension size = new Dimension(1, 20);
  if (myEditor != null) {
    size.height = myEditor.getLineHeight();

    JBInsets.addTo(size, getInsets());
    JBInsets.addTo(size, myEditor.getInsets());
  }

  return size;
}
项目:intellij-ce-playground    文件:CellRendererPanel.java   
@Override
public void doLayout() {
  synchronized (getTreeLock()) {
    int count = getComponentCount();
    if (count == 1) {
      Rectangle bounds = new Rectangle(getWidth(), getHeight());
      JBInsets.removeFrom(bounds, getInsets());
      Component child = getComponent(0);
      child.setBounds(bounds);
      if (child instanceof CellRendererPanel) {
        ((CellRendererPanel)child).invalidateLayout();
        child.doLayout();
      }
    }
    else {
      invalidateLayout();
      super.doLayout();
      for (int i = 0; i < count; i++) {
        Component c = getComponent(i);
        if (c instanceof CellRendererPanel) {
          c.doLayout();
        }
      }
    }
  }
}
项目:intellij-ce-playground    文件:AdvancedSettingsAction.java   
private static int calculateCheckBoxIndent() {
  JCheckBox checkBox = new JCheckBox();
  Icon icon = checkBox.getIcon();
  int indent = 0;
  if (icon == null) {
    icon = UIManager.getIcon("CheckBox.icon");
  }
  if (UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
    icon = EmptyIcon.create(20, 18);
  }
  if (icon != null) {
    final Rectangle r1 = new Rectangle(checkBox.getWidth(), checkBox.getHeight());
    JBInsets.removeFrom(r1, checkBox.getInsets());
    final Rectangle iconRect = new Rectangle();
    SwingUtilities.layoutCompoundLabel(
      checkBox, checkBox.getFontMetrics(checkBox.getFont()), checkBox.getText(), icon,
      checkBox.getVerticalAlignment(), checkBox.getHorizontalAlignment(),
      checkBox.getVerticalTextPosition(), checkBox.getHorizontalTextPosition(),
      r1, new Rectangle(), iconRect,
      checkBox.getText() == null ? 0 : checkBox.getIconTextGap());
    indent = iconRect.x;
  }
  return indent + checkBox.getIconTextGap();
}
项目:material-theme-jetbrains    文件:MTFrameComponentExtension.java   
@Override
public JComponent getComponent() {
  if (myWrapperPanel == null) {
    myWrapperPanel = new MTWrapperPanel(new BorderLayout()) {
      @Override
      public Insets getInsets() {
        return new JBInsets(0, 0, 0, 0);
      }

      @Override
      protected void paintComponent(final Graphics g) {
        super.paintComponent(g);
      }

    };
    myWrapperPanel.add(buildMTPanel(), BorderLayout.CENTER);
  }
  return myWrapperPanel;
}
项目:consulo    文件:ScreenUtil.java   
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);
}
项目:consulo    文件:VerticalLayout.java   
private Dimension getPreferredSize(Container container, boolean aligned) {
  synchronized (container.getTreeLock()) {
    Dimension top = getPreferredSize(myTop);
    Dimension bottom = getPreferredSize(myBottom);
    Dimension center = getPreferredSize(myCenter);
    Dimension result = join(join(join(null, myGap + myGap, top), myGap + myGap, center), myGap + myGap, bottom);
    if (result == null) {
      result = new Dimension();
    }
    else if (aligned && center != null) {
      int topHeight = top == null ? 0 : top.height;
      int bottomHeight = bottom == null ? 0 : bottom.height;
      result.width += Math.abs(topHeight - bottomHeight);
    }
    JBInsets.addTo(result, container.getInsets());
    return result;
  }
}
项目:consulo    文件:EditorTextField.java   
@Override
public Dimension getMinimumSize() {
  if (isMinimumSizeSet()) {
    return super.getMinimumSize();
  }

  Dimension size = new Dimension(1, 20);
  if (myEditor != null) {
    size.height = myEditor.getLineHeight();

    JBInsets.addTo(size, getInsets());
    JBInsets.addTo(size, myEditor.getInsets());
  }

  return size;
}
项目:consulo    文件:DesktopBalloonLayoutImpl.java   
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 = UIUtil.findComponentOfType2(myParent, ToolWindowPanelImplEx.class);
  JComponent layeredPane = pane != null ? pane.getMyLayeredPane() : null;
  int eachColumnX = (layeredPane == null ? myLayeredPane.getWidth() : layeredPane.getX() + layeredPane.getWidth()) - 4;

  newLayout(columns.get(0), eachColumnX + 4, (int)myLayeredPane.getBounds().getMaxY());
}
项目:consulo    文件:CellRendererPanel.java   
@Override
public void doLayout() {
  int count = getComponentCount();
  if (count == 1) {
    Rectangle bounds = new Rectangle(getWidth(), getHeight());
    JBInsets.removeFrom(bounds, getInsets());
    Component child = getComponent(0);
    child.setBounds(bounds);
    if (child instanceof CellRendererPanel) {
      ((CellRendererPanel)child).invalidateLayout();
      child.doLayout();
    }
  }
  else {
    invalidateLayout();
    super.doLayout();
    for (int i = 0; i < count; i++) {
      Component c = getComponent(i);
      if (c instanceof CellRendererPanel) {
        c.doLayout();
      }
    }
  }
}
项目:consulo    文件:SearchTextArea.java   
@Override
public void paint(Graphics graphics) {
  Graphics2D g = (Graphics2D)graphics.create();
  try {
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    myHelper.paint(g);
  }
  finally {
    g.dispose();
  }
  super.paint(graphics);

  if (UIUtil.isUnderGTKLookAndFeel()) {
    graphics.setColor(myTextArea.getBackground());
    Rectangle bounds = myScrollPane.getViewport().getBounds();
    if (myScrollPane.getVerticalScrollBar().isVisible()) {
      bounds.width -= myScrollPane.getVerticalScrollBar().getWidth();
    }
    bounds = SwingUtilities.convertRectangle(myScrollPane.getViewport()/*myTextArea*/, bounds, this);
    JBInsets.addTo(bounds, new JBInsets(2, 2, -1, -1));
    ((Graphics2D)graphics).draw(bounds);
  }
}
项目:consulo    文件:SearchTextArea.java   
@Override
void paint(Graphics2D g) {
  Rectangle r = new Rectangle(getSize());
  JBInsets.removeFrom(r, getInsets());
  if (r.height % 2 == 1) r.height++;
  int arcSize = JBUI.scale(26);

  JBInsets.removeFrom(r, new JBInsets(1, 1, 1, 1));
  if (myTextArea.hasFocus()) {
    g.setColor(myTextArea.getBackground());
    RectanglePainter.FILL.paint(g, r.x, r.y, r.width, r.height, arcSize);
    DarculaUIUtil.paintSearchFocusRing(g, r, myTextArea, arcSize);
  }
  else {
    arcSize -= JBUI.scale(5);
    RectanglePainter
            .paint(g, r.x, r.y, r.width, r.height, arcSize, myTextArea.getBackground(), myTextArea.isEnabled() ? Gray._100 : Gray._83);
  }
}
项目:consulo    文件:DesktopWindowManagerImpl.java   
public void showFrame() {
  final IdeFrameImpl frame = new IdeFrameImpl(ApplicationInfoEx.getInstanceEx(), 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));
  }

  frame.setBounds(myFrameBounds);
  frame.setExtendedState(myFrameExtendedState);
  frame.setVisible(true);

}
项目:intellij-ce-playground    文件:IdeaTitledBorder.java   
public IdeaTitledBorder(String title, int indent, Insets insets) {
  super(title);
  titledSeparator = new TitledSeparator(title);
  titledSeparator.setText(title);
  DialogUtil.registerMnemonic(titledSeparator.getLabel(), null);

  outsideInsets = JBInsets.create(insets);
  insideInsets = new JBInsets(TitledSeparator.BOTTOM_INSET, indent, 0, 0);
}
项目:intellij-ce-playground    文件:SearchTextField.java   
@Override
public Dimension getPreferredSize() {
  Dimension size = super.getPreferredSize();
  Border border = super.getBorder();
  if (border != null && UIUtil.isUnderAquaLookAndFeel()) {
    JBInsets.addTo(size, border.getBorderInsets(this));
  }
  return size;
}
项目:intellij-ce-playground    文件:SimpleColoredComponent.java   
public SimpleColoredComponent() {
  myFragments = new ArrayList<String>(3);
  myAttributes = new ArrayList<SimpleTextAttributes>(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);
}
项目:intellij-ce-playground    文件:JBOptionButton.java   
@Override
public Dimension getPreferredSize() {
  final Dimension size = super.getPreferredSize();
  size.width += myMoreRec.width;
  JBInsets.addTo(size, myDownIconInsets);
  return size;
}
项目:intellij-ce-playground    文件:ActionToolbarImpl.java   
@Override
public Dimension getPreferredSize() {
  final ArrayList<Rectangle> bounds = new ArrayList<Rectangle>();
  calculateBounds(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), bounds);
  if (bounds.isEmpty()) return JBUI.emptySize();
  int xLeft = Integer.MAX_VALUE;
  int yTop = Integer.MAX_VALUE;
  int xRight = Integer.MIN_VALUE;
  int yBottom = Integer.MIN_VALUE;
  for (int i = bounds.size() - 1; i >= 0; i--) {
    final Rectangle each = bounds.get(i);
    if (each.x == Integer.MAX_VALUE) continue;
    xLeft = Math.min(xLeft, each.x);
    yTop = Math.min(yTop, each.y);
    xRight = Math.max(xRight, each.x + each.width);
    yBottom = Math.max(yBottom, each.y + each.height);
  }
  final Dimension dimension = new Dimension(xRight - xLeft, yBottom - yTop);

  if (myLayoutPolicy == AUTO_LAYOUT_POLICY && myReservePlaceAutoPopupIcon) {
    if (myOrientation == SwingConstants.HORIZONTAL) {
      dimension.width += AllIcons.Ide.Link.getIconWidth();
    }
    else {
      dimension.height += AllIcons.Ide.Link.getIconHeight();
    }
  }

  JBInsets.addTo(dimension, getInsets());

  return dimension;
}
项目:intellij-ce-playground    文件:EditorTextField.java   
@Override
public Dimension getPreferredSize() {
  if (super.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();
    myPassivePreferredSize = size;
  }

  return size;
}
项目:intellij-ce-playground    文件:EditorComboBox.java   
@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));
}
项目:intellij-ce-playground    文件:Splash.java   
private void setLocationInTheCenterOfScreen() {
  Rectangle bounds = getGraphicsConfiguration().getBounds();
  if (SystemInfo.isWindows) {
    JBInsets.removeFrom(bounds, ScreenUtil.getScreenInsets(getGraphicsConfiguration()));
  }
  setLocation(UIUtil.getCenterPoint(bounds, getSize()));
}
项目:intellij-ce-playground    文件:CardLayoutPanel.java   
@Override
public void doLayout() {
  Rectangle bounds = new Rectangle(getWidth(), getHeight());
  JBInsets.removeFrom(bounds, getInsets());
  for (Component component : getComponents()) {
    component.setBounds(bounds);
  }
}
项目:intellij-ce-playground    文件:MacIntelliJSpinnerUI.java   
@Override
protected void layoutEditor(@NotNull JComponent editor) {
  int w = spinner.getWidth();
  int h = spinner.getHeight();
  JBInsets insets = JBUI.insets(spinner.getInsets());
  editor.setBounds(insets.left + 5, insets.top + 5, w - 5 - 26 - insets.width(), h - insets.height() - 10);
}
项目:intellij-ce-playground    文件:DarculaCheckBoxUI.java   
@Override
public synchronized void paint(Graphics g2d, JComponent c) {
  Graphics2D g = (Graphics2D)g2d;
  JCheckBox b = (JCheckBox) c;
  final Dimension size = c.getSize();
  final Font font = c.getFont();

  g.setFont(font);
  FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, font);

  Rectangle viewRect = new Rectangle(size);
  Rectangle iconRect = new Rectangle();
  Rectangle textRect = new Rectangle();

  JBInsets.removeFrom(viewRect, c.getInsets());

  String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), getDefaultIcon(),
                                                   b.getVerticalAlignment(), b.getHorizontalAlignment(),
                                                   b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
                                                   viewRect, iconRect, textRect, b.getIconTextGap());

  //background
  if (c.isOpaque()) {
    g.setColor(b.getBackground());
    g.fillRect(0, 0, size.width, size.height);
  }

  final boolean selected = b.isSelected();
  final boolean enabled = b.isEnabled();
  drawCheckIcon(c, g, b, iconRect, selected, enabled);
  drawText(c, g, b, fm, textRect, text);
}
项目:intellij-ce-playground    文件:DarculaTextFieldUI.java   
protected Rectangle getDrawingRect() {
  final JTextComponent c = myTextField;
  final JBInsets i = JBInsets.create(c.getInsets());
  final int x = i.right - JBUI.scale(4) - JBUI.scale(16);
  final int y = i.top - 3;
  final int w = c.getWidth() - i.width() + JBUI.scale(16*2 +7*2  - 5);
  int h = c.getBounds().height - i.height() + JBUI.scale(4*2 - 3);
  if (h%2==1) h++;
  return new Rectangle(x, y, w, h);
}
项目:intellij-ce-playground    文件:DarculaMenuItemUIBase.java   
protected void paintMenuItem(Graphics g, JComponent c,
                                 Icon checkIcon, Icon arrowIcon,
                                 Color background, Color foreground,
                                 int defaultTextIconGap) {
  // Save original graphics font and color
  Font holdf = g.getFont();
  Color holdc = g.getColor();

  JMenuItem mi = (JMenuItem) c;
  g.setFont(mi.getFont());

  Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight());
  JBInsets.removeFrom(viewRect, mi.getInsets());

  MenuItemLayoutHelper lh = new MenuItemLayoutHelper(mi, checkIcon,
      arrowIcon, viewRect, defaultTextIconGap, "-", //todo[kb] use protected field BasicMenuItemUI.acceleratorDelimiter when we move to java 1.7
      mi.getComponentOrientation().isLeftToRight(), mi.getFont(),
      acceleratorFont, MenuItemLayoutHelper.useCheckAndArrow(menuItem),
      getPropertyPrefix());
  MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem();

  paintBackground(g, mi, background);
  paintCheckIcon(g, lh, lr, holdc, foreground);
  paintIcon(g, lh, lr, holdc);
  g.setColor(foreground);
  paintText(g, lh, lr);
  paintAccText(g, lh, lr);
  paintArrowIcon(g, lh, lr, foreground);

  // Restore original graphics font and color
  g.setColor(holdc);
  g.setFont(holdf);
}
项目:intellij-ce-playground    文件:AbstractNavBarUI.java   
@Override
public Insets getWrapperPanelInsets(Insets insets) {
  final JBInsets result = JBUI.insets(insets);
  if (shouldPaintWrapperPanel()) {
    result.top += JBUI.scale(1);
  }
  return result;
}
项目:intellij-ce-playground    文件:ConfigurationErrorsPanel.java   
@Override
public void paint(Graphics g) {
  Rectangle bounds = new Rectangle(getWidth(), getHeight());
  JBInsets.removeFrom(bounds, getInsets());

  bounds.x += (bounds.width - myIcon.getIconWidth()) / 2;
  bounds.y += (bounds.height - myIcon.getIconHeight()) / 2;

  if (myBehavior.isPressedByMouse()) {
    bounds.x++;
    bounds.y++;
  }

  myIcon.paintIcon(this, g, bounds.x, bounds.y);
}
项目:material-theme-jetbrains    文件:PropertiesParser.java   
private static Insets parseInsets(final String value) {
  final java.util.List<String> numbers = StringUtil.split(value, ",");
  return new JBInsets(Integer.parseInt(numbers.get(0)),
      Integer.parseInt(numbers.get(1)),
      Integer.parseInt(numbers.get(2)),
      Integer.parseInt(numbers.get(3))).asUIResource();
}
项目:material-theme-jetbrains    文件:MTMenuItemUIBase.java   
protected final void paintMenuItem(final Graphics g, final JComponent c,
                                   final Icon checkIcon, final Icon arrowIcon,
                                   final Color background, final Color foreground,
                                   final int defaultTextIconGap) {
  // Save original graphics font and color
  Font holdf = g.getFont();
  Color holdc = g.getColor();

  JMenuItem mi = (JMenuItem) c;
  g.setFont(mi.getFont());

  Rectangle viewRect = new Rectangle(0, 0, mi.getWidth(), mi.getHeight());
  JBInsets.removeFrom(viewRect, mi.getInsets());

  MenuItemLayoutHelper lh = new MenuItemLayoutHelper(mi, checkIcon,
      arrowIcon, viewRect, defaultTextIconGap, "-", //todo[kb] use protected field BasicMenuItemUI.acceleratorDelimiter when we
      // move to java 1.7
      mi.getComponentOrientation().isLeftToRight(), mi.getFont(),
      acceleratorFont, MenuItemLayoutHelper.useCheckAndArrow(menuItem),
      getPropertyPrefix());
  MenuItemLayoutHelper.LayoutResult lr = lh.layoutMenuItem();

  paintBackground(g, mi, background);
  paintCheckIcon(g, lh, lr, holdc, foreground);
  paintIcon(g, lh, lr, holdc);
  g.setColor(foreground);
  UISettings.setupAntialiasing(g);
  paintText(g, lh, lr);
  paintAccText(g, lh, lr);
  paintArrowIcon(g, lh, lr, foreground);

  // Restore original graphics font and color
  g.setColor(holdc);
  g.setFont(holdf);
}
项目:material-theme-jetbrains    文件:MTCheckBoxUI.java   
@Override
public synchronized void paint(final Graphics g2d, final JComponent c) {
  final Graphics2D g = (Graphics2D) g2d;
  final JCheckBox b = (JCheckBox) c;
  final Dimension size = c.getSize();
  final Font font = c.getFont();

  g.setFont(font);
  final FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, font);

  final Rectangle viewRect = new Rectangle(size);
  final Rectangle iconRect = new Rectangle();
  final Rectangle textRect = new Rectangle();

  JBInsets.removeFrom(viewRect, c.getInsets());

  final String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), getDefaultIcon(),
      b.getVerticalAlignment(), b.getHorizontalAlignment(),
      b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
      viewRect, iconRect, textRect, b.getIconTextGap());

  //background
  if (c.isOpaque()) {
    g.setColor(b.getBackground());
    g.fillRect(0, 0, size.width, size.height);
  }

  final boolean selected = b.isSelected();
  final boolean enabled = b.isEnabled();
  drawCheckIcon(c, g, b, iconRect, selected, enabled);
  drawText(c, g, b, fm, textRect, text);
}
项目:material-theme-jetbrains    文件:MTTextFieldUI.java   
protected Rectangle getDrawingRect() {
  final JTextComponent c = myTextField;
  final JBInsets i = JBInsets.create(c.getInsets());
  final int x = i.right - JBUI.scale(4) - JBUI.scale(16);
  final int y = i.top - JBUI.scale(3);
  final int w = c.getWidth() - i.width() + JBUI.scale(16 * 2 + 7 * 2 - 5);
  int h = c.getBounds().height - i.height() + JBUI.scale(4 * 2 - 3);
  if (h % 2 == 1) {
    h++;
  }
  return new Rectangle(x, y, w, h);
}
项目:material-theme-jetbrains    文件:MTPasswordFieldUI.java   
private Rectangle getDrawingRect() {
  JComponent c = passwordField;
  final JBInsets i = JBInsets.create(c.getInsets());
  final int x = i.right - JBUI.scale(4) - JBUI.scale(16 * 2);
  final int y = i.top - JBUI.scale(3);
  final int w = c.getWidth() - i.width() + JBUI.scale(16 * 2 + 7 * 2 - 5);
  int h = c.getBounds().height - i.height() + JBUI.scale(4 * 2 - 3);
  if (h % 2 == 1) {
    h++;
  }
  return new Rectangle(x, y, w, h);
}
项目:tools-idea    文件:DarculaTextFieldUI.java   
protected Rectangle getDrawingRect() {
  final JTextComponent c = getComponent();
  final JBInsets i = JBInsets.create(c.getInsets());
  final int x = i.right - 4 - 16;
  final int y = i.top - 3;
  final int w = c.getWidth() - i.width() + 16*2 +7*2  - 5;
  int h = c.getBounds().height - i.height() + 4*2 - 3;
  if (h%2==1) h++;
  return new Rectangle(x, y, w, h);
}