List of usage examples for org.apache.commons.collections15.map LazyMap decorate
public static <K, V> Map<K, V> decorate(Map<K, V> map, Transformer<K, V> transformer)
From source file:net.sourceforge.ondex.cytoscape.task.ScanForKeysTask.java
/** * starts the task.// w w w .j a v a 2s .co m */ public void run() { monitor.setPercentCompleted(0); monitor.setStatus("scanning..."); CyAttributes nodeAtts = Cytoscape.getNodeAttributes(); String[] ans = nodeAtts.getAttributeNames(); HashMap<String, HashMap<String, String>> anMap = new HashMap<String, HashMap<String, String>>(); for (String an : ans) { anMap.put(an, new HashMap<String, String>()); } Map<String, Integer> counts = LazyMap.decorate(new HashMap<String, Integer>(), new Factory<Integer>() { @Override public Integer create() { return Integer.valueOf(0); } }); ArrayList<String> clashedANs = new ArrayList<String>(); ArrayList<String> remainingANs = new ArrayList<String>(); for (String an : ans) { remainingANs.add(an); } int[] index = network.getNodeIndicesArray(); for (int i = 0; i < index.length; i++) { String nodeId = network.getNode(index[i]).getIdentifier(); clashedANs.clear(); for (String an : remainingANs) { Object val = nodeAtts.getAttribute(nodeId, an); if (val != null && val instanceof String) { String sval = (String) val; int oldcount = counts.get(an); counts.put(an, oldcount + 1); HashMap<String, String> map = anMap.get(an); if (map.get(sval) == null) { map.put(sval, nodeId); } else {//an has clashes! clashedANs.add(an); } } } remainingANs.removeAll(clashedANs); if (remainingANs.size() == 0) { break; } monitor.setPercentCompleted((i * 100) / index.length); } for (String an : ans) { if (counts.get(an) == 0) { remainingANs.remove(an); } } monitor.setPercentCompleted(100); monitor.setStatus("done"); keys = remainingANs; }
From source file:thesaurusEditor.gui.graph.PersistentLayoutImpl.java
/** * create an instance with a passed layout * create containers for graph components * @param layout /*ww w .java 2 s. com*/ */ public PersistentLayoutImpl(Layout<V, E> layout) { super(layout); this.map = LazyMap.decorate(new HashMap<V, Point>(), new PointFactory(getSize())); this.dontmove = new HashSet<V>(); }