Commit d13e0ae9 authored by whitlocb's avatar whitlocb
Browse files

Improved Java API and documented it some.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@3341 18c085ea-50e0-402c-830e-de6fd14e8384
parent c8241e78
......@@ -48,7 +48,7 @@ package llnl.visit;
// Notes: Autogenerated by xml2java.
//
// Programmer: xml2java
// Creation: Wed Mar 14 17:54:39 PST 2007
// Creation: Mon Feb 25 15:14:55 PST 2008
//
// Modifications:
//
......@@ -145,6 +145,22 @@ public class AnimationAttributes extends AttributeSubject
}
}
public String toString(String indent)
{
String str = new String();
str = str + boolToString("pipelineCachingMode", pipelineCachingMode, indent) + "\n";
str = str + intToString("timeout", timeout, indent) + "\n";
str = str + indent + "playbackMode = ";
if(playbackMode == PLAYBACKMODE_LOOPING)
str = str + "PLAYBACKMODE_LOOPING";
if(playbackMode == PLAYBACKMODE_PLAYONCE)
str = str + "PLAYBACKMODE_PLAYONCE";
if(playbackMode == PLAYBACKMODE_SWING)
str = str + "PLAYBACKMODE_SWING";
str = str + "\n";
return str;
}
// Attributes
private boolean pipelineCachingMode;
......
......@@ -48,7 +48,7 @@ package llnl.visit;
// Notes: Autogenerated by xml2java.
//
// Programmer: xml2java
// Creation: Fri Jan 25 16:54:21 PST 2008
// Creation: Mon Feb 25 15:14:55 PST 2008
//
// Modifications:
//
......@@ -376,6 +376,60 @@ public class AnnotationAttributes extends AttributeSubject
}
}
public String toString(String indent)
{
String str = new String();
str = str + indent + "axes2D = {\n" + axes2D.toString(indent + " ") + indent + "}\n";
str = str + indent + "axes3D = {\n" + axes3D.toString(indent + " ") + indent + "}\n";
str = str + boolToString("userInfoFlag", userInfoFlag, indent) + "\n";
str = str + indent + "userInfoFont = {\n" + userInfoFont.toString(indent + " ") + indent + "}\n";
str = str + boolToString("databaseInfoFlag", databaseInfoFlag, indent) + "\n";
str = str + indent + "databaseInfoFont = {\n" + databaseInfoFont.toString(indent + " ") + indent + "}\n";
str = str + indent + "databaseInfoExpansionMode = ";
if(databaseInfoExpansionMode == PATHEXPANSIONMODE_FILE)
str = str + "PATHEXPANSIONMODE_FILE";
if(databaseInfoExpansionMode == PATHEXPANSIONMODE_DIRECTORY)
str = str + "PATHEXPANSIONMODE_DIRECTORY";
if(databaseInfoExpansionMode == PATHEXPANSIONMODE_FULL)
str = str + "PATHEXPANSIONMODE_FULL";
if(databaseInfoExpansionMode == PATHEXPANSIONMODE_SMART)
str = str + "PATHEXPANSIONMODE_SMART";
if(databaseInfoExpansionMode == PATHEXPANSIONMODE_SMARTDIRECTORY)
str = str + "PATHEXPANSIONMODE_SMARTDIRECTORY";
str = str + "\n";
str = str + boolToString("legendInfoFlag", legendInfoFlag, indent) + "\n";
str = str + indent + "backgroundColor = {" + backgroundColor.Red() + ", " + backgroundColor.Green() + ", " + backgroundColor.Blue() + ", " + backgroundColor.Alpha() + "}\n";
str = str + indent + "foregroundColor = {" + foregroundColor.Red() + ", " + foregroundColor.Green() + ", " + foregroundColor.Blue() + ", " + foregroundColor.Alpha() + "}\n";
str = str + indent + "gradientBackgroundStyle = ";
if(gradientBackgroundStyle == GRADIENTSTYLE_TOPTOBOTTOM)
str = str + "GRADIENTSTYLE_TOPTOBOTTOM";
if(gradientBackgroundStyle == GRADIENTSTYLE_BOTTOMTOTOP)
str = str + "GRADIENTSTYLE_BOTTOMTOTOP";
if(gradientBackgroundStyle == GRADIENTSTYLE_LEFTTORIGHT)
str = str + "GRADIENTSTYLE_LEFTTORIGHT";
if(gradientBackgroundStyle == GRADIENTSTYLE_RIGHTTOLEFT)
str = str + "GRADIENTSTYLE_RIGHTTOLEFT";
if(gradientBackgroundStyle == GRADIENTSTYLE_RADIAL)
str = str + "GRADIENTSTYLE_RADIAL";
str = str + "\n";
str = str + indent + "gradientColor1 = {" + gradientColor1.Red() + ", " + gradientColor1.Green() + ", " + gradientColor1.Blue() + ", " + gradientColor1.Alpha() + "}\n";
str = str + indent + "gradientColor2 = {" + gradientColor2.Red() + ", " + gradientColor2.Green() + ", " + gradientColor2.Blue() + ", " + gradientColor2.Alpha() + "}\n";
str = str + indent + "backgroundMode = ";
if(backgroundMode == BACKGROUNDMODE_SOLID)
str = str + "BACKGROUNDMODE_SOLID";
if(backgroundMode == BACKGROUNDMODE_GRADIENT)
str = str + "BACKGROUNDMODE_GRADIENT";
if(backgroundMode == BACKGROUNDMODE_IMAGE)
str = str + "BACKGROUNDMODE_IMAGE";
if(backgroundMode == BACKGROUNDMODE_IMAGESPHERE)
str = str + "BACKGROUNDMODE_IMAGESPHERE";
str = str + "\n";
str = str + stringToString("backgroundImage", backgroundImage, indent) + "\n";
str = str + intToString("imageRepeatX", imageRepeatX, indent) + "\n";
str = str + intToString("imageRepeatY", imageRepeatY, indent) + "\n";
return str;
}
// Attributes
private Axes2D axes2D;
......
......@@ -49,7 +49,7 @@ import java.util.Vector;
// Notes: Autogenerated by xml2java.
//
// Programmer: xml2java
// Creation: Tue Jan 15 14:07:42 PST 2008
// Creation: Mon Feb 25 15:14:55 PST 2008
//
// Modifications:
//
......@@ -421,6 +421,57 @@ public class AnnotationObject extends AttributeSubject
}
}
public String toString(String indent)
{
String str = new String();
str = str + stringToString("objectName", objectName, indent) + "\n";
str = str + indent + "objectType = ";
if(objectType == ANNOTATIONTYPE_TEXT2D)
str = str + "ANNOTATIONTYPE_TEXT2D";
if(objectType == ANNOTATIONTYPE_TEXT3D)
str = str + "ANNOTATIONTYPE_TEXT3D";
if(objectType == ANNOTATIONTYPE_TIMESLIDER)
str = str + "ANNOTATIONTYPE_TIMESLIDER";
if(objectType == ANNOTATIONTYPE_LINE2D)
str = str + "ANNOTATIONTYPE_LINE2D";
if(objectType == ANNOTATIONTYPE_ARROW2D)
str = str + "ANNOTATIONTYPE_ARROW2D";
if(objectType == ANNOTATIONTYPE_ARROW3D)
str = str + "ANNOTATIONTYPE_ARROW3D";
if(objectType == ANNOTATIONTYPE_BOX)
str = str + "ANNOTATIONTYPE_BOX";
if(objectType == ANNOTATIONTYPE_IMAGE)
str = str + "ANNOTATIONTYPE_IMAGE";
if(objectType == ANNOTATIONTYPE_LEGENDATTRIBUTES)
str = str + "ANNOTATIONTYPE_LEGENDATTRIBUTES";
if(objectType == ANNOTATIONTYPE_MAXANNOTATIONTYPE)
str = str + "ANNOTATIONTYPE_MAXANNOTATIONTYPE";
str = str + "\n";
str = str + boolToString("visible", visible, indent) + "\n";
str = str + boolToString("active", active, indent) + "\n";
str = str + doubleArrayToString("position", position, indent) + "\n";
str = str + doubleArrayToString("position2", position2, indent) + "\n";
str = str + indent + "textColor = {" + textColor.Red() + ", " + textColor.Green() + ", " + textColor.Blue() + ", " + textColor.Alpha() + "}\n";
str = str + boolToString("useForegroundForTextColor", useForegroundForTextColor, indent) + "\n";
str = str + indent + "color1 = {" + color1.Red() + ", " + color1.Green() + ", " + color1.Blue() + ", " + color1.Alpha() + "}\n";
str = str + indent + "color2 = {" + color2.Red() + ", " + color2.Green() + ", " + color2.Blue() + ", " + color2.Alpha() + "}\n";
str = str + stringVectorToString("text", text, indent) + "\n";
str = str + indent + "fontFamily = ";
if(fontFamily == FONTFAMILY_ARIAL)
str = str + "FONTFAMILY_ARIAL";
if(fontFamily == FONTFAMILY_COURIER)
str = str + "FONTFAMILY_COURIER";
if(fontFamily == FONTFAMILY_TIMES)
str = str + "FONTFAMILY_TIMES";
str = str + "\n";
str = str + boolToString("fontBold", fontBold, indent) + "\n";
str = str + boolToString("fontItalic", fontItalic, indent) + "\n";
str = str + boolToString("fontShadow", fontShadow, indent) + "\n";
str = str + doubleToString("doubleAttribute1", doubleAttribute1, indent) + "\n";
str = str + intToString("intAttribute1", intAttribute1, indent) + "\n";
return str;
}
// Attributes
private String objectName;
......
......@@ -49,7 +49,7 @@ import java.util.Vector;
// Notes: Autogenerated by xml2java.
//
// Programmer: xml2java
// Creation: Tue Mar 20 09:28:42 PDT 2007
// Creation: Mon Feb 25 15:14:55 PST 2008
//
// Modifications:
//
......@@ -133,6 +133,22 @@ public class AnnotationObjectList extends AttributeSubject
Select(0);
}
public String toString(String indent)
{
String str = new String();
str = str + indent + "annotation = {\n";
for(int i = 0; i < annotation.size(); ++i)
{
AttributeSubject s = (AttributeSubject)annotation.elementAt(i);
str = str + s.toString(indent + " ");
if(i < annotation.size()-1)
str = str + ", ";
str = str + "\n";
}
str = str + "}\n";
return str;
}
// Attributegroup convenience methods
public void AddAnnotation(AnnotationObject obj)
{
......
......@@ -48,7 +48,7 @@ package llnl.visit;
// Notes: Autogenerated by xml2java.
//
// Programmer: xml2java
// Creation: Tue Jan 15 14:07:42 PST 2008
// Creation: Mon Feb 25 15:14:55 PST 2008
//
// Modifications:
//
......@@ -169,6 +169,17 @@ public class AppearanceAttributes extends AttributeSubject
}
}
public String toString(String indent)
{
String str = new String();
str = str + stringToString("background", background, indent) + "\n";
str = str + stringToString("foreground", foreground, indent) + "\n";
str = str + stringToString("fontName", fontName, indent) + "\n";
str = str + stringToString("style", style, indent) + "\n";
str = str + intToString("orientation", orientation, indent) + "\n";
return str;
}
// Attributes
private String background;
......
......@@ -58,10 +58,21 @@ import java.util.Vector;
// Brad Whitlock, Thu Dec 12 12:58:17 PDT 2002
// Added a method to return the class name.
//
// Brad Whitlock, Mon Feb 25 14:09:31 PST 2008
// Added methods to help with string conversion. Added javadoc comments.
//
// ****************************************************************************
/**
* Base class for state objects.
*
* @author Brad Whitlock
*/
public abstract class AttributeSubject extends java.lang.Object
{
/**
* Constructor for the AttributeSubject class.
* @param nAtts The number of attributes that make up the state object.
*/
public AttributeSubject(int nAtts)
{
super();
......@@ -72,21 +83,38 @@ public abstract class AttributeSubject extends java.lang.Object
attributeId = 0;
}
/**
* Registers an observer to be called when this object's Notify()
* method is called.
* @param o The observer whose Update() method will be called.
*/
public void Attach(SimpleObserver o)
{
observers.addElement(o);
}
/**
* Removes an observer from the list of observers to be called
* when this object's Notify() method is called.
* @param o The observer to be removed.
*/
public void Detach(SimpleObserver o)
{
observers.remove(o);
}
/**
* Returns the name of the state object's class.
* @return The name of the state object's class.
*/
public String GetClassName()
{
return getClass().getName();
}
/**
* Notifies all observers of this object that they need to be updated.
*/
public void Notify()
{
for(int i = 0; i < observers.size(); ++i)
......@@ -101,23 +129,38 @@ public abstract class AttributeSubject extends java.lang.Object
UnSelectAll();
}
/**
* Selects all of the attributes in the state object so they will all be
* sent to the viewer when they are transmitted.
*/
public void SelectAll()
{
for(int i = 0; i < selected.length; ++i)
selected[i] = true;
}
/**
* Unselects all of the fields in the state object.
*/
public void UnSelectAll()
{
for(int i = 0; i < selected.length; ++i)
selected[i] = false;
}
/**
* Returns the number of attributes in the state object.
* @return The number of attributes in the state object.
*/
public int NumAttributes()
{
return selected.length;
}
/**
* Returns the number of selected attributes in the state object.
* @return The number of selected attributes in the state object.
*/
public int NumAttributesSelected()
{
int sum = 0;
......@@ -126,21 +169,41 @@ public abstract class AttributeSubject extends java.lang.Object
return sum;
}
/**
* Returns whether the specified attribute is selected.
* @param The index of the attribute to check.
* @return true if the attribute is selected; false otherwise.
*/
public boolean IsSelected(int index)
{
return selected[index];
}
public void SetAttributeId(int i)
/**
* Sets the attribute id, which is the id used in the Xfer object
* when transmitting this object to the remote process.
* @param id The new id
*/
public void SetAttributeId(int id)
{
attributeId = i;
attributeId = id;
}
/**
* Gets the attribute id, which is the id used in the Xfer object
* when transmitting this object to the remote process.
* @return The attribute id.
*/
public int GetAttributeId()
{
return attributeId;
}
/**
* Writes the object to a communication buffer, which is usually a
* socket headed for the remote process.
* @param buf The communication buffer to which the object will be written.
*/
public void Write(CommunicationBuffer buf)
{
if(NumAttributesSelected() == 0)
......@@ -153,6 +216,11 @@ public abstract class AttributeSubject extends java.lang.Object
WriteAtts(buf);
}
/**
* Reads the object from a communication buffer, which is usually a
* socket containing input from the remote process.
* @param buf The communication buffer from which the object will be read.
*/
public void Read(CommunicationBuffer buf)
{
// Make sure that no attributes are selected.
......@@ -165,17 +233,195 @@ public abstract class AttributeSubject extends java.lang.Object
ReadAtts(n, buf);
}
/**
* Selects the i'th attribute in the object so it will be transmitted
* to the remote process when written to the communication buffer.
* @param index The index of the attribute to be selected.
*/
protected void Select(int index)
{
selected[index] = true;
}
/**
* If the attribute is selected then its index is written to the
* communcation buffer.
* @param index The index of the attribute to be selected.
* @param buf Communication buffer
* @return true if the attribute needs to be written; false otherwise.
*/
protected boolean WriteSelect(int index, CommunicationBuffer buf)
{
if(selected[index])
buf.WriteByte((byte)index);
return selected[index];
}
}
// Methods that help in toString implementation.
protected String boolToString(String name, boolean val, String indent)
{
return indent + name + " = " + (val ? "true" : "false");
}
protected String intToString(String name, int val, String indent)
{
Integer iv = new Integer(val);
return indent + name + " = " + iv.toString();
}
protected String intArrayToString(String name, int[] val, String indent)
{
String s = indent + name + " = {";
for(int i = 0; i < val.length; ++i)
{
Integer iv = new Integer(val[i]);
s = s + iv.toString();
if(i < val.length - 1)
s = s + ", ";
}
s = s + "}";
return s;
}
protected String intVectorToString(String name, Vector val, String indent)
{
String s = indent + name + " = {";
for(int i = 0; i < val.size(); ++i)
{
s = s + val.elementAt(i).toString();
if(i < val.size() - 1)
s = s + ", ";
}
s = s + "}";
return s;
}
protected String floatToString(String name, float val, String indent)
{
Float iv = new Float(val);
return indent + name + " = " + iv.toString();
}
protected String floatArrayToString(String name, float[] val, String indent)
{
String s = indent + name + " = {";
for(int i = 0; i < val.length; ++i)
{
Float v = new Float(val[i]);
s = s + v.toString();
if(i < val.length - 1)
s = s + ", ";
}
s = s + "}";
return s;
}
protected String floatVectorToString(String name, Vector val, String indent)
{
String s = indent + name + " = {";
for(int i = 0; i < val.size(); ++i)
{
s = s + val.elementAt(i).toString();
if(i < val.size() - 1)
s = s + ", ";
}
s = s + "}";
return s;
}
protected String doubleToString(String name, double val, String indent)
{
Double iv = new Double(val);
return indent + name + " = " + iv.toString();
}
protected String doubleArrayToString(String name, double[] val, String indent)
{
String s = indent + name + " = {";
for(int i = 0; i < val.length; ++i)
{
Double v = new Double(val[i]);
s = s + v.toString();
if(i < val.length - 1)
s = s + ", ";
}
s = s + "}";
return s;
}
protected String doubleVectorToString(String name, Vector val, String indent)
{
String s = indent + name + " = {";
for(int i = 0; i < val.size(); ++i)
{
s = s + val.elementAt(i).toString();
if(i < val.size() - 1)
s = s + ", ";
}
s = s + "}";
return s;
}
protected String ucharToString(String name, byte val, String indent)
{
Byte iv = new Byte(val);
return indent + name + " = " + iv.toString();
}
protected String ucharArrayToString(String name, byte[] val, String indent)
{
String s = indent + name + " = {";
for(int i = 0; i < val.length; ++i)
{
Byte v = new Byte(val[i]);
s = s + v.toString();
if(i < val.length - 1)
s = s + ", ";
}
s = s + "}";
return s;
}
protected String ucharVectorToString(String name, Vector val, String indent)
{
String s = indent + name + " = {";
for(int i = 0; i < val.size(); ++i)
{
s = s + val.elementAt(i).toString();
if(i < val.size() - 1)
s = s + ", ";
}
s = s + "}";
return s;
}
protected String stringToString(String name, String val, String indent)
{
return indent + name + " = \"" + val + "\"";
}
protected String stringVectorToString(String name, Vector val, String indent)
{
String s = indent + name + " = {";
for(int i = 0; i < val.size(); ++i)
{
s = s + "\"" + val.elementAt(i).toString() + "\"";
if(i < val.size() - 1)
s = s + ", ";
}
s = s + "}";
return s;
}
public String toString(String indent)
{
return indent;
}
public String toString()
{
return toString(new String());
}
// Abstract methods.
public abstract void WriteAtts(CommunicationBuffer buf);
......
......@@ -48,7 +48,7 @@ package llnl.visit;
// Notes: Autogenerated by xml2java.
//
// Programmer: xml2java
// Creation: Fri Jan 25 16:52:22 PST 2008
// Creation: Mon Feb 25 15:14:55 PST 2008
//
// Modifications:
//
......@@ -228,6 +228,38 @@ public class Axes2D extends AttributeSubject
}
}
public String toString(String indent)
{
String str = new String();
str = str + boolToString("visible", visible, indent) + "\n";
str = str + boolToString("autoSetTicks", autoSetTicks, indent) + "\n";
str = str + boolToString("autoSetScaling", autoSetScaling, indent) + "\n";
str = str + intToString("lineWidth", lineWidth, indent) + "\n";
str = str + indent + "tickLocation = ";
if(tickLocation == LOCATION_INSIDE)
str = str + "LOCATION_INSIDE";
if(tickLocation == LOCATION_OUTSIDE)
str = str + "LOCATION_OUTSIDE";