public void fillAsVoteMerge() { HashMap<String, LWNode> nodes = new HashMap<String, LWNode>(); ConnectivityMatrixList<ConnectivityMatrix> cms = new ConnectivityMatrixList<ConnectivityMatrix>(); Iterator<LWMap> i = getMapList().iterator(); Iterator<Boolean> ci = null; if (getActiveFileList() != null) ci = getActiveFileList().iterator(); while (i.hasNext()) { Boolean b = Boolean.TRUE; LWMap next = i.next(); if (ci != null && ci.hasNext()) { b = ci.next(); } if (b.booleanValue() /*&& (next != getBaseMap())*/) cms.add(new ConnectivityMatrix(next)); } VoteAggregate voteAggregate = new VoteAggregate(cms); voteAggregate.setNodeThreshold((double) getNodeThresholdSliderValue() / 100.0); voteAggregate.setLinkThreshold((double) getLinkThresholdSliderValue() / 100.0); // compute and create nodes in Merge Map if (!excludeNodesFromBaseMap && baseMapIsActive()) { addMergeNodesFromSourceMap(baseMap, voteAggregate, nodes); } if (!getFilterOnBaseMap()) { Iterator<LWMap> maps = getMapList().iterator(); ci = null; if (getActiveFileList() != null) ci = getActiveFileList().iterator(); while (maps.hasNext()) { LWMap m = maps.next(); Boolean b = Boolean.TRUE; if (ci != null && ci.hasNext()) { b = ci.next(); } if (m != baseMap && b.booleanValue()) { addMergeNodesFromSourceMap(m, voteAggregate, nodes); } } } // compute and create links in Merge Map Iterator<LWComponent> children1 = getAllDescendents(LWComponent.ChildKind.PROPER).iterator(); // getNodeIterator(); while (children1.hasNext()) { /*LWNode*/ LWComponent node1 = /*(LWNode)*/ children1.next(); Iterator<LWComponent> children2 = getAllDescendents(LWComponent.ChildKind.PROPER).iterator(); // getNodeIterator(); while (children2.hasNext()) { /*LWNode*/ LWComponent node2 = /*(LWNode)*/ children2.next(); if (!((node1 instanceof LWNode || node1 instanceof LWImage) && (node2 instanceof LWNode || node2 instanceof LWImage))) { continue; } if (node2 != node1) { boolean addLink = voteAggregate.isLinkVoteAboveThreshold( Util.getMergeProperty(node1), Util.getMergeProperty(node2)); if (addLink) { LWLink link = new LWLink(node1, node2); addLink(link); cms.addLinkSourceMapMetadata( Util.getMergeProperty(node1), Util.getMergeProperty(node2), link); } } } } }
public void addMergeNodesFromSourceMap( LWMap map, VoteAggregate voteAggregate, HashMap<String, LWNode> nodes) { Iterator<LWComponent> children = map.getAllDescendents(LWComponent.ChildKind.PROPER).iterator(); // map.getNodeIterator(); while (children.hasNext()) { // LWNode comp = (LWNode)children.next(); LWComponent comp = children.next(); if (comp instanceof LWPortal) continue; boolean repeat = false; if (nodeAlreadyPresent(comp)) { repeat = true; /*if(RECORD_SOURCE_NODES) { LWNode node = nodes.get(Util.getMergeProperty(comp)); if(node.getNotes() !=null) { node.setNotes(node.getNotes()+"\n" + map.getLabel()); } else { node.setNotes(map.getLabel()); } }*/ } if (voteAggregate.isNodeVoteAboveThreshold(Util.getMergeProperty(comp))) { // LWNode node = (LWNode)comp.duplicate(); LWComponent node = comp.duplicate(); String sourceLabel = node.getLabel(); if (sourceLabel == null) sourceLabel = ""; edu.tufts.vue.metadata.VueMetadataElement vme = new edu.tufts.vue.metadata.VueMetadataElement(); vme.setType(edu.tufts.vue.metadata.VueMetadataElement.OTHER); // todo: looks like this may be needed in future -- may be an issue // of map list in merge maps panel -- or otherwise might require // more generic approach (certainly a seperate method either here or in // merge maps panel or in VueMetadataElement is in order) /*String mapLabel = comp.getMap().getLabel(); if(mapLabel != null) { if(mapLabel.contains(".vue")) { mapLabel = mapLabel.substring(0,mapLabel.indexOf(".vue")); } } else { mapLabel = ""; }*/ vme.setObject("source: " + comp.getMap().getLabel() + "," + sourceLabel); node.getMetadataList().getMetadata().add(vme); if (!repeat) { /*if(RECORD_SOURCE_NODES) { if(node.getNotes() !=null) { node.setNotes(node.getNotes()+"\n" + map.getLabel()); } else { node.setNotes(map.getLabel()); } nodes.put(Util.getMergeProperty(comp),node); }*/ // addNode(node); if (!excludeNodesFromBaseMap || !nodePresentOnBaseMap(node)) { add(node); } } } } }