java.awt.geom.Ellipse2D Java Examples

The following examples show how to use java.awt.geom.Ellipse2D. 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: CurvedPolylineCreationUI.java    From pumpernickel with MIT License 6 votes vote down vote up
private Selection getSelection(MouseEvent evt)
		throws NoninvertibleTransformException {
	ShapeCreationPanel scp = (ShapeCreationPanel) evt.getComponent();
	AffineTransform tx = scp.getTransform();
	double r = scp.getHandleSize() / 2;
	Point2D mouseLoc = new Point2D.Float(evt.getX(), evt.getY());
	CurvedPolyline[] shapes = getMirror(scp);
	for (int shapeIndex = 0; shapeIndex < shapes.length; shapeIndex++) {
		if (scp.getHandlesActive().supports(scp, shapeIndex)) {
			for (int b = shapes[shapeIndex].getPointCount() - 1; b >= 0; b--) {
				Point2D p = tx.transform(
						shapes[shapeIndex].getPoint(b), null);
				Ellipse2D e = new Ellipse2D.Double(p.getX() - r,
						p.getY() - r, 2 * r, 2 * r);
				if (e.contains(mouseLoc))
					return new Selection(shapeIndex, b, null);
			}
		}
	}
	return getSelectedShape(scp, evt.getPoint());
}
 
Example #2
Source File: DefaultProcessDiagramCanvas.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void drawNoneEndEvent(GraphicInfo graphicInfo, double scaleFactor) {
  Paint originalPaint = g.getPaint();
  Stroke originalStroke = g.getStroke();
  g.setPaint(EVENT_COLOR);
  Ellipse2D circle = new Ellipse2D.Double(graphicInfo.getX(), graphicInfo.getY(), 
      graphicInfo.getWidth(), graphicInfo.getHeight());
  g.fill(circle);
  g.setPaint(EVENT_BORDER_COLOR);
  if (scaleFactor == 1.0) {
    g.setStroke(END_EVENT_STROKE);
  } else {
    g.setStroke(new BasicStroke(2.0f));
  }
  g.draw(circle);
  g.setStroke(originalStroke);
  g.setPaint(originalPaint);
}
 
Example #3
Source File: ScaleTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
  BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
  Graphics2D g = image.createGraphics();

  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setPaint(Color.WHITE);
  g.fill(new Rectangle(image.getWidth(), image.getHeight()));
  g.scale(.9, .9);
  g.setPaint(Color.BLACK);
  g.setStroke(new BasicStroke(0.5f));
  g.draw(new Ellipse2D.Double(25, 25, 150, 150));

  // To visually check it
  //ImageIO.write(image, "PNG", new File(args[0]));

  boolean nonWhitePixelFound = false;
  for (int x = 100; x < 200; ++x) {
    if (image.getRGB(x, 90) != Color.WHITE.getRGB()) {
      nonWhitePixelFound = true;
      break;
    }
  }
  if (!nonWhitePixelFound) {
    throw new RuntimeException("A circle is rendered like a 'C' shape.");
  }
}
 
Example #4
Source File: Elixir_001_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * Tests two shapes for equality.  If both shapes are <code>null</code>,
 * this method will return <code>true</code>.
 * <p>
 * In the current implementation, the following shapes are supported:
 * <code>Ellipse2D</code>, <code>Line2D</code> and <code>Rectangle2D</code>
 * (implicit).
 *
 * @param s1  the first shape (<code>null</code> permitted).
 * @param s2  the second shape (<code>null</code> permitted).
 *
 * @return A boolean.
 */
public static boolean equal(Shape s1, Shape s2) {
    if (s1 instanceof Line2D && s2 instanceof Line2D) {
        return equal((Line2D) s1, (Line2D) s2);
    }
    else if (s1 instanceof Ellipse2D && s2 instanceof Ellipse2D) {
        return equal((Ellipse2D) s1, (Ellipse2D) s2);
    }
    else if (s1 instanceof Arc2D && s2 instanceof Arc2D) {
        return equal((Arc2D) s1, (Arc2D) s2);
    }
    else if (s1 instanceof Polygon && s2 instanceof Polygon) {
        return equal((Polygon) s1, (Polygon) s2);
    }
    else if (s1 instanceof GeneralPath && s2 instanceof GeneralPath) {
        return equal((GeneralPath) s1, (GeneralPath) s2);
    }
    else {
        // this will handle Rectangle2D...
        return ObjectUtilities.equal(s1, s2);
    }
}
 
