java.awt.Color#darker ( )源码实例Demo

下面列出了java.awt.Color#darker ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: qpid-broker-j   文件: ColorFactory.java
/**
 * Converts a colour name known to the JDK into a {@link Color} instance.  Additionally,
 * if the work dark_ is prepended to the colour, a darker shade of the same colour is
 * produced.
 *
 * @param colourName
 * @return colour instance
 */
public static Color toColour(String colourName)
{
    boolean darkVersion = false;
    if (colourName.toLowerCase().startsWith("dark_"))
    {
        colourName = colourName.replaceFirst("(?i)dark_", "");
        darkVersion = true;
    }

    Color colour = getColourFromStaticField(colourName);
    if (darkVersion)
    {
        return colour.darker();
    }
    else
    {
        return colour;
    }
}
 
源代码2 项目: jdk8u_jdk   文件: XComponentPeer.java
void draw3DOval(Graphics g, Color bg,
            int x, int y, int w, int h, boolean raised)
{
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? shadow : highlight);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
源代码3 项目: blog-codes   文件: ShadowBorder.java
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);
	}
}
 
源代码4 项目: hottub   文件: XComponentPeer.java
void draw3DRect(Graphics g, Color bg,
                int x, int y, int width, int height,
                boolean raised) {
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawLine(x, y, x, y + height);
    g.drawLine(x + 1, y, x + width - 1, y);
    g.setColor(raised ? shadow : highlight);
    g.drawLine(x + 1, y + height, x + width, y + height);
    g.drawLine(x + width, y, x + width, y + height - 1);
    g.setColor(c);
}
 
源代码5 项目: dragonwell8_jdk   文件: XComponentPeer.java
void draw3DOval(Graphics g, Color bg,
            int x, int y, int w, int h, boolean raised)
{
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? shadow : highlight);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
源代码6 项目: dragonwell8_jdk   文件: XComponentPeer.java
void draw3DRect(Graphics g, Color bg,
                int x, int y, int width, int height,
                boolean raised) {
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawLine(x, y, x, y + height);
    g.drawLine(x + 1, y, x + width - 1, y);
    g.setColor(raised ? shadow : highlight);
    g.drawLine(x + 1, y + height, x + width, y + height);
    g.drawLine(x + width, y, x + width, y + height - 1);
    g.setColor(c);
}
 
源代码7 项目: Pixie   文件: MonochromeIcon.java
/**
 * Create an icon of the specified dimension and color.
 *
 * @param width  - the width of the icon
 * @param height - the height of the icon
 * @param color  - the color of the icon
 */
public MonochromeIcon(int width, int height, Color color) {
    this.width = width;
    this.height = height;
    this.color = color;

    this.border = color.darker();
}
 
源代码8 项目: TencentKona-8   文件: XComponentPeer.java
void draw3DOval(Graphics g, Color bg,
            int x, int y, int w, int h, boolean raised)
{
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? shadow : highlight);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
源代码9 项目: TencentKona-8   文件: XComponentPeer.java
void draw3DRect(Graphics g, Color bg,
                int x, int y, int width, int height,
                boolean raised) {
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawLine(x, y, x, y + height);
    g.drawLine(x + 1, y, x + width - 1, y);
    g.setColor(raised ? shadow : highlight);
    g.drawLine(x + 1, y + height, x + width, y + height);
    g.drawLine(x + width, y, x + width, y + height - 1);
    g.setColor(c);
}
 
源代码10 项目: jdk8u60   文件: XComponentPeer.java
void draw3DOval(Graphics g, Color bg,
            int x, int y, int w, int h, boolean raised)
{
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? shadow : highlight);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
源代码11 项目: dsworkbench   文件: ColorCellRenderer.java
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    JLabel l = (JLabel) c;

    Color selectColor = (Color) value;
    if (isSelected && bMarkSelection && selectColor != null) {
        selectColor = selectColor.darker();
    }
    l.setBackground(selectColor);
    l.setForeground(selectColor);
    l.setText("");
    return l;
}
 
源代码12 项目: openjdk-jdk8u   文件: XComponentPeer.java
void draw3DRect(Graphics g, Color bg,
                int x, int y, int width, int height,
                boolean raised) {
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawLine(x, y, x, y + height);
    g.drawLine(x + 1, y, x + width - 1, y);
    g.setColor(raised ? shadow : highlight);
    g.drawLine(x + 1, y + height, x + width, y + height);
    g.drawLine(x + width, y, x + width, y + height - 1);
    g.setColor(c);
}
 
源代码13 项目: binnavi   文件: ZyLabelContent.java
public void updateContentSelectionColor(final Color fillColor, final boolean isSelected) {
  final Color nodeSelectionColor = fillColor.darker();

  if (isSelected) {
    setSelectionColor(nodeSelectionColor.darker());
  } else {
    setSelectionColor(nodeSelectionColor);
  }
}
 
源代码14 项目: visualvm   文件: SimpleXYChartDescriptor.java
private Color getNextItemColor() {
    int newItemIndex = itemNames.size();
    int colorsCount  = ColorFactory.getPredefinedColorsCount();
    Color color = null;

    if (newItemIndex >= colorsCount) {
        color = ColorFactory.getPredefinedColor(newItemIndex % colorsCount);
        int darkerFactor = newItemIndex / colorsCount;
        while (darkerFactor-- > 0) color = color.darker();
    } else {
        color = ColorFactory.getPredefinedColor(newItemIndex);
    }

    return color;
}
 
源代码15 项目: jdk8u_jdk   文件: XComponentPeer.java
void draw3DRect(Graphics g, Color bg,
                int x, int y, int width, int height,
                boolean raised) {
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawLine(x, y, x, y + height);
    g.drawLine(x + 1, y, x + width - 1, y);
    g.setColor(raised ? shadow : highlight);
    g.drawLine(x + 1, y + height, x + width, y + height);
    g.drawLine(x + width, y, x + width, y + height - 1);
    g.setColor(c);
}
 
