Search in sources :

Example 96 with Polygon

use of java.awt.Polygon in project hackpad by dropbox.

the class RunProxy method paint.

/**
     * Paints the component.
     */
@Override
public void paint(Graphics g) {
    super.paint(g);
    FileTextArea textArea = fileWindow.textArea;
    Font font = textArea.getFont();
    g.setFont(font);
    FontMetrics metrics = getFontMetrics(font);
    Rectangle clip = g.getClipBounds();
    g.setColor(getBackground());
    g.fillRect(clip.x, clip.y, clip.width, clip.height);
    int ascent = metrics.getMaxAscent();
    int h = metrics.getHeight();
    int lineCount = textArea.getLineCount() + 1;
    String dummy = Integer.toString(lineCount);
    if (dummy.length() < 2) {
        dummy = "99";
    }
    int startLine = clip.y / h;
    int endLine = (clip.y + clip.height) / h + 1;
    int width = getWidth();
    if (endLine > lineCount)
        endLine = lineCount;
    for (int i = startLine; i < endLine; i++) {
        String text;
        int pos = -2;
        try {
            pos = textArea.getLineStartOffset(i);
        } catch (BadLocationException ignored) {
        }
        boolean isBreakPoint = fileWindow.isBreakPoint(i + 1);
        text = Integer.toString(i + 1) + " ";
        int y = i * h;
        g.setColor(Color.blue);
        g.drawString(text, 0, y + ascent);
        int x = width - ascent;
        if (isBreakPoint) {
            g.setColor(new Color(0x80, 0x00, 0x00));
            int dy = y + ascent - 9;
            g.fillOval(x, dy, 9, 9);
            g.drawOval(x, dy, 8, 8);
            g.drawOval(x, dy, 9, 9);
        }
        if (pos == fileWindow.currentPos) {
            Polygon arrow = new Polygon();
            int dx = x;
            y += ascent - 10;
            int dy = y;
            arrow.addPoint(dx, dy + 3);
            arrow.addPoint(dx + 5, dy + 3);
            for (x = dx + 5; x <= dx + 10; x++, y++) {
                arrow.addPoint(x, y);
            }
            for (x = dx + 9; x >= dx + 5; x--, y++) {
                arrow.addPoint(x, y);
            }
            arrow.addPoint(dx + 5, dy + 7);
            arrow.addPoint(dx, dy + 7);
            g.setColor(Color.yellow);
            g.fillPolygon(arrow);
            g.setColor(Color.black);
            g.drawPolygon(arrow);
        }
    }
}
Also used : FontMetrics(java.awt.FontMetrics) Color(java.awt.Color) Rectangle(java.awt.Rectangle) Polygon(java.awt.Polygon) Font(java.awt.Font) Point(java.awt.Point)

Example 97 with Polygon

use of java.awt.Polygon in project android by JetBrains.

the class ConnectionDraw method getTopArrow.

/**
     * Static accessor to the top arrow
     *
     * @return return a Polygon representing a top arrow
     */
public static Polygon getTopArrow() {
    if (sTopArrow == null) {
        sTopArrow = new Polygon();
        sTopArrow.addPoint(0, 0);
        sTopArrow.addPoint(-CONNECTION_ARROW_SIZE, ARROW_SIDE);
        sTopArrow.addPoint(+CONNECTION_ARROW_SIZE, ARROW_SIDE);
    }
    return sTopArrow;
}
Also used : Polygon(java.awt.Polygon)

Example 98 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)

Example 99 with Polygon

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

the class DefaultProcessDiagramCanvas method drawArrowHead.

public void drawArrowHead(Line2D.Double line, double scaleFactor) {
    int doubleArrowWidth = (int) (2 * ARROW_WIDTH / scaleFactor);
    if (doubleArrowWidth == 0) {
        doubleArrowWidth = 2;
    }
    Polygon arrowHead = new Polygon();
    arrowHead.addPoint(0, 0);
    int arrowHeadPoint = (int) (-ARROW_WIDTH / scaleFactor);
    if (arrowHeadPoint == 0) {
        arrowHeadPoint = -1;
    }
    arrowHead.addPoint(arrowHeadPoint, -doubleArrowWidth);
    arrowHeadPoint = (int) (ARROW_WIDTH / scaleFactor);
    if (arrowHeadPoint == 0) {
        arrowHeadPoint = 1;
    }
    arrowHead.addPoint(arrowHeadPoint, -doubleArrowWidth);
    AffineTransform transformation = new AffineTransform();
    transformation.setToIdentity();
    double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
    transformation.translate(line.x2, line.y2);
    transformation.rotate((angle - Math.PI / 2d));
    AffineTransform originalTransformation = g.getTransform();
    g.setTransform(transformation);
    g.fill(arrowHead);
    g.setTransform(originalTransformation);
}
Also used : AffineTransform(java.awt.geom.AffineTransform) Polygon(java.awt.Polygon) Point(java.awt.Point) Paint(java.awt.Paint)

Example 100 with Polygon

use of java.awt.Polygon in project GDSC-SMLM by aherbert.

the class PSFCreator method getSpots.

/**
	 * @return Extract all the ROI points that are not within twice the box radius of any other spot
	 */
private BasePoint[] getSpots() {
    Roi roi = imp.getRoi();
    if (roi != null && roi.getType() == Roi.POINT) {
        Polygon p = ((PolygonRoi) roi).getNonSplineCoordinates();
        int n = p.npoints;
        Rectangle bounds = roi.getBounds();
        BasePoint[] roiPoints = new BasePoint[n];
        for (int i = 0; i < n; i++) {
            roiPoints[i] = new BasePoint(bounds.x + p.xpoints[i], bounds.y + p.ypoints[i], 0);
        }
        // All vs all distance matrix
        double[][] d = new double[n][n];
        for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) d[i][j] = d[j][i] = roiPoints[i].distanceXY2(roiPoints[j]);
        // Spots must be twice as far apart to have no overlap of the extracted box region
        double d2 = boxRadius * boxRadius * 4;
        int ok = 0;
        for (int i = 0; i < n; i++) {
            if (noNeighbours(d, n, i, d2))
                roiPoints[ok++] = roiPoints[i];
        }
        return Arrays.copyOf(roiPoints, ok);
    }
    return new BasePoint[0];
}
Also used : PolygonRoi(ij.gui.PolygonRoi) BasePoint(gdsc.core.match.BasePoint) Rectangle(java.awt.Rectangle) Polygon(java.awt.Polygon) Roi(ij.gui.Roi) PolygonRoi(ij.gui.PolygonRoi) Point(java.awt.Point) BasePoint(gdsc.core.match.BasePoint)

Aggregations

Polygon (java.awt.Polygon)192 Point (java.awt.Point)53 Rectangle (java.awt.Rectangle)30 Graphics2D (java.awt.Graphics2D)28 Area (java.awt.geom.Area)22 ArrayList (java.util.ArrayList)21 BasicStroke (java.awt.BasicStroke)20 Color (java.awt.Color)19 Paint (java.awt.Paint)15 Point2D (java.awt.geom.Point2D)13 AffineTransform (java.awt.geom.AffineTransform)12 Rectangle2D (java.awt.geom.Rectangle2D)12 Shape (java.awt.Shape)11 LocalPoint (net.runelite.api.coords.LocalPoint)11 Point (net.runelite.api.Point)10 FloatPolygon (ij.process.FloatPolygon)9 Font (java.awt.Font)8 List (java.util.List)8 FontMetrics (java.awt.FontMetrics)7 Stroke (java.awt.Stroke)7