1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package holeg.ui.view.inspector;
- import holeg.utility.math.vector.Vec2f;
- import holeg.utility.math.vector.Vec2i;
- /**
- * A class for saving all points of a Object with a editable state. e.g HolonElement, HolonSwitch
- *
- * @author Tom Troppmann
- */
- public class UnitGraphPoint {
- /**
- * Relative position in the UnitGraphCanvas
- */
- public double x, y;
- /**
- * To determine if this point has changed to only write back points that are changed.
- */
- public boolean changed;
- /**
- * The displayed Position of the UnitGraphPoint
- */
- public Vec2i displayedPosition;
- /**
- * Default Constructor
- */
- public UnitGraphPoint(double x, double y, boolean changed) {
- this.x = x;
- this.y = y;
- this.changed = changed;
- }
- /**
- * Constructor with a Point2D.Double
- */
- public UnitGraphPoint(Vec2f pos, boolean changed) {
- this.x = pos.getX();
- this.y = pos.getY();
- this.changed = changed;
- }
- /**
- * Constructor with a Point2D.Double when changed not specified is false;
- */
- public UnitGraphPoint(Vec2f pos) {
- this.x = pos.getX();
- this.y = pos.getY();
- this.changed = false;
- }
- public void calcDisplayedPosition(int border, int widthWithBorder, int heightWithBorder) {
- //Relativ to Border
- //1-p.y because its on the Top
- displayedPosition = new Vec2i((int) (x * widthWithBorder) + border,
- (int) ((1 - y) * heightWithBorder) + border);
- }
- public Vec2f getPoint() {
- return new Vec2f((float) x, (float) y);
- }
- @Override
- public String toString() {
- return "[" + x + ":" + y + "]";
- }
- }
|