|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.Observable
spv.spectrum.function.Function
public abstract class Function
One-dimensional analytic functions are handled by subclasses of this class.
A function stores internally a list of Parameter
objects, and is capable of expressing itself given an array of
independent variable values. It can also draw itself on screen
(not a plot, just an interactive list of parameters) and generate
a ID string that is unique for each object of the class.
A function has a read-only Units attribute, which
expresses the physical units in which its dependent values are
currently calculated. These units are dependent solely on the
units attributes of its parameters. The default units are the
standard units supplied by the Units class. Subclasses
can override this default units selection.
A function can be "moved to" some specific locus in a WCS space. The exact meaning of that operation is left for subclasses to define. The moving includes a possible change in physical units for both independent and dependent variables.
A Function object listens to update notifications
sent by its internal parameters and notifies its listeners in turn.
Thus it is both an observer and an observable. This feature can
be enabled/disabled at will.
Function instances support a "constrained" mode,
in which the instance parameters are constrained to another
instance's parameters.
| Field Summary | |
|---|---|
protected javax.swing.JPanel |
botton_panel
|
(package private) static java.lang.String |
CLASS_ATTRIBUTE
|
protected static int |
COMPONENT
|
protected java.lang.String |
description
|
private javax.swing.JDesktopPane |
desktop
|
protected static int |
EMPIRICAL
|
protected static java.text.NumberFormat |
form1
|
protected MemoryJFrame |
frame
|
static java.lang.String |
FUNCTION_ATTRIBUTE
|
protected javax.swing.JPanel |
gui
|
private static int |
INVALID_SERIAL_NUMBER
|
protected java.lang.String |
name
|
(package private) static java.lang.String |
NAME_ATTRIBUTE
|
protected boolean |
notify
|
(package private) static java.lang.String |
PARAMETER_LIST_ATTRIBUTE
|
private Function |
parent
|
private int |
parent_serial_number
|
(package private) static java.lang.String |
PARENT_SERIAL_NUMBER_ATTRIBUTE
|
protected KeyedVector |
pars
|
protected static int |
REDDENING
|
private Function |
self
|
private int |
serial_number
|
(package private) static java.lang.String |
SERIAL_NUMBER_ATTRIBUTE
|
private javax.swing.JTextField |
text
|
protected javax.swing.JPanel |
top_panel
|
protected int |
type
|
protected Units |
units
This may be overriden by subclasses if necessary. |
protected java.lang.String |
user_id
|
(package private) static java.lang.String |
USERID_ATTRIBUTE
|
| Fields inherited from interface spv.util.Constant |
|---|
DATA_MARKER, DMAX, DMIN, IINDEF, IMAX, IMIN, MODEL_ID, NORMALIZED_ID, RESIDUALS_ID |
| Constructor Summary | |
|---|---|
Function()
|
|
| Method Summary | |
|---|---|
void |
addParameter(Parameter par)
Adds a new parameter to the function, and sets the function as an Observer of the parameter. |
protected void |
addParameterGUI(int np)
Add GUIs from each parameter. |
abstract void |
addRawValues(double[] xvar,
double[] yvar)
Expresses the function over an array of independent variable values, and applies the computed values to the supplied array of dependent variable values. |
private void |
applyParameterValues()
|
java.lang.Object |
clone()
Returns a clone copy of this object. |
abstract void |
coarseAdjust(java.awt.geom.Rectangle2D.Double wcs,
XUnits xun,
YUnits yun,
double[] x,
double[] y)
Moves the function coordinates to within a WCS space. |
void |
constrainTo(Function parent)
Constrain a function to another. |
void |
dispose()
Disposes the GUI widget. |
void |
enableNotifications(boolean notify)
Sets/resets the notification capability. |
protected java.lang.String |
getDescription()
This method must be overriden by subclasses that want to provide a more verbose description to be used in places such as tool tips. |
protected java.awt.Dimension |
getFrameSize(int np)
Gets the frame size. |
abstract java.lang.String |
getID()
Gets the function ID. |
static int |
GetInvalidSerialNumber()
Returns a constant that signals that a serial number is not valid. |
java.lang.String |
getName()
|
int |
getNumberOfParameters()
Gets the total number of parameters. |
Parameter |
getParameter(int i)
Gets the i-th parameter. |
Parameter |
getParameter(java.lang.String id)
Gets the parameter specified by the given ID. |
Function |
getParent()
Returns the parent of this, when in constrained mode. |
int |
getParentSerialNumber()
Gets the parent's serial number. |
int |
getSerialNumber()
Gets the serial number. |
int |
getType()
Gets the type of this function. |
Units |
getUnits()
Gets the units. |
abstract double |
getValidRangeMaxLimit()
Returns the maximum value of the range of values of the independent variable where the function is valid. |
abstract double |
getValidRangeMinLimit()
Returns the minimum value of the range of values of the independent variable where the function is valid. |
void |
getWidget()
|
void |
getWidget(javax.swing.JDesktopPane desktop)
Gets a screen-representable form of the function. |
abstract boolean |
isEmission()
Returns true if this is a emission component,
false otherwise. |
(package private) abstract boolean |
isNarrow()
Returns true if this is a narrow band component,
false otherwise. |
boolean |
isShowing()
Tells if the GUI is showing on screen. |
void |
print(java.io.PrintWriter pw)
Write the contents of the function into a print stream. |
private void |
readText()
|
abstract void |
recenter(double x)
Recenters the function at the provided X coordinate. |
protected void |
refreshGUI()
Replaces the GUI by a new one. |
void |
release()
Releases (un-constrains) this function from its parent. |
protected Parameter |
removeParameter(int index)
Removes the parameter pointed by the index, and breaks the Observer link. |
void |
replaceParameterValue(Parameter par,
int i)
Replaces the i-th parameter value. |
void |
resetObservables()
This method reestablishes the observer-observable links that exist between the function and its parameters. |
void |
saveAsXML(org.w3c.dom.Document document,
com.sun.xml.tree.ElementNode parent_node)
Saves function as an XML element. |
protected void |
setChanged()
This exists only to provide access from within an anonymous class, since setChanged is a protected method. |
void |
setDefaultMode()
This method returns all parameters in the function to default mode. |
(package private) void |
setInternalLinks()
This method is called when a function instance is being re-constructed from a database file. |
void |
setParametersFromList(java.util.ArrayList list)
Sets all parameters for this function from a list. |
void |
setParentSerialNumber(int serial_number)
Sets the parent's serial number. |
void |
setParentSerialNumber(java.lang.Integer serial_number)
Sets the parent's serial number. |
void |
setSerialNumber(int serial_number)
Sets the serial number. |
void |
setUserID(java.lang.String userID)
sets the user ID string. |
protected void |
setValue(Parameter par,
double value)
This is a convenience method that sets a parameter value, even if the parameter is in fixed and/or constrained mode. |
java.lang.String |
toString()
Builds a string representation. |
void |
update(java.util.Observable p,
java.lang.Object a)
In the default implementation provided by the superclass this method simply passes the notification to listeners. |
| Methods inherited from class java.util.Observable |
|---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String FUNCTION_ATTRIBUTE
static final java.lang.String SERIAL_NUMBER_ATTRIBUTE
static final java.lang.String CLASS_ATTRIBUTE
static final java.lang.String NAME_ATTRIBUTE
static final java.lang.String USERID_ATTRIBUTE
static final java.lang.String PARENT_SERIAL_NUMBER_ATTRIBUTE
static final java.lang.String PARAMETER_LIST_ATTRIBUTE
protected static final int COMPONENT
protected static final int REDDENING
protected static final int EMPIRICAL
private static final int INVALID_SERIAL_NUMBER
protected java.lang.String name
protected java.lang.String description
protected int type
protected java.lang.String user_id
protected KeyedVector pars
protected boolean notify
protected javax.swing.JPanel gui
protected javax.swing.JPanel top_panel
protected javax.swing.JPanel botton_panel
private javax.swing.JDesktopPane desktop
protected MemoryJFrame frame
private javax.swing.JTextField text
private int serial_number
private int parent_serial_number
private Function parent
private Function self
protected static final java.text.NumberFormat form1
protected Units units
| Constructor Detail |
|---|
public Function()
| Method Detail |
|---|
public static int GetInvalidSerialNumber()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getName()
protected java.lang.String getDescription()
public int getType()
public int getNumberOfParameters()
public Units getUnits()
public Parameter getParameter(int i)
i - the index
Parameter object, or
null if the index is invalid.public Parameter getParameter(java.lang.String id)
Function
object. The reason is that this method of parameter retrieval
will be used, most likely, only by the parameter expression
evaluator using user-typed parameter IDs. So the code will
have no need to know parameter IDs.
id - the ID
Parameter object, or
null if the ID is invalid.public int getSerialNumber()
Serial numbers are auxiliary quantities useful in the process of assembling a collection of functions. They are not used by the functions themselves.
Serial numbers are 1-indexed.
public void setSerialNumber(int serial_number)
serial_number - the serial numberpublic int getParentSerialNumber()
public void setParentSerialNumber(int serial_number)
serial_number - the parent's serial numberpublic void setParentSerialNumber(java.lang.Integer serial_number)
serial_number - the parent's serial numberpublic void setUserID(java.lang.String userID)
userID - the user ID stringpublic void enableNotifications(boolean notify)
notify - if true, listeners are notifiedpublic void getWidget(javax.swing.JDesktopPane desktop)
public void getWidget()
private void readText()
private void applyParameterValues()
protected java.awt.Dimension getFrameSize(int np)
np - the number of parameters
protected void addParameterGUI(int np)
np - the number of parameterspublic void print(java.io.PrintWriter pw)
pw - the stream to write to
public void saveAsXML(org.w3c.dom.Document document,
com.sun.xml.tree.ElementNode parent_node)
document - the document where to save the functionparent_node - the parent element where to save the functionprotected void refreshGUI()
public void dispose()
public void addParameter(Parameter par)
Observer of the parameter.
par - the parameter to addprotected Parameter removeParameter(int index)
Observer link.
index - the index of the parameter to remove
public void setParametersFromList(java.util.ArrayList list)
Function instances.
list - the list with Parameter objects
public void replaceParameterValue(Parameter par,
int i)
par - the Parameter object with the new valuei - the index
protected void setValue(Parameter par,
double value)
throws OutOfRangeFunctionException
coarseAdjust method.
par - the parameter to be changedvalue - the new value
OutOfRangeFunctionExceptionpublic void setDefaultMode()
Subclasses override this method in case custom behavior is required.
public void constrainTo(Function parent)
throws FunctionException
Parameters of this are constrained on an individual basis against matching parameters of the parent component. The matching criterion is the parameter name.
Constrained parameters are set to fixed mode.
parent - the parent instance to constrain to
FunctionExceptionpublic void release()
public Function getParent()
null if not
constrained.public void resetObservables()
Observable does not implement
Serializable. Thus this method must be called
for every function that gets deserialized.
public boolean isShowing()
true if the GUI is showingvoid setInternalLinks()
The superclass provides a default implementation (do nothing). Subclasses must override this as required.
public abstract void addRawValues(double[] xvar,
double[] yvar)
Function subtypes enables
the building of multi-component models with both emission
(additive) and absorption (multiplicative transparency)
components. It is up to each subclass to decide how exactly
it should act on the dependent variable array.
No checking for Constant.INDEF input values is
performed.
xvar - array with the independent variable valuesyvar - on input: array with the dependent variable values.
on output: array with the updated dependent variable
valuespublic abstract java.lang.String getID()
public abstract void coarseAdjust(java.awt.geom.Rectangle2D.Double wcs,
XUnits xun,
YUnits yun,
double[] x,
double[] y)
null.
wcs - a rectangle that defines the WCSxun - units of independent variableyun - units of dependent variablex - array with independent variable valuesy - array with dependent variable valuespublic abstract void recenter(double x)
x - the new centerpublic abstract double getValidRangeMinLimit()
INDEF.
public abstract double getValidRangeMaxLimit()
INDEF.
public abstract boolean isEmission()
true if this is a emission component,
false otherwise.
true if this is a emission component,
false otherwiseabstract boolean isNarrow()
true if this is a narrow band component,
false otherwise.
true if this is a barrow band component,
false otherwise
public void update(java.util.Observable p,
java.lang.Object a)
Parameter object must override this
method to perform the required acivities and them end the
method with a call to the superclass:
super.update (p, a);
update in interface java.util.Observerp - the object that sent the notificationa - the object sent as a notification messageprotected void setChanged()
setChanged is a protected method.
setChanged in class java.util.Observable
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||