源代码16 项目: netbeans   文件: TimelineColorFactory.java
static Color getColor(int index) {
    Color color;

    if (index >= PREDEFINED_COLORS.length) {
        color = getPredefinedColor(index % PREDEFINED_COLORS.length);
        int darkerFactor = index / PREDEFINED_COLORS.length;
        while (darkerFactor-- > 0) color = color.darker();
    } else {
        color = getPredefinedColor(index);
    }

    return color;
}
 
源代码17 项目: openjdk-jdk8u-backup   文件: XComponentPeer.java
void draw3DOval(Graphics g, Color bg,
            int x, int y, int w, int h, boolean raised)
{
    Color c = g.getColor();
    Color shadow = bg.darker();
    Color highlight = bg.brighter();

    g.setColor(raised ? highlight : shadow);
    g.drawArc(x, y, w, h, 45, 180);
    g.setColor(raised ? shadow : highlight);
    g.drawArc(x, y, w, h, 225, 180);
    g.setColor(c);
}
 
源代码18 项目: chipster   文件: PeakSelectable.java
public void render(GBrowserView view, Color color) {		

		Rectangle rect = new Rectangle();

		rect.x = view.bpToTrack(region.start);
		rect.width = view.bpToTrack(region.end) - rect.x;

		if (rect.width < MIN_VISIBLE_PEAK_SIZE) {
			rect.width = MIN_VISIBLE_PEAK_SIZE;
		}

		rect.y = 0;
		rect.height = PEAK_SYMBOL_HEIGHT;

		this.rectDrawable = new RectDrawable(rect, color, color.darker());
	}
 
源代码19 项目: netbeans   文件: OutputOptions.java
static Color ensureContrastingColor(Color fg, Color bg) {
    if (bg == null) {
        if (isNimbus()) {
            bg = UIManager.getColor("Tree.background"); //NOI18N
            if (null == bg) {
                bg = Color.WHITE;
            }
        } else {
            bg = UIManager.getColor("text"); //NOI18N

            if (bg == null) {
                bg = Color.WHITE;
            }
        }
    }
    if (fg == null) {
        if (isNimbus()) {
            fg = UIManager.getColor("Tree.foreground"); //NOI18N
            if (null == fg) {
                fg = Color.BLACK;
            }
        } else {
            fg = UIManager.getColor("textText"); //NOI18N
            if (fg == null) {
                fg = Color.BLACK;
            }
        }
    }

    if (Color.BLACK.equals(fg) && Color.WHITE.equals(fg)) {
        return fg;
    }

    boolean replace = fg.equals(bg);
    int dif = 0;

    if (!replace) {
        dif = difference(fg, bg);
        replace = dif < 60;
    }

    if (replace) {
        int lum = luminance(bg);
        boolean darker = lum >= 128;

        if (darker) {
            fg = fg.darker();
        } else {
            fg = fg.brighter();
        }
    }

    return fg;
}
 
源代码20 项目: netbeans   文件: CoverageBar.java
@Override
protected void paintComponent(Graphics g) {

    if (!(g instanceof Graphics2D)) {
        return;
    }

    int width = getWidth();
    int barRectWidth = width;
    int height = getHeight();
    int barRectHeight = height;

    if (barRectWidth <= 0 || barRectHeight <= 0) {
        return;
    }

    int amountFull = (int) (barRectWidth * coveragePercentage / 100.0f);

    Graphics2D g2 = (Graphics2D) g;

    g2.setColor(getBackground());

    Color notCoveredLight = NOT_COVERED_LIGHT;
    Color notCoveredDark = NOT_COVERED_DARK;
    Color coveredLight = COVERED_LIGHT;
    Color coveredDark = COVERED_DARK;
    if (emphasize) {
        coveredDark = coveredDark.darker();
    } else if (selected) {
        coveredLight = coveredLight.brighter();
        coveredDark = coveredDark.darker();
    }
    if (emphasize) {
        notCoveredDark = notCoveredDark.darker();
    } else if (selected) {
        notCoveredLight = notCoveredLight.brighter();
        notCoveredDark = notCoveredDark.darker();
    }

    g2.setPaint(new GradientPaint(0, 0, notCoveredLight,
            0, height / 2, notCoveredDark));
    g2.fillRect(amountFull, 1, width - 1, height / 2);
    g2.setPaint(new GradientPaint(0, height / 2, notCoveredDark,
            0, 2 * height, notCoveredLight));
    g2.fillRect(amountFull, height / 2, width - 1, height / 2);

    g2.setColor(getForeground());

    g2.setPaint(new GradientPaint(0, 0, coveredLight,
            0, height / 2, coveredDark));
    g2.fillRect(1, 1, amountFull, height / 2);
    g2.setPaint(new GradientPaint(0, height / 2, coveredDark,
            0, 2 * height, coveredLight));
    g2.fillRect(1, height / 2, amountFull, height / 2);

    Rectangle oldClip = g2.getClipBounds();
    if (coveragePercentage > 0.0f) {
        g2.setColor(coveredDark);
        g2.clipRect(0, 0, amountFull + 1, height);
        g2.drawRect(0, 0, width - 1, height - 1);
    }
    if (coveragePercentage < 100.0f) {
        g2.setColor(notCoveredDark);
        g2.setClip(oldClip);
        g2.clipRect(amountFull, 0, width, height);
        g2.drawRect(0, 0, width - 1, height - 1);
    }
    g2.setClip(oldClip);

    g2.setFont(getFont());
    paintDropShadowText(g2, barRectWidth, barRectHeight);
}