Class PrintExporter

java.lang.Object
de.cau.cs.kieler.klighd.piccolo.export.AbstractDiagramExporter
de.cau.cs.kieler.klighd.ui.printing.PrintExporter

public final class PrintExporter extends AbstractDiagramExporter
Diagram printing exporter providing methods for creating previews and the final printout.
Author:
csp, chsch
  • Constructor Details

    • PrintExporter

      public PrintExporter(PiccoloViewer viewer)
      Create new exporter using the given viewer.
      Parameters:
      viewer - the viewer to print
  • Method Details

    • getDiagramTrim

      public IExportBranding.Trim getDiagramTrim()
      Provides the cumulated diagram IExportBranding.Trim required by the employed IExportBrandings.
      Returns:
      the required (overall) diagram IExportBranding.Trim
    • getDiagramTileTrim

      public IExportBranding.Trim getDiagramTileTrim(Dimension tileBounds, IExportBranding.Trim printerTrim, Point dotsPerInch)
      Provides the cumulated diagram tile IExportBranding.Trim required by the employed IExportBrandings.
      Parameters:
      tileBounds - the non-scaled bounds of each tile
      printerTrim - the printers technically required trim, i.e., the reduction of its printable area
      dotsPerInch - the image resolution applied by the employed drawing Device, maybe null if not valid
      Returns:
      the required diagram tile IExportBranding.Trim
    • getTrimmedTileBounds

      public Dimension2D getTrimmedTileBounds(PrintOptions options)
      Provides the size of the area being available for a diagram excerpt, which is the options.getPrinterBounds() subtracted by the size of the required tile trim.
      Parameters:
      options - the current PrintOptions configuration
      Returns:
      a Dimension2D describing the reduced tile size.
    • getDiagramBoundsIncludingTrim

      public edu.umd.cs.piccolo.util.PDimension getDiagramBoundsIncludingTrim()
      Provides the printed diagram's size supplemented with the diagram trim.
      Returns:
      the diagram's size supplemented with the diagram trim
    • createPaintContext

      protected KlighdPaintContext createPaintContext(KlighdSWTGraphics graphics, DiagramExportConfig exportConfig)


      Specialization contributes a KlighdPaintContext being configured for printouts rather than image exports.
      Overrides:
      createPaintContext in class AbstractDiagramExporter
    • createExportConfig

      public DiagramExportConfig createExportConfig(PrintOptions options)
      Convenience helper method creating the DiagramExportConfigs that are required for printing diagrams.
      Parameters:
      options - the current PrintOptions configuration
      Returns:
      the required DiagramExportConfig
    • getBasicPageClip

      public Rectangle getBasicPageClip(Dimension drawablesBounds, IExportBranding.Trim tileTrimScaled)
      Parameters:
      drawablesBounds - the actual bounds of the employed Drawable
      tileTrimScaled - the cumulated required IExportBranding.Trim scaled to drawablesBounds if necessary
      Returns:
      a Rectangle describing the unadjusted clip rectangle that is to be applied to the employed KlighdSWTGraphics without having configured any transform on that graphics
      See Also:
    • exportPreview

      public org.eclipse.swt.graphics.Image exportPreview(DiagramExportConfig exportConfig, org.eclipse.swt.printing.Printer printer, Dimension imageBounds, Rectangle imageClip, double previewScale, Point2D centeringOffset)
      Export preview. Can export the diagram in tiles to print on multiple pages.
      Parameters:
      exportConfig - the employed DiagramExportConfig
      printer - the printer to print to, required for creating SWT Fonts while drawing exportBrandings
      imageBounds - the absolute (unadjusted) bounds of the diagram preview Image to be returned
      imageClip - the basic clip of the diagram printout page being previewed as provided by AbstractDiagramExporter.getBasicTileClip(Dimension, Trim), can be provided here in order to avoid re-computations (of the same values) for each diagram tile, maybe null
      previewScale - the scale factor to be applied to the whole tile while drawing the preview image
      centeringOffset - the offset to be applied to centrally align the diagram as requested
      Returns:
      the image
    • print

      public void print(DiagramExportConfig exportConfig, org.eclipse.swt.printing.Printer printer, Dimension pageBounds, Rectangle pageClip, Point2D centeringOffset)
      Export print. Can export the diagram in tiles to print on multiple pages.
      Parameters:
      exportConfig - the employed DiagramExportConfig
      printer - the printer to print to
      pageBounds - the bounds of the diagram preview Image to be returned
      pageClip - the bounds of the diagram print page being previewed
      centeringOffset - the offset to be applied to centrally align the diagram as requested