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);
}
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;
}
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()]);
}
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;
}
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;
}
Aggregations