Example #5
Source File: ProcessDiagramCanvas.java    From maven-framework-project with MIT License 6 votes vote down vote up
public void drawCatchingEvent(int x, int y, int width, int height, 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();
  g.setPaint(BOUNDARY_EVENT_COLOR);
  g.fill(outerCircle);

  g.setPaint(originalPaint);
  g.draw(outerCircle);
  g.draw(innerCircle);

  g.drawImage(image, innerCircleX, innerCircleY, innerCircleWidth, innerCircleHeight, null);
}
 
Example #6
Source File: MultiplePiePlot.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new plot.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 */
public MultiplePiePlot(CategoryDataset dataset) {
    super();
    setDataset(dataset);
    PiePlot piePlot = new PiePlot(null);
    piePlot.setIgnoreNullValues(true);
    this.pieChart = new JFreeChart(piePlot);
    this.pieChart.removeLegend();
    this.dataExtractOrder = TableOrder.BY_COLUMN;
    this.pieChart.setBackgroundPaint(null);
    TextTitle seriesTitle = new TextTitle("Series Title",
            new Font("SansSerif", Font.BOLD, 12));
    seriesTitle.setPosition(RectangleEdge.BOTTOM);
    this.pieChart.setTitle(seriesTitle);
    this.aggregatedItemsKey = "Other";
    this.aggregatedItemsPaint = Color.lightGray;
    this.sectionPaints = new HashMap();
    this.legendItemShape = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0);
}
 
Example #7
Source File: Ellipse2DObjectDescription.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Sets the parameters of this description object to match the supplied object.
 *
 * @param o
 *          the object (should be an instance of <code>Rectangle2D</code>).
 * @throws ObjectFactoryException
 *           if the object is not an instance of <code>Rectangle2D</code>.
 */
public void setParameterFromObject( final Object o ) throws ObjectFactoryException {
  if ( !( o instanceof Ellipse2D ) ) {
    throw new ObjectFactoryException( "The given object is no java.awt.geom.Rectangle2D." );
  }

  final Ellipse2D rect = (Ellipse2D) o;
  final float x = (float) rect.getX();
  final float y = (float) rect.getY();
  final float w = (float) rect.getWidth();
  final float h = (float) rect.getHeight();

  setParameter( "x", new Float( x ) );
  setParameter( "y", new Float( y ) );
  setParameter( "width", new Float( w ) );
  setParameter( "height", new Float( h ) );
}
 
Example #8
Source File: RenderTests.java    From openjdk-jdk9 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: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
public static Image makeImage(int size, Color color) {
  // BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB);
  BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
  Graphics2D g2 = image.createGraphics();
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g2.setPaint(color);
  g2.fill(new Ellipse2D.Double(0d, 0d, size - 1d, size - 1d));
  FontRenderContext frc = g2.getFontRenderContext();
  Font font = g2.getFont().deriveFont(AffineTransform.getScaleInstance(.8, 1d));
  Shape s = new TextLayout(Integer.toString(size), font, frc).getOutline(null);
  g2.setPaint(Color.BLACK);
  Rectangle r = s.getBounds();
  double cx = size / 2d - r.getCenterX();
  double cy = size / 2d - r.getCenterY();
  AffineTransform toCenterAtf = AffineTransform.getTranslateInstance(cx, cy);
  g2.fill(toCenterAtf.createTransformedShape(s));
  g2.dispose();
  return image;
}
 
Example #10
Source File: GraphicsRenderer.java    From CSSBox with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Draws a bullet or text marker
 */
protected void drawListBullet(ListItemBox elem, Graphics2D g)
{
    final VisualContext ctx = elem.getVisualContext();
    float x = elem.getAbsoluteContentX() - 1.2f * ctx.getEm();
    float y = elem.getAbsoluteContentY() + 0.5f * ctx.getEm();
    float r = 0.4f * ctx.getEm();
    if (elem.getStyleType() == CSSProperty.ListStyleType.CIRCLE) 
        g.draw(new Ellipse2D.Float(x, y, r, r));
    else if (elem.getStyleType() == CSSProperty.ListStyleType.SQUARE) 
        g.fill(new Rectangle2D.Float(x, y, r, r));
    else if (elem.getStyleType() == CSSProperty.ListStyleType.DISC)
        g.fill(new Ellipse2D.Float(x, y, r, r));
    else if (elem.getStyleType() != CSSProperty.ListStyleType.NONE)
        drawListTextMarker(elem, g, elem.getMarkerText());
}
 
Example #11
Source File: StandardDialFrame.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the frame.  This method is called by the {@link DialPlot} class,
 * you shouldn't need to call it directly.
 *
 * @param g2  the graphics target (<code>null</code> not permitted).
 * @param plot  the plot (<code>null</code> not permitted).
 * @param frame  the frame (<code>null</code> not permitted).
 * @param view  the view (<code>null</code> not permitted).
 */
@Override
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
        Rectangle2D view) {

    Shape window = getWindow(frame);

    Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius + 0.02,
            this.radius + 0.02);
    Ellipse2D e = new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(),
            f.getHeight());

    Area area = new Area(e);
    Area area2 = new Area(window);
    area.subtract(area2);
    g2.setPaint(this.backgroundPaint);
    g2.fill(area);

    g2.setStroke(this.stroke);
    g2.setPaint(this.foregroundPaint);
    g2.draw(window);
    g2.draw(e);
}
 
Example #12
Source File: BpmnJsonConverterTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testLineCircleIntersections() {
    // Arrange
    Path2D line = new Path2D.Double(Path2D.WIND_NON_ZERO, 3);
    line.moveTo(1, 10);
    line.lineTo(20 - 1, 10);
    line.lineTo(20 - 1 + SMALL_DELTA, 10 + SMALL_DELTA);
    line.closePath();
    Ellipse2D.Double circle = new Ellipse2D.Double(4, 8, 4, 4);

    // Act
    Area intersectionArea = new Area(line);
    intersectionArea.intersect(new Area(circle));

    // Assert
    assertThat(intersectionArea.isEmpty()).isFalse();
    Rectangle2D bounds2D = intersectionArea.getBounds2D();
    assertThat(bounds2D.getX()).isCloseTo(4d, offset(PRECISION));
    assertThat(bounds2D.getY()).isCloseTo(10d, offset(PRECISION));
    assertThat(bounds2D.getX() + bounds2D.getWidth()).isCloseTo(8d, offset(PRECISION));
    assertThat(bounds2D.getY() + bounds2D.getHeight()).isCloseTo(10d, offset(PRECISION));
}
 
Example #13
Source File: MapRouteDrawer.java    From triplea with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws Points on the Map.
 *
 * @param graphics The {@linkplain Graphics2D} Object being drawn on
 * @param points The {@linkplain Point2D} array aka the "Joints" to be drawn
 */
private void drawJoints(final Graphics2D graphics, final Point2D[] points) {
  final int jointsize = 10;
  // If the points array is bigger than 1 the last joint should not be drawn (draw an arrow
  // instead)
  final Point2D[] newPoints =
      points.length > 1 ? Arrays.copyOf(points, points.length - 1) : points;
  for (final Point2D[] joints : routeCalculator.getAllPoints(newPoints)) {
    for (final Point2D p : joints) {
      final Ellipse2D circle =
          new Ellipse2D.Double(jointsize / -2.0, jointsize / -2.0, jointsize, jointsize);
      final AffineTransform ellipseTransform = getDrawingTransform();
      ellipseTransform.translate(p.getX(), p.getY());
      graphics.fill(ellipseTransform.createTransformedShape(circle));
    }
  }
}
 
