Commit 56e8aca4 authored by Nico Mack's avatar Nico Mack

Changes required by making Markers clonable

parent f0e57f1d
......@@ -48,11 +48,39 @@ public class DisplayMarker extends InfoMarker implements InputChangeListener, Va
this.dispatcher = new HashMap<>();
}
// ---------------------------------------------------------------------------
public DisplayMarker(DisplayMarker original) {
super(original);
this.setupDispatcher();
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/**
* iterates over all value coronas assigned to this widget and populates the dispatcher table, using
* variable names as keys and associating depending coronas as values
*/
// ---------------------------------------------------------------------------
private void setupDispatcher() {
this.variables = new HashMap<>();
this.dispatcher = new HashMap<>();
List<ValueCorona> displays = this.getCoronas(ValueCorona.class);
for (ValueCorona display : displays) {
Variable<?> variable = display.getVariable();
if (variable != null) {
dispatcher.put(variable.getName(), display);
variables.put(variable.getName(), variable);
}
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
......@@ -133,4 +161,13 @@ public class DisplayMarker extends InfoMarker implements InputChangeListener, Va
return declared;
}
// ---------------------------------------------------------------------------
@Override
public DisplayMarker clone() {
return new DisplayMarker(this);
}
// ---------------------------------------------------------------------------
}
......@@ -33,6 +33,14 @@ public class InfoMarker<T> extends TetherableMarker implements InformationReceiv
this.variable = (Variable<T>) builder.variable;
}
// ---------------------------------------------------------------------------
public InfoMarker(InfoMarker original) {
super(original);
this.information = (T) original.information;
this.variable = (original.variable != null) ? original.variable.clone() : null;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
......@@ -45,6 +53,13 @@ public class InfoMarker<T> extends TetherableMarker implements InformationReceiv
// ***************************************************************************
// ---------------------------------------------------------------------------
@Override
public InfoMarker<T> clone() {
return new InfoMarker<T>(this);
}
// ---------------------------------------------------------------------------
@Override
public T getInformation(Point position) {
return this.getInformation();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment