Package prefuse.data

Examples of prefuse.data.Tuple


  public static Table copyTable(Table oldTable) {
    Schema oldSchema = oldTable.getSchema();
    Table newTable = oldSchema.instantiate();
   
    for (Iterator rowIt = oldTable.tuples(); rowIt.hasNext();) {
      Tuple row = (Tuple) rowIt.next();     
      newTable.addTuple(row);
    }   
   
    return newTable;
  }
View Full Code Here


  public static Table copyTable(Table t) {
    Table tCopy = new Table();
    tCopy.addColumns(t.getSchema());
   
    for (Iterator ii = t.tuples(); ii.hasNext();) {
      Tuple tuple = (Tuple) ii.next();
      tCopy.addTuple(tuple);
    }
    return tCopy;
  }
View Full Code Here

  private boolean areEqual(Table t1, Table t2) {
    Iterator tuplesIterator1 = t1.tuples();
    Iterator tuplesIterator2 = t2.tuples();
   
    while (tuplesIterator1.hasNext()) {
      Tuple tuple1 = (Tuple) tuplesIterator1.next();
      Tuple tuple2 = (Tuple) tuplesIterator2.next();
     
      if (! areEqual(tuple1, tuple2)) {
        return false;
      }
    }
View Full Code Here

  protected boolean areEqual(Table t1, Table t2) {
    Iterator tuplesIterator1 = t1.tuples();
    Iterator tuplesIterator2 = t2.tuples();
   
    while (tuplesIterator1.hasNext()) {
      Tuple tuple1 = (Tuple) tuplesIterator1.next();
      Tuple tuple2 = (Tuple) tuplesIterator2.next();
     
      if (! areEqual(tuple1, tuple2)) {
        return false;
      }
    }
View Full Code Here

            Iterator it = allNodes.tuples();
            int mover = 1;
            while(it.hasNext())
            {
                //=== Get the node's tuple
                Tuple node = (Node)it.next();
                //=== If it isn't a FOCUS node, move it a little
                if(node.getString("refType").equals("REFERENCES") || node.getString("refType").equals("CITATIONS"))
                {
                    //=== Get the VisualItem for the node, and it's current location
                    VisualItem item = m_vis.getVisualItem(treeNodes, node);
                    double currentX = item.getX();
                    double currentY = item.getY();
View Full Code Here

     * @param field the column / data field name
     * @param cmp a comparator for sorting the column contents
     * @return the Tuple with the minimum data field value
     */
    public static Tuple min(Iterator tuples, String field, Comparator cmp) {
        Tuple t = null, tmp;
        Object min = null;
        if ( tuples.hasNext() ) {
            t = (Tuple)tuples.next();
            min = t.get(field);
        }
        while ( tuples.hasNext() ) {
            tmp = (Tuple)tuples.next();
            Object obj = tmp.get(field);
            if ( cmp.compare(obj,min) < 0 ) {
View Full Code Here

     * @param field the column / data field name
     * @param cmp a comparator for sorting the column contents
     * @return the Tuple with the maximum data field value
     */
    public static Tuple max(Iterator tuples, String field, Comparator cmp) {
        Tuple t = null, tmp;
        Object min = null;
        if ( tuples.hasNext() ) {
            t = (Tuple)tuples.next();
            min = t.get(field);
        }
        while ( tuples.hasNext() ) {
            tmp = (Tuple)tuples.next();
            Object obj = tmp.get(field);
            if ( cmp.compare(obj,min) > 0 ) {
View Full Code Here

            return ((Table)tuples).getColumnType(field);
        } else {
            Class type = null, type2 = null;
            Iterator iter = tuples.tuples();
            while ( iter.hasNext() ) {
                Tuple t = (Tuple)iter.next();
                if ( type == null ) {
                    type = t.getColumnType(field);
                } else if ( !type.equals(type2=t.getColumnType(field)) ) {
                    if ( type2.isAssignableFrom(type) ) {
                        type = type2;
                    } else if ( !type.isAssignableFrom(type2) ) {
                        throw new IllegalArgumentException(
                           "The data field ["+field+"] does not have " +
View Full Code Here

     * Compares two tuples. If either input Object is not a Tuple,
     * a ClassCastException will be thrown.
     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
     */
    public int compare(Object o1, Object o2) {
        Tuple t1 = (Tuple)o1, t2 = (Tuple)o2;
        int c = 0;
       
        if ( m_col == -1 ) {
            if ( m_type == int.class || m_type == byte.class ) {
                c = ((LiteralComparator)m_cmp).compare(
                        t1.getInt(m_field), t2.getInt(m_field));
            } else if ( m_type == double.class ) {
                c = ((LiteralComparator)m_cmp).compare(
                        t1.getDouble(m_field), t2.getDouble(m_field));
            } else if ( m_type == long.class ) {
                c = ((LiteralComparator)m_cmp).compare(
                        t1.getLong(m_field), t2.getLong(m_field));
            } else if ( m_type == float.class ) {
                c = ((LiteralComparator)m_cmp).compare(
                        t1.getFloat(m_field), t2.getFloat(m_field));
            } else if ( m_type == boolean.class ) {
                c = ((LiteralComparator)m_cmp).compare(
                        t1.getBoolean(m_field), t2.getBoolean(m_field));
            } else if ( !m_type.isPrimitive() ) {
                c = m_cmp.compare(t1.get(m_field), t2.get(m_field));
            } else {
                throw new IllegalStateException(
                        "Unsupported type: " + m_type.getName());
            }
        } else {
            if ( m_type == int.class || m_type == byte.class ) {
                c = ((LiteralComparator)m_cmp).compare(
                        t1.getInt(m_col), t2.getInt(m_col));
            } else if ( m_type == double.class ) {
                c = ((LiteralComparator)m_cmp).compare(
                        t1.getDouble(m_col), t2.getDouble(m_col));
            } else if ( m_type == long.class ) {
                c = ((LiteralComparator)m_cmp).compare(
                        t1.getLong(m_col), t2.getLong(m_col));
            } else if ( m_type == float.class ) {
                c = ((LiteralComparator)m_cmp).compare(
                        t1.getFloat(m_col), t2.getFloat(m_col));
            } else if ( m_type == boolean.class ) {
                c = ((LiteralComparator)m_cmp).compare(
                        t1.getBoolean(m_col), t2.getBoolean(m_col));
            } else if ( !m_type.isPrimitive() ) {
                c = m_cmp.compare(t1.get(m_col), t2.get(m_col));
            } else {
                throw new IllegalStateException(
                        "Unsupported type: " + m_type.getName());
            }
        }
View Full Code Here

        next = advance();
    }
   
    private Tuple advance() {
        while ( tuples.hasNext() ) {
            Tuple t = (Tuple)tuples.next();
            if ( predicate.getBoolean(t) ) {
                return t;
            }
        }
        tuples = null;
View Full Code Here

TOP

Related Classes of prefuse.data.Tuple

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.