List of usage examples for java.util AbstractSet add
boolean add(E e);
From source file:org.ontologyengineering.conceptdiagrams.web.shared.concretesyntax.ConcreteBoundaryRectangle.java
private AbstractSet<ConcreteDiagramElement> elementsInBoundingBoxHelper(Point topLeft, Point botRight) { AbstractSet<ConcreteDiagramElement> result = new HashSet<ConcreteDiagramElement>(); for (ConcreteSpider s : getSpiders()) { if (ConcreteRectangularElement.rectangleContainment(s.centre(), topLeft, botRight)) { result.add(s); }//w w w . j a v a 2 s . c o m } for (ConcreteArrow a : getArrows()) { if (a.intersectsBox(topLeft, botRight)) { result.add(a); } } // NOT quite the right test. But should do as the only error is if the rounded corner doens't make it into // the bounding box ... need to think about this for the things that call this function for (ConcreteCurve c : getCurves()) { if (ConcreteRectangularElement.rectanglesIntersect(c.topLeft(), c.bottomRight(), topLeft, botRight)) { result.add(c); } } for (ConcreteZone z : getZones()) { if (ConcreteRectangularElement.rectanglesIntersect(z.topLeft(), z.bottomRight(), topLeft, botRight)) { result.add(z); } } return result; }
From source file:org.ontologyengineering.conceptdiagrams.web.shared.concretesyntax.ConcreteBoundaryRectangle.java
public AbstractSet<ConcreteDiagramElement> elementsInBoundingBox(Point topLeft, Point botRight) { AbstractSet<ConcreteDiagramElement> result = new HashSet<ConcreteDiagramElement>(); if (completelyEnclosed(topLeft, botRight)) { // we are completely inside the given bounds, so return everything, including this boundary rectangle result.add(this); result.addAll(getAllChildren()); } else if (completelyEncloses(topLeft, botRight)) { // the bound is completely inside me result.addAll(elementsInBoundingBoxHelper(topLeft, botRight)); } else {/*from w ww.j a v a 2s .co m*/ if (ConcreteRectangularElement.rectanglesIntersect(topLeft(), bottomRight(), topLeft, botRight)) { // must intersect the rectangle so add that too result.add(this); result.addAll(elementsInBoundingBoxHelper(topLeft, botRight)); } } return result; }
From source file:com.metaparadigm.jsonrpc.SetSerializer.java
public Object unmarshall(SerializerState state, Class clazz, Object o) throws UnmarshallException { JSONObject jso = (JSONObject) o;//w w w. j av a 2 s . c o m String java_class = null; try { java_class = jso.getString("javaClass"); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (java_class == null) throw new UnmarshallException("no type hint"); AbstractSet abset = null; if (java_class.equals("java.util.Set") || java_class.equals("java.util.AbstractSet") || java_class.equals("java.util.HashSet")) { abset = new HashSet(); } else if (java_class.equals("java.util.TreeSet")) { abset = new TreeSet(); } else if (java_class.equals("java.util.LinkedHashSet")) { abset = new LinkedHashSet(); } else { throw new UnmarshallException("not a Set"); } JSONObject jsonset = null; try { jsonset = jso.getJSONObject("set"); } catch (JSONException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (jsonset == null) throw new UnmarshallException("set missing"); Iterator i = jsonset.keys(); String key = null; try { while (i.hasNext()) { key = (String) i.next(); Object setElement = jsonset.get(key); abset.add(ser.unmarshall(state, null, setElement)); } } catch (UnmarshallException e) { throw new UnmarshallException("key " + i + e.getMessage()); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return abset; }
From source file:org.jabsorb.serializer.impl.SetSerializer.java
public Object unmarshall(SerializerState state, Class clazz, Object o) throws UnmarshallException { JSONObject jso = (JSONObject) o;/* ww w. ja v a2s. c o m*/ String java_class; try { java_class = jso.getString("javaClass"); } catch (JSONException e) { throw new UnmarshallException("Could not read javaClass", e); } if (java_class == null) { throw new UnmarshallException("no type hint"); } AbstractSet abset = null; if (java_class.equals("java.util.Set") || java_class.equals("java.util.AbstractSet") || java_class.equals("java.util.HashSet")) { abset = new HashSet(); } else if (java_class.equals("java.util.TreeSet")) { abset = new TreeSet(); } else if (java_class.equals("java.util.LinkedHashSet")) { abset = new LinkedHashSet(); } else { throw new UnmarshallException("not a Set"); } JSONObject jsonset; try { jsonset = jso.getJSONObject("set"); } catch (JSONException e) { throw new UnmarshallException("set missing", e); } if (jsonset == null) { throw new UnmarshallException("set missing"); } Iterator i = jsonset.keys(); String key = null; state.setSerialized(o, abset); try { while (i.hasNext()) { key = (String) i.next(); Object setElement = jsonset.get(key); abset.add(ser.unmarshall(state, null, setElement)); } } catch (UnmarshallException e) { throw new UnmarshallException("key " + i + e.getMessage(), e); } catch (JSONException e) { throw new UnmarshallException("key " + key + " " + e.getMessage(), e); } return abset; }
From source file:gate.creole.tokeniser.SimpleTokeniser.java
/** * Converts the finite state machine to a deterministic one. * * @param s//ww w. j a va 2s .c o m */ private AbstractSet<FSMState> lambdaClosure(Set<FSMState> s) { //the stack/queue used by the algorithm LinkedList<FSMState> list = new LinkedList<FSMState>(s); //the set to be returned AbstractSet<FSMState> lambdaClosure = new HashSet<FSMState>(s); FSMState top; FSMState currentState; Set<FSMState> nextStates; Iterator<FSMState> statesIter; while (!list.isEmpty()) { top = list.removeFirst(); nextStates = top.nextSet(null); if (null != nextStates) { statesIter = nextStates.iterator(); while (statesIter.hasNext()) { currentState = statesIter.next(); if (!lambdaClosure.contains(currentState)) { lambdaClosure.add(currentState); list.addFirst(currentState); } //if(!lambdaClosure.contains(currentState)) } //while(statesIter.hasNext()) } //if(null != nextStates) } return lambdaClosure; }