Class PrintOptions
java.lang.Object
de.cau.cs.kieler.klighd.ui.printing.PrintOptions
- Direct Known Subclasses:
DiagramPrintOptions
Data record definition providing storage of the information required by the
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
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAbstract preference initializer skeleton contributing default values for preference entries used inPrintOptions. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringObservables ID for all pages range.static final StringObservables ID for horizontal centering.static final StringObservables ID for vertical centering.static final StringObservables ID for collate.static final StringObservables ID for number of copies.static final StringObservables ID for duplex mode.static final StringObservables ID for orientation.static final StringObservables ID for number of pages tall.static final StringObservables ID for number of pages wide.static final StringObservables ID for printer data.static final StringObservables ID for printer name.static final StringObservables ID for print range from.static final StringObservables ID for print range to.static final StringObservables ID for scale factor.static final StringObservables ID for displaying the scale factor. -
Constructor Summary
ConstructorsConstructorDescriptionPrintOptions(org.eclipse.jface.preference.IPreferenceStore prefStore) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a property change listener.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) Adds a property change listener for a specific property.protected voidfirePropertyChange(String propertyName, Object oldValue, Object newValue) Fires a property change.Provides the absolute offset that is required to horizontally and/or vertically center the diagram on the page(s) as desired (configured).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 givenscalefactor, which is be required, e.g., in order to create the print preview properly.intGets the number of copies.intGets the duplex mode.booleanChecks whether the diagram is to be centered horizontally.intGets the orientation.intGets the number of vertical pages the diagram is divided into.intGets the number of horizontal pages the diagram is divided into.org.eclipse.swt.printing.PrinterProvides a (cached)Printeraccording to the configuredPrinterData.Provides a (cached)Dimensioncontaining the bounds of the currently configuredPrinter.org.eclipse.swt.printing.PrinterDataGets the printer data.Provides the currently chosen printer's resolution in DPI for both x and y direction.Gets the printer name.Provides a (cached)IExportBranding.Trimdescribing the technical trim of the currently configuredPrinter.Gets all registered property change listeners.getPropertyChangeListeners(String propertyName) Gets all registered property change listeners for a specific property.intGets the first printed page.intGets the last printed page.doubleGets the scale factor.intGets the scale factor in percent.booleanChecks whether the diagram is to be centered vertically.booleanhasListeners(String propertyName) Checks if there are listener registered on a specific property.booleanChecks if is the print range is set to all pages.booleanChecks whether to collate.voidRemoves a property change listener.voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener) Removes a property change listener from a specific property.protected voidResets cachedIExportBranding.Triminformation, which is necessary, e.g., after changing the paper format or page orientation.voidRestore the options from preference store.voidsetAllPages(boolean allPages) Sets whether to print all pages.voidsetCollate(boolean collate) Sets whether to collate.voidsetCopies(int copies) Sets the number of copies.voidsetDuplex(int duplex) Sets the duplex mode.voidsetHorizontallyCentered(boolean horCentered) Sets whether to horizontally center the diagram on the page(s).voidsetOrientation(int orientation) Sets the orientation.voidsetPagesTall(int pagesTall) Sets the number of vertical pages to divide the diagram into.voidsetPagesWide(int pagesWide) Sets the number of horizontal pages to divide the diagram into.voidsetPrinterData(org.eclipse.swt.printing.PrinterData printerData) Sets the printer data.voidsetRangeFrom(int rangeFrom) Sets the first printed page.voidsetRangeTo(int rangeTo) Sets the last printed page.voidsetScaleFactor(double scaleFactor) Sets the scale factor.voidsetScalePercent(int scalePercent) Sets the scale factor in percent.voidsetVerticallyCentered(boolean verCentered) Sets whether to vertically center the diagram on the page(s).voidStore the options in the preference store.protected Point2DRe-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.
-
Field Details
-
PROPERTY_PRINTER_DATA
Observables ID for printer data.- See Also:
-
PROPERTY_PRINTER_NAME
Observables ID for printer name.- See Also:
-
PROPERTY_COPIES
Observables ID for number of copies.- See Also:
-
PROPERTY_COLLATE
Observables ID for collate.- See Also:
-
PROPERTY_ALL_PAGES
Observables ID for all pages range.- See Also:
-
PROPERTY_RANGE_FROM
Observables ID for print range from.- See Also:
-
PROPERTY_RANGE_TO
Observables ID for print range to.- See Also:
-
PROPERTY_DUPLEX
Observables ID for duplex mode.- See Also:
-
PROPERTY_ORIENTATION
Observables ID for orientation.- See Also:
-
PROPERTY_SCALE_FACTOR
Observables ID for scale factor.- See Also:
-
PROPERTY_SCALE_PERCENT
Observables ID for displaying the scale factor.- See Also:
-
PROPERTY_PAGES_WIDE
Observables ID for number of pages wide. Denotes the number of vertical pages to print on.- See Also:
-
PROPERTY_PAGES_TALL
Observables ID for number of pages tall. Denotes the number of horizontal pages to print on.- See Also:
-
PROPERTY_CENTER_HORIZONTALLY
Observables ID for horizontal centering.- See Also:
-
PROPERTY_CENTER_VERTICALLY
Observables ID for vertical centering.- See Also:
-
-
Constructor Details
-
PrintOptions
public PrintOptions(org.eclipse.jface.preference.IPreferenceStore prefStore) Constructor.- Parameters:
prefStore- theIPreferenceStoreto 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
Gets the printer name.
Note: The printer name cannot be set separately because that would invalidate the printer data. To set a new printer, usesetPrinterData(PrinterData)with valid PrinterData.- Returns:
- the printer name
-
getPrinter
public org.eclipse.swt.printing.Printer getPrinter()Provides a (cached)Printeraccording to the configuredPrinterData.- Returns:
- a
Printerornullif no validPrinterDataare configured
-
getPrinterBounds
Provides a (cached)Dimensioncontaining the bounds of the currently configuredPrinter.- Returns:
- a
Dimensiondenoting the printer's bounds, ornullif no valid printer configuration is present
-
getPrinterTrim
Provides a (cached)IExportBranding.Trimdescribing the technical trim of the currently configuredPrinter. Those margins are not included ingetPrinterBounds(). Thus,getPrinterBounds()+ the result of this method == selected paper size- Returns:
- a
IExportBranding.Trimdenoting the printer's technical trim, ornullif no valid printer configuration is present
-
getPrinterDPI
Provides the currently chosen printer's resolution in DPI for both x and y direction.- Returns:
- a
Pointdenoting the printer's resolution, ornullif no valid printer configuration is present
-
resetTrimData
protected void resetTrimData()Resets cachedIExportBranding.Triminformation, which is necessary, e.g., after changing the paper format or page orientation. Must be implemented by subclasses if necessary. -
getCenteringOffset
Provides the absolute offset that is required to horizontally and/or vertically center the diagram on the page(s) as desired (configured). -
getCenteringOffset
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 givenscalefactor, which is be required, e.g., in order to create the print preview properly. -
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
Point2Ddetermining the (x,y) offset, ornullif not supported
-
addPropertyChangeListener
Adds a property change listener.- Parameters:
listener- the listener to add- See Also:
-
addPropertyChangeListener
Adds a property change listener for a specific property.- Parameters:
propertyName- the property to listen onlistener- the listener to add- See Also:
-
getPropertyChangeListeners
Gets all registered property change listeners.- Returns:
- the registered property change listeners
- See Also:
-
getPropertyChangeListeners
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
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
Removes a property change listener.- Parameters:
listener- the listener to remove- See Also:
-
removePropertyChangeListener
Removes a property change listener from a specific property.- Parameters:
propertyName- the property being listened tolistener- the listener to remove- See Also:
-
firePropertyChange
Fires a property change.- Parameters:
propertyName- the property being changedoldValue- the old value of the propertynewValue- the new value of the property- See Also:
-