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); }
public void paintIcon(java.awt.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 void initialize() { Color fg = super.getLineColor(); // Use super because not fully init'd Color fill = super.getFillColor(); outlineFig = new FigPoly(fg, fill); outlineFig.addPoint(0, 0); outlineFig.addPoint(width - 1 - dogear, 0); outlineFig.addPoint(width - 1, dogear); outlineFig.addPoint(width - 1, height - 1); outlineFig.addPoint(0, height - 1); outlineFig.addPoint(0, 0); outlineFig.setFilled(true); outlineFig.setLineWidth(LINE_WIDTH); urCorner = new FigPoly(fg, fill); urCorner.addPoint(width - 1 - dogear, 0); urCorner.addPoint(width - 1, dogear); urCorner.addPoint(width - 1 - dogear, dogear); urCorner.addPoint(width - 1 - dogear, 0); urCorner.setFilled(true); Color col = outlineFig.getFillColor(); urCorner.setFillColor(col.darker()); urCorner.setLineWidth(LINE_WIDTH); setBigPort(new FigRect(0, 0, width, height, null, null)); getBigPort().setFilled(false); getBigPort().setLineWidth(0); // add Figs to the FigNode in back-to-front order addFig(getBigPort()); addFig(outlineFig); addFig(urCorner); addFig(getStereotypeFig()); addFig(bodyTextFig); col = outlineFig.getFillColor(); urCorner.setFillColor(col.darker()); setBlinkPorts(false); // make port invisible unless mouse enters Rectangle r = getBounds(); setBounds(r.x, r.y, r.width, r.height); updateEdges(); readyToEdit = false; // Mark this as newly created. This is to get round the problem with // creating figs for loaded comments that had stereotypes. They are // saved with their dimensions INCLUDING the stereotype, but since we // pretend the stereotype is not visible, we add height the first time // we render such a comment. This is a complete fudge, and really we // ought to address how comment objects with stereotypes are saved. But // that will be hard work. newlyCreated = true; }
protected void paintDisabledText(DateComponent dc, Graphics g, String s, int textX, int textY) { Color background = dc.getBackground(); g.setColor(background.brighter()); SwingUtilities2.drawString(dc, g, s, textX + 1, textY + 1); g.setColor(background.darker()); SwingUtilities2.drawString(dc, g, s, textX, textY); }
/** * Function: getJavaColor Pre: Takes an ANIMAL color string 'c' Post: Returns the java color for * this node (Note: returns "white" as a default) */ private Color getJavaColor(String c) { if (!isValidNodeColor(c)) return Color.white; // Temporary color to use with numbered colors Color temp = Color.white; if (c.compareTo("black") == 0) return Color.black; if (c.compareTo("white") == 0) return Color.white; if (c.compareTo("gray") == 0) return Color.gray; if (c.compareTo("yellow") == 0) return Color.yellow; if (c.startsWith("blue")) temp = Color.blue; if (c.startsWith("cyan")) temp = Color.cyan; if (c.startsWith("pink")) temp = Color.pink; if (c.startsWith("red")) temp = Color.red; if (c.startsWith("magenta")) temp = Color.magenta; if (c.startsWith("green")) temp = Color.green; // Finally, do some final handling for temp = temp.darker().darker(); if (c.endsWith("2")) return temp.brighter(); if (c.endsWith("3")) return temp.brighter().brighter(); if (c.endsWith("4")) return temp.brighter().brighter().brighter(); return temp; }
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); }
/** * overridden to draw the component * * @param g graphics object */ public void paintComponent(java.awt.Graphics g) { gp = new GradientPaint(20, 20, c.brighter(), getWidth() / 2, getHeight() / 2, c.darker(), true); Graphics2D g2 = (Graphics2D) g; if (gp != null) { g2.setColor(c); g2.setPaint(gp); g2.drawRoundRect(0, 0, getWidth() + 1, getHeight() - 2, 8, 8); g2.setColor(c.darker()); g2.drawRoundRect(0, 1, getWidth() + 2, getHeight() - 3, 7, 7); g2.setColor(c.darker().darker()); g2.drawRoundRect(0, 2, getWidth() + 4, getHeight() - 4, 6, 6); g2.setPaint(gp); g2.fillRoundRect(0, 3, getWidth() + 6, getHeight() - 6, 5, 5); } paintChildren(g); }
@Override public boolean apply(NodeRenderingProperty p) { if (!isColorEnabled) { p.targetFillColor = NodeColors.getDefaultColor(); return true; } @SuppressWarnings("unchecked") NodeColorData vals = (NodeColorData) p.pluginStore.get(this); Color color = guessColor(p); if (p.isSelected()) { p.targetStrokeColor = Color.red; p.targetFillColor = color.darker().darker(); return true; } if (seedColoring && vals.degree == 0) { p.targetStrokeColor = Color.green; p.targetFillColor = Color.green; // c.brighter().brighter(); return true; } p.targetFillColor = color; p.targetStrokeColor = Color.blue; return true; }
/** * Returns the default table cell renderer. * * @param table the <code>JTable</code> * @param value the value to assign to the cell at <code>[row, column]</code> * @param isSelected true if cell is selected * @param hasFocus true if cell has focus * @param row the row of the cell to render * @param column the column of the cell to render * @return the default table cell renderer */ @Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { this.setBackground(table.getSelectionBackground()); this.setForeground(table.getSelectionForeground()); } else { this.setBackground(table.getBackground()); this.setForeground(table.getForeground()); } this.setEnabled(table.isEnabled()); this.setFont(table.getFont()); if (value instanceof CEMSystemActivity) { CEMSystemActivity activity = (CEMSystemActivity) value; int state = activity.getState(); this.setText(activity.getText()); if (state == CEMEntry.STATUS_ACCEPTED_INT || state == CEMEntry.STATUS_PENDING_INT) { Color backgroundColor = table.getBackground(); if (state == CEMEntry.STATUS_ACCEPTED_INT) { backgroundColor = this.colorAccepted; } else if (state == CEMEntry.STATUS_PENDING_INT) { backgroundColor = this.colorPending; } if (isSelected) { this.setBackground(backgroundColor.darker()); } else { this.setBackground(backgroundColor); } } } return (this); }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { // choose which colors we want to use Color bg = c.getBackground(); if (c.getParent() != null) { bg = c.getParent().getBackground(); } if (bg != null) { Color mid = bg.darker(); Color edge = average(mid, bg); g.setColor(bg); g.drawLine(0, h - 2, w, h - 2); g.drawLine(0, h - 1, w, h - 1); g.drawLine(w - 2, 0, w - 2, h); g.drawLine(w - 1, 0, w - 1, h); // draw the drop-shadow g.setColor(mid); g.drawLine(1, h - 2, w - 2, h - 2); g.drawLine(w - 2, 1, w - 2, h - 2); g.setColor(edge); g.drawLine(2, h - 1, w - 2, h - 1); g.drawLine(w - 1, 2, w - 1, h - 2); } }
@NotNull public Color getSeparatorColor(@Nullable Color highlightColor) { if (myApplied) { return highlightColor == null ? Color.DARK_GRAY : highlightColor.darker(); } return Color.GRAY; }
public void refresh(GameView view) { Color c = view.getCountryColor(country); if (c != null) { if (view.isCountrySelected(country)) { c = c.darker(); c = c.darker(); c = c.darker(); } else if (view.isCountryNeighbourSelected(country)) { c = c.brighter(); c = c.brighter(); c = c.brighter(); } setBackground(c); setText(view.getCountryTroops(country) + ""); } }
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 draw(Graphics2D g) { g.setColor(color); g.fillOval((int) x - r, (int) y - r, 2 * r, 2 * r); g.setStroke(new BasicStroke(3)); g.setColor(color.darker()); g.drawOval((int) x - r, (int) y - r, 2 * r, 2 * r); g.setStroke(new BasicStroke(1)); }
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); }
@Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Color background = c.getBackground(); g.setColor(background == null ? Color.LIGHT_GRAY : background.darker()); g.drawLine(0, 0, width - 1, 0); g.drawLine(width - 1, 0, width - 1, height - 1); g.drawLine(0, height - 1, width - 1, height - 1); g.drawLine(0, 0, 0, height - 1); }
/** @return the color */ public Color getActiveColor() { synchronized (blinkingState) { if (blinkingState == BlinkingStateEnum.BLINKING_BRILLIANT) { return (color == Color.WHITE) ? color.darker() : color.brighter(); } return color; } }
/** * Prints the colour red, green and blue values of the colour displayed in the frame after calling * the Color#darker method. */ public void displayDarkerColour() { JFrame frame = new JFrame(); frame.setSize(200, 200); Color myColor = Color.RED; Color c2 = myColor.darker(); frame.getContentPane().setBackground(c2); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
public Element(String name, Color c) { this.name = name; border = c; fill = c.darker(); if (fill.equals(border)) { Color iborder = new Color(255 - border.getRed(), 255 - border.getGreen(), 255 - border.getBlue()); fill = new Color( 255 - iborder.darker().getRed(), 255 - iborder.darker().getGreen(), 255 - iborder.darker().getBlue()); } rr = new RoundRectangle2D.Double(0, 0, 1, 1, 20, 20); labelBox = new Rectangle(0, 0, 1, 1); closeBox = new Rectangle(0, 0, 1, 1); editor = null; drawName = true; }
private Color getColor(int posValue) { Color result = Color.white; int mul = 0; int mod = 0; int getColorBaseNum = 9; // black is invalid colour if (posValue < 0) result = Color.black; // white is neutral colour else if (posValue == 0) result = Color.white; else { if (posValue > getColorBaseNum) { mul = posValue / getColorBaseNum; mod = (posValue % getColorBaseNum) + 1; } else { mod = posValue; } switch (mod) { // case 0: result = Color.white; break; case 1: result = Color.yellow; break; case 2: result = Color.blue; break; case 3: result = Color.green; break; case 4: result = Color.orange; break; case 5: result = Color.red; break; case 6: result = Color.magenta; break; case 7: result = Color.gray; break; case 8: result = Color.cyan; break; case 9: result = Color.pink; break; // default: result = Color.black; break; } for (int i = 0; i <= mul - 1; i++) { result = result.darker(); } } return result; }
@Override public void draw( Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project, IDrawingObserver drawingObserver) { Shape clip = g2d.getClip(); if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y) && !clip.contains(secondPoint.x, firstPoint.y)) { return; } super.draw(g2d, componentState, outlineMode, project, drawingObserver); if (componentState != ComponentState.DRAGGING) { if (alpha < MAX_ALPHA) { g2d.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA)); } Point p = new Point(firstPoint); int diameter = getClosestOdd((int) PAD_SIZE.convertToPixels()); int holeDiameter = getClosestOdd((int) HOLE_SIZE.convertToPixels()); int spacing = (int) this.spacing.convertToPixels(); while (p.y < secondPoint.y - spacing) { p.x = firstPoint.x; p.y += spacing; while (p.x < secondPoint.x - spacing - diameter) { p.x += spacing; g2d.setColor(padColor); g2d.fillOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter); g2d.setColor(padColor.darker()); g2d.drawOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter); g2d.setColor(Constants.CANVAS_COLOR); g2d.fillOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter); g2d.setColor(padColor.darker()); g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter); } } super.drawCoordinates(g2d, spacing); } }
public void setBaseBackground(Color base) { if (base == null) { setBackground(SystemColor.control); hoverBackground = SystemColor.controlHighlight; depressedBackground = SystemColor.controlShadow; } else { setBackground(base); hoverBackground = base.brighter(); depressedBackground = base.darker(); } }
public void setBaseForeground(Color base) { if (base == null) { setForeground(SystemColor.controlText); hoverForeground = SystemColor.controlText; depressedForeground = SystemColor.controlHighlight; } else { hoverForeground = base.darker(); depressedForeground = base.brighter(); setForeground(base); } }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { if (g instanceof Graphics2D) { ((Graphics2D) g) .setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } g.setColor(tagSet.equals(highlighted) ? color.brighter() : color); g.fillRoundRect(x, y, ICON_WIDTH - 1, ICON_HEIGHT - 1, ICON_WIDTH / 2, ICON_WIDTH / 2); g.setColor(color.darker()); g.drawRoundRect(x, y, ICON_WIDTH - 1, ICON_HEIGHT - 1, ICON_WIDTH / 2, ICON_WIDTH / 2); }
public Paint getNextPaint() { // get new color from the default supplier Color baseColor = (Color) super.getNextPaint(); // ban colors that are too bright int colorSum = baseColor.getRed() + baseColor.getGreen() + baseColor.getBlue(); if (colorSum > 520) baseColor = baseColor.darker(); return baseColor; }
/** Set the LED colour to a user specified RGB */ public void setColor(int r, int g, int b) { // arbitrary colour LED Color mainColour = new Color(r, g, b); Color outerColour = mainColour.darker().darker().darker(); Color highlightColour = new Color(148, 148, 148); state = new Colours(mainColour, outerColour, highlightColour); off = false; repaint(); }
private BlockType(Color color, int dimension, int cols, int rows, boolean[][] blocks) { this.baseColor = color; this.lightColor = color.brighter(); this.darkColor = color.darker(); this.dimension = dimension; this.blocks = blocks; this.cols = cols; this.rows = rows; this.spawnCol = 5 - (dimension >> 1); this.spawnRow = getTopInset(0); }
/** * 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); } }
private static void drawMenuBezel( Graphics g, Color background, int x, int y, int width, int height) { // shadowed button region g.setColor(background); g.fillRect(x, y, width, height); g.setColor(background.brighter().brighter()); g.drawLine(x + 1, y + height - 1, x + width - 1, y + height - 1); g.drawLine(x + width - 1, y + height - 2, x + width - 1, y + 1); g.setColor(background.darker().darker()); g.drawLine(x, y, x + width - 2, y); g.drawLine(x, y + 1, x, y + height - 2); }