46 lines
1.3 KiB
Java
46 lines
1.3 KiB
Java
package de.synolo.app.qs.editor;
|
|
|
|
import javafx.beans.property.DoubleProperty;
|
|
import javafx.beans.property.SimpleDoubleProperty;
|
|
import javafx.geometry.Point2D;
|
|
|
|
public class ItemNode {
|
|
|
|
public static final int PADDING = 10;
|
|
|
|
private boolean lockXAxis = false,
|
|
lockYAxis = false;
|
|
private DoubleProperty xProperty = new SimpleDoubleProperty(),
|
|
yProperty = new SimpleDoubleProperty();
|
|
|
|
public ItemNode(double x, double y) {
|
|
setX(x);
|
|
setY(y);
|
|
}
|
|
|
|
public DoubleProperty xProperty() { return this.xProperty; }
|
|
public double getX() { return this.xProperty.get(); }
|
|
public void setX(double x) { this.xProperty.set(x); }
|
|
|
|
public DoubleProperty yPropert() { return this.yProperty; }
|
|
public double getY() { return this.yProperty.get(); }
|
|
public void setY(double y) { this.yProperty.set(y); }
|
|
|
|
public boolean isLockedXAxis() { return this.lockXAxis; }
|
|
public void setLockedXAxis(boolean lock) { this.lockXAxis = lock; }
|
|
|
|
public boolean isLockedYAxis() { return this.lockYAxis; }
|
|
public void setLockedYAxis(boolean lock) { this.lockYAxis = lock; }
|
|
|
|
public boolean isInBounds(double x, double y) {
|
|
boolean containsX = false,
|
|
containsY = false;
|
|
|
|
containsX = x >= getX()-PADDING && x <= getX() + PADDING;
|
|
containsY = y >= getY()-PADDING && y <= getY() + PADDING;
|
|
|
|
return containsX && containsY;
|
|
}
|
|
|
|
}
|