package workbench.ui;
import java.io.PrintWriter;
import java.io.Reader;
import javax.swing.JScrollPane;
import att.grappa.Graph;
import att.grappa.GrappaPanel;
import att.grappa.Parser;
public class DiagramPanel extends JScrollPane {
private static final long serialVersionUID = 1L;
private Graph diagram = new Graph("Graph");
public DiagramPanel(){
GrappaPanel grappa = new GrappaPanel(diagram);
setName("Diagram");
setViewportView(grappa);
}
public void drawGraph(Reader reader){
try {
Parser program = new Parser(reader, new PrintWriter(System.err), diagram);
program.parse();
// diagram.printGraph(new PrintWriter(System.err));
diagram.repaint();
} catch(Exception ex) {
System.err.println("Exception: " + ex.getMessage());
}
}
}