本文整理汇总了Java中java.awt.Graphics.drawOval方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.drawOval方法的具体用法?Java Graphics.drawOval怎么用?Java Graphics.drawOval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Graphics
的用法示例。
在下文中一共展示了Graphics.drawOval方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintInstance
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
InstanceDataSingleton data = (InstanceDataSingleton) painter.getData();
Value val = data == null ? Value.FALSE : (Value) data.getValue();
Bounds bds = painter.getBounds().expand(-1);
Graphics g = painter.getGraphics();
if (painter.getShowState()) {
Color onColor = painter.getAttributeValue(Io.ATTR_ON_COLOR);
Color offColor = painter.getAttributeValue(Io.ATTR_OFF_COLOR);
Boolean activ = painter.getAttributeValue(Io.ATTR_ACTIVE);
Object desired = activ.booleanValue() ? Value.TRUE : Value.FALSE;
g.setColor(val == desired ? onColor : offColor);
g.fillOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
}
g.setColor(Color.BLACK);
GraphicsUtil.switchToWidth(g, 2);
g.drawOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
GraphicsUtil.switchToWidth(g, 1);
painter.drawLabel();
painter.drawPorts();
}
示例2: paintInstance
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
Graphics g = painter.getGraphics();
Bounds b = painter.getBounds();
int x = b.getX();
int y = b.getY();
g.setColor(Color.BLACK);
for (int k = 0; k <= 20; k += 5)
g.drawOval((x + 20) - k, (y + 20) - k, k * 2, k * 2);
painter.drawPort(0);
painter.drawPort(1);
painter.drawPort(2);
Data d = (Data) painter.getData();
if (d != null && d.is_on) {
d.still_alive = true;
if (!d.thread.isAlive())
d.StartThread();
}
}
示例3: paintIcon
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
ComponentDrawContext context = new ComponentDrawContext(c, null, null, g, g);
factory.paintIcon(context, x, y, factory.createAttributeSet());
// draw magnifying glass if appropriate
if (isCurrentView) {
int tx = x + 13;
int ty = y + 13;
int[] xp = { tx - 1, x + 18, x + 20, tx + 1 };
int[] yp = { ty + 1, y + 20, y + 18, ty - 1 };
g.setColor(ProjectExplorer.MAGNIFYING_INTERIOR);
g.fillOval(x + 5, y + 5, 10, 10);
g.setColor(Color.BLACK);
g.drawOval(x + 5, y + 5, 10, 10);
g.fillPolygon(xp, yp, xp.length);
}
}
示例4: paintComponent
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintComponent(Graphics g)
{
super.paintComponent(g);
this.setBackground(Color.WHITE);
g.setColor(Color.RED);
g.drawLine(5, 30, 380, 30);
g.setColor(Color.BLUE);
g.drawRect(5, 40, 90, 55);
g.fillRect(100, 40, 90, 55);
g.setColor(Color.BLACK);
g.fillRoundRect(195, 40, 90, 55, 50, 50);
g.drawRoundRect(290, 40, 90, 55, 20, 20);
g.setColor(Color.GREEN);
g.draw3DRect(5, 100, 90, 55, true);
g.fill3DRect(100, 100, 90, 55, false);
g.setColor(Color.MAGENTA);
g.drawOval(195, 100, 90, 55);
g.fillOval(290, 100, 90, 55);
}
示例5: paintIcon
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(InstancePainter painter) {
Graphics g = painter.getGraphics();
Icon icon = isInverter ? ICON_INVERTER : ICON_BUFFER;
if (icon != null) {
icon.paintIcon(painter.getDestination(), g, 2, 2);
} else {
int x = isInverter ? 0 : 2;
g.setColor(Color.BLACK);
int[] xp = new int[] { x + 15, x + 1, x + 1, x + 15 };
int[] yp = new int[] { 10, 3, 17, 10 };
g.drawPolyline(xp, yp, 4);
if (isInverter)
g.drawOval(x + 13, 8, 4, 4);
g.setColor(Value.FALSE_COLOR);
g.drawLine(x + 8, 14, x + 8, 18);
}
}
示例6: paint
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paint(Graphics g, HandleGesture gesture) {
Location location = getLocation();
int x = location.getX();
int y = location.getY();
g.setColor(SYMBOL_COLOR);
g.drawOval(x - RADIUS, y - RADIUS, 2 * RADIUS, 2 * RADIUS);
Location e0 = location.translate(facing, RADIUS);
Location e1 = location.translate(facing, RADIUS + INDICATOR_LENGTH);
g.drawLine(e0.getX(), e0.getY(), e1.getX(), e1.getY());
}
示例7: paint
import java.awt.Graphics; //导入方法依赖的package包/类
@Override public void paint(Graphics gr) {
gr.setColor(Color.GREEN);
((Graphics2D)gr).setStroke(new BasicStroke(3));
gr.translate(width/2, height/2);
int R = width/4;
gr.drawOval(-R, -R, 2*R, 2*R);
gr.drawLine(-R, R, R, -R);
}
示例8: paintIconShaped
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIconShaped(InstancePainter painter) {
Graphics g = painter.getGraphics();
GraphicsUtil.drawCenteredArc(g, 0, -5, 22, -90, 53);
GraphicsUtil.drawCenteredArc(g, 0, 23, 22, 90, -53);
GraphicsUtil.drawCenteredArc(g, -8, 9, 16, -30, 60);
GraphicsUtil.drawCenteredArc(g, -10, 9, 16, -30, 60);
g.drawOval(16, 8, 4, 4);
}
示例9: paintIconRectangular
import java.awt.Graphics; //导入方法依赖的package包/类
protected void paintIconRectangular(InstancePainter painter) {
Graphics g = painter.getGraphics();
g.drawRect(1, 2, 16, 16);
if (negateOutput)
g.drawOval(16, 8, 4, 4);
String label = getRectangularLabel(painter.getAttributeSet());
GraphicsUtil.drawCenteredText(g, label, 9, 8);
}
示例10: paintIcon
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(InstancePainter painter) {
Graphics g = painter.getGraphics();
g.setColor(Color.black);
if (painter.getGateShape() == AppPreferences.SHAPE_RECTANGULAR) {
if (toolIconRect != null) {
toolIconRect.paintIcon(painter.getDestination(), g, 2, 2);
} else {
g.drawRect(0, 2, 16, 16);
GraphicsUtil.drawCenteredText(g, RECT_LABEL, 8, 8);
g.drawOval(16, 8, 4, 4);
}
} else if (painter.getGateShape() == AppPreferences.SHAPE_DIN40700) {
if (toolIconDin != null) {
toolIconDin.paintIcon(painter.getDestination(), g, 2, 2);
} else {
g.drawRect(0, 2, 16, 16);
GraphicsUtil.drawCenteredText(g, RECT_LABEL, 8, 8);
g.drawOval(16, 8, 4, 4);
}
} else {
if (toolIcon != null) {
toolIcon.paintIcon(painter.getDestination(), g, 2, 2);
} else {
int[] xp = new int[4];
int[] yp = new int[4];
xp[0] = 15;
yp[0] = 10;
xp[1] = 1;
yp[1] = 3;
xp[2] = 1;
yp[2] = 17;
xp[3] = 15;
yp[3] = 10;
g.drawPolyline(xp, yp, 4);
g.drawOval(15, 8, 4, 4);
}
}
}
示例11: draw
import java.awt.Graphics; //导入方法依赖的package包/类
public void draw(Graphics g)
{
g.setColor(getColor());
if (isFilled())
g.fillOval(getUpperLeftX(), getUpperLeftY(),
getWidth(), getHeight());
else
g.drawOval(getUpperLeftX(), getUpperLeftY(),
getWidth(), getHeight());
}
示例12: paintIcon
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(java.awt.Component c, Graphics g, int x, int y) {
// draw halo if appropriate
if (tool == haloedTool && AppPreferences.ATTRIBUTE_HALO.getBoolean()) {
g.setColor(Canvas.HALO_COLOR);
g.fillRoundRect(x, y, getIconWidth(), getIconHeight(), 5, 5);
g.setColor(Color.BLACK);
}
// draw tool icon
Graphics gIcon = g.create();
ComponentDrawContext context = new ComponentDrawContext(ProjectExplorer.this, null, null, g, gIcon);
tool.paintIcon(context, x, y);
gIcon.dispose();
// draw magnifying glass if appropriate
if (circ == proj.getCurrentCircuit()) {
int tx = x + 13;
int ty = y + 13;
int[] xp = { tx - 1, x + 18, x + 20, tx + 1 };
int[] yp = { ty + 1, y + 20, y + 18, ty - 1 };
g.setColor(MAGNIFYING_INTERIOR);
g.fillOval(x + 5, y + 5, 10, 10);
g.setColor(Color.darkGray);
g.drawOval(x + 5, y + 5, 10, 10);
g.fillPolygon(xp, yp, xp.length);
}
}
示例13: drawBall
import java.awt.Graphics; //导入方法依赖的package包/类
private static void drawBall(Graphics g, int x, int y, Color c, boolean inColor) {
if (inColor) {
g.setColor(c == null ? Color.RED : c);
} else {
int hue = c == null ? 128 : (c.getRed() + c.getGreen() + c.getBlue()) / 3;
g.setColor(new Color(hue, hue, hue));
}
GraphicsUtil.switchToWidth(g, 1);
g.fillOval(x - 4, y - 4, 8, 8);
g.setColor(Color.BLACK);
g.drawOval(x - 4, y - 4, 8, 8);
}
示例14: paintGhost
import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintGhost(InstancePainter painter) {
Bounds b = painter.getBounds();
Graphics g = painter.getGraphics();
g.setColor(Color.GRAY);
g.drawOval(b.getX(), b.getY(), 40, 40);
}
示例15: draw
import java.awt.Graphics; //导入方法依赖的package包/类
public void draw(Graphics g, Matter matter)
{
int centerX = (int) matter.posX;
int centerY = (int) matter.posY;
int radius = (int) matter.radius;
int size = radius * 2;
float dir = matter.rotation;
int bodyFromX = centerX - radius;
int bodyFromY = centerY - radius;
g.setColor(matter.getColor());
g.fillOval(bodyFromX, bodyFromY, size, size);
g.setColor(COLOR_OUTLINE);
g.drawOval(bodyFromX, bodyFromY, size, size);
g.drawLine(centerX, centerY,
centerX + (int) (Math.cos(dir) * radius),
centerY + (int) (Math.sin(dir) * radius));
if (matter instanceof Pye)
{
Pye pye = (Pye) matter;
for(Appendage appendage : pye.getAppendages())
{
if (appendage == null) continue;
int i = pye.indexOf(appendage);
Vector2f vec = pye.getPosition(i, new Vector2f());
g.setColor(Color.GREEN);
g.fillOval((int) vec.x() - 2, (int) vec.y() - 2, 4, 4);
}
}
}