edu.rice.cs.drjava.ui
Class PreviewFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by edu.rice.cs.util.swing.SwingFrame
                          extended by edu.rice.cs.drjava.ui.PreviewFrame
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
Direct Known Subclasses:
ErrorPanel.PreviewErrorFrame, PreviewConsoleFrame, PreviewDefDocFrame

public abstract class PreviewFrame
extends SwingFrame

DrJava's print preview window

Version:
$Id: PreviewFrame.java 5436 2011-08-02 06:58:19Z mgricken $
See Also:
Serialized Form

Nested Class Summary
private  class PreviewFrame.JSpinnerChanger
           
private  class PreviewFrame.JTextFieldChanger
           
private static class PreviewFrame.PageChangerUpdater
           
(package private) static class PreviewFrame.PagePreview
          Static inner class which displays the image on the screen, and holds the Image object.
(package private)  class PreviewFrame.PagePreviewContainer
          Internal class which holds (and places) the PagePreview object.
 
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private  Action _closeAction
          Prints the current document.
protected  MainFrame _mainFrame
           
protected  SingleDisplayModel _model
           
private  Action _nextPageAction
          Displays the next page of the document.
private  PreviewFrame.PageChangerUpdater _pageChanger
           
protected  int _pageNumber
           
private  PreviewFrame.PagePreview _pagePreview
           
private  JScrollPane _previewScroll
           
private  Action _prevPageAction
          Displays the previous page of the document.
protected  Pageable _print
           
private  ActionListener _printListener
          Prints the current document.
(package private)  Dimension _screenSize
           
private  JToolBar _toolBar
           
private  WindowListener _windowCloseListener
          How Preview Pane responds to window events.
(package private)  JSlider _zoomSlider
           
private static String ICON_PATH
           
private static int PAGE_BORDER
           
private static double PAGE_ZOOM
           
private  int PREVIEW_HEIGHT
           
private  int PREVIEW_PAGE_HEIGHT
           
private  int PREVIEW_PAGE_WIDTH
           
private  int PREVIEW_WIDTH
           
private static int TOOLBAR_HEIGHT
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PreviewFrame(SingleDisplayModel model, MainFrame mainFrame, boolean interactions)
          Contructs a new PreviewFrame using a parent model and a Pageable object print to show.
 
Method Summary
private  void _close()
           
private  ImageIcon _getIcon(String name)
          Mirrored from MainFrame, will later use the same Icon access code.
private  void _goToPage(int pi)
           
private  void _nextPage()
           
private  void _previousPage()
           
protected abstract  void _print()
          Prints the document being previewed
private  void _setUpActions()
          Initializes all action objects.
private  void _setUpToolBar()
          Sets up the toolbar with all of the necessary buttons.
protected  void _showError(Exception e, String title, String message)
           
private  void _updateActions()
          Updates all of the buttons on the page to reflect the current state of the PreviewWindows.
private static Object callMethod(Object rec, Class<?> c, String name, Class<?>[] ca, Object[] args)
           
private  PreviewFrame.PageChangerUpdater createPageChanger()
           
 void refreshScreen()
           
protected abstract  Pageable setUpDocument(SingleDisplayModel model, boolean interactions)
          Sets up the document to be displayed and returns the Pageable object that allows display by pages
 void setZoom(int percent, boolean fast)
           
private  void showPage()
          Generates an Image, prints to it, and then displays the image on the page.
 
Methods inherited from class edu.rice.cs.util.swing.SwingFrame
duringInit, initDone
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

_model

protected final SingleDisplayModel _model

_mainFrame

protected final MainFrame _mainFrame

_print

protected final Pageable _print

_pageNumber

protected volatile int _pageNumber

_screenSize

Dimension _screenSize

_zoomSlider

JSlider _zoomSlider

_previewScroll

private JScrollPane _previewScroll

_pageChanger

private final PreviewFrame.PageChangerUpdater _pageChanger

PREVIEW_WIDTH

private final int PREVIEW_WIDTH

PREVIEW_HEIGHT

private final int PREVIEW_HEIGHT

PREVIEW_PAGE_WIDTH

private final int PREVIEW_PAGE_WIDTH

PREVIEW_PAGE_HEIGHT

private final int PREVIEW_PAGE_HEIGHT

PAGE_ZOOM

private static final double PAGE_ZOOM
See Also:
Constant Field Values

PAGE_BORDER

private static final int PAGE_BORDER
See Also:
Constant Field Values

TOOLBAR_HEIGHT

private static final int TOOLBAR_HEIGHT
See Also:
Constant Field Values

ICON_PATH

private static final String ICON_PATH
See Also:
Constant Field Values

_toolBar

private JToolBar _toolBar

_pagePreview

private PreviewFrame.PagePreview _pagePreview

_printListener

private final ActionListener _printListener
Prints the current document.


_closeAction

private final Action _closeAction
Prints the current document.


_nextPageAction

private final Action _nextPageAction
Displays the next page of the document.


_prevPageAction

private final Action _prevPageAction
Displays the previous page of the document.


_windowCloseListener

private final WindowListener _windowCloseListener
How Preview Pane responds to window events.

Constructor Detail

PreviewFrame

public PreviewFrame(SingleDisplayModel model,
                    MainFrame mainFrame,
                    boolean interactions)
             throws IllegalStateException
Contructs a new PreviewFrame using a parent model and a Pageable object print to show. Should only be called in event thread.

Throws:
IllegalStateException
Method Detail

setZoom

public void setZoom(int percent,
                    boolean fast)

refreshScreen

public void refreshScreen()

_print

protected abstract void _print()
Prints the document being previewed


setUpDocument

protected abstract Pageable setUpDocument(SingleDisplayModel model,
                                          boolean interactions)
Sets up the document to be displayed and returns the Pageable object that allows display by pages

Parameters:
model - the current display model
interactions - whether the document is an interactions document
Returns:
a Pageable object that allows the document to be displayed by pages

_close

private void _close()

_nextPage

private void _nextPage()

_previousPage

private void _previousPage()

_goToPage

private void _goToPage(int pi)

_showError

protected void _showError(Exception e,
                          String title,
                          String message)

_updateActions

private void _updateActions()
Updates all of the buttons on the page to reflect the current state of the PreviewWindows. Enables/Disables the page buttons, and updates the gotopage field.


_setUpActions

private void _setUpActions()
Initializes all action objects. Adds icons and descriptions to several of the actions.


createPageChanger

private PreviewFrame.PageChangerUpdater createPageChanger()

callMethod

private static Object callMethod(Object rec,
                                 Class<?> c,
                                 String name,
                                 Class<?>[] ca,
                                 Object[] args)
                          throws Exception
Throws:
Exception

_getIcon

private ImageIcon _getIcon(String name)
Mirrored from MainFrame, will later use the same Icon access code.


_setUpToolBar

private void _setUpToolBar()
Sets up the toolbar with all of the necessary buttons.


showPage

private void showPage()
Generates an Image, prints to it, and then displays the image on the page.