[ main | data | draw | functions | awt | applets ]

WCM
Packages net.sourceforge.webcompmath.*.beans



This page discusses the more useful Java classes in the packages net.sourceforge.webcompmath.*.beans, which is part of the WCM project. The full API can be found in the JavaDoc documentation. JavaBeans is a specification for creating reusable Java components. One common use is to enable GUI builder tools, such as Eclipse Visual Editor (VE) to introspect a class and learn about properties of the bean that a designer of a GUI can get and set via property editors at design time. The *.bean classes in WCM extend the base WCM classes to enhance them to meet the JavaBeans specification. In particular, setter and getter methods are supplied that meet the JavaBeans specification and hence can be used by GUI builder tools like VE. The WCM bean classes also attempt to hide more of the infrastructure of WCM (e.g., controllers and error reporters) from the designer, allowing many applets to be build without the designer writing any Java code at all. Some bean classes do very little to enhance their base class, since many of the base WCM classes already adhered to the JavaBeans specification. However, some base WCM classes used other names for methods, or used add() to connect two classes together in a way not supported by JavaBeans. The WCM bean classes provide new getter/setter methods in these cases to allow property editors in GUI builders to manipulate the beans.


class net.sourceforge.webcompmath.awt.beans.WCMPanelBean

The WCMPanelBean is the foundation for building WCM JavaBeans. Like WcmPanel, it should be the base panel for your applet, and any WCM objects that you add via a GUI builder should be added inside a WCMPanelBean. You can nest WCMPanelBeans, just like you can next WcmPanels (but note that WCMPanelBean subclasses JPanel directly; it does not subclass WcmPanel). WCMPanelBean manages controllers by building a tree of controllers that mirror the tree of WCMPanelBeans, and it connects these controllers together, as well as connecting any InputObjects and Computables added to one of the WCMPanelBeans. When a computation is triggered, the entire tree is activated, making it appear as if there is only one single controller for the applet. WCMPanelBeans also manage ErrorReporters by using the firect WCMDisplayCanvasBean added to the applet as the output location for errors. If no WCMDisplayCanvasBean is added, then a popup error reported is used instead. 

Ties are not handled automatically. You need to create a WCMTieBean and add it to the top-level WCMPanelBean via a set method. You can set up to three WCMTieBeans in this manner; if you need more, you will have to add them via hand coding. 

classes net.sourceforge.webcompmath.data.beans.*

The WCMParserBean class provides a way to add a parser to an applet and the set its options and add named objects to it. The options get set at design time via property editor fields in a GUI builder. Currently you can only set them true, you cannot set them to false (this is only relevant to the Boolean and Standard Functions properties, as these are the only two that are true by default for a new Parser). You can also added named objects to the WCMParserBean so that they can be referenced by their names in expressions. You can add any object that implements the ParserMathObject interface, which currently includes WCMVariableBean, WCMExpressionInputBean, WCMExpressionFunctionBean, WCMVariableInputBean, WCMVariableJSliderBean, or WCMConstantBean. Unlike a Parser, a WCMParserBean can handle a change of name in one of its ParserMathObjects (this is required because the code generated by a GUI builder might add a ParserMathObject to a WCMParserBean before the code that actually sets the ParserMathObject's name). The WCMConstantBean subclasses Constant, but does little enhancement. The WCMVariableBean (which subclasses Variable) is also one that you commonly give a name (e.g., "x"), add to your applet, then set into a WCMParserBean so that expressions can be written that reference the variable. WCMValueMathBean subclasses ValueMath and works just like it.

Like net.sourceforge.webcompmath.data, the classes in net.sourceforge.webcompmath.data.beans do not reference any WCM classes outside of their package (but obviously do import classes from net.sourceforge.webcompmath.data).

classes net.sourceforge.webcompmath.awt.beans.*

These beans include: WCMAnimatorBean, WCMComputeButtonBean, WCMDataTableInputBean, WCMDisplayLabelBean, WCMExamplesBean, WCMExpressionInputBean, WCMFunctionLabelBean, WCMPanelBean (described above), WCMTieBean, WCMVariableInputBean, and WCMVariableJSliderBean. Most of these are straightforward extensions of their corresponding base WCM classes. Some, such as WCMAnimatorBean, provide get/set methods for properties that are set in the base class via a bit string, so that GUI builder tools can expose the properties to the designer. Some also include default initialization beyond what is done in the base class, in order to avoid code order dependencies that might get create by the GUI builder (e.g. a GUI builder adds a bean to a WCMPanelBean before any of its properties are set; this might cause errors unless the bean has enough of its properties initialized to some default values).

The WCMDisplayTableBean is a restricted version of the base DisplayTable class. This makes it simpler to set properties and values in a GUI builder, but does limit the capabilities. It currently supports only two columns. If you need more columns, need to manually initialize the table, access row or column variables outside of a parsed expression, or read data from a file into the table, then you will need to hand-code method calls to the superclass DataTableInput.

The WCMExpressionInputBean is aimed at handling the most common case (an ExpressionInput representing a function's definition). This class extends ExpressionInput but then decorates it with Function, ParserExtension, and ExpressionCommand features. Hence you can set the function property of a WCMGraph1DBean to this class, since this class implements Function. You can also add an instance of this class to a WCParserBean, since this class implements ParserExtendion and ParserMathObject.

WCMFunctionLabelBean extends JLabel and just provides a convenient way to prepend some text to the definition of a function when displaying it. For example, if a function is defined as "x^2", and you point the WCMFunctionLabelBean at this function and set the prefix text string to "f(x) = ", the label will display "f(x) = x^2".

WCMExamplesBean provides a way to build configurable applets. You build a template for the examples using addTemplateElement(Object o, String methodName, int type). For each element you specify the object in your applet that will be modified by an example, the name of the method to call, and the data type of the argument to be passed to that method. You can then define examples either using the getExample(int i) method, set examples using the Example0, Example1, etc. properties in a GUI builder like Eclipse VE, or load the examples from applet params with loadAppletExamples(JApplet applet). WCMExamplesBean is a WCMPanelBean that has a load button (which is optional) and a JComboBox.

classes net.sourceforge.webcompmath.draw.beans.*

These beans include: WCMAxesBean, WCMAxisTickBean, WCMCrossHairBean, WCMDisplayCanvasBean, WCMDraggablePointBean, WCMDrawGometricBean, WCMDrawStringBean, WCMGraph1DBean, WCMGridBean, WCMLimitControlPanelBean, WCMMouseTrackerBean, WCMMouseVariableBean, WCMPannerBean, WCMParametricCurveBean, WCMPolarCurveBean, WCMRiemannSumRectsBean, WCMScatterPlotBean, WCMTangentLineBean, and WCMVectorFieldBean. Most are a simple subclass of the corresponding base WCM class, providing little or no enhancements. Some, like WCMDrawStringBean, use a fixed number of set methods to set certain parameters (for WCMDrawStringBean, it has setters for up to four values); if you need more of this type of parameter, you will have to hand-code calls to the base class methods.

WCMLimitControlPanelBean is another example of this issue, in that it supports only three WCMDisplayCanvasBeans; if you need more, you will have to hand-code calls to methods in the superclass. This bean also exposes the button options as properties. Like WCMParserBean, you can only set an option to true; setting it to false has no effect. WCMLimitControlPanelBean also allows you to add the tmin, tmax, and tintervals fields for a parametric curve via setParametricFields(boolean) and the various setParametricCurve1(WCMParametricCurveBean) methods. You can also get Value objects associated with these fields. The saveParams() and restoreParams() methods enable you to manage the restore buffer for these fields (they are not handled automatically by the LimitControlPanel when the user clicks a Restore Limits button).

The WCMMouseVariableBean class is used with WCMMouseTrackerBeans and WCMDraggablePointBeans, After dropping a WCMMouseTrackerBean or a WCMDraggablePointBean on a canvas, you can access it's x and y variables by creating a WCMMouseVariableBean and setting its Mouse property (and optionally it's AxisDirection property, which defaults to the x axis). Once set up, you can use this anywhere you would normally use a variable (e.g., in a WCMDrawStringBean, add it to a WCMParserBean, etc.).

WCMScatterPlotBean graphs the points in a WCMDataTableInputBean. It can plot the data in the first two columns.. You can optionally show the regression line. If you want to plot expressions of the column values, instead of just the columns themselves, you will need to hand-code method calls to ScatterPlot. Also, if you want to obtain various statistical values, you also need to hand code method calls to ScatterPlot.

WCMIntegralCurveBean plots the solution to a pair of differential equations. You can set one of the equations to "1" to plot the solution to a single differential equation. This bean supports both Euler's method and Runge-Kutta, and you can specify the color, line width, and dashed/solid style of the curve to be graphed.

WCMAxisTickBean enables you to draw a tick mark with an optional label on either the x or y axis. You specify the location of the tick mark with setCoord(Value v)and specify which axis with setXAxis(boolean b).

WCMTangentLineBean provides support for both functions of one variable and parametric functions.

WCMPolarCurveBean is an extension of WCMParametricCurveBean. You define a function of one variable, which is interpreted as r(θ). The class then sets the appropriate parametric equations to enable the curve to be graphed.

classes net.sourceforge.webcompmath.functions.beans.*

These beans include: WCMDerivativeBean, WCMExpressionFunctionBean, WCMTableFunctionBean, and WCMTableFunctionGraphBean.

WCMExpressionFunctionBean extends ExpressionFunction. You need to set its definition before it will do anything. By default, it uses a default parser with one variable, "x". If you want to use more variables in the definition, or if you need to use the value of "x" somewhere else in your applet, set the parser to one that has those additional variables set for it (plus "x"). You can use this bean as either an expression, where it is just evaluated at the current values of any parameters in it, or as a function (and hence you can graph it by adding it to a WCMGraph1DBean). If you add this bean to a parser, you can then use it like a function (change the default name if you would like something other than "ef1").

WCMDerivativeBean (which is a subclass of WrapperFunction) is a new class used to create an object that is the derivative of some function. When you set it's function, it gets the derivative of the function you pass in and uses that as it's own definition.

WCMTableFunctionBean implements a TableFunction. It supports only the addIntervals method of adding points, via bean properties. If you wish to add explicit points other than via intervals, you should call removeAllPoints() and then add points directly via method calls to TableFunction.

[ main | data | draw | functions | awt | applets ]