1 package de.lathanda.eos.geo;
3 import java.util.ArrayList;
4 import java.util.LinkedList;
6 import de.lathanda.eos.base.FillStyle;
7 import de.lathanda.eos.base.Picture;
8 import de.lathanda.eos.base.layout.BalancePoint;
9 import de.lathanda.eos.base.layout.BoundingBox;
10 import de.lathanda.eos.base.layout.Transform;
11 import de.lathanda.eos.base.math.Point;
12 import de.lathanda.eos.base.math.Vector;
13 import de.lathanda.eos.game.geom.Tesselation;
14 import de.lathanda.eos.game.geom.tesselation.TesselationFailedException;
22 private ArrayList<Point> points;
23 private LinkedList<? extends Point> bound;
24 private double weight = 0;
26 points =
new ArrayList<>();
41 for (
int i = 1; i < points.size(); i++) {
42 p.
drawLine(points.get(i - 1), points.get(i));
50 for (
int i = points.size(); i-- > 0;) {
51 points.get(i).scale(factor);
64 return points.size() > 1;
77 private void updatePolygon() {
78 if (points.isEmpty())
return;
88 Point a = points.get(points.size() - 1);
89 for (
int i = 0; i < points.size(); i++) {
90 Point b = points.get(i);
100 }
catch (TesselationFailedException tfe) {
102 BoundingBox bb =
new BoundingBox();
103 for (Point p:points) {
106 weight = bb.getArea();
107 x = bb.getCenter().getX();
108 y = bb.getCenter().getY();
112 Point a = points.get(0);
113 for (
int i = 1; i < points.size(); i++) {
114 Point b = points.get(i);
116 x += (a.getX() + b.getX()) * line_weight / 2;
117 y += (b.getY() + b.getY()) * line_weight / 2;
118 weight += line_weight;
131 for(Point p : points) {
135 for(Point p : bound) {
144 synchronized (
this) {
145 for (
Point p:points) {
153 synchronized (
this) {
155 poly.points =
new ArrayList<>();
156 for(
Point p : points) {
157 poly.points.add(
new Point(p));
160 poly.updatePolygon();
166 return "Polygon{" + points +
'}';
void setDrawWidth(double width)
abstract void drawLine(double x1, double y1, double x2, double y2)
abstract void drawPolygon(double[] x, double[] y)
BoundingBox calculateBoundingBox(Transform base, Transform own)
BalancePoint getBalancePoint()
void scaleInternal(double factor)
void drawObject(Picture p)
LinkedList<? extends Point > getOuterBorder()
static Tesselation getDefaultTesselation()
default void addVertices(Collection<? extends Point > points)