JavaView® v2.12

jv.loader
Class PgLoader

java.lang.Object
  |
  +--jv.loader.PgLoader

public final class PgLoader
extends java.lang.Object

Dispatcher for loading/saving geometries and images from/to file. Depending on the file name extension the appropriate filter is invoked.

Version:
26.02.01, 3.10 revised (kp) Loading of STL format added.
25.02.01, 3.00 revised (kp) Handling of animations added.
11.12.00, 2.30 revised (ur) References to 'PgMathData' replaced with 'PgJvxSrc[]'.
17.09.00, 2.20 revised (kp) Ansys loader added.
27.04.00, 2.10 revised (kp) Allow compressed archives for loading.
08.04.00, 2.00 revised (kp) Completely new saving methods.
25.12.98, 1.10 revised (kp) Non-static instances removed.
00.00.98, 1.00 created (kp)
Author:
Konrad Polthier

Constructor Summary
PgLoader()
           
 
Method Summary
static PvDisplayOption getDisplayOption()
          Get display options which some parsers fill out.
static boolean isAnimation()
          Determine if currently loaded data is an animation.
static boolean isEnabledSmallSize()
          Determine if saving of data should try to reduce size of output file.
static PvDisplayOption[] load(java.io.BufferedReader in, java.lang.String ext)
          Deprecated. use #loadDisplay(BufferedReader in, String ext)
static PgGeometry[] load(PgGeometry[] geom, java.io.BufferedReader in, java.lang.String ext)
          Read a geometry from a buffered reader with the content of a geometry file.
static PgGeometry[] load(PgGeometry[] geom, java.lang.String fileName)
          Read a geometry from named file whose extension determines the file format.
static PgGeometry[] load(PgGeometry[] geom, java.lang.String data, java.lang.String ext)
          Read a geometry from a string representing content of a geometry file.
static PgGeometry[] load(java.lang.String fileName)
          Read a geometry from named file whose extension determines the file format.
static PvDisplayOption[] loadDisplay(java.io.BufferedReader in, java.lang.String ext)
          Read display options from a buffered reader.
static double parseDouble(java.io.StreamTokenizer st)
          Parse double value in exponential notation.
static double parseDouble(java.lang.String string)
          Parse double value in exponential notation using Double(String).doubleValue().
static PgGeometry[] read(PgJvxSrc[][] geomAnim, boolean bIsAnimation, boolean bShowAnimationPanel)
          Create a set of keyframe objects from a double array of geometries.
static PgGeometry[] read(PgJvxSrc[] geomAnim, boolean bIsAnimation, boolean bShowAnimationPanel)
          Create a set of keyframe objects containing a single keyframe from an array of geometries.
static boolean readAll(java.awt.List list, java.lang.String fileName)
          Read list of files from a given XML listing file.
static boolean readDirs(java.awt.List list, java.lang.String fileName)
          Read list of directories from a given XML listing file.
static java.lang.String[] readDirs(java.lang.String fileName)
          Read list of directories from a given XML listing file into array.
static boolean save(java.awt.Image image, java.lang.String fileName)
          Write an image to a named file whose extension determines the file format.
static boolean save(PgGeometryIf[] geom, java.lang.String fileName)
          Write a set of geometries to a named file whose extension determines the format.
static boolean save(PvDisplayOption[] option, java.lang.String fileName)
          Deprecated. use PgLoader.saveDisplay(PvDisplayOption [] option, String fileName).
static boolean save(java.lang.String data, java.lang.String fileName)
          Write a string to a named file if running as application.
static boolean saveDisplay(PvDisplayOption[] option, java.lang.String fileName)
          Write display settings to a JVD file.
static java.lang.String saveToString(PgGeometryIf[] geom, java.lang.String ext)
          Write a geometry to a string in a given format determined by its file extension.
static void setAnimation(boolean flag)
          Set flag whether currently loaded data is an animation.
static void setDisplayOption(PvDisplayOption option)
          Set the display options obtained from some parsers.
static void setEnabledSmallSize(boolean flag)
          Determine if saving of data should try to reduce size of output file.
static void showAnimationPanel(boolean flag)
          Set flag whether an anination control panel pops up when animations are read.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PgLoader

public PgLoader()
Method Detail

getDisplayOption

public static PvDisplayOption getDisplayOption()
Get display options which some parsers fill out.

setDisplayOption

public static void setDisplayOption(PvDisplayOption option)
Set the display options obtained from some parsers.

showAnimationPanel

public static void showAnimationPanel(boolean flag)
Set flag whether an anination control panel pops up when animations are read.

isAnimation

public static boolean isAnimation()
Determine if currently loaded data is an animation.

setAnimation

public static void setAnimation(boolean flag)
Set flag whether currently loaded data is an animation.

isEnabledSmallSize

public static boolean isEnabledSmallSize()
Determine if saving of data should try to reduce size of output file.

setEnabledSmallSize

public static void setEnabledSmallSize(boolean flag)
Determine if saving of data should try to reduce size of output file.

load

public static PgGeometry[] load(PgGeometry[] geom,
                                java.lang.String data,
                                java.lang.String ext)
Read a geometry from a string representing content of a geometry file. Method creates a StringReader and calls load(PgGeometry [],String,String) load(PgGeometry [],String,String)) with a null geometry array. Method is supplied for convenience.
Parameters:
geom - Geometry which will be filled with data, maybe null.
data - String with geometry data
ext - Extension identifying the file format, usually 3 characters.
Returns:
either old geometry array with new data, or new geometry array, or null if failure.

load

public static PgGeometry[] load(java.lang.String fileName)
Read a geometry from named file whose extension determines the file format. Extension of file name determines the type of loader. Models may be compressed having extensions like "filename.obj.gz" or "filename.obj.zip" where middle extension determines the file format and the last extension the compression type.
Parameters:
fileName - full qualified name of geometry file, e.g. http://... or file:/...
Returns:
newGeom Either old geometry with new data, or new geometry, or null.

load

public static PgGeometry[] load(PgGeometry[] geom,
                                java.lang.String fileName)
Read a geometry from named file whose extension determines the file format. The geometry is passed as an argument and filled. Passing the geometry allows updating of the same geometry. Extension of file name determines the type of loader. Models may be compressed having extensions like "filename.obj.gz" or "filename.obj.zip" where middle extension determines the file format and the last extension the compression type.
Parameters:
geom - Geometry which will be filled with data, maybe null.
fileName - full qualified name of geometry file, e.g. http://... or file:/...
Returns:
newGeom Either old geometry with new data, or new geometry, or null.

load

public static PgGeometry[] load(PgGeometry[] geom,
                                java.io.BufferedReader in,
                                java.lang.String ext)
Read a geometry from a buffered reader with the content of a geometry file. The geometry is passed as an argument and filled. Passing the geometry allows updating of the same geometry. Format is same as file extension and determines the type of loader.

If the geometry data is available at an input stream 'data', for example standard input System.in, then use the following command to generate a BufferedReader new BufferedReader(new InputStreamReader(data)) as argument of this method. If data is read from a file, then use jv.object.PsUtil#open(String) to create a buffered reader or use another load of this class.

Parameters:
geom - Geometry which will be filled with data, maybe null.
br - Buffered reader with geometry data
ext - Extension identifying the file format, usually 3 characters.
Returns:
either old geometry array with new data, or new geometry array, or null if failure.

load

public static PvDisplayOption[] load(java.io.BufferedReader in,
                                     java.lang.String ext)
Deprecated. use #loadDisplay(BufferedReader in, String ext)

Read display options from a buffered reader.

loadDisplay

public static PvDisplayOption[] loadDisplay(java.io.BufferedReader in,
                                            java.lang.String ext)
Read display options from a buffered reader. Format is same as file extension and determines the type of loader.

If the display data is available at an input stream 'data', for example standard input System.in, then use the following command to generate a BufferedReader new BufferedReader(new InputStreamReader(data)) as argument of this method. If data is read from a file, then use jv.object.PsUtil#open(String) to create a buffered reader or use another load of this class.

