Search in sources :

Example 21 with Polygon

use of java.awt.Polygon in project OpenNotebook by jaltekruse.

the class LineObjectGUI method getCollisionAndSelectionPolygon.

public Polygon getCollisionAndSelectionPolygon(LineObject line, Point pageOrigin, float zoomLevel) {
    ScaledSizeAndPosition sap = getSizeAndPosition(line, pageOrigin, zoomLevel);
    GridPoint[] pts = line.getAdjustedVertices();
    int[] xVals = new int[pts.length];
    int[] yVals = new int[pts.length];
    int i = 0;
    for (GridPoint pt : pts) {
        xVals[i] = (int) (pt.getx() * sap.getWidth()) + sap.getxOrigin();
        yVals[i] = (int) (pt.gety() * sap.getHeight()) + sap.getyOrigin();
        i++;
    }
    return new Polygon(xVals, yVals, pts.length);
}
Also used : GridPoint(doc.GridPoint) Polygon(java.awt.Polygon) GridPoint(doc.GridPoint) Point(java.awt.Point)

Example 22 with Polygon

use of java.awt.Polygon in project scriptographer by scriptographer.

the class AbstractGraphics2D method fillPolygon.

/**
     * Fills a closed polygon defined by
     * arrays of <i>x</i> and <i>y</i> coordinates.
     * <p>
     * This method draws the polygon defined by <code>nPoint</code> line
     * segments, where the first <code>nPoint&nbsp;-&nbsp;1</code>
     * line segments are line segments from
     * <code>(xPoints[i&nbsp;-&nbsp;1],&nbsp;yPoints[i&nbsp;-&nbsp;1])</code>
     * to <code>(xPoints[i],&nbsp;yPoints[i])</code>, for
     * 1&nbsp;&le;&nbsp;<i>i</i>&nbsp;&le;&nbsp;<code>nPoints</code>.
     * The figure is automatically closed by drawing a line connecting
     * the final point to the first point, if those points are different.
     * <p>
     * The area inside the polygon is defined using an
     * even-odd fill rule, also known as the alternating rule.
     * @param        xPoints   a an array of <code>x</code> coordinates.
     * @param        yPoints   a an array of <code>y</code> coordinates.
     * @param        nPoints   a the total number of points.
     * @see          java.awt.Graphics#drawPolygon(int[], int[], int)
     */
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
    Polygon polygon = new Polygon(xPoints, yPoints, nPoints);
    fill(polygon);
}
Also used : Polygon(java.awt.Polygon)

Example 23 with Polygon

use of java.awt.Polygon in project scriptographer by scriptographer.

the class AbstractGraphics2D method drawPolygon.

/**
     * Draws a closed polygon defined by
     * arrays of <i>x</i> and <i>y</i> coordinates.
     * Each pair of (<i>x</i>,&nbsp;<i>y</i>) coordinates defines a point.
     * <p>
     * This method draws the polygon defined by <code>nPoint</code> line
     * segments, where the first <code>nPoint&nbsp;-&nbsp;1</code>
     * line segments are line segments from
     * <code>(xPoints[i&nbsp;-&nbsp;1],&nbsp;yPoints[i&nbsp;-&nbsp;1])</code>
     * to <code>(xPoints[i],&nbsp;yPoints[i])</code>, for
     * 1&nbsp;&le;&nbsp;<i>i</i>&nbsp;&le;&nbsp;<code>nPoints</code>.
     * The figure is automatically closed by drawing a line connecting
     * the final point to the first point, if those points are different.
     * @param        xPoints   a an array of <code>x</code> coordinates.
     * @param        yPoints   a an array of <code>y</code> coordinates.
     * @param        nPoints   a the total number of points.
     * @see          java.awt.Graphics#fillPolygon(int[],int[],int)
     * @see          java.awt.Graphics#drawPolyline
     */
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
    Polygon polygon = new Polygon(xPoints, yPoints, nPoints);
    draw(polygon);
}
Also used : Polygon(java.awt.Polygon)

