当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.getColor方法代码示例

本文整理汇总了Java中java.awt.Graphics.getColor方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.getColor方法的具体用法?Java Graphics.getColor怎么用?Java Graphics.getColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Graphics的用法示例。


在下文中一共展示了Graphics.getColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
/**
 * Overrides the super method to set the stroke first.
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width,
        int height) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setStroke(this.stroke);

    Color oldColor = g.getColor();
    int i = this.thickness / 2;
    g.setColor(this.lineColor);
    if (!this.roundedCorners) {
        g.drawRect(x + i, y + i, width - i - i - 1, height - i - i - 1);
    } else {
        g.drawRoundRect(x + i, y + i, width - i - i - 1,
            height - i - i - 1, this.thickness, this.thickness);
    }
    g.setColor(oldColor);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:27,代码来源:StrokedLineBorder.java

示例2: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintBorder (
    Component c,
    Graphics g,
    int x, int y, int w, int h
) {
    Color oldColor = g.getColor ();
    g.translate (x, y);
    g.setColor (darker);
    g.drawLine (0, 0, 0, h - 1);
    g.drawLine (1, 0, w - 1, 0);
    g.setColor (brighter);
    g.drawLine (1, h - 1, w - 1, h - 1);
    g.drawLine (w - 1, 1, w - 1, h - 2);
    g.translate (-x, -y);
    g.setColor (oldColor);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:LoweredBorder.java

示例3: drawCheckBezelOut

import java.awt.Graphics; //导入方法依赖的package包/类
public void drawCheckBezelOut(Graphics g, int x, int y, int csize){
    Color controlShadow = UIManager.getColor("controlShadow");

    int w = csize;
    int h = csize;
    Color oldColor = g.getColor();

    g.translate(x,y);
    g.setColor(highlight);    // inner 3D border
    g.drawLine(0, 0, 0, h-1);
    g.drawLine(1, 0, w-1, 0);

    g.setColor(shadow);         // black drop shadow  __|
    g.drawLine(1, h-1, w-1, h-1);
    g.drawLine(w-1, h-1, w-1, 1);
    g.translate(-x,-y);
    g.setColor(oldColor);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:MotifIconFactory.java

示例4: paintRaisedBevel

import java.awt.Graphics; //导入方法依赖的package包/类
protected void paintRaisedBevel(Component c, Graphics g, int x, int y, int width, int height) {
    Color oldColor = g.getColor();
    int h = height;
    int w = width;

    g.translate(x, y);

    g.setColor(getHighlightOuterColor(c));
    g.drawLine(0, 0, 0, h - 2);
    g.drawLine(1, 0, w - 2, 0);

    g.setColor(getShadowOuterColor(c));
    g.drawLine(0, h - 1, w - 1, h - 1);
    g.drawLine(w - 1, 0, w - 1, h - 2);

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ThinBevelBorder.java

示例5: paintLoweredBevel

import java.awt.Graphics; //导入方法依赖的package包/类
protected void paintLoweredBevel(Component c, Graphics g, int x, int y, int width, int height) {
    Color oldColor = g.getColor();
    int h = height;
    int w = width;

    g.translate(x, y);

    g.setColor(getShadowInnerColor(c));
    g.drawLine(0, 0, 0, h - 1);
    g.drawLine(1, 0, w - 1, 0);

    g.setColor(getHighlightOuterColor(c));
    g.drawLine(1, h - 1, w - 1, h - 1);
    g.drawLine(w - 1, 1, w - 1, h - 2);

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ThinBevelBorder.java

示例6: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintBorder( Component c, Graphics g, int x, int y, int w, int h ) {
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();

    Color shade = shadow;
    Component p = b.getParent();
    if (p != null && p.getBackground().equals(shadow)) {
        shade = darkShadow;
    }

    if ((model.isRollover() && !(model.isPressed() && !model.isArmed())) ||
        model.isSelected()) {

        Color oldColor = g.getColor();
        g.translate(x, y);

        if (model.isPressed() && model.isArmed() || model.isSelected()) {
            // Draw the pressd button
            g.setColor(shade);
            g.drawRect(0, 0, w-1, h-1);
            g.setColor(lightHighlight);
            g.drawLine(w-1, 0, w-1, h-1);
            g.drawLine(0, h-1, w-1, h-1);
        } else {
            // Draw a rollover button
            g.setColor(lightHighlight);
            g.drawRect(0, 0, w-1, h-1);
            g.setColor(shade);
            g.drawLine(w-1, 0, w-1, h-1);
            g.drawLine(0, h-1, w-1, h-1);
        }
        g.translate(-x, -y);
        g.setColor(oldColor);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:BasicBorders.java

示例7: draw3DRect

import java.awt.Graphics; //导入方法依赖的package包/类
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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:XComponentPeer.java

示例8: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    Color oldColor = g.getColor();
    int i;

    g.setColor(lineColor);
    for(i = 0; i < thickness; i++)  {
        BasicGraphicsUtils.drawDashedRect(g, x+i, y+i, width-i-i, height-i-i);
    }
    g.setColor(oldColor);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:WindowsBorders.java

示例9: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintIcon(Component c, Graphics g, int x, int y) {
    Color oldColor = g.getColor();
    g.translate(x, y);

    g.setColor(color);
    g.fillRect(0, 0, ICON_SIZE.width, ICON_SIZE.height);

    g.setColor(Color.black);
    g.drawRect(0, 0, ICON_SIZE.width, ICON_SIZE.height);

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:14,代码来源:ColorChooserButton.java

示例10: print

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
	public void print(Graphics g, GraphicPanel f)
	{
//		if(radius <= 0)
//			g.fillOval(f.XtoWindow(position.getX()) - 5, f.YtoWindow(position.getY()) - 5, 10, 10);
//		else
		g.drawOval(f.XtoWindow(position.getX() - radius), f.YtoWindow(position.getY() + radius), f.distanceXtoWindow((radius) * 2), f.distanceYtoWindow((radius) * 2));
		
		Color c = g.getColor();
		Color cTransparent = new Color(c.getRed(), c.getGreen(), c.getBlue(), 30);
		g.setColor(cTransparent);
		
		g.fillOval(f.XtoWindow(position.getX() - radius), f.YtoWindow(position.getY() + radius), f.distanceXtoWindow((radius) * 2), f.distanceYtoWindow((radius) * 2));		
	}
 
开发者ID:PFGimenez,项目名称:The-Kraken-Pathfinding,代码行数:15,代码来源:CircularObstacle.java

示例11: paintText

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintText(SynthContext context, Graphics g, String text,
                      int x, int y, int mnemonicIndex) {
    if (text == null || text.length() <= 0) {
        // We don't need to paint empty strings
        return;
    }

    if (context.getRegion() == Region.INTERNAL_FRAME_TITLE_PANE) {
        // Metacity handles painting of text on internal frame title,
        // ignore this.
        return;
    }
    int componentState = context.getComponentState();
    if ((componentState & SynthConstants.DISABLED) ==
                          SynthConstants.DISABLED){
        Color orgColor = g.getColor();
        g.setColor(context.getStyle().getColor(context,
                                               GTKColorType.WHITE));
        x += 1;
        y += 1;
        super.paintText(context, g, text, x, y, mnemonicIndex);

        g.setColor(orgColor);
        x -= 1;
        y -= 1;
        super.paintText(context, g, text, x, y, mnemonicIndex);
    }
    else {
        String themeName = GTKLookAndFeel.getGtkThemeName();
        if (themeName != null && themeName.startsWith("blueprint") &&
            shouldShadowText(context.getRegion(), componentState)) {

            g.setColor(Color.BLACK);
            super.paintText(context, g, text, x+1, y+1, mnemonicIndex);
            g.setColor(Color.WHITE);
        }

        super.paintText(context, g, text, x, y, mnemonicIndex);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:GTKGraphicsUtils.java

示例12: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintIcon(Component c, Graphics g, int x, int y) {
    Color col = g.getColor();
    try {
        g.setColor(Color.BLUE);
        g.drawRect(x, y, getIconWidth(), getIconHeight());
        g.fillRect(x+3, y+3, getIconWidth()-5, getIconHeight()-5);
    } finally {
        g.setColor(col);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ComboTest.java

示例13: paintBackground

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
	ButtonModel model = menuItem.getModel();
	Color oldColor = g.getColor();
	int menuWidth = menuItem.getWidth();
	int menuHeight = menuItem.getHeight();

	g.setColor(colorBg);
	g.fillRect(0, 0, menuWidth, menuHeight);

	if (model.isArmed()
			|| (menuItem instanceof JMenu && model.isSelected())) {
		paintButtonPressed(g, menuItem);
	} else {
		// if (menuItem.getIcon() != null) {
		// int gap = menuItem.getIcon().getIconWidth() + 2;
		// g.setColor(this.darkColor);
		// g.drawLine(gap, 0, gap, menuItem.getHeight());
		// g.setColor(this.lightColor);
		// g.drawLine(gap + 1, 0, gap + 1, menuItem.getHeight());
		// }
	}

	if (menuItem instanceof JCheckBoxMenuItem) {
		if (((JCheckBoxMenuItem) menuItem).isSelected()) {
			// chkIcon.paintIcon(menuItem, g, 5, 5);
		}
	}

	g.setColor(oldColor);
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:32,代码来源:XDMMenuItemUI.java

示例14: paintScaledTriangle

import java.awt.Graphics; //导入方法依赖的package包/类
private void paintScaledTriangle(Graphics g, double x, double y, double size,
                                 int direction, boolean isEnabled) {
    size = Math.max(size, 2);
    Path2D.Double path = new Path2D.Double();
    path.moveTo(-size, size / 2);
    path.lineTo(size, size / 2);
    path.lineTo(0, -size / 2);
    path.closePath();
    AffineTransform affineTransform = new AffineTransform();
    affineTransform.rotate(Math.PI * (direction - 1) / 4);
    path.transform(affineTransform);

    Graphics2D g2d = (Graphics2D) g;
    double tx = x + size / 2;
    double ty = y + size / 2;
    g2d.translate(tx, ty);
    Color oldColor = g.getColor();
    if (!isEnabled) {
        g2d.translate(1, 0);
        g2d.setColor(highlight);
        g2d.fill(path);
        g2d.translate(-1, 0);
    }
    g2d.setColor(isEnabled ? darkShadow : shadow);
    g2d.fill(path);
    g2d.translate(-tx, -ty);
    g2d.setColor(oldColor);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:BasicArrowButton.java

示例15: draw

import java.awt.Graphics; //导入方法依赖的package包/类
/** Renders the rubber band on the given graphics object. */
public void draw(Graphics g) {
    if (this.bounds.width >= 0) {
        Color oldColor = g.getColor();
        g.setColor(JAttr.RUBBER_FOREGROUND);
        g.drawRect(this.bounds.x, this.bounds.y, this.bounds.width,
            this.bounds.height);
        g.setColor(JAttr.RUBBER_BACKGROUND);
        g.fillRect(this.bounds.x, this.bounds.y, this.bounds.width,
            this.bounds.height);
        g.setColor(oldColor);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:14,代码来源:JGraphUI.java


注:本文中的java.awt.Graphics.getColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。