Java Code Examples for com.intellij.util.ui.UIUtil#drawLine()
The following examples show how to use
com.intellij.util.ui.UIUtil#drawLine() .
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: DrawUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void drawRoundRect(Graphics g, double x1d, double y1d, double x2d, double y2d, Color color) { final Color oldColor = g.getColor(); g.setColor(color); int x1 = (int) Math.round(x1d); int x2 = (int) Math.round(x2d); int y1 = (int) Math.round(y1d); int y2 = (int) Math.round(y2d); UIUtil.drawLine(g, x1 + 1, y1, x2 - 1, y1); UIUtil.drawLine(g, x1 + 1, y2, x2 - 1, y2); UIUtil.drawLine(g, x1, y1 + 1, x1, y2 - 1); UIUtil.drawLine(g, x2, y1 + 1, x2, y2 - 1); g.setColor(oldColor); }
Example 2
Source File: ContentRootPanel.java From consulo with Apache License 2.0 | 6 votes |
private void drawDottedLine(Graphics2D g, int x1, int y1, int x2, int y2) { /* // TODO!!! final Color color = g.getColor(); g.setColor(getBackground()); g.setColor(color); for (int i = x1 / 2 * 2; i < x2; i += 2) { g.drawRect(i, y1, 0, 0); } */ final Stroke saved = g.getStroke(); if (!SystemInfo.isMac && !UIUtil.isUnderDarcula()) { g.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 0, DASH, y1 % 2)); } if (UIUtil.isUnderDarcula()) { UIUtil.drawDottedLine(g, x1, y1, x2, y2, null, g.getColor()); } else { UIUtil.drawLine(g, x1, y1, x2, y2); } g.setStroke(saved); }
Example 3
Source File: BegTabbedPaneUI.java From consulo with Apache License 2.0 | 6 votes |
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { if (tabPlacement == LEFT || myPaintContentBorder) { Rectangle selRect = selectedIndex < 0 ? null : getTabBounds(selectedIndex, calcRect); g.setColor(darkShadow); // Draw unbroken line if tabs are not on LEFT, OR // selected tab is not in run adjacent to content, OR // selected tab is not visible (SCROLL_TAB_LAYOUT) // if (tabPlacement != LEFT || selectedIndex < 0 || (selRect.x + selRect.width + 1 < x) || (selRect.y < y || selRect.y > y + h)) { UIUtil.drawLine(g, x, y, x, y + h - 2); } else { // Break line to show visual connection to selected tab UIUtil.drawLine(g, x, y, x, selRect.y + 1); if (selRect.y + selRect.height < y + h - 2) { UIUtil.drawLine(g, x, selRect.y + selRect.height + 1, x, y + h + 2); } } } }
Example 4
Source File: StrikeoutLabel.java From consulo with Apache License 2.0 | 6 votes |
protected void paintComponent(Graphics g) { super.paintComponent(g); if (myStrikeout){ Dimension size = getSize(); Dimension prefSize = getPreferredSize(); int width = Math.min(size.width, prefSize.width); int iconWidth = 0; Icon icon = getIcon(); if (icon != null){ iconWidth = icon.getIconWidth(); iconWidth += getIconTextGap(); } g.setColor(getForeground()); UIUtil.drawLine(g, iconWidth, size.height / 2, width, size.height / 2); } }
Example 5
Source File: EditorPlace.java From consulo with Apache License 2.0 | 6 votes |
private void drawPolygon(@Nonnull Graphics2D g, int startY, int height, @Nonnull Color color, boolean applied) { int scrollbarWidth = myEditor.getScrollPane().getVerticalScrollBar().getWidth(); int startX = 0; int endX = startX + scrollbarWidth - 1; int endY = startY + height; g.setColor(color); if (!applied) { if (height > 2) { g.fillRect(startX, startY, scrollbarWidth, height); Color framingColor = DiffUtil.getFramingColor(color); UIUtil.drawLine(g, startX, startY, endX, startY, null, framingColor); UIUtil.drawLine(g, startX, endY, endX, endY, null, framingColor); } else { DiffUtil.drawDoubleShadowedLine(g, startX, endX, startY, color); } } else { UIUtil.drawBoldDottedLine(g, startX, endX, startY, null, color, false); UIUtil.drawBoldDottedLine(g, startX, endX, endY, null, color, false); } }
Example 6
Source File: DiffDrawUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void drawChunkBorderLine(@Nonnull Graphics2D g, int x1, int x2, int y, @Nonnull Color color, boolean doubleLine, boolean dottedLine) { if (dottedLine && doubleLine) { UIUtil.drawBoldDottedLine(g, x1, x2, y - 1, null, color, false); UIUtil.drawBoldDottedLine(g, x1, x2, y, null, color, false); } else if (dottedLine) { UIUtil.drawBoldDottedLine(g, x1, x2, y - 1, null, color, false); } else if (doubleLine) { UIUtil.drawLine(g, x1, y, x2, y, null, color); UIUtil.drawLine(g, x1, y + 1, x2, y + 1, null, color); } else { UIUtil.drawLine(g, x1, y, x2, y, null, color); } }
Example 7
Source File: ArrowPainter.java From consulo with Apache License 2.0 | 5 votes |
/** * Paints arrow at the given graphics buffer using given coordinate parameters. * * @param g target graphics buffer to use * @param y defines baseline of the row where the arrow should be painted * @param start starting <code>'x'</code> position to use during drawing * @param stop ending <code>'x'</code> position to use during drawing */ public void paint(Graphics g, int y, int start, int stop) { stop -= myWidthProvider.compute() / 4; Color oldColor = g.getColor(); g.setColor(myColorHolder.getColor()); final int height = myHeightProvider.compute(); final int halfHeight = height / 2; int mid = y - halfHeight; int top = y - height; UIUtil.drawLine(g, start, mid, stop, mid); UIUtil.drawLine(g, stop, y, stop, top); g.fillPolygon(new int[]{stop - halfHeight, stop - halfHeight, stop}, new int[]{y, y - height, y - halfHeight}, 3); g.setColor(oldColor); }
Example 8
Source File: DarculaTableHeaderUI.java From consulo with Apache License 2.0 | 5 votes |
@Override public void paint(Graphics g2, JComponent c) { final Graphics2D g = (Graphics2D)g2; final GraphicsConfig config = new GraphicsConfig(g); final Color bg = c.getBackground(); g.setPaint(bg); TableColumnModel model = ((JTableHeader)c).getColumnModel(); final int h = c.getHeight(); final int w = model.getTotalColumnWidth(); g.fillRect(0, 0, w, h); JBColor bottomSeparatorColor = JBColor.namedColor("TableHeader.bottomSeparatorColor", ColorUtil.shift(bg, 0.75)); g.setPaint(bottomSeparatorColor); UIUtil.drawLine(g, 0, h - 1, w, h - 1); final Enumeration<TableColumn> columns = model.getColumns(); final Color lineColor = JBColor.namedColor("TableHeader.separatorColor", ColorUtil.shift(bg, 0.7)); int offset = 0; while (columns.hasMoreElements()) { final TableColumn column = columns.nextElement(); if (columns.hasMoreElements() && column.getWidth() > 0) { offset += column.getWidth(); g.setColor(lineColor); UIUtil.drawLine(g, offset - 1, 1, offset - 1, h - 3); } } config.restore(); super.paint(g, c); }
Example 9
Source File: ModernMenuUI.java From consulo with Apache License 2.0 | 5 votes |
private void drawIconBorder(Graphics g) { int i1 = a - JBUI.scale(1); int j1 = e - JBUI.scale(2); int k1 = i1 + myMaxGutterIconWidth + JBUI.scale(1); int l1 = j1 + myMaxGutterIconWidth + JBUI.scale(4); g.setColor(BegResources.m); UIUtil.drawLine(g, i1, j1, i1, l1); UIUtil.drawLine(g, i1, j1, k1, j1); g.setColor(BegResources.j); UIUtil.drawLine(g, k1, j1, k1, l1); UIUtil.drawLine(g, i1, l1, k1, l1); }
Example 10
Source File: BegBorders.java From consulo with Apache License 2.0 | 5 votes |
static void drawActiveButtonBorder(Graphics g, int x, int y, int w, int h) { drawFlush3DBorder(g, x, y, w, h); g.setColor(MetalLookAndFeel.getPrimaryControl()); UIUtil.drawLine(g, x + 1, y + 1, x + 1, h - 3); UIUtil.drawLine(g, x + 1, y + 1, w - 3, x + 1); g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); UIUtil.drawLine(g, x + 2, h - 2, w - 2, h - 2); UIUtil.drawLine(g, w - 2, y + 2, w - 2, h - 2); }
Example 11
Source File: LineStatusMarkerRenderer.java From consulo with Apache License 2.0 | 5 votes |
private static void paintRect(@Nonnull Graphics g, @javax.annotation.Nullable Color color, @Nullable Color borderColor, int x1, int y1, int x2, int y2) { if (color != null) { g.setColor(color); g.fillRect(x1, y1, x2 - x1, y2 - y1); } if (borderColor != null) { g.setColor(borderColor); UIUtil.drawLine(g, x1, y1, x2 - JBUI.scale(1), y1); UIUtil.drawLine(g, x1, y1, x1, y2 - JBUI.scale(1)); UIUtil.drawLine(g, x1, y2 - JBUI.scale(1), x2 - JBUI.scale(1), y2 - JBUI.scale(1)); } }
Example 12
Source File: BegTabbedPaneUI.java From consulo with Apache License 2.0 | 5 votes |
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { if (tabPlacement == BOTTOM || myPaintContentBorder) { boolean leftToRight = isLeftToRight(tabPane); int bottom = y + h - 1; int right = x + w - 1; Rectangle selRect = selectedIndex < 0 ? null : getTabBounds(selectedIndex, calcRect); g.setColor(darkShadow); // Draw unbroken line if tabs are not on BOTTOM, OR // selected tab is not in run adjacent to content, OR // selected tab is not visible (SCROLL_TAB_LAYOUT) // if (tabPlacement != BOTTOM || selectedIndex < 0 || (selRect.y - 1 > h) || (selRect.x < x || selRect.x > x + w)) { UIUtil.drawLine(g, x, y + h - 1, x + w - 1, y + h - 1); } else { // Break line to show visual connection to selected tab boolean lastInRun = isLastInRun(selectedIndex); if (leftToRight || lastInRun) { UIUtil.drawLine(g, x, bottom, selRect.x, bottom); } else { UIUtil.drawLine(g, x, bottom, selRect.x - 1, bottom); } if (selRect.x + selRect.width < x + w - 2) { if (leftToRight && !lastInRun) { UIUtil.drawLine(g, selRect.x + selRect.width, bottom, right, bottom); } else { UIUtil.drawLine(g, selRect.x + selRect.width - 1, bottom, right, bottom); } } } } }
Example 13
Source File: BegBorders.java From consulo with Apache License 2.0 | 5 votes |
static void drawDefaultButtonPressedBorder(Graphics g, int x, int y, int w, int h) { drawPressed3DBorder(g, x + 1, y + 1, w - 1, h - 1); g.translate(x, y); g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawRect(0, 0, w - 3, h - 3); UIUtil.drawLine(g, w - 2, 0, w - 2, 0); UIUtil.drawLine(g, 0, h - 2, 0, h - 2); g.translate(-x, -y); }
Example 14
Source File: BegBorders.java From consulo with Apache License 2.0 | 5 votes |
static void drawDefaultButtonBorder(Graphics g, int x, int y, int w, int h, boolean active) { drawButtonBorder(g, x + 1, y + 1, w - 1, h - 1, active); g.translate(x, y); g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawRect(0, 0, w - 3, h - 3); UIUtil.drawLine(g, w - 2, 0, w - 2, 0); UIUtil.drawLine(g, 0, h - 2, 0, h - 2); g.translate(-x, -y); }
Example 15
Source File: TitlePanel.java From consulo with Apache License 2.0 | 5 votes |
protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; int width = getSize().width; int height = getSize().height; Object oldAntialiasing = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(new JBColor(Gray._247, UIUtil.getPanelBackground())); RoundRectangle2D rect = new RoundRectangle2D.Double(0, 0, width - 1, height - 1, 0, 0); g2.fill(rect); g2.setPaint(new JBColor(Color.GRAY, Gray._100)); UIUtil.drawLine(g2, 0, height - 1, width - 1, height - 1); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasing); }
Example 16
Source File: IdeaMenuUI.java From consulo with Apache License 2.0 | 5 votes |
private void drawIconBorder(Graphics g) { int i1 = a - JBUI.scale(1); int j1 = e - JBUI.scale(2); int k1 = i1 + myMaxGutterIconWidth + JBUI.scale(1); int l1 = j1 + myMaxGutterIconWidth + JBUI.scale(4); g.setColor(BegResources.m); UIUtil.drawLine(g, i1, j1, i1, l1); UIUtil.drawLine(g, i1, j1, k1, j1); g.setColor(BegResources.j); UIUtil.drawLine(g, k1, j1, k1, l1); UIUtil.drawLine(g, i1, l1, k1, l1); }
Example 17
Source File: DiffUtil.java From consulo with Apache License 2.0 | 4 votes |
public static void drawDoubleShadowedLine(@Nonnull Graphics2D g, int startX, int endX, int y, @Nonnull Color color) { UIUtil.drawLine(g, startX, y, endX, y, null, getFramingColor(color)); UIUtil.drawLine(g, startX, y + 1, endX, y + 1, null, color); }
Example 18
Source File: Graphics2DDelegate.java From consulo with Apache License 2.0 | 4 votes |
@Override public void drawLine(int x1, int y1, int x2, int y2) { UIUtil.drawLine(myDelegate, x1, y1, x2, y2); }
Example 19
Source File: DrawUtil.java From consulo with Apache License 2.0 | 4 votes |
public static void drawPlainRect(Graphics g, int x1, int y1, int x2, int y2) { UIUtil.drawLine(g, x1, y1, x2 - 1, y1); UIUtil.drawLine(g, x2, y1, x2, y2 - 1); UIUtil.drawLine(g, x1 + 1, y2, x2, y2); UIUtil.drawLine(g, x1, y1 + 1, x1, y2); }
Example 20
Source File: BegTabbedPaneUI.java From consulo with Apache License 2.0 | 4 votes |
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { g.setColor(darkShadow); switch (tabPlacement) { case TOP: { if (isSelected) { // left UIUtil.drawLine(g, x, y + 1, x, y + h - 1); // top UIUtil.drawLine(g, x + 1, y, x + w - 3, y); // right UIUtil.drawLine(g, x + w - 2, y + 1, x + w - 2, y + h - 1); } else { // left UIUtil.drawLine(g, x, y + 1, x, y + h - 1); // top UIUtil.drawLine(g, x + 1, y, x + w - 3, y); // right UIUtil.drawLine(g, x + w - 2, y + 1, x + w - 2, y + h - 1); } break; } case LEFT: { // top UIUtil.drawLine(g, x + 1, y + 1, x + w - 1, y + 1); // left UIUtil.drawLine(g, x, y + 2, x, y + h - 2); //bottom UIUtil.drawLine(g, x + 1, y + h - 1, x + w - 1, y + h - 1); break; } case BOTTOM: { if (isSelected) { // left UIUtil.drawLine(g, x, y, x, y + h - 2); // bottom UIUtil.drawLine(g, x + 1, y + h - 1, x + w - 2, y + h - 1); // right UIUtil.drawLine(g, x + w - 1, y, x + w - 1, y + h - 2); } else { // left UIUtil.drawLine(g, x, y, x, y + h - 1); // bottom UIUtil.drawLine(g, x + 1, y + h - 1, x + w - 3, y + h - 1); // right UIUtil.drawLine(g, x + w - 2, y, x + w - 2, y + h - 1); } break; } case RIGHT: { // top UIUtil.drawLine(g, x, y + 1, x + w - 2, y + 1); // right UIUtil.drawLine(g, x + w - 1, y + 2, x + w - 1, y + h - 2); //bottom UIUtil.drawLine(g, x, y + h - 1, x + w - 2, y + h - 1); break; } default: { throw new IllegalArgumentException("unknown tabPlacement: " + tabPlacement); } } }