Package prefuse.data

Examples of prefuse.data.Schema


     * String label field, and numeric value field for storing the value
     * which the axis label corresponds to.
     * @return the Schema for axis tick marks and labels.
     */
    public static Schema getAxisLabelSchema() {
        Schema s = getVisualItemSchema();

        s.setDefault(VisualItem.STARTVISIBLE, Boolean.FALSE);
       
        Integer defColor = new Integer(ColorLib.gray(230));
        s.setInterpolatedDefault(VisualItem.STROKECOLOR, defColor);
       
        defColor = new Integer(ColorLib.gray(150));
        s.setInterpolatedDefault(VisualItem.TEXTCOLOR, defColor);

        Double nan = new Double(Double.NaN);
        s.addInterpolatedColumn(VisualItem.X2, double.class);
        s.addInterpolatedColumn(VisualItem.Y2, double.class);
       
        s.addColumn(VisualItem.LABEL, String.class);
        s.addColumn(VisualItem.VALUE, double.class, nan);
       
        return s;
    }
View Full Code Here


     * Create a new table for representing axis labels.
     */
    protected VisualTable getTable() {
        TupleSet ts = m_vis.getGroup(m_group);
        if ( ts == null ) {
            Schema s = PrefuseLib.getAxisLabelSchema();
            VisualTable vt = m_vis.addTable(m_group, s);
            vt.index(VALUE);
            return vt;
        } else if ( ts instanceof VisualTable ) {
            return (VisualTable)ts;
View Full Code Here

     * @see prefuse.data.io.GraphWriter#writeGraph(prefuse.data.Graph, java.io.OutputStream)
     */
    public void writeGraph(Graph graph, OutputStream os) throws DataIOException
    {
        // first, check the schemas to ensure GraphML compatibility
        Schema ns = graph.getNodeTable().getSchema();
        Schema es = graph.getEdgeTable().getSchema();
        checkGraphMLSchema(ns);
        checkGraphMLSchema(es);
       
        XMLWriter xml = new XMLWriter(new PrintWriter(os));
        xml.begin(Tokens.GRAPHML_HEADER, 2);
       
        xml.comment("prefuse GraphML Writer | "
                + new Date(System.currentTimeMillis()));
       
        // print the graph schema
        printSchema(xml, Tokens.NODE, ns, null);
        printSchema(xml, Tokens.EDGE, es, new String[] {
            graph.getEdgeSourceField(), graph.getEdgeTargetField()
        });
        xml.println();
       
        // print graph contents
        xml.start(Tokens.GRAPH, Tokens.EDGEDEF,
            graph.isDirected() ? Tokens.DIRECTED : Tokens.UNDIRECTED);
       
        // print the nodes
        xml.comment("nodes");
        Iterator nodes = graph.nodes();
        while ( nodes.hasNext() ) {
            Node n = (Node)nodes.next();
           
            if ( ns.getColumnCount() > 0 ) {
                xml.start(Tokens.NODE, Tokens.ID, String.valueOf(n.getRow()));
                for ( int i=0; i<ns.getColumnCount(); ++i ) {
                    String field = ns.getColumnName(i);
                    xml.contentTag(Tokens.DATA, Tokens.KEY, field,
                                   n.getString(field));
                }
                xml.end();
            } else {
                xml.tag(Tokens.NODE, Tokens.ID, String.valueOf(n.getRow()));
            }
        }
       
        // add a blank line
        xml.println();
       
        // print the edges
        String[] attr = new String[]{Tokens.ID, Tokens.SOURCE, Tokens.TARGET};
        String[] vals = new String[3];
       
        xml.comment("edges");
        Iterator edges = graph.edges();
        while ( edges.hasNext() ) {
            Edge e = (Edge)edges.next();
            vals[0] = String.valueOf(e.getRow());
            vals[1] = String.valueOf(e.getSourceNode().getRow());
            vals[2] = String.valueOf(e.getTargetNode().getRow());
           
            if ( es.getColumnCount() > 2 ) {
                xml.start(Tokens.EDGE, attr, vals, 3);
                for ( int i=0; i<es.getColumnCount(); ++i ) {
                    String field = es.getColumnName(i);
                    if ( field.equals(graph.getEdgeSourceField()) ||
                         field.equals(graph.getEdgeTargetField()) )
                        continue;
                   
                    xml.contentTag(Tokens.DATA, Tokens.KEY, field,
View Full Code Here

     * @return a Comparator instance for sorting tuples from the given
     * set using the sorting criteria given in this specification
     */
    public Comparator getComparator(TupleSet ts) {
        // get the schema, so we can lookup column value types       
        Schema s = null;
        if ( ts instanceof Table ) {
            // for Tables, we can get this directly
          s = ((Table)ts).getSchema();
        } else {
          // if non-table tuple set is empty, we punt
          if ( ts.getTupleCount() == 0 )
            return new NullComparator();
          // otherwise, use the schema of the first tuple in the set
            s = ((Tuple)ts.tuples().next()).getSchema();
        }
        // create the comparator
        CompositeComparator cc = new CompositeComparator(m_fields.length);
        for ( int i=0; i<m_fields.length; ++i ) {
            cc.add(new TupleComparator(m_fields[i],
                       s.getColumnType(m_fields[i]), m_ascend[i]));
        }
        return cc;
    }
View Full Code Here

     * @see prefuse.data.io.GraphWriter#writeGraph(prefuse.data.Graph, java.io.OutputStream)
     */
    public void writeGraph(Graph graph, OutputStream os) throws DataIOException
    {
        // first, check the schemas to ensure GraphML compatibility
        Schema ns = graph.getNodeTable().getSchema();
        checkTreeMLSchema(ns);
       
        XMLWriter xml = new XMLWriter(new PrintWriter(os));
        xml.begin();
       
        xml.comment("prefuse TreeML Writer | "
                + new Date(System.currentTimeMillis()));
               
        // print the tree contents
        xml.start(Tokens.TREE);
       
        // print the tree node schema
        xml.start(Tokens.DECLS);
        String[] attr = new String[] {Tokens.NAME, Tokens.TYPE };
        String[] vals = new String[2];

        for ( int i=0; i<ns.getColumnCount(); ++i ) {
            vals[0] = ns.getColumnName(i);
            vals[1] = (String)TYPES.get(ns.getColumnType(i));
            xml.tag(Tokens.DECL, attr, vals, 2);
        }
        xml.end();
        xml.println();
       
       
        // print the tree nodes
        attr[0] = Tokens.NAME;
        attr[1] = Tokens.VALUE;
       
        Node n = graph.getSpanningTree().getRoot();
        while ( n != null ) {
            boolean leaf = (n.getChildCount() == 0);
           
            if ( leaf ) {
                xml.start(Tokens.LEAF);
            } else {
                xml.start(Tokens.BRANCH);
            }
           
            if ( ns.getColumnCount() > 0 ) {
                for ( int i=0; i<ns.getColumnCount(); ++i ) {
                    vals[0] = ns.getColumnName(i);
                    vals[1] = n.getString(vals[0]);
                    if (vals[1] != null) {
                      xml.tag(Tokens.ATTR, attr, vals, 2);
                    }
                }
View Full Code Here

     */
    public Schema getSchema(ResultSetMetaData metadata, SQLDataHandler handler)
        throws SQLException
    {
        int ncols = metadata.getColumnCount();
        Schema schema = new Schema(ncols);
       
        // determine the table schema
        for ( int i=1; i<=ncols; ++i ) {
            String name = metadata.getColumnName(i);
            int sqlType = metadata.getColumnType(i);
            Class type = handler.getDataType(name, sqlType);
            if ( type != null )
                schema.addColumn(name, type);
        }
       
        return schema;
    }
View Full Code Here

        m_vis.run("layout");
        m_vis.run("animate");
    }
   
    private static Schema getDataSchema() {
        Schema s = PrefuseLib.getVisualItemSchema();
        s.setDefault(VisualItem.INTERACTIVE, false);
        s.setDefault(VisualItem.FILLCOLOR, ColorLib.rgb(100,100,75));
        return s;
    }
View Full Code Here

        s.setDefault(VisualItem.FILLCOLOR, ColorLib.rgb(100,100,75));
        return s;
    }
   
    private static Schema getLabelSchema() {
        Schema s = PrefuseLib.getMinimalVisualSchema();
        s.setDefault(VisualItem.INTERACTIVE, false);
       
        // default font is 16 point Georgia
        s.addInterpolatedColumn(
                VisualItem.FONT, Font.class, FontLib.getFont("Georgia",16));
       
        // default fill color should be invisible
        s.addInterpolatedColumn(VisualItem.FILLCOLOR, int.class);
        s.setInterpolatedDefault(VisualItem.FILLCOLOR, 0);
       
        s.addInterpolatedColumn(VisualItem.TEXTCOLOR, int.class);
        // default text color is white
        s.setInterpolatedDefault(VisualItem.TEXTCOLOR, ColorLib.gray(255));
        // default start text color is fully transparent
        s.setDefault(VisualItem.STARTTEXTCOLOR, ColorLib.gray(255,0));
        return s;
    }
View Full Code Here

TOP

Related Classes of prefuse.data.Schema

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.