Java Code Examples for java.awt.geom.Ellipse2D#setFrame()

The following examples show how to use java.awt.geom.Ellipse2D#setFrame() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderTests.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    DrawEllipse2Ds.Context cctx = (DrawEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.draw(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
Example 2
Source File: RenderTests.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    FillEllipse2Ds.Context cctx = (FillEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.fill(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
Example 3
Source File: RenderTests.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    FillEllipse2Ds.Context cctx = (FillEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.fill(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
Example 4
Source File: RenderTests.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    DrawEllipse2Ds.Context cctx = (DrawEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.draw(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
Example 5
Source File: RenderTests.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    DrawEllipse2Ds.Context cctx = (DrawEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.draw(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
Example 6
Source File: RenderTests.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    DrawEllipse2Ds.Context cctx = (DrawEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.draw(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
Example 7
Source File: RenderTests.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    FillEllipse2Ds.Context cctx = (FillEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.fill(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
Example 8
Source File: RenderTests.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    DrawEllipse2Ds.Context cctx = (DrawEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.draw(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
Example 9
Source File: RenderTests.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    FillEllipse2Ds.Context cctx = (FillEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.fill(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
Example 10
Source File: RenderTests.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    FillEllipse2Ds.Context cctx = (FillEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.fill(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
Example 11
Source File: RenderTests.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    FillEllipse2Ds.Context cctx = (FillEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.fill(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
Example 12
Source File: FilamentAlignment.java    From libreveris with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderLine (Graphics2D g)
{
    if (!glyph.getBounds().intersects(g.getClipBounds())) {
        return;
    }

    // The curved line itself
    if (line != null) {
        g.draw((NaturalSpline) line);
    }

    // Then the absolute defining points?
    if (constants.showFilamentPoints.isSet() && (points != null)) {
        // Point radius
        double r = glyph.getInterline() * constants.filamentPointSize.
                getValue();
        Ellipse2D ellipse = new Ellipse2D.Double();

        for (Point2D p : points) {
            ellipse.setFrame(p.getX() - r, p.getY() - r, 2 * r, 2 * r);
            g.fill(ellipse);
        }
    }
}
 
Example 13
Source File: RenderTests.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    FillEllipse2Ds.Context cctx = (FillEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.fill(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
Example 14
Source File: GridOverlayPainter.java    From Forsythia with GNU General Public License v3.0 5 votes vote down vote up
private void renderDefaultVertices(Graphics2D graphics,Color color){
graphics.setPaint(color);
float span=UI.GRID_DEFAULTVERTEXSPAN;
double[] p;
Ellipse2D dot=new Ellipse2D.Double();
for(GVertex v:GE.ge.editor_jig.editedjig.getGraph().vertices){
  p=GE.ge.editor_jig.editedjig.getJigEditorGeometryCache().getPoint(v.kvertex);
  dot.setFrame(p[0]-span/2,p[1]-span/2,span,span);
  graphics.fill(dot);}}
 
Example 15
Source File: DrawTest.java    From spring-boot-cookbook with Apache License 2.0 5 votes vote down vote up
@Override
    public void paintComponent(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;

        double centerX = DEFAULT_W / 2;
        double centerY = DEFAULT_H / 2;

        double conerX = centerX + 100;
        double conerY = centerY + 100;

        Rectangle2D rect = new Rectangle2D.Double();
        rect.setFrameFromCenter(centerX, centerY, conerX, conerY);

        Ellipse2D ellipse = new Ellipse2D.Double();
        ellipse.setFrame(rect);

        Ellipse2D circle = new Ellipse2D.Double();
        double radius = Point2D.distance(centerX, centerY, conerX, conerY);
        circle.setFrameFromCenter(centerX, centerY, centerX + radius, centerY + radius);

        Line2D line = new Line2D.Double(conerX, conerY, conerX - 200, conerY - 200);
        Line2D line2 = new Line2D.Double(conerX - 200, conerY, conerX, conerY - 200);


//        g2d.draw(rect);

        g2d.draw(ellipse);
        g2d.setColor(Color.BLUE);
        g2d.draw(circle);

//        g2d.draw(line);
//        g2d.draw(line2);
    }
 
Example 16
Source File: WaferMapPlot.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Calculates the location of the waferedge.
 *
 * @param plotArea  the plot area.
 *
 * @return The wafer edge.
 */
protected Ellipse2D getWaferEdge(Rectangle2D plotArea) {
    Ellipse2D edge = new Ellipse2D.Double();
    double diameter = plotArea.getWidth();
    double upperLeftX = plotArea.getX();
    double upperLeftY = plotArea.getY();
    //get major dimension
    if (plotArea.getWidth() != plotArea.getHeight()) {
        double major, minor;
        if (plotArea.getWidth() > plotArea.getHeight()) {
            major = plotArea.getWidth();
            minor = plotArea.getHeight();
        }
        else {
            major = plotArea.getHeight();
            minor = plotArea.getWidth();
        }
        //ellipse diameter is the minor dimension
        diameter = minor;
        //set upperLeft point
        if (plotArea.getWidth() == minor) { // x is minor
            upperLeftY = plotArea.getY() + (major - minor) / 2;
        }
        else { // y is minor
            upperLeftX = plotArea.getX() + (major - minor) / 2;
        }
    }
    edge.setFrame(upperLeftX, upperLeftY, diameter, diameter);
    return edge;
}
 
Example 17
Source File: WaferMapPlot.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Calculates the location of the waferedge.
 *
 * @param plotArea  the plot area.
 *
 * @return The wafer edge.
 */
protected Ellipse2D getWaferEdge(Rectangle2D plotArea) {
    Ellipse2D edge = new Ellipse2D.Double();
    double diameter = plotArea.getWidth();
    double upperLeftX = plotArea.getX();
    double upperLeftY = plotArea.getY();
    //get major dimension
    if (plotArea.getWidth() != plotArea.getHeight()) {
        double major, minor;
        if (plotArea.getWidth() > plotArea.getHeight()) {
            major = plotArea.getWidth();
            minor = plotArea.getHeight();
        }
        else {
            major = plotArea.getHeight();
            minor = plotArea.getWidth();
        }
        //ellipse diameter is the minor dimension
        diameter = minor;
        //set upperLeft point
        if (plotArea.getWidth() == minor) { // x is minor
            upperLeftY = plotArea.getY() + (major - minor) / 2;
        }
        else { // y is minor
            upperLeftX = plotArea.getX() + (major - minor) / 2;
        }
    }
    edge.setFrame(upperLeftX, upperLeftY, diameter, diameter);
    return edge;
}
 
Example 18
Source File: WaferMapPlot.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Calculates the location of the waferedge.
 *
 * @param plotArea  the plot area.
 *
 * @return The wafer edge.
 */
protected Ellipse2D getWaferEdge(Rectangle2D plotArea) {
    Ellipse2D edge = new Ellipse2D.Double();
    double diameter = plotArea.getWidth();
    double upperLeftX = plotArea.getX();
    double upperLeftY = plotArea.getY();
    //get major dimension
    if (plotArea.getWidth() != plotArea.getHeight()) {
        double major, minor;
        if (plotArea.getWidth() > plotArea.getHeight()) {
            major = plotArea.getWidth();
            minor = plotArea.getHeight();
        }
        else {
            major = plotArea.getHeight();
            minor = plotArea.getWidth();
        }
        //ellipse diameter is the minor dimension
        diameter = minor;
        //set upperLeft point
        if (plotArea.getWidth() == minor) { // x is minor
            upperLeftY = plotArea.getY() + (major - minor) / 2;
        }
        else { // y is minor
            upperLeftX = plotArea.getX() + (major - minor) / 2;
        }
    }
    edge.setFrame(upperLeftX, upperLeftY, diameter, diameter);
    return edge;
}
 
Example 19
Source File: CurvedFilament.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void renderLine (Graphics2D g,
                        boolean showPoints,
                        double pointWidth)
{
    Rectangle clip = g.getClipBounds();

    if ((clip != null) && !clip.intersects(getBounds())) {
        return;
    }

    // The curved line itself
    if (spline != null) {
        g.draw(spline);
    }

    // Then the absolute defining points?
    if (showPoints && (points != null)) {
        // Point radius
        double r = pointWidth / 2;
        Ellipse2D ellipse = new Ellipse2D.Double();

        for (Point2D p : points) {
            ellipse.setFrame(p.getX() - r, p.getY() - r, 2 * r, 2 * r);

            Color oldColor = null;

            if (p.getClass() != Point2D.Double.class) {
                oldColor = g.getColor();
                g.setColor(Color.red);
            }

            g.fill(ellipse);

            if (oldColor != null) {
                g.setColor(oldColor);
            }
        }
    }
}
 
Example 20
Source File: CurvedPolylineCreationUI.java    From pumpernickel with MIT License 4 votes vote down vote up
@Override
protected void paintControls(Graphics2D g0, ShapeCreationPanel scp) {
	AffineTransform tx = scp.getTransform();
	Graphics2D g = (Graphics2D) g0.create();
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
			RenderingHints.VALUE_STROKE_PURE);
	g.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND,
			BasicStroke.JOIN_ROUND));
	float r = (float) (scp.getHandleSize()) / 2f;
	Selection selection = scp.getSelectionModel().getSelection();
	Selection indication = scp.getSelectionModel().getIndication();
	Shape[] shapes = scp.getDataModel().getShapes();
	float[] coords = new float[6];
	Ellipse2D ellipse = new Ellipse2D.Float();
	for (int shapeIndex = 0; shapeIndex < shapes.length; shapeIndex++) {
		if (scp.getHandlesActive().supports(scp, shapeIndex)) {
			PathIterator iter = shapes[shapeIndex].getPathIterator(tx);
			int nodeCtr = -1;
			while (!iter.isDone()) {
				int k = iter.currentSegment(coords);
				float x, y;
				if (k == PathIterator.SEG_MOVETO
						|| k == PathIterator.SEG_LINETO) {
					x = coords[0];
					y = coords[1];
					nodeCtr++;
				} else if (k == PathIterator.SEG_QUADTO) {
					x = coords[2];
					y = coords[3];
					nodeCtr++;
				} else if (k == PathIterator.SEG_CUBICTO) {
					x = coords[4];
					y = coords[5];
					nodeCtr++;
				} else if (k == PathIterator.SEG_CLOSE) {
					x = -1;
					y = -1;
				} else {
					throw new RuntimeException("unexpected segment type: "
							+ k);
				}
				g.setColor(Color.white);
				if (selection != null
						&& selection.getShapeIndex() == shapeIndex
						&& selection.getNodeIndex() == nodeCtr) {
					g.setColor(Color.darkGray);
				} else if (indication != null
						&& indication.getShapeIndex() == shapeIndex
						&& indication.getNodeIndex() == nodeCtr) {
					g.setColor(Color.gray);
				}
				ellipse.setFrame(x - r, y - r, 2 * r, 2 * r);
				g.fill(ellipse);
				g.setColor(Color.black);
				g.draw(ellipse);

				iter.next();
			}
		}
	}
	g.dispose();
}