public synchronized void focus(Variable... vars) { if (currentFocus == null) { currentFocus = new FocusConstraint(); } Vector<Variable> scopeVars = new Vector<Variable>(); for (Variable v : currentFocus.getScope()) scopeVars.add(v); for (Variable v : vars) scopeVars.add(v); currentFocus.setScope(scopeVars.toArray(new Variable[scopeVars.size()])); }
public synchronized void removeFromCurrentFocus(Variable... vars) { if (currentFocus == null) throw new NoFocusDefinedException(vars); Vector<Variable> newScope = new Vector<Variable>(); for (Variable vOld : currentFocus.getScope()) { boolean found = false; for (Variable vToRem : vars) { if (vOld.equals(vToRem)) found = true; } if (!found) newScope.add(vOld); } currentFocus.setScope(newScope.toArray(new Variable[newScope.size()])); }
public synchronized Variable[] getFocused() { if (currentFocus != null) return currentFocus.getScope(); return null; }