57 lines
1.9 KiB
Java
57 lines
1.9 KiB
Java
package de.synolo.app.qs.editor;
|
|
|
|
import javafx.beans.property.BooleanProperty;
|
|
import javafx.beans.property.SimpleBooleanProperty;
|
|
import javafx.beans.property.SimpleStringProperty;
|
|
import javafx.beans.property.StringProperty;
|
|
import javafx.collections.FXCollections;
|
|
import javafx.collections.ListChangeListener.Change;
|
|
import javafx.collections.ObservableList;
|
|
import javafx.scene.canvas.GraphicsContext;
|
|
|
|
public class EditorLayer {
|
|
|
|
private EditorCanvas parent;
|
|
|
|
private StringProperty nameProperty = new SimpleStringProperty("Layer");
|
|
private BooleanProperty visibleProperty = new SimpleBooleanProperty(true),
|
|
lockedProperty = new SimpleBooleanProperty(false);
|
|
|
|
private ObservableList<EditorItem> items = FXCollections.observableArrayList();
|
|
|
|
public EditorLayer(EditorCanvas parent, String name, boolean visible, boolean locked) {
|
|
setName(name);
|
|
setVisible(visible);
|
|
setLocked(locked);
|
|
this.parent = parent;
|
|
|
|
this.visibleProperty.addListener((v, ov, nv) -> this.parent.paint());
|
|
this.items.addListener((Change<? extends EditorItem> c) -> this.parent.paint());
|
|
}
|
|
|
|
public StringProperty nameProperty() { return this.nameProperty; }
|
|
public String getName() { return this.nameProperty.get(); }
|
|
public void setName(String name) { this.nameProperty.set(name); }
|
|
|
|
public BooleanProperty visibleProperty() { return this.visibleProperty; }
|
|
public boolean isVisible() { return this.visibleProperty.get(); }
|
|
public void setVisible(boolean visible) { this.visibleProperty.set(visible); }
|
|
|
|
public BooleanProperty lockedProperty() { return this.lockedProperty; }
|
|
public boolean isLocked() { return this.lockedProperty.get(); }
|
|
public void setLocked(boolean locked) { this.lockedProperty.set(locked); }
|
|
|
|
public EditorCanvas getParent() { return this.parent; }
|
|
|
|
public ObservableList<EditorItem> getItems() { return this.items; }
|
|
|
|
void paint(GraphicsContext gc){
|
|
if(isVisible()) {
|
|
for(EditorItem item : this.items) {
|
|
item.paint(gc);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|