Package PamView

Class ClipboardCopier

java.lang.Object
PamView.ClipboardCopier
All Implemented Interfaces:
ClipboardOwner, Transferable, Printable

public class ClipboardCopier extends Object implements ClipboardOwner, Transferable, Printable
Class to Copy graphics content to the clipboard and the printer

Written so that it can easily be added to any PAMGUARD component. Provides default menu items for including in pop up menus or main menu.

Author:
Doug Gillespie
  • Constructor Details

    • ClipboardCopier

      public ClipboardCopier(Component component)
      Parameters:
      component - Component to copy. All children will also be copied.
    • ClipboardCopier

      public ClipboardCopier(Component component, String printJobName)
      Parameters:
      component - Component to copy. All children will also be copied.
      printJobName - name for print job (default is PAMGUARD)
  • Method Details

    • copyToClipBoard

      public void copyToClipBoard()
      Copy an image of the component to the clip board
    • createTransferImage

      protected void createTransferImage()
      Create the image to be transfered to the clipboard.
    • lostOwnership

      public void lostOwnership(Clipboard arg0, Transferable arg1)
      Specified by:
      lostOwnership in interface ClipboardOwner
    • getTransferData

      public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException
      Specified by:
      getTransferData in interface Transferable
      Throws:
      UnsupportedFlavorException
      IOException
    • getTransferDataFlavors

      public DataFlavor[] getTransferDataFlavors()
      Specified by:
      getTransferDataFlavors in interface Transferable
    • isDataFlavorSupported

      public boolean isDataFlavorSupported(DataFlavor flavor)
      Specified by:
      isDataFlavorSupported in interface Transferable
    • print

      public int print(Graphics g, PageFormat pf, int page) throws PrinterException
      Specified by:
      print in interface Printable
      Throws:
      PrinterException
    • getCopyMenuItem

      public JMenuItem getCopyMenuItem()
      Get a menu item with a default title of "Copy to clipboard". Menu action listeners will automatically be set up
      Returns:
      menu item.
    • getCopyMenuItem

      public JMenuItem getCopyMenuItem(String menuTitle)
      Get a menu item with a given title. Menu action listeners will automatically be set up
      Parameters:
      menuTitle - menu title
      Returns:
      menu item.
    • getPrintMenuItem

      public JMenuItem getPrintMenuItem()
      Get a menu item with a default title of "Print ...". Menu action listeners will automatically be set up
      Returns:
      menu item.
    • getPrintMenuItem

      public JMenuItem getPrintMenuItem(String menuTitle)
      Get a menu item with a given title. Menu action listeners will automatically be set up
      Parameters:
      menuTitle - menu title
      Returns:
      menu item.
    • getPrintJobName

      public String getPrintJobName()
    • setPrintJobName

      public void setPrintJobName(String printJobName)
    • setImage

      public void setImage(Image image)