Commit dbf85e20 authored by Nico Mack's avatar Nico Mack

Added missing setSelected method to ShapeGraph

Added atomic update method to ApplicationContext
parent 435deac1
package lu.list.itis.dkd.tui.utility;
import lu.list.itis.dkd.tui.cps.InputChangeListener;
import lu.list.itis.dkd.tui.cps.InputEvent;
import lu.list.itis.dkd.tui.cps.variable.Variable;
import com.jgoodies.common.base.Preconditions;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import lu.list.itis.dkd.tui.cps.variable.Variable;
//***************************************************************************
//* Class Definition and Members *
//***************************************************************************
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public class ApplicationContext {
private static Map <String,Variable<?>> context = new HashMap<>();
private static Map<String, Variable<?>> context = new HashMap<>();
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s)
......@@ -21,33 +27,54 @@ public class ApplicationContext {
private ApplicationContext() {
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body
// ***************************************************************************
// ---------------------------------------------------------------------------
public static void addAll (Map <String,Variable<?>> variables) {
context.putAll(variables);
}
// ---------------------------------------------------------------------------
public static Map <String,Variable<?>> getContext() {
return context;
}
// ---------------------------------------------------------------------------
public static Variable<?> getVariable (String identifier) {
return context.get(identifier);
}
// ---------------------------------------------------------------------------
public static void addAll(Map<String, Variable<?>> variables) {
context.putAll(variables);
}
// ---------------------------------------------------------------------------
public static Map<String, Variable<?>> getContext() {
return context;
}
// ---------------------------------------------------------------------------
public static Variable<?> getVariable(String identifier) {
return context.get(identifier);
}
// ---------------------------------------------------------------------------
public static void atomicUpdate(List<Variable<?>> variables, List<Object> values) {
Preconditions.checkArgument(!variables.isEmpty(), "No variables to update!"); //$NON-NLS-1$
Preconditions.checkArgument(variables.size() == values.size(), "Sizes of variables and values lists must match!"); //$NON-NLS-1$
HashMap<InputChangeListener, List<Variable<?>>> consolidated = new HashMap<>();
for (int i = 0; i < variables.size(); i++) {
Variable<?> variable = variables.get(i);
variable.suspendListenerNotification(true);
variable.setValueFromObject(values.get(i));
variable.suspendListenerNotification(false);
consolidated = variable.consolidateListeners(consolidated);
}
for (Entry<InputChangeListener, List<Variable<?>>> entry : consolidated.entrySet()) {
entry.getKey().inputChanged(new InputEvent(entry.getValue()));
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class
// ***************************************************************************
// ---------------------------------------------------------------------------
}
......@@ -133,6 +133,18 @@ public class ShapeGraph extends ValueCorona {
// ***************************************************************************
// ---------------------------------------------------------------------------
@Override
public void setSelected(boolean selectIt) {
super.setSelected(selectIt);
if (fillColour != null)
fillColour.setSwitched(selectIt);
if (strokeColour != null)
strokeColour.setSwitched(selectIt);
}
// ---------------------------------------------------------------------------
public void setShownValue(double value) {
shownValue = value;
......
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