A Drawing object has a collection of InputFormat and OutputFormat objects.

An InputFormat is used to read a Drawing from a file, an input stream or from the clipboard. An OutputFormat is used to write a Drawing to a file, an output stream or to the clipboard.

The DOMStorableInputOutputFormat is a simple mechanism for loading and saving Drawings in an XML file. To use this format, the Drawing, and all its Figures need to implement the DOMStorable interface, and a DOMFactory must be implemented, that associates XML element names to the class names of the Figures.

The ImageInputFormat and the ImageOutputFormat are useful for data interchange over the clipboard with programs that can copy and paste Java images. To use the ImageInputFormat, the Drawing must support a Figure that implements the ImageHolder interface. To use the ImageOutputFormat, no additional functionality needs to be implemented.

For a copy and for a cut clipboard operation, a DrawingView can construct a CompositeTransferable that holds all clipboard Transferable objects constructed from the OutputFormats of its Drawing. For a paste operation, a DrawingView can retrieve the InputFormats from its Drawing until it finds one that can read the data from the Transferable in the clipboard. The DefaultDrawingView implements this behavior.

Loading and Saving Drawings

JHotDraw 7