Example #14
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 #15
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 #16
Source File: ShapeUtilities.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests two shapes for equality.  If both shapes are <code>null</code>,
 * this method will return <code>true</code>.
 * <p>
 * In the current implementation, the following shapes are supported:
 * <code>Ellipse2D</code>, <code>Line2D</code> and <code>Rectangle2D</code>
 * (implicit).
 *
 * @param s1  the first shape (<code>null</code> permitted).
 * @param s2  the second shape (<code>null</code> permitted).
 *
 * @return A boolean.
 */
public static boolean equal(Shape s1, Shape s2) {
    if (s1 instanceof Line2D && s2 instanceof Line2D) {
        return equal((Line2D) s1, (Line2D) s2);
    }
    else if (s1 instanceof Ellipse2D && s2 instanceof Ellipse2D) {
        return equal((Ellipse2D) s1, (Ellipse2D) s2);
    }
    else if (s1 instanceof Arc2D && s2 instanceof Arc2D) {
        return equal((Arc2D) s1, (Arc2D) s2);
    }
    else if (s1 instanceof Polygon && s2 instanceof Polygon) {
        return equal((Polygon) s1, (Polygon) s2);
    }
    else if (s1 instanceof GeneralPath && s2 instanceof GeneralPath) {
        return equal((GeneralPath) s1, (GeneralPath) s2);
    }
    else {
        // this will handle Rectangle2D...
        return ObjectUtilities.equal(s1, s2);
    }
}
 
Example #17
Source File: Part.java    From energy2d with GNU Lesser General Public License v3.0 6 votes vote down vote up
private boolean reflect(Ellipse2D.Float e, Discrete p, float predictedX, float predictedY, boolean scatter) {
	float a = e.width * 0.5f;
	float b = e.height * 0.5f;
	float x = e.x + a;
	float y = e.y + b;
	int polygonize = 50;
	float[] vx = new float[polygonize];
	float[] vy = new float[polygonize];
	float theta;
	float delta = (float) (2 * Math.PI / polygonize);
	for (int i = 0; i < polygonize; i++) {
		theta = -delta * i;
		vx[i] = (float) (x + a * Math.cos(theta));
		vy[i] = (float) (y + b * Math.sin(theta));
	}
	Line2D.Float line = new Line2D.Float();
	for (int i = 0; i < polygonize - 1; i++) {
		line.setLine(vx[i], vy[i], vx[i + 1], vy[i + 1]);
		if (reflectFromLine(p, line, predictedX, predictedY, scatter, true))
			return true;
	}
	line.setLine(vx[polygonize - 1], vy[polygonize - 1], vx[0], vy[0]);
	if (reflectFromLine(p, line, predictedX, predictedY, scatter, true))
		return true;
	return false;
}
 
