com.tensegrity.gui.swing.dialog.graphfilechooser
Class SVGFilter

java.lang.Object
  extended byjavax.swing.filechooser.FileFilter
      extended bycom.tensegrity.gui.swing.dialog.graphfilechooser.SVGFilter
All Implemented Interfaces:
ExtendedFileFilter

public class SVGFilter
extends javax.swing.filechooser.FileFilter
implements ExtendedFileFilter

The graphfilechooser for tensegrity apps.

Version:
$Id: SVGFilter.java,v 1.10 2006/03/02 11:40:58 BurkhardWick Exp $
Author:
Stepan Rutz

Field Summary
static java.lang.String[] extensions
          Predefined string array of valid extensions.
 
Constructor Summary
SVGFilter()
          Constructs a new SVGFilter instance.
 
Method Summary
 boolean accept(java.io.File f)
          Returns true on all directories and files which have the right extension.
 java.lang.String getDescription()
          Returns a descriptive string for the tensegrity file format.
 java.lang.String[] getExtensionList()
          Returns an array with all valid extensions for this file type
 int getType()
          Returns the type of this filter.
 java.lang.String getValidFilename(java.io.File file)
          Method isValidFilename checks whether the given filename has a valid extension.
static boolean isValidExtension(java.lang.String ext)
          Method isValidExtension iterates through the list of extensions and checks whether the given extension matches one of the listed ones.
static boolean isXMLFile(java.io.File file)
          Method isXMLFile reads the first line of the file and checks whether it starts with the typical xml definition.
 void openInViewer(java.io.File file)
          Opens the given File in the viewer.
 boolean supportsOpenInViewer()
          Returns true if the file can be opened in the viewer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

extensions

public static java.lang.String[] extensions
Predefined string array of valid extensions.

Constructor Detail

SVGFilter

public SVGFilter()
Constructs a new SVGFilter instance.

Method Detail

isXMLFile

public static boolean isXMLFile(java.io.File file)
Method isXMLFile reads the first line of the file and checks whether it starts with the typical xml definition. If such a definition is found the method returns true, otherwise false.

Parameters:
file - the File to examine.
Returns:
boolean true iff the file is an xml file.

accept

public boolean accept(java.io.File f)
Returns true on all directories and files which have the right extension.

See Also:
FileFilter.accept(File)

getDescription

public java.lang.String getDescription()
Returns a descriptive string for the tensegrity file format.

See Also:
FileFilter.getDescription()

isValidExtension

public static boolean isValidExtension(java.lang.String ext)
Method isValidExtension iterates through the list of extensions and checks whether the given extension matches one of the listed ones. If the first matching extension is found, true is returned, otherwise false.

Parameters:
ext - the extension to examine.
Returns:
boolean true if the extension is valid.

getValidFilename

public java.lang.String getValidFilename(java.io.File file)
Method isValidFilename checks whether the given filename has a valid extension. If not, its checked if its recognized as one of the supported filetypes.

Specified by:
getValidFilename in interface ExtendedFileFilter
Parameters:
file - the filename to check.
Returns:
boolean true if the filename is valid.

supportsOpenInViewer

public boolean supportsOpenInViewer()
Returns true if the file can be opened in the viewer.

Specified by:
supportsOpenInViewer in interface ExtendedFileFilter
Returns:
true if the file can be opened in the viewer.

getType

public int getType()
Returns the type of this filter.

Specified by:
getType in interface ExtendedFileFilter
Returns:
the type of this filter.

openInViewer

public void openInViewer(java.io.File file)
Opens the given File in the viewer.

Specified by:
openInViewer in interface ExtendedFileFilter
Parameters:
file - the File to open in the viewer.

getExtensionList

public java.lang.String[] getExtensionList()
Description copied from interface: ExtendedFileFilter
Returns an array with all valid extensions for this file type

Specified by:
getExtensionList in interface ExtendedFileFilter
Returns:
an array with all valid extensions for this file type


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.