12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 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 + "]";
- }
- }
|