kcl.waterloo.xml
Class GJEncoder
- java.lang.Object
-
- kcl.waterloo.xml.GJEncoder
-
public class GJEncoder extends java.lang.ObjectA static library used to serialize all Waterloo graphics to an XML file. Uses the standard java.bean.util.XMLEncoder. Note: The singleton instance of GJDefaults is set as the owner of the XMLEncoder. The defaults are written to each XML file together with the appropriate setting for the data vector class used by plots. The matching XML decoder routine needs to save and restore the default settings when de-serializing the generated XML file (the supplied GJDecoder does this). Any changes here need to be tested for backwards compatibility. The GJDefaults also set the verbosity of exception logging: 0 (quiet) to 2 (verbose). Exceptions are also logged to the file (verbosely) Exceptions are expected: e.g. when non-serializable listeners are used. They do not (generally) represent errors.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classGJEncoder.CompressionModeEnumerated type for supported compression modes.
-
Field Summary
Fields Modifier and Type Field and Description static java.util.LinkedHashMap<java.lang.Class,java.beans.PersistenceDelegate>customDelegates
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static voidaddDelegates(java.beans.XMLEncoder e)Static method that adds the required persistence delegates to an XMLEncoder instance.static javax.swing.SwingWorker<java.lang.Void,java.lang.Void>createForMATLAB(java.lang.String fileName, java.awt.Component[] compList, java.util.ArrayList<double[]> pos)Used to save Waterloo graphics housed in a MATLAB figure.static booleangetCompression()Returns true if the compression mode is anything other thanCompressionMode.nonestatic GJEncoder.CompressionModegetCompressionMode()Returns the current compression mode.static java.util.ArrayList<java.lang.String>getExceptionLog()static voidsave(java.lang.String fileName, java.lang.Object comp)Static method for saving Waterloo graphics objects.static voidsaveOnEDT(java.lang.String fileName, java.lang.Object comp)static voidsaveOnThread(java.lang.String fileName, java.lang.Object comp)static voidsetCompression(boolean flag)Sets the compression mode to be used by all output streams subsequently created using createOutputStream.static voidsetCompressionMode(GJEncoder.CompressionMode mode)Sets the compression mode to be used by all output streams subsequently created using createOutputStream.static voidsetContext(java.beans.XMLEncoder e)
-
-
-
Field Detail
-
customDelegates
public static final java.util.LinkedHashMap<java.lang.Class,java.beans.PersistenceDelegate> customDelegates
-
-
Method Detail
-
save
public static void save(java.lang.String fileName, java.lang.Object comp)Static method for saving Waterloo graphics objects. Presently supported objects on input are GCFrames, GCPanels, graph containers and graphs.- Parameters:
fileName- fully qualified file name as a String. Compression will be used if the file extension is ".gz". Otherwise, compression will be applied if it has been selected as the default by a call to setCompression.comp- the component to save
-
saveOnEDT
public static void saveOnEDT(java.lang.String fileName, java.lang.Object comp)
-
saveOnThread
public static void saveOnThread(java.lang.String fileName, java.lang.Object comp)
-
setCompressionMode
public static void setCompressionMode(GJEncoder.CompressionMode mode)
Sets the compression mode to be used by all output streams subsequently created using createOutputStream.- Parameters:
mode- the CompressionMode
-
getCompressionMode
public static GJEncoder.CompressionMode getCompressionMode()
Returns the current compression mode.- Returns:
- the CompressionMode
-
setCompression
public static void setCompression(boolean flag)
Sets the compression mode to be used by all output streams subsequently created using createOutputStream. If set true, gzip compression mode will be used. If set false, no compression will be used.- Parameters:
flag- true to activate compression
-
getCompression
public static boolean getCompression()
Returns true if the compression mode is anything other thanCompressionMode.none- Returns:
- the flag
-
setContext
public static void setContext(java.beans.XMLEncoder e)
-
getExceptionLog
public static java.util.ArrayList<java.lang.String> getExceptionLog()
-
addDelegates
public static void addDelegates(java.beans.XMLEncoder e)
Static method that adds the required persistence delegates to an XMLEncoder instance.- Parameters:
e- the XMLEncoder
-
createForMATLAB
public static javax.swing.SwingWorker<java.lang.Void,java.lang.Void> createForMATLAB(java.lang.String fileName, java.awt.Component[] compList, java.util.ArrayList<double[]> pos)Used to save Waterloo graphics housed in a MATLAB figure.- Parameters:
fileName- - the file name.compList- - a list of GJGraphContainers.pos- - the pixel positions of those in the MATLAB figure.- Returns:
- a SwingWorker
instance that saves the data on a background thread.
-
-
DMelt 3.0 © DataMelt by jWork.ORG