grid.printDebug();
long start = System.currentTimeMillis();
Diagram diagram = new Diagram(grid, options);
final RenderedImage image = new BitmapRenderer().renderToImage(diagram, options.renderingOptions);
System.out.println("0. Rendered in " + (System.currentTimeMillis() - start) + " ms");
// ImageIO.write(image, "png", os);
JFrame frame = new JFrame("Ditaa Test");
frame.setSize(image.getWidth()+30, image.getHeight()+80);
Panel panel = new Panel() {
public void paint(Graphics g) {
g.drawImage((Image) image, 0, 0, null);
}
};
frame.getContentPane().add(panel);
panel.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.out.println("Mouse clicked.");
System.exit(0);
}
});
// this doesn't seem to be working:
frame.addWindowStateListener(new WindowStateListener() {
public void windowStateChanged(WindowEvent e) {
System.out.println("Window state changed: " + e.getNewState());
if (e.getNewState() == WindowEvent.WINDOW_CLOSED)
System.exit(0);
}
});
frame.setVisible(true);
for (int i = 0; i < 10; ++i) {
start = System.currentTimeMillis();
Diagram nDiagram = new Diagram(grid, options);
new BitmapRenderer().renderToImage(nDiagram, options.renderingOptions);
System.out.println((i+1) + ". Rendered in " + (System.currentTimeMillis() - start) + " ms");
}
}