Class DefaultPrintFeature

    • Constructor Detail

    • Method Detail

      • print

        public void print​(IPrintContext context)
        Performs the print operation. The default implementation delegates to getGraphicalViewer(IPrintContext) to retrieve the GraphicalViewer that already displays the diagram, queries for PrinterData to use by calling getPrinterData(IPrintContext) and finally uses #getPrintOperation(Printer, IPrintConfiguration) to create an operation to perform the printing. All those methods may be overridden to change the default behavior, so normally one would not need to override this method unless the complete sequence needs to changed or the printing is performed in a completely different scenario.
        Specified by:
        print in interface IPrintFeature
        Parameters:
        context - Context information for printing.
      • getGraphicalViewer

        protected org.eclipse.gef.GraphicalViewer getGraphicalViewer​(IPrintContext context)
        Must return a GraphicalViewer that contains the diagram to be printed. The default implementation returns the viewer of the DiagramEditor that started this print feature; this is the one associated to the feature provider of the currently opened diagram, see #getDiagramEditor().
        Parameters:
        context - Context information for printing.
        Returns:
        the viewer holding the diagram to print.
      • getPrinterData

        protected org.eclipse.swt.printing.PrinterData getPrinterData​(IPrintContext context)
        Creates the PrinterData information used for this print feature. The default implementation simply gets the info for the default printer of the system or the first printer in the list of available printers in case no default is defined.
        Parameters:
        context - Context information for printing.
        Returns:
        The printer data to use for this print feature.
      • getPrintConfiguration

        protected IPrintConfiguration getPrintConfiguration​(org.eclipse.gef.GraphicalViewer viewer,
                                                            org.eclipse.swt.printing.Printer printer)
        Called to create a configuration object for the printing that defines what to print on which printer and how. The default implementation returns the standard Graphiti dialog used for printing that allows the user to define which printer to use, which figure to print and various other print settings.
        Parameters:
        viewer - The viewer displaying the diagram to print
        printer - The printer to use as default
        Returns:
        A newly created dialog that implements the IPrintConfiguration interface used in the print job.
      • getPrintOperation

        protected org.eclipse.draw2d.PrintFigureOperation getPrintOperation​(IPrintConfiguration printConfiguration)
        Called to create the operation that is actually used for printing a diagram. The default implementation returns the Graphiti default print operation that should be sufficient for almost all use cases.
        Parameters:
        printConfiguration - The IPrintConfiguration instance that was used to configure this print operation. In the default implementation this is the dialog to use for selecting the printer and other settings.
        Returns:
        The operation that will be used to actually perform the printing.