Class PgAbstractLoader
- java.lang.Object
-
- jv.loader.PgAbstractLoader
-
- All Implemented Interfaces:
- PgLoaderIf
- Direct Known Subclasses:
- PgAbcLoader, PgAnsLoader, PgBdLoader, PgByuLoader, PgDxfLoader, PgFeLoader, PgJvfLoader, PgJvxLoader, PgMaLoader, PgMapleLoader, PgMathLoader, PgObjLoader, PgOffLoader, PgPdfLoader, PgPlyLoader, PgPovLoader, PgStlbLoader, PgStlLoader, PgU3dLoader, PgWrlLoader, PgXyzLoader
public class PgAbstractLoader extends java.lang.Object implements PgLoaderIf
Abstract loader for geometry files implements basic functionality of PgLoaderIf interface. This class simplifies writing of loader by simple subclassing and only implementing the parse and write methods.- Author:
- Konrad Polthier
- Version:
- 21.03.10, 1.00 created (kp) Based on PgBuyLoader.
-
-
Field Summary
-
Fields inherited from interface jv.loader.PgLoaderIf
GEOM_DATA_AUTHOR, GEOM_DATA_COLORS, GEOM_DATA_HEADER, GEOM_DATA_INFO, GEOM_DATA_NORMALS, GEOM_DATA_TEXTURE, GEOM_DATA_VECTORS
-
-
Constructor Summary
Constructors Constructor and Description PgAbstractLoader()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description PgJvxSrc[][]getAnimations()Retrieve the previously loaded animations.PvDisplayOptiongetDisplayOption()Get display options which some parsers and geometry file formats supply.PgJvxSrc[]getGeometries()Retrieve the previously loaded geometries.PgGeometryIf[]getSpecializedGeometries()Currently, this method always returnsnull.booleanisAnimation()Determine if currently loaded data is an animation.booleanisEnabledOptimization()Determines if the loaded geometry requires some optimization.booleanload(java.io.BufferedReader in)Read a geometry file containing a set of geometries or animations.PgJvxSrc[]read(java.io.BufferedReader in)Read a geometry file and return an array of new geometries.PgJvxSrc[]read(java.io.DataInputStream inReader)Read an array of geometries from a binary input stream.voidsetAnimation(boolean flag)Set flag whether current geometry data is an animation.voidsetDisplayOption(PvDisplayOption option)Set the display options to be saved within the geometry file.voidsetGeometryOption(java.util.BitSet option)Set the geometry options which indicate which parts of a geometry shall be saved.booleanwrite(java.io.DataOutputStream outWriter, PgJvxSrc[] geomArr)Write an array of geometries into a binary output stream writer.booleanwrite(java.io.Writer writer, PgJvxSrc[] geomArr)Write an array of geometries into an output stream writer.
-
-
-
Method Detail
-
isEnabledOptimization
public boolean isEnabledOptimization()
Determines if the loaded geometry requires some optimization. The method in this class prohibits optimization and always returns false.For example, some file formats do not store a connected mesh but provide individual vertices for each face every time the face is mentioned. In this case, a loader manager may identify equal vertices.
A similar method in the loader manager PgLoader may override the individual settings of each loader.
- Specified by:
isEnabledOptimizationin interfacePgLoaderIf- Returns:
trueif loader is enabled for optimization.- Since:
- JavaView 2.99.018
- See Also:
PgLoader.isEnabledOptimization(),PgLoader.setEnabledOptimization(boolean)- Version:
- 06.10.03, 1.00 created (kp)
-
setGeometryOption
public void setGeometryOption(java.util.BitSet option)
Set the geometry options which indicate which parts of a geometry shall be saved. This method must be called before writing the geometry. Note, not all geometry file formats support geometry options.- Specified by:
setGeometryOptionin interfacePgLoaderIf- Since:
- JavaView 2.68.000
- Version:
- 19.04.03, 1.00 created (kp)
-
getDisplayOption
public PvDisplayOption getDisplayOption()
Get display options which some parsers and geometry file formats supply. This geometry file format does not support loading/saving of display options.- Specified by:
getDisplayOptionin interfacePgLoaderIf- See Also:
PgLoaderIf.load(BufferedReader)
-
setDisplayOption
public void setDisplayOption(PvDisplayOption option)
Set the display options to be saved within the geometry file. This method must be called before writing the geometry. This geometry file format does not support loading/saving of display options.- Specified by:
setDisplayOptionin interfacePgLoaderIf
-
isAnimation
public boolean isAnimation()
Determine if currently loaded data is an animation.This method may be called after successful parsing an input stream with the method
load(BufferedReader).- Specified by:
isAnimationin interfacePgLoaderIf- Returns:
trueif loaded data is an animation.- See Also:
load(BufferedReader)
-
setAnimation
public void setAnimation(boolean flag)
Set flag whether current geometry data is an animation.- Specified by:
setAnimationin interfacePgLoaderIf- Parameters:
flag-trueif loaded data is an animation.
-
getAnimations
public PgJvxSrc[][] getAnimations()
Retrieve the previously loaded animations.This method may be called after successful parsing an input stream with the method
load(BufferedReader)and ifisAnimation()returnstrue.- Specified by:
getAnimationsin interfacePgLoaderIf- Returns:
- Double array of JVX geometries.
- See Also:
load(BufferedReader)- Author:
- Konrad Polthier
- Version:
- 21.08.02, 1.00 created (kp)
-
getGeometries
public PgJvxSrc[] getGeometries()
Retrieve the previously loaded geometries.This method may be called after successful parsing an input stream with the method
load(BufferedReader)and ifisAnimation()returnsfalse.- Specified by:
getGeometriesin interfacePgLoaderIf- Returns:
- Array of JVX geometries.
- See Also:
load(BufferedReader)- Author:
- Konrad Polthier
- Version:
- 21.08.02, 1.00 created (kp)
-
getSpecializedGeometries
public PgGeometryIf[] getSpecializedGeometries()
Currently, this method always returnsnull.Return the loaded geometry in a more specialized class. This method allows a loader to return a geometry class which best fits the data found in a geometry file.
The loader manager
jv.loader.PgLoaderin JavaView will first check if a loader returns specialized geometries, and if not, check for a data supplied in a container class PgJvxSrc.This method may be called after successful parsing an input stream with the method
load(BufferedReader)and ifisAnimation()returnsfalse.- Specified by:
getSpecializedGeometriesin interfacePgLoaderIf- Returns:
- Array of geometries whose actual class type may vary between loaders.
- See Also:
getGeometries()- Author:
- Konrad Polthier
- Version:
- 25.03.04, 1.00 created (kp)
-
load
public boolean load(java.io.BufferedReader in)
Read a geometry file containing a set of geometries or animations.After successful parsing retrieve the loaded geometries or animations using the methods
getGeometries()respectivelygetAnimations()depending on the return value of the methodisAnimation().- Specified by:
loadin interfacePgLoaderIf- Parameters:
in- BufferedReader to read textual data from.- Returns:
trueif parsing was successfull.- See Also:
getAnimations(),getGeometries(),isAnimation()- Author:
- Konrad Polthier
- Version:
- 21.08.02, 1.00 created (kp)
-
read
public PgJvxSrc[] read(java.io.BufferedReader in)
Read a geometry file and return an array of new geometries.The returned array of geometry may contain keyframes of an animation. This is checked with the method
isAnimation().Alternatively, one may call load(BuffereredReader) followed by getGeometries() resp. getAnimations() to have a finer control about which information one wants to use from a source. For example, optional display information must be retrieve by a subsequent call getDisplayOption() if available.
- Specified by:
readin interfacePgLoaderIf- Parameters:
in- BufferedReader to read textual data from.- Returns:
- Array of JVX geometries.
- See Also:
write(Writer, PgJvxSrc [])- Author:
- Konrad Polthier
- Version:
- 10.06.01, 1.00 revised (kp)
10.06.01, 1.00 created (kp)
-
read
public PgJvxSrc[] read(java.io.DataInputStream inReader)
Read an array of geometries from a binary input stream.- Parameters:
inReader- Provides all data to this stream- Returns:
- set of loaded geometries on success.
- Since:
- JavaView 3.99.061
- See Also:
load(BufferedReader),write(Writer, PgJvxSrc [])- Version:
- 21.03.10, 1.00 created (kp)
-
write
public boolean write(java.io.Writer writer, PgJvxSrc[] geomArr) throws java.io.IOExceptionWrite an array of geometries into an output stream writer.- Specified by:
writein interfacePgLoaderIf- Parameters:
writer- Write all data to this streamgeomArr- Array with geometries to save- Returns:
trueon success.- Throws:
java.io.IOException- See Also:
read(BufferedReader),write(DataOutputStream, PgJvxSrc [])- Version:
- 22.03.10, 1.10 revised (kp) Method body added.
10.06.01, 1.00 created (kp)
-
write
public boolean write(java.io.DataOutputStream outWriter, PgJvxSrc[] geomArr) throws java.io.IOExceptionWrite an array of geometries into a binary output stream writer.- Specified by:
writein interfacePgLoaderIf- Parameters:
outWriter- Write all data to this streamgeomArr- Array with geometries to save- Returns:
trueon success.- Throws:
java.io.IOException- See Also:
read(BufferedReader),read(DataInputStream),write(Writer, PgJvxSrc [])- Version:
- 30.04.06, 1.00 created (kp)
-
-
"