Example 24 with Polygon

use of java.awt.Polygon in project DistributedFractalNetwork by Budder21.

the class ArrowButton method isClicked.

/**
	 * Used to determine whether or not the button was clicked
	 * @param p a point on the screen that was clicked
	 * @return whether or not the arrow contains the point
	 */
public boolean isClicked(Point p) {
    if (down) {
        int[] xPoints = { location.x, location.x - 6, location.x + 6 };
        int[] yPoints = { location.y, location.y - 9, location.y - 9 };
        Polygon poly = new Polygon(xPoints, yPoints, 3);
        Rectangle r = new Rectangle(location.x - 6, location.y - 12 - 9, 13, 12);
        return poly.contains(p) || r.contains(p);
    }
    int[] xPoints = { location.x, location.x - 6, location.x + 6 };
    int[] yPoints = { location.y, location.y + 9, location.y + 9 };
    Polygon poly = new Polygon(xPoints, yPoints, 3);
    Rectangle r = new Rectangle(location.x - 6, location.y + 9, 13, 12);
    return poly.contains(p) || r.contains(p);
}
Also used : Rectangle(java.awt.Rectangle) Polygon(java.awt.Polygon)

Example 25 with Polygon

use of java.awt.Polygon in project Activiti by Activiti.

the class DefaultProcessDiagramCanvas method drawConditionalSequenceFlowIndicator.

public void drawConditionalSequenceFlowIndicator(Line2D.Double line, double scaleFactor) {
    if (scaleFactor > 1.0)
        return;
    int horizontal = (int) (CONDITIONAL_INDICATOR_WIDTH * 0.7);
    int halfOfHorizontal = horizontal / 2;
    int halfOfVertical = CONDITIONAL_INDICATOR_WIDTH / 2;
    Polygon conditionalIndicator = new Polygon();
    conditionalIndicator.addPoint(0, 0);
    conditionalIndicator.addPoint(-halfOfHorizontal, halfOfVertical);
    conditionalIndicator.addPoint(0, CONDITIONAL_INDICATOR_WIDTH);
    conditionalIndicator.addPoint(halfOfHorizontal, halfOfVertical);
    AffineTransform transformation = new AffineTransform();
    transformation.setToIdentity();
    double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
    transformation.translate(line.x1, line.y1);
    transformation.rotate((angle - Math.PI / 2d));
    AffineTransform originalTransformation = g.getTransform();
    g.setTransform(transformation);
    g.draw(conditionalIndicator);
    Paint originalPaint = g.getPaint();
    g.setPaint(CONDITIONAL_INDICATOR_COLOR);
    g.fill(conditionalIndicator);
    g.setPaint(originalPaint);
    g.setTransform(originalTransformation);
}
Also used : AffineTransform(java.awt.geom.AffineTransform) Paint(java.awt.Paint) Polygon(java.awt.Polygon) Point(java.awt.Point) Paint(java.awt.Paint)

Aggregations

Polygon (java.awt.Polygon)39 Point (java.awt.Point)15 Graphics2D (java.awt.Graphics2D)11 Color (java.awt.Color)6 Rectangle (java.awt.Rectangle)6 GridPoint (doc.GridPoint)5 BasicStroke (java.awt.BasicStroke)5 Font (java.awt.Font)5 Paint (java.awt.Paint)5 FontMetrics (java.awt.FontMetrics)4 AffineTransform (java.awt.geom.AffineTransform)4 GradientPaint (java.awt.GradientPaint)2 Shape (java.awt.Shape)2 ShapeSpanIterator (sun.java2d.pipe.ShapeSpanIterator)2 BasePoint (gdsc.core.match.BasePoint)1 PolygonRoi (ij.gui.PolygonRoi)1 Roi (ij.gui.Roi)1 AlphaComposite (java.awt.AlphaComposite)1 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1