private Table processJournalName(Table table) throws IOException { ScimapsJournalMatcher scimapsJournalMatcher = new ScimapsJournalMatcher(); // Create new output table Table outputTable = TableUtilities.copyTable(table); outputTable.addColumn(STANDARDIZED_JOURNAL_NAME_COLUMN, String.class); int standardizedJournalNameColumnIndex = outputTable.getColumnNumber(STANDARDIZED_JOURNAL_NAME_COLUMN); // Retrieve iterator Iterator<?> rows = outputTable.tuples(); // Process journal names int rowIndex = 0; while (rows.hasNext()) { Tuple row = (Tuple) rows.next(); if (row.canGetString(journalColumnName)) { String name = row.getString(journalColumnName); String suggestedName = scimapsJournalMatcher.get(name); outputTable.setString(rowIndex, standardizedJournalNameColumnIndex, suggestedName); } rowIndex++; } return outputTable; }
@Override public int getColor(VisualItem item) { // highlight border of glyphs for which search is true // TODO: thicker borders? more outstanding highlighting? // do (inefficient) manual comparison (for now) Iterator itemsInGroup = m_vis.getGroup(Visualization.SEARCH_ITEMS).tuples(); while (itemsInGroup.hasNext()) { Tuple itemInGroup = (Tuple) itemsInGroup.next(); if (item.getString(DocumentGridTable.NODE_NAME) .equals(itemInGroup.getString(DocumentGridTable.NODE_NAME))) { // debug // System.out.println("debug: "+this.getClass().getName()+": item in // group! "+item.toString()); return ColorLib.rgb(191, 99, 130); } } if (item.isHover()) { return Color.LIGHT_GRAY.getRGB(); } // default border color // return ColorLib.gray(50); return Color.DARK_GRAY.getRGB(); }
public float getUpdateCenterY() { System.out.println("oink"); TupleSet tset = getAllItems(); for (Iterator<Tuple> it = tset.tuples(); it.hasNext(); ) { Tuple tuple = it.next(); System.out.print(tuple.getString("_x")); System.out.print(", "); System.out.println(tuple.getString("_y")); } return 0.0f; }
/** Force a refresh of all names assigned to graph nodes. */ @SuppressWarnings("unchecked") void refreshNodeNames(boolean showCode, boolean abbreviate) { for (Iterator<Tuple> tuples = getNodes().tuples(); tuples.hasNext(); ) { Tuple t = tuples.next(); ResolvedConceptReference rcr = (ResolvedConceptReference) t.get("RCR"); if (rcr != null) { String code = showCode ? rcr.getConceptCode() : null; String desc = rcr.getEntityDescription() != null ? rcr.getEntityDescription().getContent() : null; t.set("name", getNodeName(code, desc, abbreviate, "\n")); } } }
/** * Preloads images for use in a visualization. Images to load are determined by taking objects * from the given iterator and retrieving the value of the specified field. The items in the * iterator must be instances of the {@link prefuse.data.Tuple} class. * * <p>Images are loaded in the order specified by the iterator until the the iterator is empty or * the maximum image cache size is met. Thus higher priority images should appear sooner in the * iteration. * * @param iter an Iterator of {@link prefuse.data.Tuple} instances * @param field the data field that contains the image location */ public void preloadImages(Iterator iter, String field) { boolean synch = m_asynch; m_asynch = false; String loc = null; while (iter.hasNext() && imageCache.size() <= m_imageCacheSize) { // get the string describing the image location Tuple t = (Tuple) iter.next(); loc = t.getString(field); if (loc != null) { getImage(loc); } } m_asynch = synch; }
public Data[] execute() { Graph graph = (Graph) data[0].getData(); String attribute = (String) parameters.get("attribute"); String comparator = (String) parameters.get("comparator"); double cutoff = ((Double) parameters.get("cutoff")).doubleValue(); // empty tables with the same schemas as the originals Table nodeTable = graph.getNodeTable().getSchema().instantiate(); Table edgeTable = graph.getEdgeTable().getSchema().instantiate(); // keep all nodes Iterator nodes = graph.getNodeTable().iterator(); while (nodes.hasNext()) { nodeTable.addTuple(graph.getNodeTable().getTuple(((Integer) nodes.next()).intValue())); } // keep all edges matching the criteria Iterator edges = graph.getEdgeTable().iterator(); while (edges.hasNext()) { Tuple tuple = graph.getEdgeTable().getTuple(((Integer) edges.next()).intValue()); Object value = tuple.get(attribute); if (value != null) { if (passes(comparator, ((Number) value).doubleValue(), cutoff)) { edgeTable.addTuple(tuple); } } } Graph resultGraph = new Graph( nodeTable, edgeTable, graph.isDirected(), graph.getNodeKeyField(), graph.getEdgeSourceField(), graph.getEdgeTargetField()); Data result = new BasicData(resultGraph, Graph.class.getName()); Dictionary metadata = result.getMetadata(); metadata.put( DataProperty.LABEL, "Only edges with " + attribute + " " + comparator + " " + cutoff); metadata.put(DataProperty.PARENT, this.data[0]); metadata.put(DataProperty.TYPE, DataProperty.NETWORK_TYPE); return new Data[] {result}; }
private ListMap sortNodesByAttributePrefix( Table nodeTable, String compareAttributeName, int numPrefixLetters) { ListMap nodesByAttributePrefix = new ListMap(); // for each node in the node table... for (IntIterator nodeIndexIt = nodeTable.rows(); nodeIndexIt.hasNext(); ) { int nodeIndex = nodeIndexIt.nextInt(); Tuple row = nodeTable.getTuple(nodeIndex); // get the attribute contents String comparisonAttributeContents = row.getString(compareAttributeName); if (comparisonAttributeContents == null) continue; // add the node index to our list map, in the bin with a key made from a prefix of the // attribute e.g. "do" for "donkey" String prefixKey = extractPrefixKey(comparisonAttributeContents, numPrefixLetters); nodesByAttributePrefix.put(prefixKey, new Integer(nodeIndex)); } return nodesByAttributePrefix; }
public boolean getBoolean(Tuple t) { if (t instanceof Node) { System.err.println("===" + ((Node) t).getInt(NODECOUNT)); if (((Node) t).getDepth() == 0) return true; else return t.canGetInt(NODECOUNT) && ((Node) t).getInt(NODECOUNT) > cutoff_frequency; } if (((Edge) t).getSourceNode().getInt(NODECOUNT) <= cutoff_frequency) return false; if (((Edge) t).getTargetNode().getInt(NODECOUNT) <= cutoff_frequency) return false; return true; }
private Merger collectMerges(Table mergingTable, DatabaseTable toBeMerged, Connection connection) throws AlgorithmExecutionException { Merger merger = new Merger(toBeMerged, monitor); try { String[] primaryKeyColumns = toBeMerged.getPrimaryKeyColumns(connection); ColumnProjection primaryKeyColumnFilter = new NamedColumnProjection(primaryKeyColumns, true); ForeignKey[] foreignKeys = toBeMerged.getRelations(connection); for (ForeignKey foreignKey : foreignKeys) { // merge units are the units of work that will repoint the foreign keys referring to the // entities merged away to point at the primary entities merger.addMergeUnit(new MergeUnit(foreignKey)); } TableIterator merges = mergingTable.iterator( mergingTable.rowsSortedBy(CreateMergingTable.MERGE_GROUP_IDENTIFIER_COLUMN, true)); while (merges.hasNext()) { int row = merges.nextInt(); Tuple tuple = mergingTable.getTuple(row); String groupIdentifier = tuple.getString(CreateMergingTable.MERGE_GROUP_IDENTIFIER_COLUMN); // for every key someone used for a merge group, there's an EntityGroup EntityGroup group = merger.getOrCreateEntityGroup( groupIdentifier, toBeMerged, primaryKeyColumnFilter, foreignKeys); try { group.addRecord(tuple); } catch (MergingErrorException e) { problems.add(e.getMessage()); } } return merger; } catch (SQLException e) { throw new AlgorithmExecutionException("There was a problem creating the output data.", e); } }