org.jhotdraw.draw.io
Interface InputFormat
-
- All Known Implementing Classes:
- DOMStorableInputOutputFormat, ImageInputFormat, ODGInputFormat, SerializationInputOutputFormat, SVGInputFormat, SVGZInputFormat, TextInputFormat
public interface InputFormatAn input format implements a strategy for reading aDrawingusing a specific format from either anInputStream, anURIor aTransferable.Typically the format can be recognized by a Mime type or by a file extension. To identify the format used by a file, an appropriate
FileFilterfor a javax.swing.JFileChooser component can be requested fromInputFormat.This interface intentionally contains many identical operations like OutputFormat to make it easy, to write classes that implement both interfaces.
Design PatternsStrategy
InputFormatencapsulates a strategy for reading drawings from input streams.
Strategy:InputFormat; Context:Drawing.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description javax.swing.filechooser.FileFiltergetFileFilter()Return a FileFilter that can be used to identify files which can be read with this input format.javax.swing.JComponentgetInputFormatAccessory()Return a JFileChooser accessory that can be used to customize the input format.booleanisDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)Returns true, if this InputFormat can readFigures TransferData using the specified DataFlavor.voidread(java.io.InputStream in, Drawing drawing, boolean replace)Reads figures from a file and adds them to the specified drawing.voidread(java.awt.datatransfer.Transferable t, Drawing drawing, boolean replace)Reads figures from the specified Transferable and adds them to the specified drawing.voidread(java.net.URI uri, Drawing drawing)Reads figures from an URI and replaces the children of the drawing with them.voidread(java.net.URI uri, Drawing drawing, boolean replace)Reads figures from an URI and adds them to the specified drawing.
-
-
-
Method Detail
-
getFileFilter
javax.swing.filechooser.FileFilter getFileFilter()
Return a FileFilter that can be used to identify files which can be read with this input format. Typically, each input format has its own recognizable file naming convention.- Returns:
- FileFilter to be used with a javax.swing.JFileChooser
-
getInputFormatAccessory
@Nullable javax.swing.JComponent getInputFormatAccessory()
Return a JFileChooser accessory that can be used to customize the input format.- Returns:
- A JFileChooser accessory to be used with a javax.swing.JFileChooser Returns null, if no accessory is provided for this format.
-
read
void read(java.net.URI uri, Drawing drawing) throws java.io.IOExceptionReads figures from an URI and replaces the children of the drawing with them.This is a convenience method for calling read(URI,Drawing,true).
- Parameters:
uri- The URI.drawing- The drawing.- Throws:
java.io.IOException
-
read
void read(java.net.URI uri, Drawing drawing, boolean replace) throws java.io.IOExceptionReads figures from an URI and adds them to the specified drawing.- Parameters:
uri- The URI.drawing- The drawing.replace- Set this to true, if the contents of the file replaces the contents of the drawing (for example, when loading a drawing from a file). Set this to false, to add the contents of the file to the drawing (for example, when the file has been dropped into the drawing view).- Throws:
java.io.IOException
-
read
void read(java.io.InputStream in, Drawing drawing, boolean replace) throws java.io.IOExceptionReads figures from a file and adds them to the specified drawing.- Parameters:
in- The input stream.drawing- The drawing.replace- Set this to true, if the contents of the stream replaces the contents of the drawing (for example, when loading a drawing from a stream). Set this to false, to add the contents of the file to the drawing (for example, when the stream has been dropped into the drawing view).- Throws:
java.io.IOException
-
isDataFlavorSupported
boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Returns true, if this InputFormat can readFigures TransferData using the specified DataFlavor.- Parameters:
flavor- A DataFlavor.
-
read
void read(java.awt.datatransfer.Transferable t, Drawing drawing, boolean replace) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOExceptionReads figures from the specified Transferable and adds them to the specified drawing.- Parameters:
t- The Transferable.drawing- The drawing.replace- Set this to true, if the contents of the transferable replaces the contents of the drawing (for example, when loading a drawing from a transferable). Set this to false, to add the contents of the transferable to the drawing (for example, when the transferable has been dropped or pasted into the drawing view).- Throws:
java.awt.datatransfer.UnsupportedFlavorExceptionjava.io.IOException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG