src/main/java/org/thegalactic/lattice/io/ConceptLatticeSerializerDot.java
public void write(ConceptLattice lattice, BufferedWriter file) throws IOException {
        file.write("digraph G {");
        file.newLine();
        file.write("Graph [rankdir=BT]");
        file.newLine();
        StringBuilder builder = new StringBuilder();
        for (Object node : lattice.getNodes()) {
            builder.setLength(0);
            Concept concept = (Concept) node;
            file.write(String.valueOf(concept.getIdentifier()));
            file.write(" [label=\"");
            if (concept.hasSetA()) {
                builder.append(concept.getSetA().toString().replace("\"", "\\\""));
            }
            if (concept.hasSetA() && concept.hasSetB()) {
                builder.append("\\n");
            }
            if (concept.hasSetB()) {
                builder.append(concept.getSetB().toString().replace("\"", "\\\""));
            }
            file.write(builder.toString());
            file.write("\"]");
            file.newLine();
        }
        for (Object edge : lattice.getEdges()) {
            file.write(String.valueOf(((Edge) edge).getSource().getIdentifier()));
            file.write("->");
            file.write(String.valueOf(((Edge) edge).getTarget().getIdentifier()));
            if (((Edge) edge).hasContent()) {
                file.write(" [label=\"");
                builder.append(((Edge) edge).getContent().toString().replace("\"", "\\\""));
                file.write("\"]");
            }
            file.newLine();
        }
        file.write("}");
    }
/**
     * Write a graph to a output stream.
     *
     * @param lattice a concept lattice to write
     * @param file    a file
     *
     * @throws IOException When an IOException occurs
     */
Write a graph to a output stream.
@param lattice a concept lattice to write
@param file    a file


Write a graph to a output stream . @param lattice a concept lattice to write @param file a file
public void write(ConceptLattice lattice, BufferedWriter file) throws IOException {
        file.write("digraph G {");
        file.newLine();
        file.write("Graph [rankdir=BT]");
        file.newLine();
        StringBuilder builder = new StringBuilder();
        for (Object node : lattice.getNodes()) {
            builder.setLength(0);
            Concept concept = (Concept) node;
            file.write(String.valueOf(concept.getIdentifier()));
            file.write(" [label=\"");
            if (concept.hasSetA()) {
                builder.append(concept.getSetA().toString().replace("\"", "\\\""));
            }
            if (concept.hasSetA() && concept.hasSetB()) {
                builder.append("\\n");
            }
            if (concept.hasSetB()) {
                builder.append(concept.getSetB().toString().replace("\"", "\\\""));
            }
            file.write(builder.toString());
            file.write("\"]");
            file.newLine();
        }
        for (Object edge : lattice.getEdges()) {
            file.write(String.valueOf(((Edge) edge).getSource().getIdentifier()));
            file.write("->");
            file.write(String.valueOf(((Edge) edge).getTarget().getIdentifier()));
            if (((Edge) edge).hasContent()) {
                file.write(" [label=\"");
                builder.append(((Edge) edge).getContent().toString().replace("\"", "\\\""));
                file.write("\"]");
            }
            file.newLine();
        }
        file.write("}");
    }
public void write ( ConceptLattice lattice , BufferedWriter file ) throws IOException { file . write ( "digraph G {" ) ; file . newLine ( ) ; file . write ( "Graph [rankdir=BT]" ) ; file . newLine ( ) ; StringBuilder builder = new StringBuilder ( ) ; for ( Object node : lattice . getNodes ( ) ) { builder . setLength ( 0 ) ; Concept concept = ( Concept ) node ; file . write ( String . valueOf ( concept . getIdentifier ( ) ) ) ; file . write ( " [label=\"" ) ; if ( concept . hasSetA ( ) ) { builder . append ( concept . getSetA ( ) . toString ( ) . replace ( "\"" , "\\\"" ) ) ; } if ( concept . hasSetA ( ) && concept . hasSetB ( ) ) { builder . append ( "\\n" ) ; } if ( concept . hasSetB ( ) ) { builder . append ( concept . getSetB ( ) . toString ( ) . replace ( "\"" , "\\\"" ) ) ; } file . write ( builder . toString ( ) ) ; file . write ( "\"]" ) ; file . newLine ( ) ; } for ( Object edge : lattice . getEdges ( ) ) { file . write ( String . valueOf ( ( ( Edge ) edge ) . getSource ( ) . getIdentifier ( ) ) ) ; file . write ( "->" ) ; file . write ( String . valueOf ( ( ( Edge ) edge ) . getTarget ( ) . getIdentifier ( ) ) ) ; if ( ( ( Edge ) edge ) . hasContent ( ) ) { file . write ( " [label=\"" ) ; builder . append ( ( ( Edge ) edge ) . getContent ( ) . toString ( ) . replace ( "\"" , "\\\"" ) ) ; file . write ( "\"]" ) ; } file . newLine ( ) ; } file . write ( "}" ) ; }
Write a graph to a output stream.
Write a graph to a output stream .