Class PrintOptions

java.lang.Object
de.cau.cs.kieler.klighd.ui.printing.PrintOptions
Direct Known Subclasses:
DiagramPrintOptions

public class PrintOptions extends Object
Data record definition providing storage of the information required by the KlighdPrintDialog.

The is class contains only basic print configuration data fields. This way the print dialog can be incorporated for printing non-diagram content either, a subclass of this class can be created enabling the storage of further information.

During the KLighD diagram print an instance of DiagramPrintOptions, which is a subclass of this one as well, is incorporated.
Author:
Christian Damus (cdamus), James Bruck (jbruck), chsch
  • Field Details

    • PROPERTY_PRINTER_DATA

      public static final String PROPERTY_PRINTER_DATA
      Observables ID for printer data.
      See Also:
    • PROPERTY_PRINTER_NAME

      public static final String PROPERTY_PRINTER_NAME
      Observables ID for printer name.
      See Also:
    • PROPERTY_COPIES

      public static final String PROPERTY_COPIES
      Observables ID for number of copies.
      See Also:
    • PROPERTY_COLLATE

      public static final String PROPERTY_COLLATE
      Observables ID for collate.
      See Also:
    • PROPERTY_ALL_PAGES

      public static final String PROPERTY_ALL_PAGES
      Observables ID for all pages range.
      See Also:
    • PROPERTY_RANGE_FROM

      public static final String PROPERTY_RANGE_FROM
      Observables ID for print range from.
      See Also:
    • PROPERTY_RANGE_TO

      public static final String PROPERTY_RANGE_TO
      Observables ID for print range to.
      See Also:
    • PROPERTY_DUPLEX

      public static final String PROPERTY_DUPLEX
      Observables ID for duplex mode.
      See Also:
    • PROPERTY_ORIENTATION

      public static final String PROPERTY_ORIENTATION
      Observables ID for orientation.
      See Also:
    • PROPERTY_SCALE_FACTOR

      public static final String PROPERTY_SCALE_FACTOR
      Observables ID for scale factor.
      See Also:
    • PROPERTY_SCALE_PERCENT

      public static final String PROPERTY_SCALE_PERCENT
      Observables ID for displaying the scale factor.
      See Also:
    • PROPERTY_PAGES_WIDE

      public static final String PROPERTY_PAGES_WIDE
      Observables ID for number of pages wide. Denotes the number of vertical pages to print on.
      See Also:
    • PROPERTY_PAGES_TALL

      public static final String PROPERTY_PAGES_TALL
      Observables ID for number of pages tall. Denotes the number of horizontal pages to print on.
      See Also:
    • PROPERTY_CENTER_HORIZONTALLY

      public static final String PROPERTY_CENTER_HORIZONTALLY
      Observables ID for horizontal centering.
      See Also:
    • PROPERTY_CENTER_VERTICALLY

      public static final String PROPERTY_CENTER_VERTICALLY
      Observables ID for vertical centering.
      See Also:
  • Constructor Details

    • PrintOptions

      public PrintOptions(org.eclipse.jface.preference.IPreferenceStore prefStore)
      Constructor.
      Parameters:
      prefStore - the IPreferenceStore to use for storing and loading the configuration.
  • Method Details

    • restoreFromPreferences

      public void restoreFromPreferences()
      Restore the options from preference store.
    • storeToPreferences

      public void storeToPreferences()
      Store the options in the preference store.
    • getScaleFactor

      public double getScaleFactor()
      Gets the scale factor.
      Returns:
      the scale factor
    • setScaleFactor

      public void setScaleFactor(double scaleFactor)
      Sets the scale factor.
      Parameters:
      scaleFactor - the new scale factor greater than zero
      Throws:
      IllegalArgumentException - if scaleFactor is less or equal zero
    • getScalePercent

      public int getScalePercent()
      Gets the scale factor in percent. Used for displaying the scale in percent.
      Returns:
      the scale factor in percent
    • setScalePercent

      public void setScalePercent(int scalePercent)
      Sets the scale factor in percent. If the percent is less or equal zero, this setter has no effect. Used for setting the scale in percent from a GUI element showing the scale in percent.
      Parameters:
      scalePercent - the new scale factor in percent greater than zero
      Throws:
      IllegalArgumentException - if scalePercent is less or equal zero
    • getPagesWide

      public int getPagesWide()
      Gets the number of horizontal pages the diagram is divided into.
      Returns:
      the number of pages wide
    • setPagesWide

      public void setPagesWide(int pagesWide)
      Sets the number of horizontal pages to divide the diagram into.
      Parameters:
      pagesWide - the new number of pages wide greater than zero
      Throws:
      IllegalArgumentException - if pagesWide is less or equal zero
    • getPagesTall

      public int getPagesTall()
      Gets the number of vertical pages the diagram is divided into.
      Returns:
      the number of pages tall
    • setPagesTall

      public void setPagesTall(int pagesTall)
      Sets the number of vertical pages to divide the diagram into.
      Parameters:
      pagesTall - the new number of pages tall greater than zero
      Throws:
      IllegalArgumentException - if pagesTall is less or equal zero
    • isAllPages

      public boolean isAllPages()
      Checks if is the print range is set to all pages.
      Returns:
      true, if printing all pages
    • setAllPages

      public void setAllPages(boolean allPages)
      Sets whether to print all pages.
      Parameters:
      allPages - whether to print all pages
    • getRangeFrom

      public int getRangeFrom()
      Gets the first printed page.
      Returns:
      the range from
    • setRangeFrom

      public void setRangeFrom(int rangeFrom)
      Sets the first printed page.
      Parameters:
      rangeFrom - the new range from
    • getRangeTo

      public int getRangeTo()
      Gets the last printed page.
      Returns:
      the range to
    • setRangeTo

      public void setRangeTo(int rangeTo)
      Sets the last printed page.
      Parameters:
      rangeTo - the new range to
    • getCopies

      public int getCopies()
      Gets the number of copies.
      Returns:
      the number of copies
    • setCopies

      public void setCopies(int copies)
      Sets the number of copies.
      Parameters:
      copies - the new number copies
    • isCollate

      public boolean isCollate()
      Checks whether to collate.
      Returns:
      true, if collating is set
    • setCollate

      public void setCollate(boolean collate)
      Sets whether to collate.
      Parameters:
      collate - whether to collate
    • getDuplex

      public int getDuplex()
      Gets the duplex mode. Returns one of:
      • PrinterData.DUPLEX_NONE
      • PrinterData.DUPLEX_LONG_EDGE
      • PrinterData.DUPLEX_SHORT_EDGE
      Returns:
      the duplex mode
    • setDuplex

      public void setDuplex(int duplex)
      Sets the duplex mode. Must be one of:
      • PrinterData.DUPLEX_NONE
      • PrinterData.DUPLEX_LONG_EDGE
      • PrinterData.DUPLEX_SHORT_EDGE
      Parameters:
      duplex - the new duplex mode
    • getPrinterData

      public org.eclipse.swt.printing.PrinterData getPrinterData()
      Gets the printer data. This contains printer specific settings.
      Returns:
      the printer data
    • setPrinterData

      public void setPrinterData(org.eclipse.swt.printing.PrinterData printerData)
      Sets the printer data. This contains printer specific settings.
      Parameters:
      printerData - the new printer data
    • getOrientation

      public int getOrientation()
      Gets the orientation. Returns one of:
      • PrinterData.PORTRAIT
      • PrinterData.LANDSCAPE
      Returns:
      the orientation
    • setOrientation

      public void setOrientation(int orientation)
      Sets the orientation. Must be one of:
      • PrinterData.PORTRAIT
      • PrinterData.LANDSCAPE
      Parameters:
      orientation - the new orientation
    • getHorizontallyCentered

      public boolean getHorizontallyCentered()
      Checks whether the diagram is to be centered horizontally.
      Returns:
      true, if the diagram is to be centered horizontally
    • setHorizontallyCentered

      public void setHorizontallyCentered(boolean horCentered)
      Sets whether to horizontally center the diagram on the page(s).
      Parameters:
      horCentered - whether to horizontally center the diagram
    • getVerticallyCentered

      public boolean getVerticallyCentered()
      Checks whether the diagram is to be centered vertically.
      Returns:
      true, if the diagram is to be centered vertically
    • setVerticallyCentered

      public void setVerticallyCentered(boolean verCentered)
      Sets whether to vertically center the diagram on the page(s).
      Parameters:
      verCentered - whether to vertically center the diagram
    • getPrinterName

      public String getPrinterName()
      Gets the printer name.
      Note: The printer name cannot be set separately because that would invalidate the printer data. To set a new printer, use setPrinterData(PrinterData) with valid PrinterData.
      Returns:
      the printer name
    • getPrinter

      public org.eclipse.swt.printing.Printer getPrinter()
      Provides a (cached) Printer according to the configured PrinterData.
      Returns:
      a Printer or null if no valid PrinterData are configured
    • getPrinterBounds

      public Dimension getPrinterBounds()
      Provides a (cached) Dimension containing the bounds of the currently configured Printer.
      Returns:
      a Dimension denoting the printer's bounds, or null if no valid printer configuration is present
    • getPrinterTrim

      public IExportBranding.Trim getPrinterTrim()
      Provides a (cached) IExportBranding.Trim describing the technical trim of the currently configured Printer. Those margins are not included in getPrinterBounds(). Thus, getPrinterBounds() + the result of this method == selected paper size
      Returns:
      a IExportBranding.Trim denoting the printer's technical trim, or null if no valid printer configuration is present
    • getPrinterDPI

      public Point getPrinterDPI()
      Provides the currently chosen printer's resolution in DPI for both x and y direction.
      Returns:
      a Point denoting the printer's resolution, or null if no valid printer configuration is present
    • resetTrimData

      protected void resetTrimData()
      Resets cached IExportBranding.Trim information, which is necessary, e.g., after changing the paper format or page orientation. Must be implemented by subclasses if necessary.
    • getCenteringOffset

      public Point2D getCenteringOffset()
      Provides the absolute offset that is required to horizontally and/or vertically center the diagram on the page(s) as desired (configured).
      Returns:
      a Point2D providing the x and y offset
    • getCenteringOffset

      public Point2D getCenteringOffset(double scale)
      Provides the absolute offset that is required to horizontally and/or vertically center the diagram on the page(s) as desired (configured), adjusted by the given scale factor, which is be required, e.g., in order to create the print preview properly.
      Parameters:
      scale - the scale factor to be applied to the result's x and y components before returning
      Returns:
      a Point2D providing the x and y offset
    • updateCenteringOffset

      protected Point2D updateCenteringOffset()
      Re-calculates the (x,y) offset being required for aligning the page content centrally and/or vertically, which is necessary, e.g., after changing the paper format or page orientation. Must be implemented by subclasses if necessary.
      Returns:
      a Point2D determining the (x,y) offset, or null if not supported
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener)
      Adds a property change listener.
      Parameters:
      listener - the listener to add
      See Also:
    • addPropertyChangeListener

      public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
      Adds a property change listener for a specific property.
      Parameters:
      propertyName - the property to listen on
      listener - the listener to add
      See Also:
    • getPropertyChangeListeners

      public PropertyChangeListener[] getPropertyChangeListeners()
      Gets all registered property change listeners.
      Returns:
      the registered property change listeners
      See Also:
    • getPropertyChangeListeners

      public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
      Gets all registered property change listeners for a specific property.
      Parameters:
      propertyName - the property being listened to
      Returns:
      the registered property change listeners
      See Also:
    • hasListeners

      public boolean hasListeners(String propertyName)
      Checks if there are listener registered on a specific property.
      Parameters:
      propertyName - the property being listened on
      Returns:
      true, if there are listeners registered
      See Also:
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
      Removes a property change listener.
      Parameters:
      listener - the listener to remove
      See Also:
    • removePropertyChangeListener

      public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
      Removes a property change listener from a specific property.
      Parameters:
      propertyName - the property being listened to
      listener - the listener to remove
      See Also:
    • firePropertyChange

      protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
      Fires a property change.
      Parameters:
      propertyName - the property being changed
      oldValue - the old value of the property
      newValue - the new value of the property
      See Also: