本文整理汇总了Java中java.awt.Graphics2D.fillOval方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics2D.fillOval方法的具体用法?Java Graphics2D.fillOval怎么用?Java Graphics2D.fillOval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Graphics2D
的用法示例。
在下文中一共展示了Graphics2D.fillOval方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawShadowPoint
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
* It draw a temporary point when a point is moved in another place
*
* @param g
* The graphic object
* @param p
* The position of the point
* @param c
* The color of the point
* @param size
* The size of the point
*/
public void drawShadowPoint(Graphics2D g, Point p, Color c, int size) {
g.setColor(c);
int fontSize = 7 + getPointSize();
Font f = new Font("Arial", Font.PLAIN, fontSize);
g.setFont(f);
double x = Math.max(p.getX(), GRAPH_LEFT_MARGIN);
double y = Math.min(p.getY(), getHeight() - GRAPH_BOTTOM_MARGIN);
g.drawString("(" + FORMAT_3_DEC.format(getTrueX(x)) + ", "
+ FORMAT_3_DEC.format(getTrueY(y)) + ")",
(int) (x - (fontSize * 3)), (int) y - 5 - getPointSize());
g.drawOval((int) x - (((size / 2))), (int) y - (((size / 2))), size,
size);
g.setColor(Color.GRAY);
Composite oldComp = g.getComposite();
Composite alphaComp = AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, 0.3f);
g.setComposite(alphaComp);
g.fillOval((int) x - (((size / 2))), (int) y - (((size / 2))), size,
size);
g.setComposite(oldComp);
}
示例2: createSystemTrayIconImage
import java.awt.Graphics2D; //导入方法依赖的package包/类
private Image createSystemTrayIconImage() {
final BufferedImage trayImage = new BufferedImage(
imageSize,
imageSize,
BufferedImage.TYPE_INT_ARGB);
final Graphics2D imageGraphics = (Graphics2D) trayImage.getGraphics();
imageGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
imageGraphics.setColor(new Color(255, 255, 255, 0));
imageGraphics.fillRect(0, 0, trayImage.getWidth(),
trayImage.getHeight());
imageGraphics.setColor(Color.green);
int imageWidth = trayImage.getWidth() - 2 * imageInset;
int imageHeight = trayImage.getHeight() - 2 * imageInset;
imageGraphics.fillOval(imageInset, imageInset, imageWidth, imageHeight);
imageGraphics.setColor(Color.darkGray);
imageGraphics.drawOval(imageInset, imageInset, imageWidth, imageHeight);
return trayImage;
}
示例3: render
import java.awt.Graphics2D; //导入方法依赖的package包/类
private static void render(Graphics g, int w, int h, boolean useNonOpaque) {
if (useNonOpaque) {
Graphics2D g2d = (Graphics2D)g;
GradientPaint p =
new GradientPaint(0.0f, 0.0f,
new Color(rnd.nextInt(0xffffff)),
w, h,
new Color(rnd.nextInt(0xff),
rnd.nextInt(0xff),
rnd.nextInt(0xff), 0),
true);
g2d.setPaint(p);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.fillOval(0, 0, w, h);
} else {
g.setColor(new Color(rnd.nextInt(0xffffff)));
g.fillRect(0, 0, w, h);
}
}
示例4: processRequest
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void processRequest(RequestContext context) {
final int size = 200;
BufferedImage bim = new BufferedImage(size, size,
BufferedImage.TYPE_3BYTE_BGR);
Graphics2D g2d = bim.createGraphics();
g2d.setColor(Color.WHITE);
g2d.fillRect(0, 0, size, size);
g2d.setColor(Color.RED);
g2d.fillOval(0, 0, size, size);
g2d.dispose();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
ImageIO.write(bim, "png", bos);
context.setMimeType("image/png");
context.write(bos.toByteArray());
} catch (IOException e) {
System.out.println("Server ERROR: " + e.getMessage());
}
}
示例5: drawShadowPoint
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
* It draw a temporary point when a point is moved in another place
* @param g The graphic object
* @param p The position of the point
* @param c The color of the point
* @param size The size of the point
*/
public void drawShadowPoint(Graphics2D g, Point p, Color c, int size) {
g.setColor(c);
int fontSize = 7 + pointSize;
Font f = new Font("Arial", Font.PLAIN, fontSize);
g.setFont(f);
double x = Math.max((p.getX() - tran_x) / scale, 0);
double y = Math.max((-p.getY() + tran_y) / scale, 0);
double X = (x * scale) + tran_x;
double Y = -((y * scale) - tran_y);
g.drawString("(" + format2Dec.format(x) + ", " + format2Dec.format(y) + ")", (int) (X - (fontSize * 3)), (int) Y - 5 - pointSize);
g.drawOval((int) X - (((size / 2))), (int) Y - (((size / 2))), size, size);
g.setColor(Color.GRAY);
Composite oldComp = g.getComposite();
Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
g.setComposite(alphaComp);
g.fillOval((int) X - (((size / 2))), (int) Y - (((size / 2))), size, size);
g.setComposite(oldComp);
}
示例6: paintComponent
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
// TODO Auto-generated method stub
// super.paintComponent(g);
graphics2d = (Graphics2D)g;
if(getModel().isArmed()){
graphics2d.setColor(Color.RED);
}
else{
graphics2d.setColor(getBackground());
}
graphics2d.fillOval(0
, 0,
getSize().width-1,
getSize().height-1);
super.paintComponent(graphics2d);
}
示例7: paint
import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paint(Graphics g) {
if (selectedValues.isEmpty()) return;
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHints(chart.getRenderingHints());
Iterator<Point> it = selectedValues.iterator();
boolean linePainted = false;
while (it.hasNext()) {
Point p = it.next();
if (!linePainted) {
g2.setPaint(evenPerfPaint);
g2.setStroke(evenPerfStroke);
g2.drawLine(p.x, 0, p.x, getHeight());
g2.setPaint(oddPerfPaint);
g2.setStroke(oddPerfStroke);
g2.drawLine(p.x, 0, p.x, getHeight());
g2.setPaint(markPaint);
g2.setStroke(markStroke);
linePainted = true;
}
g2.fillOval(p.x - selectionExtent + 1, p.y - selectionExtent + 1,
selectionExtent * 2 - 1, selectionExtent * 2 - 1);
}
}
示例8: paintComponent
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
final float POINTS = 9;
final float SIZE = 8;
Graphics2D g2 = (Graphics2D) g.create();
g2.setColor(Color.BLUE);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
long time = gTime;
gTime += 1;
time %= POINTS + 1;
double angle = time / (POINTS + 1) * Math.PI * 2.0;
double w = getWidth();
double h = getHeight();
for (int i = 0; i < POINTS; i++) {
double x = Math.sin(angle);
double y = -Math.cos(angle);
angle += Math.PI * 2.0 / (POINTS + 1);
float strength = 1f - (POINTS - i - 1) / POINTS;
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, strength));
double mx = w / 2 + x * w * (SIZE - 2) / SIZE / 2.0;
double my = h / 2 + y * h * (SIZE - 2) / SIZE / 2.0;
g2.fillOval((int) (mx - w / SIZE / 2), (int) (my - h / SIZE / 2), (int) (w / SIZE), (int) (h / SIZE));
}
g2.dispose();
}
示例9: drawBeacons
import java.awt.Graphics2D; //导入方法依赖的package包/类
public void drawBeacons(Graphics2D g2d){
for (int i = 0; i < blocks.size(); i++){
if (blocks.get(i).getBeacon() != null){
double[] x_coords = blocks.get(i).getXCoordinates();
double[] y_coords = blocks.get(i).getYCoordinates();
int x = (int)x_coords[x_coords.length/2]-1;
int y = (int)y_coords[x_coords.length/2]-1;
int w = 3;
int h = 3;
// Semi transparent glow layer 1
g2d.setColor(new Color(0, 100, 255, 50));
g2d.fillOval(x - 5, y - 5, w + 10, h + 10);
// Semi transparent glow layer 2
g2d.setColor(new Color(0, 100, 255, 30));
g2d.fillOval(x - 12, y - 12, w + 24, h + 24);
// Nice blue color :)
g2d.setColor(new Color(0, 100, 255));
g2d.fillOval(x, y, w, h);
}
}
}
示例10: createTestImage
import java.awt.Graphics2D; //导入方法依赖的package包/类
private static BufferedImage createTestImage(int type)
throws IOException {
int w = 200;
int h = 200;
BufferedImage b = new BufferedImage(w, h, type);
Graphics2D g = b.createGraphics();
g.setColor(Color.white);
g.fillRect(0,0, w, h);
g.setColor(Color.black);
g.fillOval(10, 10, w -20, h-20);
return b;
}
示例11: makeOval
import java.awt.Graphics2D; //导入方法依赖的package包/类
private static void makeOval(Graphics2D graphics, ImageSize maxSize, Random rand) {
switchColor(graphics, rand);
int x = rand.nextInt(maxSize.getWidth());
int y = rand.nextInt(maxSize.getHeight());
int width = rand.nextInt(maxSize.getWidth() - x) + 1;
int height = rand.nextInt(maxSize.getHeight() - y) + 1;
if (rand.nextBoolean()) {
graphics.fillOval(x, y, width, height);
}
graphics.drawOval(x, y, width, height);
}
示例12: drawHead
import java.awt.Graphics2D; //导入方法依赖的package包/类
final public void drawHead(Graphics2D objPgraphics2D, float fltPframeSizeRatio, boolean bolPfill) {
if (bolPfill) {
objPgraphics2D.fillOval(Math.round((Constants.intS_GRAPHICS_CORRECTION_X + this.intGheadX - this.intGheadRadius - 2) * fltPframeSizeRatio),
Math.round((this.intGheadY - this.intGheadRadius * 1.1F - 2) * fltPframeSizeRatio),
Math.round((2 * this.intGheadRadius + 4) * fltPframeSizeRatio),
Math.round((2 * this.intGheadRadius * 1.1F + 4) * fltPframeSizeRatio));
} else {
objPgraphics2D.drawOval(Math.round((Constants.intS_GRAPHICS_CORRECTION_X + this.intGheadX - this.intGheadRadius) * fltPframeSizeRatio),
Math.round((this.intGheadY - this.intGheadRadius * 1.1F) * fltPframeSizeRatio),
Math.round(2 * this.intGheadRadius * fltPframeSizeRatio),
Math.round(2 * this.intGheadRadius * 1.1F * fltPframeSizeRatio));
}
}
示例13: summary
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
* It draws that explains the simbols on the graphic
*
* @param g
* The graphic object
*/
public void summary(Graphics2D g) {
int size = getPointSize() + 1;
int x = getWidth() - 53 - (getPointSize() * 5);
int y = 7 + size;
int fontSize = 6 + Math.min(getPointSize() + 1, 9);
Font f = new Font("Arial", Font.PLAIN, fontSize);
g.setFont(f);
// Potential Bottleneck
g.setColor(Color.RED);
g.fillOval(5 + (x) - ((size / 2)), (int) (y + (0.5) * fontSize)
- ((Math.min(getPointSize() + 1, 9) / 2)),
Math.min(getPointSize() + 1, 9),
Math.min(getPointSize() + 1, 9));
g.setColor(Color.BLACK);
g.drawString("Potential", x + 11 + ((size / 2)), y);
g.drawString("Bottleneck", x + 11 + ((size / 2)), y + fontSize);
g.drawString("Stations", x + 11 + ((size / 2)), y + 2 * fontSize);
// Masked-off
g.setColor(Color.BLUE);
g.fillOval(5 + (x) - ((size / 2)),
-3 + y + (4) * fontSize - Math.min(getPointSize() + 1, 9),
Math.min(getPointSize() + 1, 9),
Math.min(getPointSize() + 1, 9));
g.setColor(Color.BLACK);
g.drawString("Masked-off", x + 11 + ((size / 2)), 3 + y + (3)
* fontSize);
g.drawString("Stations", x + 11 + ((size / 2)), 3 + y + (4) * fontSize);
// Dominated
g.setColor(new Color(15, 185, 100));
g.fillOval(
5 + (x) - ((size / 2)),
6 + y + (((6 * fontSize) + (5 * fontSize)) / 2)
- Math.min(getPointSize() + 1, 9),
Math.min(getPointSize() + 1, 9),
Math.min(getPointSize() + 1, 9));
g.setColor(Color.BLACK);
g.drawString("Dominated", x + 11 + ((size / 2)), 6 + y + (5) * fontSize);
g.drawString("Stations", x + 11 + ((size / 2)), 6 + y + (6) * fontSize);
// Masked off-Area
g.drawString("Masked-off", x + 11 + ((size / 2)), 2 + y + (8)
* fontSize);
g.drawString("Area", x + 11 + ((size / 2)), 2 + y + (9) * fontSize);
int xP1 = 4 + x - ((size / 2));
int yP1 = 3 + y + (8) * fontSize + ((size / 2));
int xP2 = 4 + x + size;
int yP2 = 3 + (y + (8) * fontSize) - size;
Polygon p = twoPointRectangle(xP1, yP1, xP2, yP2);
g.setColor(Color.ORANGE);
g.fill(p);
g.setColor(Color.GRAY);
g.draw(p);
// Dominated Area
g.setColor(Color.BLACK);
g.drawString("Dominated", x + 11 + ((size / 2)), 3 + y + (10)
* fontSize);
g.drawString("Area", x + 11 + ((size / 2)), 3 + y + (11) * fontSize);
xP1 = 4 + x - ((size / 2));
yP1 = 4 + y + (10) * fontSize + ((size / 2));
xP2 = 4 + x + size;
yP2 = 4 + (y + (10) * fontSize) - size;
p = twoPointRectangle(xP1, yP1, xP2, yP2);
g.setColor(new Color(255, 250, 120));
g.fill(p);
g.setColor(Color.GRAY);
g.draw(p);
}
示例14: paintComponent
import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D)g.create();
int w = getWidth();
int h = getHeight();
g2d.setColor(Color.black);
g2d.fillRect(0, 0, w, h);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
antialiasHint);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
renderHint);
g2d.transform(transform);
g2d.setPaint(paint);
switch (shapeType) {
default:
case RECT:
g2d.fillRect(0, 0, w, h);
break;
case ELLIPSE:
g2d.fillOval(0, 0, w, h);
break;
case MULTIPLE:
g2d.fillRect(0, 0, w/2, h/2);
g2d.fillOval(w/2, 0, w/2, h/2);
g2d.drawOval(0, h/2, w/2, h/2);
g2d.drawLine(0, h/2, w/2, h);
g2d.drawLine(0, h, w/2, h/2);
Polygon p = new Polygon();
p.addPoint(w/2, h);
p.addPoint(w, h);
p.addPoint(3*w/4, h/2);
g2d.fillPolygon(p);
break;
}
switch (paintType) {
default:
case BASIC:
case LINEAR:
g2d.setColor(Color.white);
g2d.fillRect(startX-1, startY-1, 2, 2);
g2d.drawString("1", startX, startY + 12);
g2d.fillRect(endX-1, endY-1, 2, 2);
g2d.drawString("2", endX, endY + 12);
break;
case RADIAL:
g2d.setColor(Color.white);
g2d.fillRect(ctrX-1, ctrY-1, 2, 2);
g2d.drawString("C", ctrX, ctrY + 12);
g2d.fillRect(focusX-1, focusY-1, 2, 2);
g2d.drawString("F", focusX, focusY + 12);
break;
}
g2d.dispose();
}
示例15: drawCond
import java.awt.Graphics2D; //导入方法依赖的package包/类
public static void drawCond(
Graphics2D g2d,
int circleCondX, int circleCondY,
int triangleCondX, int triangleCondY,
int lineCondStartX, int lineCondEndX,
char trianglePos, int addToLineX, int addToLineY) {
g2d.setColor(Constants.CONDITION_RELATION_COLOR);
// circle
g2d.fillOval(circleCondX - Constants.DOT_SIZE / 2, circleCondY - Constants.DOT_SIZE /2, Constants.DOT_SIZE, Constants.DOT_SIZE);
// triangle
Point pCond1 = new Point(triangleCondX, triangleCondY);
int pResp2X = 0;
int pResp3X = 0;
int pResp2Y = 0;
int pResp3Y = 0;
switch(trianglePos) {
case 'U':
pResp2X = pCond1.x - Constants.TRIANGLE_HEIGHT / 2;
pResp3X = pCond1.x + Constants.TRIANGLE_HEIGHT / 2;
pResp2Y = pCond1.y + Constants.TRIANGLE_HEIGHT;
pResp3Y = pCond1.y + Constants.TRIANGLE_HEIGHT;
break;
case 'D':
pResp2X = pCond1.x - Constants.TRIANGLE_HEIGHT / 2;
pResp3X = pCond1.x + Constants.TRIANGLE_HEIGHT / 2;
pResp2Y = pCond1.y - Constants.TRIANGLE_HEIGHT;
pResp3Y = pCond1.y - Constants.TRIANGLE_HEIGHT;
break;
case 'L':
pResp2X = pCond1.x + Constants.TRIANGLE_HEIGHT;
pResp3X = pCond1.x + Constants.TRIANGLE_HEIGHT;
pResp2Y = pCond1.y - Constants.TRIANGLE_HEIGHT / 2;
pResp3Y = pCond1.y + Constants.TRIANGLE_HEIGHT / 2;
break;
case 'R':
pResp2X = pCond1.x - Constants.TRIANGLE_HEIGHT;
pResp3X = pCond1.x - Constants.TRIANGLE_HEIGHT;
pResp2Y = pCond1.y - Constants.TRIANGLE_HEIGHT / 2;
pResp3Y = pCond1.y + Constants.TRIANGLE_HEIGHT / 2;
break;
}
Point pCond2 = new Point(pResp2X, pResp2Y);
Point pCond3 = new Point(pResp3X, pResp3Y);
int[] xsCond = {pCond1.x, pCond2.x, pCond3.x};
int[] ysCond = {pCond1.y, pCond2.y, pCond3.y};
g2d.fillPolygon(xsCond, ysCond, 3);
// line
g2d.drawLine(circleCondX + addToLineX, circleCondY + addToLineY, lineCondStartX, lineCondEndX);
}