Java Code Examples for com.intellij.util.ui.JBInsets#removeFrom()
The following examples show how to use
com.intellij.util.ui.JBInsets#removeFrom() .
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: DarculaActionButtonUI.java From consulo with Apache License 2.0 | 6 votes |
@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 2
Source File: DarculaButtonPainter.java From consulo with Apache License 2.0 | 6 votes |
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 3
Source File: ScreenUtil.java From consulo with Apache License 2.0 | 6 votes |
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 4
Source File: DesktopWindowManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
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 5
Source File: GlassPaneDialogWrapperPeer.java From consulo with Apache License 2.0 | 6 votes |
@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 6
Source File: DarculaActionButtonUI.java From consulo with Apache License 2.0 | 5 votes |
@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 7
Source File: DarculaComboBoxUI.java From consulo with Apache License 2.0 | 5 votes |
@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 8
Source File: DarculaTextBorder.java From consulo with Apache License 2.0 | 5 votes |
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 9
Source File: JBTextField.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); if (!myEmptyText.getStatusTriggerText().isEmpty() && myEmptyText.isStatusVisible()) { g.setColor(getBackground()); Rectangle rect = new Rectangle(getSize()); JBInsets.removeFrom(rect, getInsets()); JBInsets.removeFrom(rect, getMargin()); ((Graphics2D)g).fill(rect); g.setColor(getForeground()); } myEmptyText.paintStatusText(g); }
Example 10
Source File: DarculaPopupMenuBorder.java From consulo with Apache License 2.0 | 5 votes |
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 11
Source File: DarculaProgressBarUI.java From consulo with Apache License 2.0 | 4 votes |
@Override protected void paintIndeterminate(Graphics g, JComponent c) { 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); Rectangle r = new Rectangle(progressBar.getSize()); if (c.isOpaque()) { g2.setColor(c.getParent().getBackground()); g2.fill(r); } Insets i = progressBar.getInsets(); JBInsets.removeFrom(r, i); int orientation = progressBar.getOrientation(); // Use foreground color as a reference, don't use it directly. This is done for compatibility reason. // Colors are hardcoded in UI delegates by design. If more colors are needed contact designers. Color startColor, endColor; Color foreground = progressBar.getForeground(); if (foreground == ColorProgressBar.RED) { startColor = FAILED_COLOR; endColor = FAILED_END_COLOR; } else if (foreground == ColorProgressBar.GREEN) { startColor = PASSED_COLOR; endColor = PASSED_END_COLOR; } else { startColor = getStartColor(); endColor = getEndColor(); } int pHeight = progressBar.getPreferredSize().height; int pWidth = progressBar.getPreferredSize().width; int yOffset = r.y + (r.height - pHeight) / 2; int xOffset = r.x + (r.width - pWidth) / 2; if (isSimplified()) { Color[] ca = {startColor, endColor}; int idx = 0; int delta = JBUIScale.scale(10); if (orientation == SwingConstants.HORIZONTAL) { for (float offset = r.x; offset - r.x < r.width; offset += delta) { g2.setPaint(ca[(getAnimationIndex() + idx++) % 2]); g2.fill(new Rectangle2D.Float(offset, yOffset, delta, pHeight)); } } else { for (float offset = r.y; offset - r.y < r.height; offset += delta) { g2.setPaint(ca[(getAnimationIndex() + idx++) % 2]); g2.fill(new Rectangle2D.Float(xOffset, offset, delta, pWidth)); } } } else { Shape shape; int step = JBUIScale.scale(6); if (orientation == SwingConstants.HORIZONTAL) { shape = getShapedRect(r.x, yOffset, r.width, pHeight, pHeight); yOffset = r.y + pHeight / 2; g2.setPaint(new GradientPaint(r.x + getAnimationIndex() * step * 2, yOffset, startColor, r.x + getFrameCount() * step + getAnimationIndex() * step * 2, yOffset, endColor, true)); } else { shape = getShapedRect(xOffset, r.y, pWidth, r.height, pWidth); xOffset = r.x + pWidth / 2; g2.setPaint(new GradientPaint(xOffset, r.y + getAnimationIndex() * step * 2, startColor, xOffset, r.y + getFrameCount() * step + getAnimationIndex() * step * 2, endColor, true)); } g2.fill(shape); } // Paint text if (progressBar.isStringPainted()) { if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) { paintString((Graphics2D)g, i.left, i.top, r.width, r.height, boxRect.x, boxRect.width); } else { paintString((Graphics2D)g, i.left, i.top, r.width, r.height, boxRect.y, boxRect.height); } } } finally { g2.dispose(); } }
Example 12
Source File: DarculaRadioButtonUI.java From consulo with Apache License 2.0 | 4 votes |
protected Dimension updatePreferredSize(JComponent c, Dimension size) { if (c.getBorder() instanceof DarculaRadioButtonBorder) { JBInsets.removeFrom(size, c.getInsets()); } return size; }
Example 13
Source File: MultiIconSimpleColoredComponent.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
private Rectangle computePaintArea() { Rectangle area = new Rectangle(getWidth(), getHeight()); JBInsets.removeFrom(area, getInsets()); JBInsets.removeFrom(area, myIpad); return area; }
Example 14
Source File: WindowResizeListener.java From consulo with Apache License 2.0 | 4 votes |
@Override int getCursorType(Component view, Point location) { Component parent = view instanceof Window ? null : view.getParent(); if (parent != null) { convertPointFromScreen(location, parent); } Rectangle bounds = view.getBounds(); JBInsets.removeFrom(bounds, getResizeOffset(view)); int top = location.y - bounds.y; if (top < 0) return CUSTOM_CURSOR; int left = location.x - bounds.x; if (left < 0) return CUSTOM_CURSOR; int right = bounds.width - left; if (right < 0) return CUSTOM_CURSOR; int bottom = bounds.height - top; if (bottom < 0) return CUSTOM_CURSOR; if (myCorner != null && right < myCorner.getIconWidth() && bottom < myCorner.getIconHeight()) { return DEFAULT_CURSOR; } Insets expected = getResizeBorder(view); if (expected != null) { if (view instanceof Frame) { int state = ((Frame)view).getExtendedState(); if (isStateSet(Frame.MAXIMIZED_HORIZ, state)) { left = Integer.MAX_VALUE; right = Integer.MAX_VALUE; } if (isStateSet(Frame.MAXIMIZED_VERT, state)) { top = Integer.MAX_VALUE; bottom = Integer.MAX_VALUE; } } if (top < expected.top) { if (left < expected.left * 2) return NW_RESIZE_CURSOR; if (right < expected.right * 2) return NE_RESIZE_CURSOR; return N_RESIZE_CURSOR; } if (bottom < expected.bottom) { if (left < expected.left * 2) return SW_RESIZE_CURSOR; if (right < expected.right * 2) return SE_RESIZE_CURSOR; return S_RESIZE_CURSOR; } if (left < expected.left) { if (top < expected.top * 2) return NW_RESIZE_CURSOR; if (bottom < expected.bottom * 2) return SW_RESIZE_CURSOR; return W_RESIZE_CURSOR; } if (right < expected.right) { if (top < expected.top * 2) return NE_RESIZE_CURSOR; if (bottom < expected.bottom * 2) return SE_RESIZE_CURSOR; return E_RESIZE_CURSOR; } } return CUSTOM_CURSOR; }
Example 15
Source File: JBCardLayout.java From consulo with Apache License 2.0 | 4 votes |
public void swipe(@Nonnull final Container parent, @Nonnull final String name, @Nonnull SwipeDirection direction, final @Nullable Runnable onDone) { stopSwipeIfNeed(); mySwipeFrom = findVisible(parent); mySwipeTo = myMap.get(name); if (mySwipeTo == null) return; if (mySwipeFrom == null || mySwipeFrom == mySwipeTo) { super.show(parent, name); if (onDone != null) { onDone.run(); } return; } final boolean isForward; if (direction == SwipeDirection.AUTO) { boolean b = true; for (Component component : myMap.values()) { if (component == mySwipeFrom || component == mySwipeTo) { b = component == mySwipeFrom; break; } } isForward = b; } else { isForward = direction == SwipeDirection.FORWARD; } final double[] linearProgress = new double[1]; linearProgress[0] = 0; final long startTime = System.currentTimeMillis(); ActionListener listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { long timePassed = System.currentTimeMillis() - startTime; if (timePassed >= mySwipeTime) { Component currentFocusComponent = IdeFocusManager.getGlobalInstance().getFocusedDescendantFor(parent); show(parent, name); if (currentFocusComponent != null) currentFocusComponent.requestFocusInWindow(); if (onDone != null) { onDone.run(); } return; } linearProgress[0] = Math.min(1, Math.max(0, (float)timePassed / mySwipeTime)); double naturalProgress = (1 - Math.cos(Math.PI * linearProgress[0])) / 2; Rectangle bounds = new Rectangle(parent.getWidth(), parent.getHeight()); JBInsets.removeFrom(bounds, parent.getInsets()); Rectangle r = new Rectangle(bounds); int x = (int)((naturalProgress * r.width)); r.translate(isForward ? -x : x, 0); mySwipeFrom.setBounds(r); Rectangle r2 = new Rectangle(bounds); r2.translate(isForward ? r2.width - x : x - r2.width, 0); mySwipeTo.setVisible(true); mySwipeTo.setBounds(r2); parent.repaint(); } }; for (ActionListener actionListener : myTimer.getActionListeners()) { myTimer.removeActionListener(actionListener); } myTimer.addActionListener(listener); myTimer.start(); }
Example 16
Source File: ScreenUtil.java From consulo with Apache License 2.0 | 4 votes |
private static Rectangle applyInsets(Rectangle rect, Insets i) { rect = new Rectangle(rect); JBInsets.removeFrom(rect, i); return rect; }
Example 17
Source File: ColorPanel.java From consulo with Apache License 2.0 | 4 votes |
@Override public void doLayout() { Rectangle bounds = new Rectangle(getWidth(), getHeight()); JBInsets.removeFrom(bounds, getInsets()); myTextField.setBounds(bounds); }
Example 18
Source File: DarculaCheckBoxUI.java From consulo with Apache License 2.0 | 4 votes |
protected Rectangle updateViewRect(AbstractButton b, Rectangle viewRect) { if (!(b.getBorder() instanceof DarculaCheckBoxBorder)) { JBInsets.removeFrom(viewRect, b.getInsets()); } return viewRect; }
Example 19
Source File: DarculaCheckBoxUI.java From consulo with Apache License 2.0 | 4 votes |
protected Dimension updatePreferredSize(JComponent c, Dimension size) { if (c.getBorder() instanceof DarculaCheckBoxBorder) { JBInsets.removeFrom(size, c.getInsets()); } return size; }
Example 20
Source File: DarculaRadioButtonUI.java From consulo with Apache License 2.0 | 4 votes |
protected Rectangle updateViewRect(AbstractButton b, Rectangle viewRect) { if (!(b.getBorder() instanceof DarculaRadioButtonBorder)) { JBInsets.removeFrom(viewRect, b.getInsets()); } return viewRect; }