ach.image
Class PrintDialog

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Dialog
                  extended byach.image.PrintDialog
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, java.awt.event.KeyListener, java.awt.MenuContainer, java.io.Serializable, java.awt.event.TextListener, java.awt.event.WindowListener

public class PrintDialog
extends java.awt.Dialog
implements java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.WindowListener, java.awt.event.TextListener, java.awt.event.FocusListener, java.awt.event.KeyListener

PrintDialog.java
Copyright (c) 1997, 2000 Helge Hackbarth, All Rights Reserved.
Print Dialog to specify page size, orientation, borders, image location and size. The dialog has a preview window to visualize current settings and is using the Java 1.1 event model. Default settings can be passed as properties (HashTable) and will be updated when dialog is closed. For an example how to use this dialog please refer to ImagePanel.java.

THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PrintDialog(java.awt.Frame parent, java.lang.String title, int width, int height, int imgDpi, int printDpi, java.awt.Image img, java.util.Hashtable props)
          Constructor for print dialog.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          event handler for action events
 void focusGained(java.awt.event.FocusEvent e)
          event handler for focus events
 void focusLost(java.awt.event.FocusEvent e)
           
 java.lang.String getPageRange()
          Get page range
 java.awt.Dimension getPaperDimension()
          Get dimension of selected paper measured in dots related to printers resolution (printDpi; see constructor)
 java.awt.Rectangle getPrintArea()
          Get print area measured in dots related to printers resolution (printDpi; see constructor)
 int getResolution()
          Get preferred resolution
 void itemStateChanged(java.awt.event.ItemEvent e)
          event handler for changes of item states
 void keyPressed(java.awt.event.KeyEvent e)
           
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
          event handler for key events
 void setPrintArea(java.awt.Rectangle r)
          Set print area measured in dots related to printers resolution (printDpi; see constructor)
 void textValueChanged(java.awt.event.TextEvent e)
          event handler for changes of text values
 void windowActivated(java.awt.event.WindowEvent event)
           
 void windowClosed(java.awt.event.WindowEvent event)
          event handler for window events
 void windowClosing(java.awt.event.WindowEvent event)
           
 void windowDeactivated(java.awt.event.WindowEvent event)
           
 void windowDeiconified(java.awt.event.WindowEvent event)
           
 void windowIconified(java.awt.event.WindowEvent event)
           
 void windowOpened(java.awt.event.WindowEvent event)
           
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getAccessibleContext, getTitle, hide, isModal, isResizable, isUndecorated, paramString, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, 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, isOpaque, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrintDialog

public PrintDialog(java.awt.Frame parent,
                   java.lang.String title,
                   int width,
                   int height,
                   int imgDpi,
                   int printDpi,
                   java.awt.Image img,
                   java.util.Hashtable props)
Constructor for print dialog.

Parameters:
parent - the parent frame
title - displayed in the titlebar of the window
width - horizontal number of pixels of the image
height - vertical number of pixels of the image
imgDpi - image resolution (to be able to calculate 1:1 view)
printDpi - printer resolution (to be able to calculate 1:1 view)
img - Image to be shown as preview
props - Hashtable with properties (values for "PAGESIZE", "RESOLUTION", "ORIENTATION","LEFTMARGIN", "RIGHTMARGIN", "TOPMARGIN", "BOTTOMMARGIN", "PAGERANGE", "FORCEJDK11PRINTJOB")
Method Detail

getPrintArea

public java.awt.Rectangle getPrintArea()
Get print area measured in dots related to printers resolution (printDpi; see constructor)

Returns:
null, if dialog was canceled or a rectangle containing position and size of image
See Also:
PrintDialog(java.awt.Frame, java.lang.String, int, int, int, int, java.awt.Image, java.util.Hashtable)

setPrintArea

public void setPrintArea(java.awt.Rectangle r)
Set print area measured in dots related to printers resolution (printDpi; see constructor)

Parameters:
r - image location and size as a rectangle
See Also:
PrintDialog(java.awt.Frame, java.lang.String, int, int, int, int, java.awt.Image, java.util.Hashtable)

getPageRange

public java.lang.String getPageRange()
Get page range

Returns:
a string describing page range. Empty string ("") indicates current page, "ALL" indicates all pages may be extended later by semicolon seperated numbers and ranges (low-high) like "1;2;8-10"
See Also:
PrintDialog(java.awt.Frame, java.lang.String, int, int, int, int, java.awt.Image, java.util.Hashtable)

getResolution

public int getResolution()
Get preferred resolution

Returns:
the preferred resolution in dots per inch (dpi)
See Also:
PrintDialog(java.awt.Frame, java.lang.String, int, int, int, int, java.awt.Image, java.util.Hashtable)

getPaperDimension

public java.awt.Dimension getPaperDimension()
Get dimension of selected paper measured in dots related to printers resolution (printDpi; see constructor)

Returns:
the dimension of the selected paper and orientation
See Also:
PrintDialog(java.awt.Frame, java.lang.String, int, int, int, int, java.awt.Image, java.util.Hashtable)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
event handler for action events

Specified by:
actionPerformed in interface java.awt.event.ActionListener

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
event handler for changes of item states

Specified by:
itemStateChanged in interface java.awt.event.ItemListener

textValueChanged

public void textValueChanged(java.awt.event.TextEvent e)
event handler for changes of text values

Specified by:
textValueChanged in interface java.awt.event.TextListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
event handler for key events

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

focusGained

public void focusGained(java.awt.event.FocusEvent e)
event handler for focus events

Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Specified by:
focusLost in interface java.awt.event.FocusListener

windowClosed

public void windowClosed(java.awt.event.WindowEvent event)
event handler for window events

Specified by:
windowClosed in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent event)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent event)
Specified by:
windowIconified in interface java.awt.event.WindowListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent event)
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent event)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent event)
Specified by:
windowOpened in interface java.awt.event.WindowListener

windowClosing

public void windowClosing(java.awt.event.WindowEvent event)
Specified by:
windowClosing in interface java.awt.event.WindowListener