Class ScalePrint

  • All Implemented Interfaces:
    Print

    public class ScalePrint
    extends java.lang.Object
    implements Print
    A decorator print that scales it's target larger or smaller.

    Note: On Windows, this class depends on a bugfix available as of Eclipse build 3.2, release candidate 3 (2006-04-28). Prior to this release, using ScalePrint triggers the bug, causing the document to scale very large on paper. This bug manifests itself only on paper, not with on-screen viewing.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.lang.Double scale  
      (package private) Print target  
    • Constructor Summary

      Constructors 
      Constructor Description
      ScalePrint​(Print target)
      Constructs a ScalePrint which scales down it's target to print at it's preferred size.
      ScalePrint​(Print target, java.lang.Double scale)
      Constructs a ScalePrint which scales it's target by the given factor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      java.lang.Double getScale()
      Returns the scale by which the target will be scaled, or null (indicating automatic scale down to fit).
      Print getTarget()
      Returns the print being scaled.
      int hashCode()  
      PrintIterator iterator​(org.eclipse.swt.graphics.Device device, org.eclipse.swt.graphics.GC gc)
      Returns a PrintIterator for laying out the contents of this Print.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • target

        final Print target
      • scale

        final java.lang.Double scale
    • Constructor Detail

      • ScalePrint

        public ScalePrint​(Print target)
        Constructs a ScalePrint which scales down it's target to print at it's preferred size. This constructor is equivalent to calling new ScalePrint(target, null).
        Parameters:
        target - the print to scale down.
      • ScalePrint

        public ScalePrint​(Print target,
                          java.lang.Double scale)
        Constructs a ScalePrint which scales it's target by the given factor.
        Parameters:
        target -
        scale - the scale factor (must be >0). A value of 2.0 draws at double the size, and a value of 0.5 draws at half the size. A null value automatically scales down so the target is rendered at it's preferred size.
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • getTarget

        public Print getTarget()
        Returns the print being scaled.
        Returns:
        the print being scaled.
      • getScale

        public java.lang.Double getScale()
        Returns the scale by which the target will be scaled, or null (indicating automatic scale down to fit).
        Returns:
        the scale by which the target will be scaled, or null (indicating automatic scale down to fit).
      • iterator

        public PrintIterator iterator​(org.eclipse.swt.graphics.Device device,
                                      org.eclipse.swt.graphics.GC gc)
        Description copied from interface: Print
        Returns a PrintIterator for laying out the contents of this Print. The iterator uses a snapshot of the print at the time this method is invoked, so subsequent changes to the Print will not affect the output of the iterator.
        Specified by:
        iterator in interface Print
        Parameters:
        device - the graphics device this Print will be drawn onto.
        gc - the graphics context to be used for calculating layout and drawing the Print's contents.
        Returns:
        a PrintIterator for laying out the contents of this Print.