JHotDraw 7.3.1

org.jhotdraw.samples.odg.io
Class ODGInputFormat

java.lang.Object
  extended by org.jhotdraw.samples.odg.io.ODGInputFormat
All Implemented Interfaces:
InputFormat

public class ODGInputFormat
extends java.lang.Object
implements InputFormat

ODGInputFormat. This format is aimed to comply to the Open Document Version 1.1 Drawing format. http://docs.oasis-open.org/office/v1.1/OS/OpenDocument-v1.1.pdf

Version:
$Id: ODGInputFormat.java 564 2009-10-10 10:21:01Z rawcoder $
Author:
Werner Randelshofer

Constructor Summary
ODGInputFormat()
          Creates a new instance.
 
Method Summary
 javax.swing.filechooser.FileFilter getFileFilter()
          Return a FileFilter that can be used to identify files which can be read with this input format.
 javax.swing.JComponent getInputFormatAccessory()
          Return a JFileChooser accessory that can be used to customize the input format.
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
          Returns true, if this InputFormat can readFigures TransferData using the specified DataFlavor.
 void read(java.io.File file, Drawing drawing)
          Reads figures from a file and replaces the children of the drawing with them.
 void read(java.io.File file, Drawing drawing, boolean replace)
          Reads figures from a file and adds them to the specified drawing.
 void read(java.io.InputStream in, Drawing drawing, boolean replace)
          Reads figures from a file and adds them to the specified drawing.
 void read(java.awt.datatransfer.Transferable t, Drawing drawing, boolean replace)
          Reads figures from the specified Transferable and adds them to the specified drawing.
 void readFiguresFromDocumentContent(java.io.InputStream in, Drawing drawing, boolean replace)
          Reads figures from the content.xml file of an ODG open document drawing document.
static java.awt.geom.AffineTransform toTransform(java.lang.String str)
          Converts an ODG draw:transform attribute value into an AffineTransform.
static java.lang.String[] toWSOrCommaSeparatedArray(java.lang.String str)
          Returns a value as a String array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ODGInputFormat

public ODGInputFormat()
Creates a new instance.

Method Detail

getFileFilter

public javax.swing.filechooser.FileFilter getFileFilter()
Description copied from interface: InputFormat
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.

Specified by:
getFileFilter in interface InputFormat
Returns:
FileFilter to be used with a javax.swing.JFileChooser

getInputFormatAccessory

public javax.swing.JComponent getInputFormatAccessory()
Description copied from interface: InputFormat
Return a JFileChooser accessory that can be used to customize the input format.

Specified by:
getInputFormatAccessory in interface InputFormat
Returns:
A JFileChooser accessory to be used with a javax.swing.JFileChooser Returns null, if no accessory is provided for this format.

read

public void read(java.io.File file,
                 Drawing drawing)
          throws java.io.IOException
Description copied from interface: InputFormat
Reads figures from a file and replaces the children of the drawing with them.

This is a convenience method for calling read(File,Drawing,true).

Specified by:
read in interface InputFormat
Parameters:
file - The file.
drawing - The drawing.
Throws:
java.io.IOException

read

public void read(java.io.File file,
                 Drawing drawing,
                 boolean replace)
          throws java.io.IOException
Description copied from interface: InputFormat
Reads figures from a file and adds them to the specified drawing.

Specified by:
read in interface InputFormat
Parameters:
file - The file.
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

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Description copied from interface: InputFormat
Returns true, if this InputFormat can readFigures TransferData using the specified DataFlavor.

Specified by:
isDataFlavorSupported in interface InputFormat
Parameters:
flavor - A DataFlavor.

read

public void read(java.awt.datatransfer.Transferable t,
                 Drawing drawing,
                 boolean replace)
          throws java.awt.datatransfer.UnsupportedFlavorException,
                 java.io.IOException
Description copied from interface: InputFormat
Reads figures from the specified Transferable and adds them to the specified drawing.

Specified by:
read in interface InputFormat
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.UnsupportedFlavorException
java.io.IOException

read

public void read(java.io.InputStream in,
                 Drawing drawing,
                 boolean replace)
          throws java.io.IOException
Description copied from interface: InputFormat
Reads figures from a file and adds them to the specified drawing.

Specified by:
read in interface InputFormat
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

readFiguresFromDocumentContent

public void readFiguresFromDocumentContent(java.io.InputStream in,
                                           Drawing drawing,
                                           boolean replace)
                                    throws java.io.IOException
Reads figures from the content.xml file of an ODG open document drawing document.

Throws:
java.io.IOException

toWSOrCommaSeparatedArray

public static java.lang.String[] toWSOrCommaSeparatedArray(java.lang.String str)
                                                    throws java.io.IOException
Returns a value as a String array. The values are separated by whitespace or by commas with optional white space.

Throws:
java.io.IOException

toTransform

public static java.awt.geom.AffineTransform toTransform(java.lang.String str)
                                                 throws java.io.IOException
Converts an ODG draw:transform attribute value into an AffineTransform.

The draw:transform attribute specifies a list of transformations that can be applied to a drawing shape. The value of this attribute is a list of transform definitions, which are applied to the drawing shape in the order in which they are listed. The transform definitions in the list must be separated by a white space and/or a comma. The types of transform definitions available include: • matrix( ), which specifies a transformation in the form of a transformation matrix of six values. matrix(a,b,c,d,e,f) is the equivalent of applying the transformation matrix [a b c d e f]. • translate( []), which specifies a translation by tx and ty. • scale( []), which specifies a scale operation by sx and sy. If is not provided, it is assumed to be equal to . • rotate(), which specifies a rotation by about the origin of the shapes coordinate system. • skewX(), which specifies a skew transformation along the X axis. • skewY(), which specifies a skew transformation along the Y axis.

Throws:
java.io.IOException

Copyright 1996-2009 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.