Java Code Examples for java.awt.geom.Ellipse2D#Double

The following examples show how to use java.awt.geom.Ellipse2D#Double . 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: StraightFilament.java    From audiveris with GNU Affero General Public License v3.0 6 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())) {
        checkLine();

        if (startPoint != null) {
            g.draw(getLine());

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

                for (Point2D p : new Point2D[]{startPoint, stopPoint}) {
                    ellipse.setFrame(p.getX() - r, p.getY() - r, 2 * r, 2 * r);
                    g.fill(ellipse);
                }
            }
        }
    }
}
 
Example 2
Source File: GeometryPainter.java    From mrgeo with Apache License 2.0 6 votes vote down vote up
public void paintEllipse(Point center, double major, double minor, double orientation)
{
  gr.setColor(fillColor);
  gr.setStroke(new BasicStroke(1));

  double width = major * transform.getScaleX();
  double height = minor * -transform.getScaleY();

  Point2D.Double dst = new Point2D.Double();

  transform.transform(new Point2D.Double(center.getX(), center.getY()), dst);

  if (!FloatUtils.isEqual(orientation, 0.0))
  {
    gr.rotate(-orientation, dst.getX(), dst.getY());
  }

  Ellipse2D.Double ellipse = new Ellipse2D.Double(dst.getX() - (width / 2), dst.getY() - (height / 2), width, height);
  gr.fill(ellipse);

  // rotate back
  if (!FloatUtils.isEqual(orientation, 0.0))
  {
    gr.rotate(orientation, dst.getX(), dst.getY());
  }
}
 
Example 3
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 4
Source File: MultiplePiePlot.java    From openstock 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 5
Source File: VirtualNodeGeometry.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
static Shape createShapePixel(AmodeusComponent amodeusComponent, Tensor hull) {
    if (Tensors.isEmpty(hull))
        return new Ellipse2D.Double(0, 0, 0, 0);
    Path2D path2d = new Path2D.Double();
    boolean init = false;
    for (Tensor vector : hull)
        if (!init) {
            init = true;
            path2d.moveTo( //
                    vector.Get(0).number().doubleValue(), //
                    vector.Get(1).number().doubleValue());
        } else
            path2d.lineTo( //
                    vector.Get(0).number().doubleValue(), //
                    vector.Get(1).number().doubleValue());
    path2d.closePath();
    return path2d;
}
 
Example 6
Source File: InfiniteProgressPanel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private Area buildPrimitive() {
    Rectangle2D.Double body = new Rectangle2D.Double( 6, 0, 30, 12 ); // location and size
    Ellipse2D.Double head = new Ellipse2D.Double( 0, 0, 12, 12 );
    Ellipse2D.Double tail = new Ellipse2D.Double( 30, 0, 12, 12 );
    
    Area tick = new Area(body);
    tick.add( new Area( head ) );
    tick.add( new Area( tail ) );
    
    return tick;
}
 
Example 7
Source File: TrafficLight.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public BufferedImage createYellowOffImage(final int WIDTH, final int HEIGHT) {
    final GraphicsConfiguration GFX_CONF = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    if (WIDTH <= 0 || HEIGHT <= 0) {
        return GFX_CONF.createCompatibleImage(1, 1, java.awt.Transparency.TRANSLUCENT);
    }
    final BufferedImage IMAGE = GFX_CONF.createCompatibleImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT);
    final Graphics2D G2 = IMAGE.createGraphics();
    G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

    final int IMAGE_WIDTH = IMAGE.getWidth();
    final int IMAGE_HEIGHT = IMAGE.getHeight();
    final Ellipse2D LIGHT_OFF = new Ellipse2D.Double(0.17346938775510204 * IMAGE_WIDTH, 0.38489208633093525 * IMAGE_HEIGHT, 0.6530612244897959 * IMAGE_WIDTH, 0.2302158273381295 * IMAGE_HEIGHT);
    G2.setPaint(new RadialGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.5 * IMAGE_HEIGHT), (0.32653061224489793f * IMAGE_WIDTH), new float[]{0.0f, 1.0f}, new Color[]{new Color(1f, 1f, 0f, 0.2470588235f), new Color(1f, 1f, 0f, 0.0470588235f)}));
    G2.fill(LIGHT_OFF);

    final Ellipse2D INNER_SHADOW = new Ellipse2D.Double(0.17346938775510204 * IMAGE_WIDTH, 0.38489208633093525 * IMAGE_HEIGHT, 0.6530612244897959 * IMAGE_WIDTH, 0.2302158273381295 * IMAGE_HEIGHT);
    G2.setPaint(new RadialGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.5 * IMAGE_HEIGHT), (0.32653061224489793f * IMAGE_WIDTH), new float[]{0.0f, 0.55f, 0.5501f, 0.78f, 0.79f, 1.0f}, new Color[]{new Color(0.0039215686f, 0.0039215686f, 0.0039215686f, 0f), new Color(0f, 0f, 0f, 0f), new Color(0f, 0f, 0f, 0f), new Color(0f, 0f, 0f, 0.1215686275f), new Color(0f, 0f, 0f, 0.1294117647f), new Color(0f, 0f, 0f, 0.4980392157f)}));
    G2.fill(INNER_SHADOW);

    final TexturePaint HATCH_PAINT = new TexturePaint(HATCH_TEXTURE, new java.awt.Rectangle(0, 0, 2, 2));
    G2.setPaint(HATCH_PAINT);
    G2.fill(INNER_SHADOW);

    G2.dispose();
    return IMAGE;
}
 
