net.sourceforge.plantuml.svek.image.ConnectedCircle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.svek.image;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.klimt.UTranslate;
import net.sourceforge.plantuml.klimt.color.HColors;
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
import net.sourceforge.plantuml.klimt.geom.XPoint2D;
import net.sourceforge.plantuml.klimt.shape.UDrawable;
import net.sourceforge.plantuml.klimt.shape.UEllipse;
public class ConnectedCircle implements UDrawable {
private final double radius;
private final List angles = new ArrayList<>();
private final List points = new ArrayList<>();
public ConnectedCircle(double radius) {
this.radius = radius;
}
public void drawU(UGraphic ug) {
final UEllipse circle = UEllipse.build(2 * radius, 2 * radius);
// ug.draw(circle);
for (Double angle : angles) {
final double delta = 30;
final UEllipse part = new UEllipse(2 * radius, 2 * radius, angle - delta, 2 * delta);
ug.draw(part);
}
ug = ug.apply(HColors.GREEN).apply(HColors.GREEN.bg());
for (XPoint2D pt : points) {
final UTranslate tr = UTranslate.point(pt);
// ug.apply(tr).draw(UEllipse.build(2, 2));
}
}
public void addSecondaryConnection(XPoint2D pt) {
points.add(pt);
// double angle = Math.atan2(pt.getY() - radius, pt.getX() - radius);
// double angle = Math.atan2(pt.getX() - radius, pt.getY() - radius);
double angle = Math.atan2(radius - pt.getY(), pt.getX() - radius);
angle = angle * 180.0 / Math.PI;
System.err.println("pt1=" + pt + " " + angle);
angles.add(angle);
}
}