Search in sources :

Example 61 with Polygon

use of java.awt.Polygon in project kernel by cristal-ise.

the class DefaultVertexRenderer method drawOutline.

/**
 * Fill and then draw the outline as a Polygon
 *
 * @param g2d the canvas
 * @param vertex the vertex to be drawn
 */
public void drawOutline(Graphics2D g2d, Vertex vertex, Paint fillPaint, Paint linePaint) {
    Polygon outline = vertex.getOutlinePolygon();
    g2d.setPaint(fillPaint);
    g2d.fill(outline);
    g2d.setPaint(linePaint);
    g2d.draw(outline);
}
Also used : Polygon(java.awt.Polygon)

Example 62 with Polygon

use of java.awt.Polygon in project kernel by cristal-ise.

the class Vertex method setOutlinePoints.

/**
 * Sets the outline points and re-calculates the height and width
 *
 * @param outline the Outline coordinates
 */
public void setOutlinePoints(GraphPoint[] outline) {
    int topLeftX = outline[0].x;
    int topLeftY = outline[0].y;
    int bottomRightX = 0;
    int bottomRightY = 0;
    mOutlinePoints = outline;
    // Construct a polygon in the outline of the vertex and calculate the top left and bottom right corners
    mOutlinePolygon = new Polygon();
    for (int i = 0; i < outline.length; i++) {
        mOutlinePolygon.addPoint(outline[i].x, outline[i].y);
        if (outline[i].x < topLeftX)
            topLeftX = outline[i].x;
        if (outline[i].y < topLeftY)
            topLeftY = outline[i].y;
        if (outline[i].x > bottomRightX)
            bottomRightX = outline[i].x;
        if (outline[i].y > bottomRightY)
            bottomRightY = outline[i].y;
    }
    // Set the height and width
    mHeight = bottomRightY - topLeftY;
    mWidth = bottomRightX - topLeftX;
}
Also used : Polygon(java.awt.Polygon)

Example 63 with Polygon

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

the class RSPlayerMixin method getPolygons.

@Inject
@Override
public Polygon[] getPolygons() {
    Model model = getModel();
    if (model == null) {
        return null;
    }
    int localX = getX();
    int localY = getY();
    int orientation = getOrientation();
    List<Triangle> triangles = model.getTriangles();
    triangles = rotate(triangles, orientation);
    List<Polygon> polys = new ArrayList<Polygon>();
    for (Triangle triangle : triangles) {
        Vertex vx = triangle.getA();
        Vertex vy = triangle.getB();
        Vertex vz = triangle.getC();
        Point x = Perspective.worldToCanvas(client, localX - vx.getX(), localY - vx.getZ(), -vx.getY());
        Point y = Perspective.worldToCanvas(client, localX - vy.getX(), localY - vy.getZ(), -vy.getY());
        Point z = Perspective.worldToCanvas(client, localX - vz.getX(), localY - vz.getZ(), -vz.getY());
        int[] xx = { x.getX(), y.getX(), z.getX() };
        int[] yy = { x.getY(), y.getY(), z.getY() };
        polys.add(new Polygon(xx, yy, 3));
    }
    return polys.toArray(new Polygon[polys.size()]);
}
Also used : Vertex(net.runelite.api.model.Vertex) Model(net.runelite.api.Model) Triangle(net.runelite.api.model.Triangle) ArrayList(java.util.ArrayList) Point(net.runelite.api.Point) Polygon(java.awt.Polygon) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 64 with Polygon

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

the class RSModelMixin method getConvexHull.

@Override
@Inject
public Polygon getConvexHull(int localX, int localY, int orientation) {
    List<Vertex> vertices = getVertices();
    // rotate vertices
    for (int i = 0; i < vertices.size(); ++i) {
        Vertex v = vertices.get(i);
        vertices.set(i, v.rotate(orientation));
    }
    List<Point> points = new ArrayList<Point>();
    for (Vertex v : vertices) {
        // Compute canvas location of vertex
        Point p = Perspective.worldToCanvas(client, localX - v.getX(), localY - v.getZ(), -v.getY());
        if (p != null) {
            points.add(p);
        }
    }
    // Run Jarvis march algorithm
    points = Jarvis.convexHull(points);
    if (points == null) {
        return null;
    }
    // Convert to a polygon
    Polygon p = new Polygon();
    for (Point point : points) {
        p.addPoint(point.getX(), point.getY());
    }
    return p;
}
Also used : Vertex(net.runelite.api.model.Vertex) ArrayList(java.util.ArrayList) Point(net.runelite.api.Point) Polygon(java.awt.Polygon) Point(net.runelite.api.Point) Inject(net.runelite.api.mixins.Inject)

Example 65 with Polygon

use of java.awt.Polygon in project airavata by apache.

the class EndDoWhileNodeGUI method createHeader.

private Polygon createHeader(Point position) {
    Polygon head = new Polygon();
    head.addPoint(position.x, position.y);
    head.addPoint(position.x, position.y + this.headHeight);
    head.addPoint(position.x + this.dimension.width, position.y + this.headHeight);
    head.addPoint(position.x + this.dimension.width, position.y + this.headHeight / 2);
    return head;
}
Also used : Polygon(java.awt.Polygon)

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