Example 8
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 9
Source File: XYBoxAndWhiskerRenderer.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws two ellipses to represent overlapping outliers.
 *
 * @param point  the location.
 * @param boxWidth  the box width.
 * @param oRadius  the radius.
 * @param g2  the graphics device.
 */
protected void drawMultipleEllipse(Point2D point, double boxWidth,
                                   double oRadius, Graphics2D g2) {

    Ellipse2D.Double dot1 = new Ellipse2D.Double(point.getX()
            - (boxWidth / 2) + oRadius, point.getY(), oRadius, oRadius);
    Ellipse2D.Double dot2 = new Ellipse2D.Double(point.getX()
            + (boxWidth / 2), point.getY(), oRadius, oRadius);
    g2.draw(dot1);
    g2.draw(dot2);

}
 
Example 10
Source File: TranslucentShapedFrameTest.java    From jdk8u60 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 11
Source File: 1_AbstractCategoryItemRenderer.java    From SimFix with GNU General Public License v2.0 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 12
Source File: 1_AbstractCategoryItemRenderer.java    From SimFix with GNU General Public License v2.0 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 13
Source File: patch1-Chart-1-jMutRepair_patch1-Chart-1-jMutRepair_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 14
Source File: SVG.java    From OSPREY3 with GNU General Public License v2.0 4 votes vote down vote up
public ShapeDrawable makePoint(double x, double y, double radius) {
	double size = radius*2;
	return new ShapeDrawable(new Ellipse2D.Double(x - radius, y - radius, size, size));
}
 
Example 15
Source File: AlgoVisHelper.java    From blog with MIT License 4 votes vote down vote up
public static void strokeCircle(Graphics2D g, int x, int y, int r) {

		Ellipse2D circle = new Ellipse2D.Double(x - r, y - r, 2 * r, 2 * r);
		g.draw(circle);
	}
 
Example 16
Source File: SplineDisplay.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private Ellipse2D getDraggableArea(Point2D control) {
    Ellipse2D outer = new Ellipse2D.Double(xPositionToPixel(control.getX()) - CONTROL_POINT_SIZE / 2.0,
                                           yPositionToPixel(control.getY()) - CONTROL_POINT_SIZE / 2.0,
                                           CONTROL_POINT_SIZE, CONTROL_POINT_SIZE);
    return outer;
}
 
