/** * Create a graphviz dot representation of this manager. * * @param filename * to be written to * @throws IOException * if the file could not be written to. */ public void createDotFile( String filename ) throws IOException { BufferedWriter out = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( filename ) ) ); GraphvizDot.startDiGraph( out ); root.outputAsDot( out, "", 0, -1 ); GraphvizDot.endGraph( out ); out.close(); }
private static List<String> createAttributes( FeatureType ft ) { List<String> result = new LinkedList<String>(); if ( ft.isAbstract() ) { result.add( GraphvizDot.getFillColorDef( "red" ) ); result.add( GraphvizDot.getShapeDef( "triangle" ) ); } else { result.add( GraphvizDot.getFillColorDef( "cyan" ) ); } return result; }
/** * Writes a vertex. * * @param id * of the vertex * @param attr_List * of attributes to write to the vertex definition * * @param writer * @throws IOException */ public static void writeVertex( String id, List<String> attr_List, Writer writer ) throws IOException { writer.write( "\"" ); writer.write( id ); writer.write( "\"" ); writeAttributeList( attr_List, writer ); writer.write( ";\n" ); }
BufferedWriter out = new BufferedWriter( new FileWriter( f ) ); List<String> attribs = new ArrayList<String>(); GraphvizDot.addRankDirLeftToRight( attribs ); GraphvizDot.startDiGraph( out, attribs ); FeatureType[] roots = schema.getRootFeatureTypes(); if ( roots != null && roots.length > 0 ) { defaultRoot = "feature"; attribs.clear(); attribs.add( GraphvizDot.getShapeDef( "diamond" ) ); attribs.add( GraphvizDot.getFillColorDef( "green" ) ); GraphvizDot.writeVertex( "feature", attribs, out ); GraphvizDot.writeEdge( defaultRoot, dotName( ft ), null, out ); GraphvizDot.endGraph( out ); out.close();
attList.add( GraphvizDot.getShapeDef( "box" ) ); } else { if ( objectsCoveringEnv != null ) { attList.add( GraphvizDot.getLabelDef( label ) ); attList.add( GraphvizDot.getFillColorDef( color ) ); return attList;
/** * @param out * @param id * @param level * @param sonID * @throws IOException */ public void outputAsDot( Writer out, String id, int level, int sonID ) throws IOException { if ( isLeaf() ) { GraphvizDot.writeVertex( id, getDotVertex( level, sonID, true ), out ); } else { GraphvizDot.writeVertex( id, getDotVertex( level, sonID, false ), out ); for ( int i = 0; i < 4; ++i ) { QTree<T> child = children[i]; if ( child != null ) { String newID = id + i; child.outputAsDot( out, newID, level + 1, i ); GraphvizDot.writeEdge( id, newID, null, out ); } } } }
/** * Writes the starting directed graph definition. * * @param writer * @throws IOException */ public static void startDiGraph( Writer writer ) throws IOException { startDiGraph( writer, null ); }
/** * @param root * @throws IOException */ private static void addNode( BufferedWriter out, FeatureType ft ) throws IOException { if ( ft != null ) { String dotName = dotName( ft ); List<String> attributes = createAttributes( ft ); List<PropertyType> pd = ft.getPropertyDeclarations(); StringBuilder sb = new StringBuilder( "tooltip=\"" ); if ( pd != null && !pd.isEmpty() ) { Iterator<PropertyType> it = pd.iterator(); while ( it.hasNext() ) { sb.append( dotName( it.next().getName() ) ); if ( it.hasNext() ) { sb.append( ",<br/>" ); } } } sb.append( "\"" ); attributes.add( sb.toString() ); GraphvizDot.writeVertex( dotName, attributes, out ); } }
private static void createGraph( BufferedWriter out, AppSchema schema, FeatureType root ) throws IOException { if ( root != null ) { addNode( out, root ); } FeatureType[] directSubtypes = schema.getDirectSubtypes( root ); if ( directSubtypes != null && directSubtypes.length > 0 ) { for ( FeatureType dft : directSubtypes ) { if ( dft != null ) { GraphvizDot.writeEdge( dotName( root ), dotName( dft ), null, out ); createGraph( out, schema, dft ); } } } }
/** * Writes a vertex. * * @param from * this vertex * @param to * this vertex * * @param attr_List * of attributes to write to the edge definition * * @param writer * @throws IOException */ public static void writeEdge( String from, String to, List<String> attr_List, Writer writer ) throws IOException { writer.write( "\"" ); writer.write( from ); writer.write( "\"->\"" ); writer.write( to ); writer.write( "\"" ); writeAttributeList( attr_List, writer ); writer.write( ";\n" ); }