Example #18
Source File: SelectorUtils.java    From weblaf with GNU General Public License v3.0 6 votes vote down vote up
public static void drawWebSelection ( final Graphics2D g2d, final Color color, Rectangle selection, final boolean resizableLR,
                                      final boolean resizableUD, final boolean drawConnectors, final boolean drawSideControls )
{
    selection = validateRect ( selection );

    final Object aa = GraphicsUtils.setupAntialias ( g2d );

    final Area buttonsShape = new Area ();

    // Top
    if ( resizableUD )
    {
        if ( resizableLR )
        {
            buttonsShape.add ( new Area (
                    new Ellipse2D.Double ( selection.x - halfButton, selection.y - halfButton, halfButton * 2, halfButton * 2 ) ) );
            buttonsShape.add ( new Area (
                    new Ellipse2D.Double ( selection.x + selection.width - halfButton, selection.y - halfButton, halfButton * 2,
                            halfButton * 2 ) ) );
        }
        if ( drawSideControls )
        {
            buttonsShape.add ( new Area (
                    new Ellipse2D.Double ( selection.x + selection.width / 2 - halfButton, selection.y - halfButton, halfButton * 2,
                            halfButton * 2 ) ) );
        }
    }

    // Middle
    if ( resizableLR && drawSideControls )
    {
        buttonsShape.add ( new Area (
                new Ellipse2D.Double ( selection.x - halfButton, selection.y + selection.height / 2 - halfButton, halfButton * 2,
                        halfButton * 2 ) ) );
        buttonsShape.add ( new Area (
                new Ellipse2D.Double ( selection.x + selection.width - halfButton, selection.y + selection.height / 2 - halfButton,
                        halfButton * 2, halfButton * 2 ) ) );
    }

    // Bottom
    if ( resizableUD )
    {
        if ( resizableLR )
        {
            buttonsShape.add ( new Area (
                    new Ellipse2D.Double ( selection.x - halfButton, selection.y + selection.height - halfButton, halfButton * 2,
                            halfButton * 2 ) ) );
            buttonsShape.add ( new Area (
                    new Ellipse2D.Double ( selection.x + selection.width - halfButton, selection.y + selection.height - halfButton,
                            halfButton * 2, halfButton * 2 ) ) );
        }
        if ( drawSideControls )
        {
            buttonsShape.add ( new Area (
                    new Ellipse2D.Double ( selection.x + selection.width / 2 - halfButton, selection.y + selection.height - halfButton,
                            halfButton * 2, halfButton * 2 ) ) );
        }
    }

    // Button connectors
    if ( drawConnectors )
    {
        final Area selectionShape = new Area (
                new RoundRectangle2D.Double ( selection.x - halfLine, selection.y - halfLine, selection.width + halfLine * 2,
                        selection.height + halfLine * 2, 5, 5 ) );
        selectionShape.subtract ( new Area (
                new RoundRectangle2D.Double ( selection.x + halfLine, selection.y + halfLine, selection.width - halfLine * 2,
                        selection.height - halfLine * 2, 3, 3 ) ) );
        buttonsShape.add ( selectionShape );
    }

    // Shade
    GraphicsUtils.drawShade ( g2d, buttonsShape, Color.GRAY, shadeWidth );

    // Border
    g2d.setPaint ( Color.GRAY );
    g2d.draw ( buttonsShape );

    // Background
    g2d.setPaint ( color );
    g2d.fill ( buttonsShape );

    GraphicsUtils.restoreAntialias ( g2d, aa );
}
 
Example #19
Source File: VisualPlaceNode.java    From workcraft with MIT License 6 votes vote down vote up
@Override
public void draw(DrawRequest r) {
    Graphics2D g = r.getGraphics();

    Shape shape = new Ellipse2D.Double(
            -getSize() / 2 + getStrokeWidth() / 2,
            -getSize() / 2 + getStrokeWidth() / 2,
            getSize() - getStrokeWidth(),
            getSize() - getStrokeWidth());

    g.setColor(ColorUtils.colorise(getFillColor(), r.getDecoration().getBackground()));
    g.fill(shape);
    g.setColor(ColorUtils.colorise(getForegroundColor(), r.getDecoration().getColorisation()));
    g.setStroke(new BasicStroke((float) getStrokeWidth()));
    g.draw(shape);

    drawToken(r);
    drawErrorInLocalSpace(r);
    drawDurationInLocalSpace(r);
    drawLabelInLocalSpace(r);
    drawNameInLocalSpace(r);
}
 
Example #20
Source File: MultiplePiePlot.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new plot.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 */
public MultiplePiePlot(CategoryDataset dataset) {
    super();
    setDataset(dataset);
    PiePlot piePlot = new PiePlot(null);
    piePlot.setIgnoreNullValues(true);
    this.pieChart = new JFreeChart(piePlot);
    this.pieChart.removeLegend();
    this.dataExtractOrder = TableOrder.BY_COLUMN;
    this.pieChart.setBackgroundPaint(null);
    TextTitle seriesTitle = new TextTitle("Series Title",
            new Font("Tahoma", Font.BOLD, 12));
    seriesTitle.setPosition(RectangleEdge.BOTTOM);
    this.pieChart.setTitle(seriesTitle);
    this.aggregatedItemsKey = "Other";
    this.aggregatedItemsPaint = Color.lightGray;
    this.sectionPaints = new HashMap();
    this.legendItemShape = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0);
}
 
