fable.framework.imageprint
Class PrintSettings

java.lang.Object
  extended by fable.framework.imageprint.PrintSettings

public class PrintSettings
extends java.lang.Object

PrintSettings is a class to hold typical printer settings.

The settings for margins can be given with units, e.g. "1.234 cm". The numerical values are stored in inches since devices, such as Printers and Displays, have a DPI (dots per inch) setting, which is important for displaying images, and this is the easiest way to use the DPI.

Note that at the time this was written SWT has no means of setting the orientation in the Printer. Thus PrintSettings cannot be used to do that for the user. The orientation can be used for previews and the like, however.

Author:
Kenneth Evans, Jr.

Nested Class Summary
static class PrintSettings.Orientation
          Orientation is a complex enum that represents possible printer orientations and that also includes String names for the items.
static class PrintSettings.Units
          Units is a complex enum that represents possible units and that also includes scaling and String names for the items.
 class PrintSettings.ValueWithUnits
          ValueWithUnits is a simple class that handles a double value and an associates unit.
 
Constructor Summary
PrintSettings()
           
 
Method Summary
 PrintSettings clone()
           
 double getBottom()
           
 java.lang.String getBottomString()
           
 int getHorizontalAlign()
           
 double getLeft()
           
 java.lang.String getLeftString()
           
 PrintSettings.Orientation getOrientation()
           
 org.eclipse.swt.printing.PrinterData getPrinterData()
           
 double getRight()
           
 java.lang.String getRightString()
           
 double getTop()
           
 java.lang.String getTopString()
           
 PrintSettings.Units getUnits()
           
 java.lang.String getUnitsFormat()
           
 java.lang.String getUnitsName()
           
 int getVerticalAlign()
           
 PrintSettings.ValueWithUnits parseUnitsString(java.lang.String string)
          Parses the input String and determines the value and units.
 void resetUnitsFormat()
          Resets the units format to the default.
 PrintSettings.ValueWithUnits scaleFromInches(PrintSettings.ValueWithUnits vwu)
          Converts the value from inches given its units.
 PrintSettings.ValueWithUnits scaleToInches(PrintSettings.ValueWithUnits vwu)
          Converts the value to inches given its units.
 void setBottom(double bottom)
           
 void setBottomString(java.lang.String string)
           
 void setHorizontalAlign(int horizontalAlign)
           
 void setLeft(double left)
           
 void setLeftString(java.lang.String string)
           
 void setOrientation(PrintSettings.Orientation orientation)
           
 void setOrientation(java.lang.String name)
           
 void setPrinterData(org.eclipse.swt.printing.PrinterData printerData)
           
 void setRight(double right)
           
 void setRightString(java.lang.String string)
           
 void setTop(double top)
           
 void setTopString(java.lang.String string)
           
 void setUnits(PrintSettings.Units units)
           
 void setUnits(java.lang.String name)
           
 void setUnitsFormat(java.lang.String unitsFormat)
           
 void setVerticalAlign(int verticalAlign)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintSettings

public PrintSettings()
Method Detail

clone

public PrintSettings clone()
Overrides:
clone in class java.lang.Object

scaleToInches

public PrintSettings.ValueWithUnits scaleToInches(PrintSettings.ValueWithUnits vwu)
Converts the value to inches given its units. The result should be inconsistent and only the value part should be used after this.

Parameters:
vwu -
Returns:

scaleFromInches

public PrintSettings.ValueWithUnits scaleFromInches(PrintSettings.ValueWithUnits vwu)
Converts the value from inches given its units. The input should have the value in inches with the units to be used in the result and hence not be consistent. The result should be consistent.

Parameters:
vwu -
Returns:

parseUnitsString

public PrintSettings.ValueWithUnits parseUnitsString(java.lang.String string)
Parses the input String and determines the value and units.

Parameters:
string -
Returns:

getUnitsName

public java.lang.String getUnitsName()
Returns:
The name of units.

getUnits

public PrintSettings.Units getUnits()
Returns:
The value of units.

setUnits

public void setUnits(PrintSettings.Units units)
Parameters:
units - The new value for units.

setUnits

public void setUnits(java.lang.String name)
Parameters:
name - The new name of the units. Defaults to INCH is there is no match.

getLeft

public double getLeft()
Returns:
The value of left in inches.

setLeft

public void setLeft(double left)
Parameters:
left - The new value for left in inches.

getLeftString

public java.lang.String getLeftString()
Returns:
The value of left with units.

setLeftString

public void setLeftString(java.lang.String string)
Parameters:
left - The new value for left with units, for example "1.23 in".

getRight

public double getRight()
Returns:
The value of right in inches.

setRight

public void setRight(double right)
Parameters:
right - The new value for right in inches.

getRightString

public java.lang.String getRightString()
Returns:
The value of right with units.

setRightString

public void setRightString(java.lang.String string)
Parameters:
right - The new value for right with units, for example "1.23 in".

getTop

public double getTop()
Returns:
The value of top in inches.

setTop

public void setTop(double top)
Parameters:
top - The new value for top in inches.

getTopString

public java.lang.String getTopString()
Returns:
The value of top with units.

setTopString

public void setTopString(java.lang.String string)
Parameters:
top - The new value for top with units, for example "1.23 in".

getBottom

public double getBottom()
Returns:
The value of bottom in inches.

setBottom

public void setBottom(double bottom)
Parameters:
bottom - The new value for bottom in inches.

getBottomString

public java.lang.String getBottomString()
Returns:
The value of bottom with units.

setBottomString

public void setBottomString(java.lang.String string)
Parameters:
bottom - The new value for bottom with units, for example "1.23 in".

getVerticalAlign

public int getVerticalAlign()
Returns:
The value of verticalAlign.

setVerticalAlign

public void setVerticalAlign(int verticalAlign)
Parameters:
verticalAlign - The new value for verticalAlign.

getHorizontalAlign

public int getHorizontalAlign()
Returns:
The value of horizontalAlign.

setHorizontalAlign

public void setHorizontalAlign(int horizontalAlign)
Parameters:
horizontalAlign - The new value for horizontalAlign.

getUnitsFormat

public java.lang.String getUnitsFormat()
Returns:
The value of unitsFormat.

setUnitsFormat

public void setUnitsFormat(java.lang.String unitsFormat)
Parameters:
unitsFormat - The new value for unitsFormat, something like "%.3f".

resetUnitsFormat

public void resetUnitsFormat()
Resets the units format to the default.


getOrientation

public PrintSettings.Orientation getOrientation()
Returns:
The value of orientation.

setOrientation

public void setOrientation(PrintSettings.Orientation orientation)
Parameters:
orientation - The new value for orientation.

setOrientation

public void setOrientation(java.lang.String name)
Parameters:
name - The new name of the units. Defaults to DEFAULT is there is no match.

getPrinterData

public org.eclipse.swt.printing.PrinterData getPrinterData()
Returns:
the printerData

setPrinterData

public void setPrinterData(org.eclipse.swt.printing.PrinterData printerData)
Parameters:
printerData - the printerData to set