Parameters:
in - Buffered reader with display option data
ext - Extension identifying the file format, usually 3 characters.
Returns:
display option array, or null if failure.

saveToString

public static java.lang.String saveToString(PgGeometryIf[] geom,
                                            java.lang.String ext)
Write a geometry to a string in a given format determined by its file extension. The chosen file format is determined from the 3-digit filename extension passed as argument. Many file formats allow saving only of a single geometry, in which case the first geometry in the array is saved and the others not.

Note, this method does not save texture images, use #save(PgGeometryIf [],String) instead.

Parameters:
geom - array of geometries to be saved to string
ext - filename extension to determine the file format
Returns:
geometry as string in specified file format.
See Also:
save(PgGeometryIf [],String)

save

public static boolean save(PgGeometryIf[] geom,
                           java.lang.String fileName)
Write a set of geometries to a named file whose extension determines the format. The chosen file format is determined from the 3-digit extension of the filename. Many file formats allow saving only of a single geometry, in which case the first geometry in the array is saved and the others not.

Note, only visible geometries are saved.

Note, if geometry has texture then the texture image to saved in the same directory. The name of the texture file is either name='path of geometry file'/'name of texture'(.gif), if texture has a name, or name='path of geometry file'/'geom[i].getName()'_'texture.gif'.

Parameters:
geom - array of geometries to be saved to file
fileName - full file name including path
Returns:
true on success
See Also:
PgGeometryIf.isVisible(), PgGeometryIf.getTextureImage(), saveToString(PgGeometryIf [],String)

save

public static boolean save(java.lang.String data,
                           java.lang.String fileName)
Write a string to a named file if running as application. When running as applet then the string is displayed inside a dialog PgExport_Dialog from which it may be saved using cut-and-paste.
Parameters:
data - string to be saved to file
fileName - full file name including path
Returns:
true on success

save

public static boolean save(PvDisplayOption[] option,
                           java.lang.String fileName)
Deprecated. use PgLoader.saveDisplay(PvDisplayOption [] option, String fileName).

Write display settings to a JVD file.

saveDisplay

public static boolean saveDisplay(PvDisplayOption[] option,
                                  java.lang.String fileName)
Write display settings to a JVD file.
Parameters:
option - Display options to be saved to file
fileName - full file name including path
Returns:
true on success

save

public static boolean save(java.awt.Image image,
                           java.lang.String fileName)
Write an image to a named file whose extension determines the file format.
Parameters:
data - Image to be saved to file
fileName - Full file name including path
Returns:
true on success

parseDouble

public static double parseDouble(java.io.StreamTokenizer st)
                          throws java.io.IOException
Parse double value in exponential notation. This method tries to catch different settings of character in the StreamTokenizer, but not any situations might be handled correctly.

parseDouble

public static double parseDouble(java.lang.String string)
Parse double value in exponential notation using Double(String).doubleValue(). This method is a convenience to avoid catching NumberFormatException.

readAll

public static boolean readAll(java.awt.List list,
                              java.lang.String fileName)
                       throws java.io.IOException
Read list of files from a given XML listing file.

readDirs

public static boolean readDirs(java.awt.List list,
                               java.lang.String fileName)
                        throws java.io.IOException
Read list of directories from a given XML listing file.

readDirs

public static java.lang.String[] readDirs(java.lang.String fileName)
                                   throws java.io.IOException
Read list of directories from a given XML listing file into array.

read

public static PgGeometry[] read(PgJvxSrc[] geomAnim,
                                boolean bIsAnimation,
                                boolean bShowAnimationPanel)
Create a set of keyframe objects containing a single keyframe from an array of geometries. Method just calls read(PgJvxSrc [][] geomAnim, ...).

read

public static PgGeometry[] read(PgJvxSrc[][] geomAnim,
                                boolean bIsAnimation,
                                boolean bShowAnimationPanel)
Create a set of keyframe objects from a double array of geometries.

JavaView® v2.12

The software JavaView® is copyright protected. All Rights Reserved.