/** * Set the data value of the given field with an <code>int</code>. * @param field the data field to set * @param val the value to set * @see #canSetInt(String) */ public final void setInt(String field, int val) { ++m_modCount; m_table.setInt(m_cur, field, val); }
/** * @see prefuse.data.Tuple#setInt(int, int) */ public final void setInt(int col, int val) { validityCheck(); m_table.setInt(m_row, col, val); }
/** * @see prefuse.data.Tuple#setInt(java.lang.String, int) */ public final void setInt(String field, int val) { validityCheck(); m_table.setInt(m_row, field, val); }
/** * @see prefuse.data.Graph#updateDegrees(int, int, int, int) */ protected void updateDegrees(int e, int s, int t, int incr) { super.updateDegrees(e, s, t, incr); int od = getOutDegree(s); if ( incr > 0 ) { // if added, child index is the last index in child array m_links.setInt(t, CHILDINDEX, od-1); } else if ( incr < 0 ) { // if removed, we renumber each child in the array int[] links = (int[])m_links.get(s, OUTLINKS); for ( int i=0; i<od; ++i ) { int n = getTargetNode(links[i]); m_links.setInt(n, CHILDINDEX, i); } m_links.setInt(t, CHILDINDEX, -1); } }
public void endDocument() throws SAXException { // time to actually set up the edges IntIterator rows = m_edges.rows(); while (rows.hasNext()) { int r = rows.nextInt(); String src = m_edges.getString(r, SRCID); if (!m_nodeMap.containsKey(src)) { throw new SAXException( "Tried to create edge with source node id=" + src + " which does not exist."); } int s = ((Integer) m_nodeMap.get(src)).intValue(); m_edges.setInt(r, SRC, s); String trg = m_edges.getString(r, TRGID); if (!m_nodeMap.containsKey(trg)) { throw new SAXException( "Tried to create edge with target node id=" + trg + " which does not exist."); } int t = ((Integer) m_nodeMap.get(trg)).intValue(); m_edges.setInt(r, TRG, t); } m_edges.removeColumn(SRCID); m_edges.removeColumn(TRGID); // now create the graph m_graph = new Graph(m_nodes, m_edges, m_directed); if (m_graphid != null) m_graph.putClientProperty(ID, m_graphid); }
/** * Add an item to the aggregation at the given row. * @param row the row index of the aggregate * @param member the item to add to the aggregation */ public void addToAggregate(int row, VisualItem member) { validRowCheck(row, true); if ( !aggregateContains(row, member) ) { int ar = m_aggregated.addRow(); m_aggregated.setInt(ar, AGGREGATE, row); m_aggregated.setInt(ar, MEMBER_HASH, getHashCode(member)); m_aggregated.set(ar, MEMBER, member); fireTableEvent(row, row, EventConstants.ALL_COLUMNS, EventConstants.UPDATE); } }
/** * Add an edge to the graph. Both multiple edges between two nodes * and edges from a node to itself are allowed. * @param s the source node id * @param t the target node id * @return the edge id (edge table row number) of the added edge */ public int addEdge(int s, int t) { // get keys for the nodes long key1 = getKey(s); long key2 = getKey(t); // add edge row, set source/target fields Table edges = getEdgeTable(); int r = edges.addRow(); if ( m_longKey ) { edges.setLong(r, m_skey, key1); edges.setLong(r, m_tkey, key2); } else { edges.setInt(r, m_skey, (int)key1); edges.setInt(r, m_tkey, (int)key2); } return r; }
/** * Build the spanning tree, starting at the given root. Uses an * unweighted breadth first traversal to build the spanning tree. * @param root the root node of the spanning tree */ public void buildSpanningTree(Node root) { // re-use a previously allocated tree if possible super.clearEdges(); super.setRoot(root); // build unweighted spanning tree by BFS LinkedList q = new LinkedList(); BitSet visit = new BitSet(); q.add(root); visit.set(root.getRow()); Table edges = getEdgeTable(); while ( !q.isEmpty() ) { Node p = (Node)q.removeFirst(); for ( Iterator iter = p.edges(); iter.hasNext(); ) { Edge e = (Edge)iter.next(); Node n = e.getAdjacentNode(p); if ( !visit.get(n.getRow()) ) { q.add(n); visit.set(n.getRow()); int er = super.addChildEdge(p.getRow(), n.getRow()); edges.setInt(er, SOURCE_EDGE, e.getRow()); } } } }
/** * Internal method for updating the linkage of this graph. * @param e the edge id for the updated link * @param s the source node id for the updated link * @param t the target node id for the updated link * @param incr the increment value, 1 for an added link, * -1 for a removed link */ protected void updateDegrees(int e, int s, int t, int incr) { int od = m_links.getInt(s, OUTDEGREE); int id = m_links.getInt(t, INDEGREE); // update adjacency lists if ( incr > 0 ) { // add links addLink(OUTLINKS, od, s, e); addLink(INLINKS, id, t, e); } else if ( incr < 0 ) { // remove links remLink(OUTLINKS, od, s, e); remLink(INLINKS, id, t, e); } // update degree counts m_links.setInt(s, OUTDEGREE, od+incr); m_links.setInt(t, INDEGREE, id+incr); // link structure changed, invalidate spanning tree m_spanning = null; }
case Types.SMALLINT: case Types.TINYINT: t.setInt(trow, field, rSet.getInt(rCol)); break;