agent.setRendererOverride(renderer);
renderer.setPreviewDialogDisplayed(false);
renderer.setUserAgent(agent);
renderer.clearViewportList();
final PreviewPanel previewPanel = new PreviewPanel(agent, null, renderer);
zoom.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
double value = zoom.getValue();
previewPanel.setScaleFactor(value/100);
}
});
final JProgressBar progress = new JProgressBar(0, 100);
JDialog dialog = new JDialog(parent);
dialog.getContentPane().setLayout(new BorderLayout());
dialog.getContentPane().add(zoom, BorderLayout.NORTH);
dialog.getContentPane().add(previewPanel, BorderLayout.CENTER);
dialog.getContentPane().add(progress, BorderLayout.SOUTH);
dialog.setSize(600, 800);
dialog.setVisible(true);
SwingWorker swingWorker = new SwingWorker() {
@Override
protected Object doInBackground() throws Exception {
Source source = createXSLStream();
progress.setValue(10);
Transformer transformer = TransformerFactory.newInstance().newTemplates(source).newTransformer();
Fop fop = fopFactory.newFop(agent);
StreamSource streamSource = createVelocityStream();
progress.setValue(50);
SAXResult saxr = new SAXResult(fop.getDefaultHandler());
progress.setValue(65);
transformer.transform(streamSource, saxr);
progress.setValue(90);
previewPanel.setScaleFactor(0.5);
previewPanel.setDisplayMode(PreviewPanel.CONTINUOUS);
previewPanel.reload();
progress.setValue(100);
return null;
}
};