public void paintIcon(Component c, Graphics g, int x, int y) { Color color = c == null ? Color.GRAY : c.getBackground(); // In a compound sort, make each succesive triangle 20% // smaller than the previous one. int dx = (int) (size / 2 * Math.pow(0.8, priority)); int dy = descending ? dx : -dx; // Align icon (roughly) with font baseline. y = y + 5 * size / 6 + (descending ? -dy : 0); int shift = descending ? 1 : -1; g.translate(x, y); // Right diagonal. g.setColor(color.darker()); g.drawLine(dx / 2, dy, 0, 0); g.drawLine(dx / 2, dy + shift, 0, shift); // Left diagonal. g.setColor(color.brighter()); g.drawLine(dx / 2, dy, dx, 0); g.drawLine(dx / 2, dy + shift, dx, shift); // Horizontal line. if (descending) { g.setColor(color.darker().darker()); } else { g.setColor(color.brighter().brighter()); } g.drawLine(dx, 0, 0, 0); g.setColor(color); g.translate(-x, -y); }
private static Icon getThemeIcon(ColorScheme colorScheme, boolean square) { int iSize = SubstanceSizeUtils.getTitlePaneIconSize(); BufferedImage result = SubstanceCoreUtilities.getBlankImage(iSize, iSize); Graphics2D graphics = (Graphics2D) result.getGraphics().create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Color color1 = (colorScheme == null) ? Color.red : colorScheme.getUltraDarkColor(); Color color2 = (colorScheme == null) ? Color.green : colorScheme.getMidColor(); Color color3 = (colorScheme == null) ? Color.blue : colorScheme.getExtraLightColor(); graphics.setColor(color1); if (square) graphics.fillRect(5, 2, 6, 6); else graphics.fillOval(5, 2, 6, 6); graphics.setColor(color1.darker()); if (square) graphics.drawRect(5, 2, 6, 6); else graphics.drawOval(5, 2, 6, 6); graphics.setColor(color2); if (square) graphics.fillRect(1, 9, 6, 6); else graphics.fillOval(1, 9, 6, 6); graphics.setColor(color2.darker()); if (square) graphics.drawRect(1, 9, 6, 6); else graphics.drawOval(1, 9, 6, 6); graphics.setColor(color3); if (square) graphics.fillRect(9, 9, 6, 6); else graphics.fillOval(9, 9, 6, 6); graphics.setColor(color3.darker()); if (square) graphics.drawRect(9, 9, 6, 6); else graphics.drawOval(9, 9, 6, 6); graphics.dispose(); return new ImageIcon(result); }
private void drawSquare(Graphics g, int x, int y, Tetrominoes shape) { int squareWidth = (int) getSize().getWidth() / model.getWidth(); int squareHeight = (int) getSize().getHeight() / model.getHeight(); Color colors[] = { new Color(0, 0, 0), new Color(204, 102, 102), new Color(102, 204, 102), new Color(102, 102, 204), new Color(204, 204, 102), new Color(204, 102, 204), new Color(102, 204, 204), new Color(218, 170, 0) }; Color color = colors[shape.ordinal()]; g.setColor(color); g.fillRect(x + 1, y + 1, squareWidth - 2, squareHeight - 2); g.setColor(color.brighter()); g.drawLine(x, y + squareHeight - 1, x, y); g.drawLine(x, y, x + squareWidth - 1, y); g.setColor(color.darker()); g.drawLine(x + 1, y + squareHeight - 1, x + squareWidth - 1, y + squareHeight - 1); g.drawLine(x + squareWidth - 1, y + squareHeight - 1, x + squareWidth - 1, y + 1); }
/** * Draw character in minimap * * @param g Graphics * @param Dx X Displacement * @param Dy Y Displacement */ public void MapDraw(Graphics g, int Dx, int Dy, double Scale, Color col) { // Color g.setColor(col.darker().darker().darker()); g.drawOval((int) (X * Scale + Dx), (int) (Y * Scale + Dy), 7, 7); g.setColor(col); g.fillOval((int) (X * Scale + Dx), (int) (Y * Scale + Dy), 7, 7); }
private void drawColorButton(Graphics g, int no) { g.setColor(cDarkShadowColor); g.drawLine(mRect[no].x, mRect[no].y, mRect[no].x + mRect[no].width - 2, mRect[no].y); g.drawLine(mRect[no].x, mRect[no].y, mRect[no].x, mRect[no].y + mRect[no].height - 2); g.drawLine( mRect[no].x + mRect[no].width - 2, mRect[no].y + 2, mRect[no].x + mRect[no].width - 2, mRect[no].y + mRect[no].height - 2); g.drawLine( mRect[no].x + 2, mRect[no].y + mRect[no].height - 2, mRect[no].x + mRect[no].width - 2, mRect[no].y + mRect[no].height - 2); if (mPressedButton != no || !mMouseOverButton) g.setColor(Color.white); g.drawLine( mRect[no].x + 1, mRect[no].y + 1, mRect[no].x + mRect[no].width - 3, mRect[no].y + 1); g.drawLine( mRect[no].x + 1, mRect[no].y + 1, mRect[no].x + 1, mRect[no].y + mRect[no].height - 3); if (mPressedButton == no && mMouseOverButton) g.setColor(Color.white); g.drawLine( mRect[no].x + mRect[no].width - 1, mRect[no].y + 1, mRect[no].x + mRect[no].width - 1, mRect[no].y + mRect[no].height - 1); g.drawLine( mRect[no].x + 1, mRect[no].y + mRect[no].height - 1, mRect[no].x + mRect[no].width - 1, mRect[no].y + mRect[no].height - 1); if (mColorListMode != VisualizationColor.cColorListModeCategories && no == cColorWedgeButton) { int x1 = mRect[no].x + 2; int x2 = x1 + mRect[no].width - 4; if (x1 < x2) { for (int x = x1; x < x2; x++) { int c = mWedgeColorList.length * (x - x1) / (x2 - x1); g.setColor( (mPressedButton == no && mMouseOverButton) ? mWedgeColorList[c].darker() : mWedgeColorList[c]); g.drawLine(x, mRect[no].y + 2, x, mRect[no].y + mRect[no].height - 3); } } } else { Color color = (mColorListMode == VisualizationColor.cColorListModeCategories) ? mCategoryColorList[no] : mWedgeColorList[no * (mWedgeColorList.length - 1)]; if (mPressedButton == no && mMouseOverButton) color = color.darker(); g.setColor(color); g.fillRect(mRect[no].x + 2, mRect[no].y + 2, mRect[no].width - 4, mRect[no].height - 4); } }
public void paintIcon(Component c, Graphics g, int x, int y) { if (color == null) return; g.setColor(color); g.fillRect(x, y, getIconWidth(), getIconHeight()); g.setColor(color.darker()); g.drawRect(x, y, getIconWidth() - 1, getIconHeight() - 1); }
/** * Performs disabled text painting. * * @param label label to process * @param g2d graphics context * @param text label text * @param textX text X coordinate * @param textY text Y coordinate */ protected void paintDisabledText( final E label, final Graphics2D g2d, final String text, final int textX, final int textY) { if (label.isEnabled() && drawShade) { g2d.setColor(label.getBackground().darker()); paintShadowText(g2d, text, textX, textY); } else { final int accChar = label.getDisplayedMnemonicIndex(); final Color background = label.getBackground(); g2d.setColor(background.brighter()); SwingUtils.drawStringUnderlineCharAt(g2d, text, accChar, textX + 1, textY + 1); g2d.setColor(background.darker()); SwingUtils.drawStringUnderlineCharAt(g2d, text, accChar, textX, textY); } }
/** * Initializes the default set of colors used by the PropertySheetTable. * * @see #categoryBackground * @see #categoryForeground * @see #selectedCategoryBackground * @see #selectedCategoryForeground * @see #propertyBackground * @see #propertyForeground * @see #selectedPropertyBackground * @see #selectedPropertyForeground */ private void initDefaultColors() { this.categoryBackground = UIManager.getColor(PANEL_BACKGROUND_COLOR_KEY); this.categoryForeground = UIManager.getColor(TABLE_FOREGROUND_COLOR_KEY).darker().darker().darker(); this.selectedCategoryBackground = categoryBackground.darker(); this.selectedCategoryForeground = categoryForeground; this.propertyBackground = UIManager.getColor(TABLE_BACKGROUND_COLOR_KEY); this.propertyForeground = UIManager.getColor(TABLE_FOREGROUND_COLOR_KEY); this.selectedPropertyBackground = UIManager.getColor(TABLE_SELECTED_BACKGROUND_COLOR_KEY); this.selectedPropertyForeground = UIManager.getColor(TABLE_SELECTED_FOREGROUND_COLOR_KEY); setGridColor(categoryBackground); }
/** * Esta funcion se usa para pintar la barra de seleccion de los menus. Esta aqui para no repetirla * en todas partes... */ static void pintaBarraMenu(Graphics g, JMenuItem menuItem, Color bgColor) { ButtonModel model = menuItem.getModel(); Color oldColor = g.getColor(); int menuWidth = menuItem.getWidth(); int menuHeight = menuItem.getHeight(); if (menuItem.isOpaque()) { g.setColor(menuItem.getBackground()); g.fillRect(0, 0, menuWidth, menuHeight); } if ((menuItem instanceof JMenu && !(((JMenu) menuItem).isTopLevelMenu()) && model.isSelected()) || model.isArmed()) { RoundRectangle2D.Float boton = new RoundRectangle2D.Float(); boton.x = 1; boton.y = 0; boton.width = menuWidth - 3; boton.height = menuHeight - 1; boton.arcwidth = 8; boton.archeight = 8; GradientPaint grad = new GradientPaint(1, 1, getBrilloMenu(), 0, menuHeight, getSombraMenu()); Graphics2D g2D = (Graphics2D) g; g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(bgColor); g2D.fill(boton); g.setColor(bgColor.darker()); g2D.draw(boton); g2D.setPaint(grad); g2D.fill(boton); g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT); } g.setColor(oldColor); }
public static Color getFramingColor(@NotNull Color backgroundColor) { return backgroundColor.darker(); }
public void paint(final Graphics g, final JComponent c) { final AnchoredButton button = (AnchoredButton) c; final String text = button.getText(); final Icon icon = (button.isEnabled()) ? button.getIcon() : button.getDisabledIcon(); if ((icon == null) && (text == null)) { return; } final FontMetrics fm = button.getFontMetrics(button.getFont()); ourViewInsets = c.getInsets(ourViewInsets); ourViewRect.x = ourViewInsets.left; ourViewRect.y = ourViewInsets.top; final ToolWindowAnchor anchor = button.getAnchor(); // Use inverted height & width if (ToolWindowAnchor.RIGHT == anchor || ToolWindowAnchor.LEFT == anchor) { ourViewRect.height = c.getWidth() - (ourViewInsets.left + ourViewInsets.right); ourViewRect.width = c.getHeight() - (ourViewInsets.top + ourViewInsets.bottom); } else { ourViewRect.height = c.getHeight() - (ourViewInsets.left + ourViewInsets.right); ourViewRect.width = c.getWidth() - (ourViewInsets.top + ourViewInsets.bottom); } ourIconRect.x = ourIconRect.y = ourIconRect.width = ourIconRect.height = 0; ourTextRect.x = ourTextRect.y = ourTextRect.width = ourTextRect.height = 0; final String clippedText = SwingUtilities.layoutCompoundLabel( c, fm, text, icon, button.getVerticalAlignment(), button.getHorizontalAlignment(), button.getVerticalTextPosition(), button.getHorizontalTextPosition(), ourViewRect, ourIconRect, ourTextRect, button.getText() == null ? 0 : button.getIconTextGap()); // Paint button's background final Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); final ButtonModel model = button.getModel(); final Color background = button.getBackground(); Color toBorder = model.isRollover() ? new Color(0, 0, 0, 50) : null; final boolean vertical = anchor == ToolWindowAnchor.LEFT || anchor == ToolWindowAnchor.RIGHT; if (model.isArmed() && model.isPressed() || model.isSelected()) { g2.setColor(new Color(0, 0, 0, 30)); g2.fillRect(3, 3, button.getWidth() - (vertical ? 6 : 5), button.getHeight() - 6); g2.setColor(new Color(0, 0, 0, 120)); g2.drawLine(2, 2, 3 + button.getWidth() - (vertical ? 7 : 6), 2); g2.drawLine(2, 3, 2, 3 + button.getHeight() - 7); g2.setColor(new Color(0, 0, 0, 40)); g2.drawRect(3, 3, button.getWidth() - (vertical ? 7 : 6), button.getHeight() - 7); g2.setColor(new Color(255, 255, 255, 110)); g2.drawLine( 3, button.getHeight() - 3, 3 + button.getWidth() - (vertical ? 6 : 5), button.getHeight() - 3); g2.drawLine( 3 + button.getWidth() - (vertical ? 6 : 5), 2, 3 + button.getWidth() - (vertical ? 6 : 5), 3 + button.getHeight() - 7); toBorder = null; } if (toBorder != null) { g.setColor(toBorder); g.drawRect(2, 2, button.getWidth() - (vertical ? 6 : 5), button.getHeight() - 6); } AffineTransform tr = null; if (ToolWindowAnchor.RIGHT == anchor || ToolWindowAnchor.LEFT == anchor) { tr = g2.getTransform(); if (ToolWindowAnchor.RIGHT == anchor) { if (icon != null) { // do not rotate icon icon.paintIcon(c, g2, ourIconRect.y, ourIconRect.x); } g2.rotate(Math.PI / 2); g2.translate(0, -c.getWidth()); } else { if (icon != null) { // do not rotate icon icon.paintIcon( c, g2, ourIconRect.y, c.getHeight() - ourIconRect.x - icon.getIconHeight()); } g2.rotate(-Math.PI / 2); g2.translate(-c.getHeight(), 0); } } else { if (icon != null) { icon.paintIcon(c, g2, ourIconRect.x, ourIconRect.y); } } // paint text if (text != null) { if (model.isEnabled()) { if (model.isArmed() && model.isPressed() || model.isSelected()) { g.setColor(background); } else { g.setColor(button.getForeground()); } } else { g.setColor(background.darker()); } /* Draw the Text */ if (model.isEnabled()) { /** * paint the text normally */ g.setColor(button.getForeground()); BasicGraphicsUtils.drawString( g, clippedText, button.getMnemonic2(), ourTextRect.x, ourTextRect.y + fm.getAscent()); } else { /** * paint the text disabled ** */ if (model.isSelected()) { g.setColor(c.getBackground()); } else { g.setColor(getDisabledTextColor()); } BasicGraphicsUtils.drawString( g, clippedText, button.getMnemonic2(), ourTextRect.x, ourTextRect.y + fm.getAscent()); } } if (ToolWindowAnchor.RIGHT == anchor || ToolWindowAnchor.LEFT == anchor) { g2.setTransform(tr); } }
public void setColor(Color color) { _color = color; setBackground(_color.darker()); }
@Override public boolean _setProgress( IdeFrame frame, Object processId, AppIconScheme.Progress scheme, double value, boolean isOk) { assertIsDispatchThread(); if (getAppImage() == null) return false; myCurrentProcessId = processId; if (Math.abs(myLastValue - value) < 0.02d) return true; try { int progressHeight = (int) (myAppImage.getHeight() * 0.13); int xInset = (int) (myAppImage.getWidth() * 0.05); int yInset = (int) (myAppImage.getHeight() * 0.15); final int width = myAppImage.getWidth() - xInset * 2; final int y = myAppImage.getHeight() - progressHeight - yInset; Shape rect = new RoundRectangle2D.Double( xInset, y, width, progressHeight, progressHeight, progressHeight); Shape border = new RoundRectangle2D.Double( xInset - 1, y - 1, width + 2, progressHeight + 2, (progressHeight + 2), (progressHeight + 2)); Shape progress = new RoundRectangle2D.Double( xInset + 1, y + 1, (width - 2) * value, progressHeight - 1, (progressHeight - 2), (progressHeight - 1)); AppImage appImg = createAppImage(); final Color brighter = Color.GRAY.brighter().brighter(); final Color backGround = new Color(brighter.getRed(), brighter.getGreen(), brighter.getBlue(), 85); appImg.myG2d.setColor(backGround); appImg.myG2d.fill(rect); final Color color = isOk ? scheme.getOkColor() : scheme.getErrorColor(); final Paint paint = UIUtil.getGradientPaint( xInset + 1, y + 1, color.brighter(), xInset + 1, y + progressHeight - 1, color.darker().darker()); appImg.myG2d.setPaint(paint); appImg.myG2d.fill(progress); appImg.myG2d.setColor(Color.GRAY.darker().darker()); appImg.myG2d.draw(rect); appImg.myG2d.draw(border); setDockIcon(appImg.myImg); myLastValue = value; } catch (Exception e) { LOG.error(e); } finally { myCurrentProcessId = null; } return true; }