public final class PgLoader
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
NUM_GEOMETRY_TAGS
Number of available geometry tags to describe state of geometry.
|
Constructor and Description |
---|
PgLoader()
Create an empty loader manager and initialize it.
|
Modifier and Type | Method and Description |
---|---|
PvDisplayOption |
getDisplayOption()
Get option of a single display which some parsers fill out.
|
PvDisplayOption[] |
getDisplayOptions()
Get display options which some parsers fill out.
|
boolean |
getTag(int aBit)
Check whether geometry tag is set.
|
void |
init()
Initialize and reset this loader manager.
|
boolean |
isAnimated()
Flag whether currently loaded data is interpreted as an animation.
|
boolean |
isEnabledOptimization()
Determines if the loader is allowed to do some optimization
on an imported geometry, or if it shall provide the data as
found in the geometry file.
|
static PvDisplayOption[] |
load(java.io.BufferedReader in,
java.lang.String ext)
Deprecated.
use #loadDisplay(BufferedReader in, String ext)
|
static PgGeometry[] |
load(PgGeometry[] geomArr,
java.io.BufferedReader in,
java.lang.String ext)
Deprecated.
use non-static method loadGeometry() with same method signature.
|
static PgGeometry[] |
load(PgGeometry[] geomArr,
java.lang.String fileName)
Deprecated.
use non-static method loadGeometry() with same method signature.
|
static PgGeometry[] |
load(PgGeometry[] geomArr,
java.lang.String data,
java.lang.String ext)
Deprecated.
use non-static method loadGeometry() with same method signature.
|
static PgGeometry[] |
load(java.lang.String fileName)
Deprecated.
use non-static method loadGeometry() with same method signature.
|
PvDisplayOption[] |
loadDisplay(java.io.BufferedReader in,
java.lang.String ext)
Read display options from a buffered reader.
|
PvDisplayOption[] |
loadDisplay(java.lang.String fileName)
Read display options from a buffered reader.
|
PgGeometry[] |
loadGeometry(PgGeometry[] geomArr,
java.io.BufferedReader in,
java.lang.String ext)
Read a geometry from a buffered reader with the content of a geometry file.
|
PgGeometry[] |
loadGeometry(PgGeometry[] geomArr,
java.lang.String fileName)
Read a geometry from named file whose extension determines the file format.
|
PgGeometry[] |
loadGeometry(PgGeometry[] geomArr,
java.lang.String data,
java.lang.String ext)
Read a geometry from a string representing content of a geometry file.
|
PgGeometry[] |
loadGeometry(java.lang.String fileName)
Read a geometry from named file whose extension determines the file format.
|
PgGeometry[] |
loadGeometry(java.lang.String data,
java.lang.String ext)
Read a geometry from a string representing content of a geometry file.
|
static double |
parseDouble(java.io.StreamTokenizer st)
Deprecated.
since JavaView 3.97.040, use jv.number.PuDouble#parseDouble(String) instead.
|
static double |
parseDouble(java.lang.String string)
Deprecated.
since JavaView 3.97.040, use jv.number.PuDouble#parseDouble(String) instead.
|
static boolean |
parseEndOfLine(java.io.StreamTokenizer st)
Ignore all tokens of a stream until the next end-of-line is reached.
|
static PgGeometry[] |
read(PgJvxSrc[][] geomAnim,
boolean bShowAnimationPanel)
Deprecated.
use non-static method readAnimation() with same method signature.
|
static PgGeometry[] |
read(PgJvxSrc[] geomAnim,
boolean bShowAnimationPanel)
Deprecated.
use non-static method readAnimation() with same method signature.
|
static boolean |
readAll(java.awt.List list,
java.lang.String fileName)
Read list of files from a given XML listing file.
|
PgGeometry[] |
readAnimation(PgJvxSrc[][] geomAnim,
boolean bShowAnimationPanel)
Create a set of keyframe objects from a double array of geometries
and returns the list of dynamic geometries.
|
PgGeometry[] |
readAnimation(PgJvxSrc[] geomAnim,
boolean bShowAnimationPanel)
Create a set of keyframe objects containing a single keyframe from an array of geometries.
|
static PsKeyframe[] |
readAnimation(PsKeyframe[] keyframe,
int firstKey,
int lastKey,
java.lang.String fileName)
Deprecated.
use readAnimation(PsKeyframe [], int, int, String, int);
|
PsKeyframe[] |
readAnimation(PsKeyframe[] keyframe,
int firstKey,
int lastKey,
java.lang.String fileName,
int fixedLen)
Create a set of keyframe objects from a set of files.
|
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)
Deprecated.
use saveImage(Image, String)
|
static boolean |
save(PgGeometryIf[] geomIf,
java.lang.String fileName)
Deprecated.
use saveGeometry(PgGeometry [], String).
|
static boolean |
save(PvDisplayOption[] option,
java.lang.String fileName)
Deprecated.
use saveDisplay(PvDisplayOption [] option, String fileName).
|
static boolean |
save(java.lang.String data,
java.lang.String fileName)
Deprecated.
use saveString(String, String).
|
boolean |
saveDisplay(PvDisplayOption[] option,
java.lang.String fileName)
Write display settings to a JVD file.
|
boolean |
saveGeometry(PgGeometry[] geomSrc,
java.lang.String fileName)
Write a set of geometries to a named file whose extension determines the format.
|
boolean |
saveGeometry(PgGeometryIf[] geomIf,
java.lang.String fileName)
Same functionality as
saveGeometry(PgGeometry [], String)
but provided to avoid casting. |
java.lang.String |
saveGeometryToString(PgGeometry[] geomSrc,
java.lang.String ext)
Write a geometry to a string in a given format determined by its file extension.
|
boolean |
saveImage(java.awt.Image image,
java.lang.String fileName)
Write an image to a named file whose extension determines the file format.
|
boolean |
saveString(java.lang.String data,
java.lang.String fileName)
Write a string to a named file if running as application.
|
static java.lang.String |
saveToString(PgGeometryIf[] geom,
java.lang.String ext)
Deprecated.
use non-static method saveGeometryToString(PgGeometry [], String)
|
void |
setAnimated(boolean flag)
Set flag whether currently loaded data should be interpreted as an animation.
|
void |
setDisplayOption(PvDisplayOption option)
Set option of a single display which some parsers fill out.
|
void |
setDisplayOptions(PvDisplayOption[] option)
Set the display options to be used by some parsers.
|
void |
setEnabledOptimization(boolean flag)
Set flag if the loader is allowed to do some optimization
on an imported geometry, or if it shall provide the data as
found in the geometry file.
|
void |
setTag(int aBit,
boolean flag)
Set geometry tag of this loader manager.
|
public static final int NUM_GEOMETRY_TAGS
getTag(int)
,
setTag(int, boolean)
,
Constant Field Valuespublic void init()
public boolean getTag(int aBit)
jv.loader.PgLoaderIf
.setTag(int, boolean)
public void setTag(int aBit, boolean flag)
jv.loader.PgLoaderIf
.getTag(int)
public boolean isEnabledOptimization()
For example, some file formats do not store a connected mesh but provide individual vertices for each face. In this case, a loader manager may identify equal vertices.
By default this loader manager is enabled to do optimization if the individual loader allows optimization too.
true
if loader manager is enabled for optimization.public void setEnabledOptimization(boolean flag)
For example, some file formats do not store a connected mesh but provide individual vertices for each face. In this case, a loader manager may identify equal vertices.
Optimization is sometimes not suitable without further knowledge about a specific data set. Then the loader may be advised to keep the original data by enabling this flag.
Method must be called before the loader manager starts reading a file.
flag
- true
if loader manager is enabled for optimization.public boolean isAnimated()
public void setAnimated(boolean flag)
public PvDisplayOption getDisplayOption()
Note, most geometry files provide no display options, or at most for a single display.
public void setDisplayOption(PvDisplayOption option)
Note, most geometry files provide no display options, or at most for a single display.
option
- display options for a single displaypublic PvDisplayOption[] getDisplayOptions()
public void setDisplayOptions(PvDisplayOption[] option)
option
- array of options of a set of displayspublic PgGeometry[] loadGeometry(java.lang.String data, java.lang.String ext)
loadGeometry(PgGeometry [],String,String)
with a null geometry array. Method is supplied for convenience.data
- String with geometry dataext
- Extension identifying the file format, usually 3 characters.public PgGeometry[] loadGeometry(PgGeometry[] geomArr, java.lang.String data, java.lang.String ext)
loadGeometry(PgGeometry [],BufferedReader,String)
with a null geometry array. Method is supplied for convenience.geomArr
- Geometry which will be filled with data, maybe null.data
- String with geometry dataext
- Extension identifying the file format, usually 3 characters.public PgGeometry[] loadGeometry(java.lang.String fileName)
fileName
- full qualified name of geometry file, e.g. http://... or file:/...public PgGeometry[] loadGeometry(PgGeometry[] geomArr, java.lang.String fileName)
geomArr
- Geometry which will be filled with data, maybe null.fileName
- full qualified name of geometry file, e.g. http://... or file:/...public PgGeometry[] loadGeometry(PgGeometry[] geomArr, java.io.BufferedReader in, java.lang.String ext)
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.
geomArr
- Array of geometries which will be filled with data, maybe null.in
- Buffered reader with geometry dataext
- Extension identifying the file format, usually 3 characters.public static PgGeometry[] load(PgGeometry[] geomArr, java.lang.String data, java.lang.String ext)
load(PgGeometry [], BufferedReader, String)
with a null geometry array. Method is supplied for convenience.geomArr
- Geometries which will be filled with data, maybe null.data
- String with geometry dataext
- Extension identifying the file format, usually 3 characters.public static PgGeometry[] load(java.lang.String fileName)
fileName
- full qualified name of geometry file, e.g. http://... or file:/...public static PgGeometry[] load(PgGeometry[] geomArr, java.lang.String fileName)
geomArr
- Geometries which will be filled with data, maybe null.fileName
- full qualified name of geometry file, e.g. http://... or file:/...public static PgGeometry[] load(PgGeometry[] geomArr, java.io.BufferedReader in, java.lang.String ext)
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.
geomArr
- Geometries which will be filled with data, maybe null.in
- Buffered reader with geometry dataext
- Extension identifying the file format, usually 3 characters.public static PvDisplayOption[] load(java.io.BufferedReader in, java.lang.String ext)
public PvDisplayOption[] loadDisplay(java.lang.String fileName)
Method opens the file connection and calls loadDisplay(BufferedReader,String).
fileName
- full qualified name of geometry file, e.g. http://... or file:/...public PvDisplayOption[] loadDisplay(java.io.BufferedReader in, java.lang.String ext)
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.
in
- Buffered reader with display option dataext
- Extension identifying the file format, usually 3 characters.public java.lang.String saveGeometryToString(PgGeometry[] geomSrc, java.lang.String ext)
Note, this method does not save texture images, use
saveGeometry(PgGeometry [], String)
instead.
geomSrc
- array of geometries to be saved to stringext
- filename extension to determine the file formatsaveGeometry(PgGeometry [], String)
public static java.lang.String saveToString(PgGeometryIf[] geom, java.lang.String ext)
geom
- array of geometries to be saved to stringext
- filename extension to determine the file formatsaveGeometry(PgGeometry [], String)
public boolean saveGeometry(PgGeometry[] geomSrc, java.lang.String fileName)
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'.
geomSrc
- array of geometries to be saved to filefileName
- full file name including pathtrue
on successsaveGeometry(PgGeometryIf [], String)
,
saveGeometryToString(PgGeometry [],String)
,
PgGeometryIf.isVisible()
,
PgGeometryIf.getTextureImage()
public boolean saveGeometry(PgGeometryIf[] geomIf, java.lang.String fileName)
saveGeometry(PgGeometry [], String)
but provided to avoid casting.geomIf
- array of geometries to be saved to filefileName
- full file name including pathtrue
on successsaveGeometry(PgGeometry [], String)
public static boolean save(PgGeometryIf[] geomIf, java.lang.String fileName)
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'.
geomIf
- array of geometries to be saved to filefileName
- full file name including pathtrue
on successPgGeometryIf.isVisible()
,
PgGeometryIf.getTextureImage()
,
saveToString(PgGeometryIf [], String)
public static boolean save(java.lang.String data, java.lang.String fileName)
PgExport_Dialog
from which it may be saved using cut-and-paste.data
- string to be saved to filefileName
- full file name including pathtrue
on successpublic boolean saveString(java.lang.String data, java.lang.String fileName)
PgExport_Dialog
from which it may be saved using cut-and-paste.data
- string to be saved to filefileName
- full file name including pathtrue
on successpublic static boolean save(PvDisplayOption[] option, java.lang.String fileName)
option
- Display options to be saved to filefileName
- full file name including pathtrue
on successpublic boolean saveDisplay(PvDisplayOption[] option, java.lang.String fileName)
option
- Display options to be saved to filefileName
- full file name including pathtrue
on successpublic static boolean save(java.awt.Image image, java.lang.String fileName)
image
- Image to be saved to filefileName
- Full file name including pathtrue
on successpublic boolean saveImage(java.awt.Image image, java.lang.String fileName)
image
- Image to be saved to filefileName
- Full file name including pathtrue
on successpublic static boolean parseEndOfLine(java.io.StreamTokenizer st) throws java.io.IOException
true
if EOL is found, else false
, i.e. EOF is found.java.io.IOException
public static double parseDouble(java.io.StreamTokenizer st) throws java.io.IOException
This method first acquires the next token from StreamTokenizer, then analyzes the following token if there is a number in exponential form. If yes, then the number is created in this method, otherwise the second token is pushed back.
The need for this method arise from the special setup of some StreamTokenizers in JavaView where several characters like 'e', 'E', '+', are sometimes marked as word characters.
java.io.IOException
public static double parseDouble(java.lang.String string)
public static boolean readAll(java.awt.List list, java.lang.String fileName)
public static boolean readDirs(java.awt.List list, java.lang.String fileName)
public static java.lang.String[] readDirs(java.lang.String fileName)
public PgGeometry[] readAnimation(PgJvxSrc[] geomAnim, boolean bShowAnimationPanel)
public static PgGeometry[] read(PgJvxSrc[] geomAnim, boolean bShowAnimationPanel)
public static PsKeyframe[] readAnimation(PsKeyframe[] keyframe, int firstKey, int lastKey, java.lang.String fileName)
public PsKeyframe[] readAnimation(PsKeyframe[] keyframe, int firstKey, int lastKey, java.lang.String fileName, int fixedLen)
An application calling this method typically adds the dynamic geometries of each keyframe to a display or performs another action.
The argument fixedLen==0 indicates that no leading zeros appear in the keyframe index. A positive value indicates that the keyframe index of the file name must have the format "name.0017.ext" (here fixedLen==4).
public PgGeometry[] readAnimation(PgJvxSrc[][] geomAnim, boolean bShowAnimationPanel)
Each keyframe object has a dynamic geometry which represents the current state of a keyframe animation at a specific time.
The parent of the dynamic geometry is the corresponding keyframe object.
public static PgGeometry[] read(PgJvxSrc[][] geomAnim, boolean bShowAnimationPanel)
"