Example #21
Source File: mxMarkerRegistry.java    From blog-codes with Apache License 2.0 6 votes vote down vote up
public mxPoint paintMarker(mxGraphics2DCanvas canvas,
		mxCellState state, String type, mxPoint pe, double nx,
		double ny, double size, boolean source)
{
	double cx = pe.getX() - nx / 2;
	double cy = pe.getY() - ny / 2;
	double a = size / 2;
	Shape shape = new Ellipse2D.Double(cx - a, cy - a, size, size);

	if (mxUtils.isTrue(state.getStyle(), (source) ? "startFill" : "endFill", true))
	{
		canvas.fillShape(shape);
	}
	
	canvas.getGraphics().draw(shape);

	return new mxPoint(-nx / 2, -ny / 2);
}
 
Example #22
Source File: DialCap.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Draws the background to the specified graphics device.  If the dial
 * frame specifies a window, the clipping region will already have been
 * set to this window before this method is called.
 *
 * @param g2  the graphics device (<code>null</code> not permitted).
 * @param plot  the plot (ignored here).
 * @param frame  the dial frame (ignored here).
 * @param view  the view rectangle (<code>null</code> not permitted).
 */
@Override
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
        Rectangle2D view) {

    g2.setPaint(this.fillPaint);

    Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius,
            this.radius);
    Ellipse2D e = new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(),
            f.getHeight());
    g2.fill(e);
    g2.setPaint(this.outlinePaint);
    g2.setStroke(this.outlineStroke);
    g2.draw(e);

}
 
Example #23
Source File: AgentOverlay.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void paint(Graphics2D g, int x, int y, Color color) {
	Shape shape = new Ellipse2D.Double(x - SIZE / 4, y - SIZE, SIZE, SIZE);
	g.setColor(color);
	g.fill(shape);
	g.draw(shape);
	g.setColor(Color.black);
}
 
Example #24
Source File: HumanLayer.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Shape render(Human h, Graphics2D g, ScreenTransform t) {
    Pair<Integer, Integer> location = getLocation(h);
    if (location == null) {
        return null;
    }
    int x = t.xToScreen(location.first());
    int y = t.yToScreen(location.second());
    Shape shape;
    Icon icon = useIcons ? getIcon(h) : null;
    if (icon == null) {
        if (h.isPositionDefined() && (world.getEntity(h.getPosition()) instanceof AmbulanceTeam))
            // draw humans smaller in ambulances
       	 	shape = new Ellipse2D.Double(x - SIZE / 3, y - SIZE / 3, SIZE/3*2, SIZE/3*2);
        else
        	shape = new Ellipse2D.Double(x - SIZE / 2, y - SIZE / 2, SIZE, SIZE);
        
        g.setColor(adjustColour(getColour(h), h.isHPDefined()? h.getHP():10000));
        g.fill(shape);
        g.setColor(getColour(h));
        g.draw(shape);
    }
    else {
        x -= icon.getIconWidth() / 2;
        y -= icon.getIconHeight() / 2;
        shape = new Rectangle2D.Double(x, y, icon.getIconWidth(), icon.getIconHeight());
        icon.paintIcon(null, g, x, y);
    }
    return shape;
}
 
Example #25
Source File: Cardumen_00191_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Adds an entity to the collection.
 *
 * @param entities  the entity collection being populated.
 * @param hotspot  the entity area (if <code>null</code> a default will be
 *              used).
 * @param dataset  the dataset.
 * @param row  the series.
 * @param column  the item.
 * @param selected  is the item selected?
 * @param entityX  the entity's center x-coordinate in user space (only
 *                 used if <code>area</code> is <code>null</code>).
 * @param entityY  the entity's center y-coordinate in user space (only
 *                 used if <code>area</code> is <code>null</code>).
 *
 * @since 1.2.0
 */
