import java.text.DecimalFormat;
+import javax.swing.ActionMap;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
+import javax.swing.InputMap;
import javax.swing.JComboBox;
-import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JRadioButtonMenuItem;
import javax.swing.JToolBar;
+import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
//Sets size to be 61%x90% of the screen size
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
+ // Needed due to bug in Sun's JVM 1.5 (6429775)
+ pack();
//Rather frivolous size - fits A4 page width in 1024x768 screen on my desktop
setSize(screen.width * 61 / 100, screen.height * 9 / 10);
previewPanel = new PreviewPanel(foUserAgent, renderable, renderer);
getContentPane().add(previewPanel, BorderLayout.CENTER);
+ // Keyboard shortcuts - pgup/pgdn
+ InputMap im = previewPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
+ ActionMap am = previewPanel.getActionMap();
+ im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "nextPage");
+ im.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "prevPage");
+ im.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), "firstPage");
+ im.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), "lastPage");
+ previewPanel.getActionMap().put("nextPage", nextPageAction);
+ previewPanel.getActionMap().put("prevPage", previousPageAction);
+ previewPanel.getActionMap().put("firstPage", firstPageAction);
+ previewPanel.getActionMap().put("lastPage", lastPageAction);
+
//Scaling combobox
scale = new JComboBox();
scale.addItem(translator.getString("Menu.Fit.Window"));
/** Scales page image */
public void setScale(double scaleFactor) {
-// if (scaleFactor == 25.0) {
-// scale.setSelectedIndex(0);
-// } else if (scaleFactor == 50.0) {
-// scale.setSelectedIndex(1);
-// } else if (scaleFactor == 75.0) {
-// scale.setSelectedIndex(2);
-// } else if (scaleFactor == 100.0) {
-// scale.setSelectedIndex(3);
-// } else if (scaleFactor == 150.0) {
-// scale.setSelectedIndex(4);
-// } else if (scaleFactor == 200.0) {
-// scale.setSelectedIndex(5);
-// } else if (scaleFactor == 400.0) {
-// scale.setSelectedIndex(6);
-// } else {
scale.setSelectedItem(percentFormat.format(scaleFactor) + "%");
-// }
previewPanel.setScaleFactor(scaleFactor / 100d);
}
* renderer and add it to your gui:
* </p>
* <pre>
+ * FopFactory fopFactory = FopFactory.newInstance();
* AWTRenderer renderer = new AWTRenderer();
- * FOUserAgent agent = new FOUserAgent();
+ * FOUserAgent agent = fopFactory.newFOUserAgent();
* agent.setRendererOverride(renderer);
* renderer.setPreviewDialogDisplayed(false);
* renderer.setUserAgent(agent);
+ * renderer.setUserAgent(agent);
* previewPanel = new PreviewPanel(agent, null, renderer);
* previewPanel = new PreviewPanel(ua);
* myGui.add(previewPanel);
*/
public void setPage(int number) {
if (displayMode == CONTINUOUS || displayMode == CONT_FACING) {
- // FIXME Should scroll so page is visible
currentPage = number;
+ gridPanel.scrollRectToVisible(pagePanels[currentPage].getBounds());
} else { // single page mode
currentPage = number;
firstPage = currentPage;