//FOP
import org.apache.fop.render.awt.AWTRenderer;
import org.apache.fop.viewer.PreviewDialog;
-import org.apache.fop.viewer.Translator;
//Java
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-import java.util.Locale;
/**
* AWT Viewer starter.
*/
public class AWTStarter extends CommandLineStarter {
private PreviewDialog frame;
- private Translator translator;
private Driver driver;
/**
}
private void init() throws FOPException {
- translator = new Translator();
- AWTRenderer renderer = new AWTRenderer(translator);
- frame = createPreviewDialog(renderer, translator);
- renderer.setComponent(frame);
+ AWTRenderer renderer = new AWTRenderer();
+ frame = createPreviewDialog(renderer);
+ renderer.setPreviewDialog(frame);
renderer.setOptions(commandLineOptions.getRendererOptions());
driver = new Driver();
driver.setRenderer(renderer);
public void run() throws FOPException {
driver.reset();
try {
- frame.setStatus(translator.getString("Status.Build.FO.tree"));
driver.render(inputHandler);
- frame.setStatus(translator.getString("Status.Show"));
- frame.showPage();
} catch (Exception e) {
frame.reportException(e);
}
}
- private PreviewDialog createPreviewDialog(AWTRenderer renderer,
- Translator res) {
- PreviewDialog frame = new PreviewDialog(this, renderer, res);
+ private PreviewDialog createPreviewDialog(AWTRenderer renderer) {
+ PreviewDialog frame = new PreviewDialog(this, renderer);
frame.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent we) {
System.exit(0);
private PrinterJob printerJob;
public AWTPrintRenderer() {
- super(null);
+ super();
initialize();
}
import org.apache.fop.layout.FontInfo;
import org.apache.fop.render.AbstractRenderer;
+import org.apache.fop.viewer.PreviewDialog;
import org.apache.fop.viewer.Translator;
/**
protected int pageNumber = 0;
protected List pageList = new java.util.Vector();
//protected ProgressListener progressListener = null;
- protected Translator res = null;
+
+ /**
+ * The resource bundle used for AWT messages.
+ */
+ protected Translator translator = null;
protected Map fontNames = new java.util.Hashtable();
protected Map fontStyles = new java.util.Hashtable();
/**
* The current (internal) font name
- */
+ */
protected String currentFontName;
/**
protected float currentBlue = 0;
/**
- * The parent component, used to set up the font.
- * This is needed as FontSetup needs a live AWT component
- * in order to generate valid font measures.
+ * The preview dialog frame used for display of the documents.
+ * Also used as the AWT Component for FontSetup in generating
+ * valid font measures.
*/
- protected Component parent;
+ protected PreviewDialog frame;
+
+ public AWTRenderer() {
+ translator = new Translator();
+ }
- public AWTRenderer(Translator aRes) {
- res = aRes;
+ public Translator getTranslator() {
+ return translator;
}
public int getPageCount() {
}
/**
- * Sets parent component which is used to set up the font.
- * This is needed as FontSetup needs a live AWT component
- * in order to generate valid font measures.
- * @param parent the live AWT component reference
+ * Sets the preview dialog frame used for display of the documents.
+ * @param frame the PreviewDialog frame
*/
- public void setComponent(Component parent) {
- this.parent = parent;
+ public void setPreviewDialog(PreviewDialog frame) {
+ this.frame = frame;
+ frame.setStatus(translator.getString("Status.Build.FO.tree"));
}
public int getPageNumber() {
public void stopRenderer()
throws IOException {
+ frame.setStatus(translator.getString("Status.Show"));
+ frame.showPage();
}
// Printable Interface
private JLabel infoStatus;
/**
- * Creates a new PreviewDialog that uses the given starter, renderer and translator.
+ * Creates a new PreviewDialog that uses the given starter and renderer.
* @param aStarter the to use starter
* @param aRenderer the to use renderer
- * @param aRes the to use translator
*/
- public PreviewDialog(AWTStarter aStarter, AWTRenderer aRenderer, Translator aRes) {
- this(aRenderer, aRes);
+ public PreviewDialog(AWTStarter aStarter, AWTRenderer aRenderer) {
+ this(aRenderer);
starter = aStarter;
}
/**
- * Creates a new PreviewDialog that uses the given renderer and translator.
+ * Creates a new PreviewDialog that uses the given renderer.
* @param aRenderer the to use renderer
- * @param aRes the to use translator
*/
- public PreviewDialog(AWTRenderer aRenderer, Translator aRes) {
- translator = aRes;
+ public PreviewDialog(AWTRenderer aRenderer) {
renderer = aRenderer;
+ translator = renderer.getTranslator();
//Commands aka Actions
Command printAction = new Command(translator.getString("Menu.Print"), "Print") {
//while (renderer.getPageCount() != 0)
// renderer.removePage(0);
try {
+ setStatus(translator.getString("Status.Build.FO.tree"));
starter.run();
+ setStatus(translator.getString("Status.Show"));
} catch (FOPException e) {
reportException(e);
}