本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
}