private Ellipse2D drawEllipse(Graphics2D graphics, int x, int y) { graphics.setColor(config.progressOrbBackgroundColor()); Ellipse2D ellipse = new Ellipse2D.Double(x, y, config.xpOrbSize(), config.xpOrbSize()); graphics.fill(ellipse); graphics.draw(ellipse); return ellipse; }
Transformer<Integer,Shape> vertexSize = new Transformer<Integer,Shape>(){ public Shape transform(Integer i){ Ellipse2D circle = new Ellipse2D.Double(-15, -15, 30, 30); vv.getRenderContext().setVertexShapeTransformer(vertexSize); JFrame frame = new JFrame("Simple Graph View"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); frame.pack();
/** * Draws an ellipse with given semimajor and semiminor axes, centered on (x, y). * @param x the x-coordinate of the center of the ellipse * @param y the y-coordinate of the center of the ellipse * @param semiMajorAxis is the semimajor axis of the ellipse * @param semiMinorAxis is the semiminor axis of the ellipse * @throws IllegalArgumentException if either of the axes are negative */ public void filledEllipse(double x, double y, double semiMajorAxis, double semiMinorAxis) { if (semiMajorAxis < 0) throw new IllegalArgumentException("ellipse semimajor axis can't be negative"); if (semiMinorAxis < 0) throw new IllegalArgumentException("ellipse semiminor axis can't be negative"); double xs = scaleX(x); double ys = scaleY(y); double ws = factorX(2*semiMajorAxis); double hs = factorY(2*semiMinorAxis); if (ws <= 1 && hs <= 1) pixel(x, y); else offscreen.fill(new Ellipse2D.Double(xs - ws/2, ys - hs/2, ws, hs)); draw(); }
Floor2 mainPanel = new Floor2(w, h, gridDiv); JFrame frame = new JFrame("Floor2"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(mainPanel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); if (mouseState == MouseState.DRAGGING && drawingLine != null) { g2.setColor(LINE_DRAWING_COLOR); g2.draw(drawingLine); Point2D p2d2 = new Point2D.Double(ellipses.get(1).getCenterX(), ellipses.get(1).getCenterY()); Line2D line = new Line2D.Double(p2d1, p2d2); g2.draw(line); Ellipse2D ellipse1 = new Ellipse2D.Double(x1, y1, ELLIPSE_DIAMETER, ELLIPSE_DIAMETER); x1 = drawingLine.getX2() - ELLIPSE_DIAMETER / 2; y1 = drawingLine.getY2() - ELLIPSE_DIAMETER / 2; Ellipse2D ellipse2 = new Ellipse2D.Double(x1, y1, ELLIPSE_DIAMETER, ELLIPSE_DIAMETER); newEndPoints.add(ellipse1); newEndPoints.add(ellipse2);
for(int x = 10, w = 1; w < 20; x += w*2, w++) Ellipse2D.Double ed = new Ellipse2D.Double(x, 10, w, w); g.fill( ed ); Ellipse2D.Double ed = new Ellipse2D.Double(x, 80, w, w); g.draw( ed ); JFrame frame = new JFrame(); frame.add( new MyPanel() ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setSize( 400, 400 );
final JFrame frame = new JFrame("Test"); g2d.draw(new Line2D.Double( (dia / 2) + Math.cos(angle) * dia / 2.1d, (dia / 2) + Math.sin(angle) * dia / 2.1d, g2d.draw(new Ellipse2D.Double(1, 1, dia - 1, dia - 1)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 400); frame.setVisible(true);
public void drawCatchingEvent(int x, int y, int width, int height, boolean isInterrupting, Image image) { // event circles Ellipse2D outerCircle = new Ellipse2D.Double(x, y, width, height); int innerCircleX = x + 3; int innerCircleY = y + 3; int innerCircleWidth = width - 6; int innerCircleHeight = height - 6; Ellipse2D innerCircle = new Ellipse2D.Double(innerCircleX, innerCircleY, innerCircleWidth, innerCircleHeight); Paint originalPaint = g.getPaint(); Stroke originalStroke = g.getStroke(); g.setPaint(BOUNDARY_EVENT_COLOR); g.fill(outerCircle); g.setPaint(originalPaint); if (isInterrupting) g.setStroke(INTERRUPTING_EVENT_STROKE); g.draw(outerCircle); g.setStroke(originalStroke); g.draw(innerCircle); g.drawImage(image, innerCircleX, innerCircleY, innerCircleWidth, innerCircleHeight, null); }
new Ellipse2D.Double(0,0,r.width,r.height); g2d.fill(ellipse); new Ellipse2D.Double(d,d,r.width-2*d,r.height-2*d); g2d.setColor(new Color(0f,0f,0f,b)); g2d.fill(ellipse); new Ellipse2D.Double(d,d,r.width-2*d,r.height-2*d); g2d.setColor(Color.black); g2d.fill(ellipse);
/** * Draws an ellipse with given semimajor and semiminor axes, centered on (x, y). * * @param x the x-coordinate of the center of the ellipse * @param y the y-coordinate of the center of the ellipse * @param semiMajorAxis is the semimajor axis of the ellipse * @param semiMinorAxis is the semiminor axis of the ellipse * @throws IllegalArgumentException if either of the axes are negative */ public void ellipse(double x, double y, double semiMajorAxis, double semiMinorAxis) { if (semiMajorAxis < 0) throw new IllegalArgumentException("ellipse semimajor axis can't be negative"); if (semiMinorAxis < 0) throw new IllegalArgumentException("ellipse semiminor axis can't be negative"); double xs = scaleX(x); double ys = scaleY(y); double ws = factorX(2*semiMajorAxis); double hs = factorY(2*semiMinorAxis); if (ws <= 1 && hs <= 1) pixel(x, y); else offscreen.draw(new Ellipse2D.Double(xs - ws/2, ys - hs/2, ws, hs)); draw(); }
if (!flashinglights) { g2.setColor(Color.ORANGE); Ellipse2D.Double ball = new Ellipse2D.Double(x, y, 50, 50); g2.draw(ball); g2.fill(ball); } else { if(colorIndex > colors.length - 1) Ellipse2D.Double ball = new Ellipse2D.Double(x, y, 50, 50); g2.draw(ball); g2.fill(ball); scFrame.setTitle("Circle"); scFrame.setSize(400, 400); scFrame.setDefaultCloseOperation((JFrame.EXIT_ON_CLOSE)); scFrame.setVisible(true);
@Override public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) { if (viewPoint != null) { Shape oldClip = g2.getClip(); Rectangle2D dataArea = chartPanel.getScreenDataArea(); g2.setClip(dataArea); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Ellipse2D.Double ellipse = new Ellipse2D.Double(viewPoint.getX() - 0.5 * markerSize, viewPoint.getY() - 0.5 * markerSize, markerSize, markerSize); g2.setPaint(fillPaint); g2.fill(ellipse); g2.setStroke(outlineStroke); g2.setPaint(outlinePaint); g2.draw(ellipse); Rectangle2D box = new Rectangle2D.Double(dataArea.getX() + 5, dataArea.getY() + 5, 100, 52); g2.setPaint(fillPaint); g2.fill(box); g2.setStroke(outlineStroke); g2.setPaint(outlinePaint); g2.draw(box); g2.drawString(String.format("x = %.3f", dataPoint.getX()), (int) (dataArea.getX() + 5 + 5), (int) (dataArea.getY() + 5 + 20)); g2.drawString(String.format("y = %.3f", dataPoint.getY()), (int) (dataArea.getX() + 5 + 5), (int) (dataArea.getY() + 5 + 40)); g2.setClip(oldClip); } }
public void drawStartEvent(int x, int y, int width, int height, Image image) { g.draw(new Ellipse2D.Double(x, y, width, height)); if (image != null) { g.drawImage(image, x, y, width, height, null); } }
private void drawEllipseAndString(final int x, final int y, final String string) { g2d.setFont(chartFont); g2d.draw(new Ellipse2D.Double(5 + 87.0 * x, 5 + 87.0 * y, 72, 72)); final FontMetrics metrics = g2d.getFontMetrics(); final int h = metrics.stringWidth(string) / 2; final int k = metrics.getHeight() / 2; g2d.drawString(string, 42 + 87 * x - h, 39 + 87 * y + k); }
final JFrame frame = new JFrame("Image zoom"); frame.getContentPane().add(zoomPanel); final Ticker t = new Ticker(zoomPanel); frame.setVisible(true); for (int y = 0; y < 8; y++) { g2.setColor(model[x][y]); Ellipse2D e = new Ellipse2D.Double(40 + x * STEP, 45 + y * STEP, STEP - 3, STEP - 3); g2.fill(e); g2.setColor(Color.GRAY); g2.draw(e);
case 0: g2d.fill(new Ellipse2D.Double(currX, currY, SHAPE_SIZE, SHAPE_SIZE)); break; case 1: g2d.fill(new Rectangle2D.Double(currX, currY, SHAPE_SIZE, SHAPE_SIZE)); break; case 2: g2d.fill(new Arc2D.Double(currX,currY,SHAPE_SIZE,SHAPE_SIZE,315,225,Arc2D.PIE)); break; case 3: g2d.draw(new Line2D.Double(currX,currY,currX+SHAPE_SIZE,currY+SHAPE_SIZE)); break; default: g2d.fill(new Ellipse2D.Double(distractorX, distractorY, SHAPE_SIZE, SHAPE_SIZE)); break; case 1: case 3: g2d.setStroke(lineStroke); g2d.draw(new Line2D.Double(distractorX,distractorY,distractorX+SHAPE_SIZE,distractorY+SHAPE_SIZE)); break; default:
JFrame frame = new JFrame("Testing"); frame.getContentPane().setBackground(Color.RED); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridBagLayout()); frame.add(new JLabel("Boo!")); frame.setSize(200, 200); frame.setLocationRelativeTo(null); frame.setUndecorated(true); frame.setShape(new Ellipse2D.Double(0, 0, 200, 200)); frame.setVisible(true);
/** * Draws an ellipse with the specified semimajor and semiminor axes, * centered at (<em>x</em>, <em>y</em>). * * @param x the <em>x</em>-coordinate of the center of the ellipse * @param y the <em>y</em>-coordinate of the center of the ellipse * @param semiMajorAxis is the semimajor axis of the ellipse * @param semiMinorAxis is the semiminor axis of the ellipse * @throws IllegalArgumentException if either {@code semiMajorAxis} * or {@code semiMinorAxis} is negative */ public static void filledEllipse(double x, double y, double semiMajorAxis, double semiMinorAxis) { if (!(semiMajorAxis >= 0)) throw new IllegalArgumentException("ellipse semimajor axis must be nonnegative"); if (!(semiMinorAxis >= 0)) throw new IllegalArgumentException("ellipse semiminor axis must be nonnegative"); double xs = scaleX(x); double ys = scaleY(y); double ws = factorX(2*semiMajorAxis); double hs = factorY(2*semiMinorAxis); if (ws <= 1 && hs <= 1) pixel(x, y); else offscreen.fill(new Ellipse2D.Double(xs - ws/2, ys - hs/2, ws, hs)); draw(); }
/** * Draws an ellipse with the specified semimajor and semiminor axes, * centered at (<em>x</em>, <em>y</em>). * * @param x the <em>x</em>-coordinate of the center of the ellipse * @param y the <em>y</em>-coordinate of the center of the ellipse * @param semiMajorAxis is the semimajor axis of the ellipse * @param semiMinorAxis is the semiminor axis of the ellipse * @throws IllegalArgumentException if either {@code semiMajorAxis} * or {@code semiMinorAxis} is negative */ public static void ellipse(double x, double y, double semiMajorAxis, double semiMinorAxis) { if (!(semiMajorAxis >= 0)) throw new IllegalArgumentException("ellipse semimajor axis must be nonnegative"); if (!(semiMinorAxis >= 0)) throw new IllegalArgumentException("ellipse semiminor axis must be nonnegative"); double xs = scaleX(x); double ys = scaleY(y); double ws = factorX(2*semiMajorAxis); double hs = factorY(2*semiMinorAxis); if (ws <= 1 && hs <= 1) pixel(x, y); else offscreen.draw(new Ellipse2D.Double(xs - ws/2, ys - hs/2, ws, hs)); draw(); }
JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new TestPane()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); g2d.draw(rect); g2d.draw(line); for (Point2D p : ps) { if (p != null) { g2d.fill(new Ellipse2D.Double(p.getX() - 4, p.getY() - 4, 8, 8));
final HtmlColor color = param.getColor(); if (ellipse.getStart() == 0 && ellipse.getExtend() == 0) { final Shape shape = new Ellipse2D.Double(x, y, ellipse.getWidth(), ellipse.getHeight()); ellipse.getHeight(), back); g2d.setPaint(paint); g2d.fill(shape); DriverRectangleG2d.drawBorder(param, color, mapper, ellipse, shape, g2d, x, y); } else { g2d.setColor(mapper.getMappedColor(param.getBackcolor())); DriverRectangleG2d.managePattern(param, g2d); g2d.fill(shape); if (color != null) { g2d.setColor(mapper.getMappedColor(color)); g2d.draw(arc);