protected void addEntity(EntityCollection entities, Shape hotspot,
        CategoryDataset dataset, int row, int column, boolean selected,
        double entityX, double entityY) {
    if (!getItemCreateEntity(row, column, selected)) {
        return;
    }
    Shape s = hotspot;
    if (hotspot == null) {
        double r = getDefaultEntityRadius();
        double w = r * 2;
        if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
            s = new Ellipse2D.Double(entityX - r, entityY - r, w, w);
        }
        else {
            s = new Ellipse2D.Double(entityY - r, entityX - r, w, w);
        }
    }
    String tip = null;
    CategoryToolTipGenerator generator = getToolTipGenerator(row, column,
            selected);
    if (generator != null) {
        tip = generator.generateToolTip(dataset, row, column);
    }
    String url = null;
    CategoryURLGenerator urlster = getURLGenerator(row, column, selected);
    if (urlster != null) {
        url = urlster.generateURL(dataset, row, column);
    }
    CategoryItemEntity entity = new CategoryItemEntity(s, tip, url,
            dataset, dataset.getRowKey(row), dataset.getColumnKey(column));
    entities.add(entity);
}
 
Example #26
Source File: ZoomSliderPanel.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private void initShapes() {
    shapes = new Shape[3];
    int w = getWidth();
    int h = getHeight();
    shapes[0] = new Rectangle2D.Double(w/16, h/16, w*7/8, h*7/8);
    shapes[1] = new Line2D.Double(w/16, h*15/16, w*15/16, h/16);
    shapes[2] = new Ellipse2D.Double(w/4, h/4, w/2, h/2);
    size.width = w;
    size.height = h;
}
 
Example #27
Source File: TimelineVisualizerDot.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void paint(Graphics2D g) {
    Graphics2D g2d = (Graphics2D) g.create();

    g2d.setComposite(AlphaComposite.SrcOver.derive(this.opacity));
    Shape dotShape = new Ellipse2D.Double(this.location.x - 3, this.location.y - 3, 6, 6);
    g2d.setColor(Color.green.darker());
    g2d.fill(dotShape);
    g2d.setColor(Color.black);
    g2d.draw(dotShape);

    g2d.dispose();
}
 
Example #28
Source File: XYShapeRenderer.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new <code>XYShapeRenderer</code> instance with default
 * attributes.
 */
public XYShapeRenderer() {
    this.paintScale = new LookupPaintScale();
    this.useFillPaint = false;
    this.drawOutlines = false;
    this.useOutlinePaint = true;
    this.guideLinesVisible = false;
    this.guideLinePaint = Color.darkGray;
    this.guideLineStroke = new BasicStroke();
    setBaseShape(new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0));
    setAutoPopulateSeriesShape(false);
}
 
Example #29
Source File: TranslucentShapedFrameTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void shapedCbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shapedCbActionPerformed
    if (testFrame != null) {
        Shape s = null;
        if (shapedCb.isSelected()) {
            s = new Ellipse2D.Double(0, 0,
                                     testFrame.getWidth(),
                                     testFrame.getHeight());
        }
        testFrame.setShape(s);
    }
}
 
Example #30
Source File: ThinLineTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
  Graphics2D g = image.createGraphics();

  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setPaint(Color.WHITE);
  g.fill(new Rectangle(image.getWidth(), image.getHeight()));

  g.scale(0.5 / PIXEL, 0.5 / PIXEL);
  g.setPaint(Color.BLACK);
  g.setStroke(new BasicStroke(PIXEL));
  g.draw(new Ellipse2D.Double(PIXEL * 50, PIXEL * 50, PIXEL * 300, PIXEL * 300));

  // To visually check it
  //ImageIO.write(image, "PNG", new File(args[0]));

  boolean nonWhitePixelFound = false;
  for (int x = 0; x < 200; ++x) {
    if (image.getRGB(x, 100) != Color.WHITE.getRGB()) {
      nonWhitePixelFound = true;
      break;
    }
  }
  if (!nonWhitePixelFound) {
    throw new RuntimeException("The thin line disappeared.");
  }
}