Example 17
Source File: DrawSimpleShape.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected Outline getHeadDecoration(Graphics2D graphics, LineDecoration deco, BasicStroke stroke) {
    if (deco == null || stroke == null) {
        return null;
    }
    DecorationSize headLength = deco.getHeadLength();
    if (headLength == null) {
        headLength = DecorationSize.MEDIUM;
    }
    DecorationSize headWidth = deco.getHeadWidth();
    if (headWidth == null) {
        headWidth = DecorationSize.MEDIUM;
    }

    double lineWidth = Math.max(2.5, stroke.getLineWidth());

    Rectangle2D anchor = getAnchor(graphics, getShape());
    double x1 = anchor.getX(), y1 = anchor.getY();

    double alpha = Math.atan(anchor.getHeight() / anchor.getWidth());

    AffineTransform at = new AffineTransform();
    java.awt.Shape headShape = null;
    Path p = null;
    Rectangle2D bounds;
    final double scaleY = Math.pow(DECO_SIZE_POW, headWidth.ordinal()+1.);
    final double scaleX = Math.pow(DECO_SIZE_POW, headLength.ordinal()+1.);
    DecorationShape headShapeEnum = deco.getHeadShape();

    if (headShapeEnum == null) {
        return null;
    }

    switch (headShapeEnum) {
        case OVAL:
            p = new Path();
            headShape = new Ellipse2D.Double(0, 0, lineWidth * scaleX, lineWidth * scaleY);
            bounds = headShape.getBounds2D();
            at.translate(x1 - bounds.getWidth() / 2, y1 - bounds.getHeight() / 2);
            at.rotate(alpha, bounds.getX() + bounds.getWidth() / 2, bounds.getY() + bounds.getHeight() / 2);
            break;
        case STEALTH:
        case ARROW:
            p = new Path(false, true);
            Path2D.Double arrow = new Path2D.Double();
            arrow.moveTo((lineWidth * scaleX), (-lineWidth * scaleY / 2));
            arrow.lineTo(0, 0);
            arrow.lineTo((lineWidth * scaleX), (lineWidth * scaleY / 2));
            headShape = arrow;
            at.translate(x1, y1);
            at.rotate(alpha);
            break;
        case TRIANGLE:
            p = new Path();
            Path2D.Double triangle = new Path2D.Double();
            triangle.moveTo((lineWidth * scaleX), (-lineWidth * scaleY / 2));
            triangle.lineTo(0, 0);
            triangle.lineTo((lineWidth * scaleX), (lineWidth * scaleY / 2));
            triangle.closePath();
            headShape = triangle;
            at.translate(x1, y1);
            at.rotate(alpha);
            break;
        default:
            break;
    }

    if (headShape != null) {
        headShape = at.createTransformedShape(headShape);
    }
    return headShape == null ? null : new Outline(headShape, p);
}
 
Example 18
Source File: RadioButtonMenuItemIcon.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
	JMenuItem b = (JMenuItem) c;
	ButtonModel bm = b.getModel();

	g.translate(x, y);

	boolean isSelected = bm.isSelected();
	boolean isEnabled = bm.isEnabled();
	boolean isPressed = bm.isPressed();

	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

	// drawing background section
	if (!isEnabled) {
		g2.setColor(Colors.RADIOBUTTON_BORDER_DISABLED);
	} else {
		if (isPressed) {
			g2.setColor(Colors.RADIOBUTTON_BORDER_FOCUS);
		} else {
			g2.setColor(Colors.RADIOBUTTON_BORDER);
		}
	}
	g2.setStroke(RADIO_STROKE);
	Shape circle = new Ellipse2D.Double(0, 0, 9, 9);
	g2.draw(circle);

	// drawing sphere
	if (isSelected) {
		if (isEnabled) {
			g2.setColor(Colors.RADIOBUTTON_CHECKED);
		} else {
			g2.setColor(Colors.RADIOBUTTON_CHECKED_DISABLED);
		}
		circle = new Ellipse2D.Double(3, 3, 4, 4);
		g2.fill(circle);
	}

	g.translate(-x, -y);
}
 
Example 19
Source File: InteractiveShape.java    From osp with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Creates an interactive ellipse.
 *
 * @param x
 * @param y
 * @param w
 * @param h
 * @return InteractiveShape
 */
public static InteractiveShape createEllipse(double x, double y, double w, double h) {
  Shape shape = new Ellipse2D.Double(-w/2, -h/2, w, h);
  InteractiveShape is = new InteractiveShape(shape, x, y);
  is.width = w;
  is.height = h;
  return is;
}
 
Example 20
Source File: Spotlight.java    From javagame with MIT License 2 votes vote down vote up
/**
 * �R���X�g���N�^
 * 
 * @param x �X�|�b�g���C�g���S��X���W
 * @param y �X�|�b�g���C�g���S��Y���W
 * @param radius �X�|�b�g���C�g�̔��a
 */
public Spotlight(int x, int y, int radius) {
    this.spot = new Ellipse2D.Double(x - radius, y - radius, radius * 2,
            radius * 2);
}