Class cern.lhcias.csgui.Utils.dgslStatement
java.lang.Object
|
+----cern.lhcias.csgui.Utils.dgslStatement
- public class dgslStatement
- extends Object
This class is able to interpret a set of dgsl statements which are connected to
a parameter of a dgsl command. Such statements are in the form of "data streams"
- input data streams are typically used to change one of the parameters of the dgsl
command according to values contained in a "TagArrays"
- ouput data streams are typically used to affect TagArrays according to some user
action on the dgsl object created by the dgls command.
Data stream syntax:
data_stream
- data_stream, data_stream,
data_stream
- [input_data_stream]
- [output_data_stream]
input_data_stream
- $name
- $(condition;statement;[validity])
output_data_stream
- @name
- @([condition];name=statement;[validity])
- @([condition];name;[validity])
condition
- statement returning a boolean
- default
statement
validity
- l1, l2,
list of possible values
- low-high
Examples:
a/ $d1
b/ $(default;$d1+3;)@d2
c/ $($d1<5;$d2+20;)$(default;100;)
b/ @($d5==1;d4=$input+$d6;)@d7$(default;100;)@($d1<5;d7;1,2,3)@(;d8=$input1+$input;)
COLOR
-
DOUBLE
-
FONT
-
IMAGE
-
INTEGER
-
LONGESTSTATEMENT
-
MAXSTREAM
-
SOUND
-
STRING
-
dgslStatement(int,
String, TagArrays)
- Same as the other constructor but whitout the possibility to retrieve the parameter as
an image or as a sound
dgslStatement(int,
String, TagArrays, String, Panel)
-
find_colors(String)
Given a color as a string, it returns the color as java.awt.Color
Possible string colors are:
white, blue, red, green, black, grey, yellow, orange, magenta
or #RRGGBB (in hexa)
find_font(String)
- Given a font as a string, it returns the font as java.awt.Font
Possible string fonts are:
small, large
or fontname or fontname|fontsize (ex: Serif|18)
get_load_value()
- if an error happens during the evaluation of the parameter or during
the setting of one of
the variables used in the parameter, then the method returns false.
getColorValue()
- the method will return the evaluated value as a java.awt.Color It assumes a call to
get_load_value has been made.
getDoubleValue()
- the method will return the evaluated value as a double.
getFontValue()
- the method will return the evaluated value as a java.awt.Font It assumes a call to
get_load_value has been made.
getImageValue()
- the method will return the evaluated value as a java.awt.Image It assumes a call to
get_load_value has been made.
getInput_params()
- This method returns the list of variables starting with "input" present in the
parameter.
getIntValue()
- the method will return the evaluated value as an int.
getOutputStreamNb()
- returns the number of output streams present in the parameter
getOValidity()
- returns the validity String.
getSoundValue()
- the method will return the evaluated value as a symantec.itools.multimedia.SoundPlayer
It assumes a call to get_load_value has been made.
getStringValue()
- the method will return the evaluated value as a String It assumes a call to
get_load_value has been made.
getTagNames()
- This method returns the list of the variables (tags) in the parameter.
getTagNamesAsVector()
- This method returns the list of the variables (tags) in the parameter.
getType()
- returns the type of the parameter.
isConstant()
- if the parameter doesn't contain any variable, it will return true.
replaceTags(String,
Vector, TagArrays)
Given a string containing variables such as (3.1+$d1/2*(3+$d4)), it will
replace the variables in the string by their values.
setValues(Vector)
- If there are any output stream, this method will evaluate the streams and send the
result to the tc TagArrays.

MAXSTREAM
public static final int MAXSTREAM

LONGESTSTATEMENT
public static final int LONGESTSTATEMENT

INTEGER
public static final int INTEGER

DOUBLE
public static final int DOUBLE

STRING
public static final int STRING

COLOR
public static final int COLOR

IMAGE
public static final int IMAGE

SOUND
public static final int SOUND

FONT
public static final int FONT

dgslStatement
public dgslStatement(int Type,
String param,
TagArrays ta,
String ImageURL,
Panel Pa)
- Parameters:
- Type - defines the type of the parameter. It can take one of the following value:
INTEGER DOUBLE STRING COLOR IMAGE SOUND FONT
- param - contains the statements
- tc - is the TagArrays from where to take the values of the variables contained in the
input streams and where to send the output streams.
- ImageURL - is used as the Image Base location to get the images and the sounds from
- Pa - is used to retrieve the images.

dgslStatement
public dgslStatement(int Type,
String param,
TagArrays ta)
- Same as the other constructor but whitout the possibility to retrieve the parameter as
an image or as a sound

find_colors
public static Color find_colors(String colorstr)
Given a color as a string, it returns the color as java.awt.Color
Possible string colors are:
white, blue, red, green, black, grey, yellow, orange, magenta
or #RRGGBB (in hexa)

find_font
public static Font find_font(String fontstr)
- Given a font as a string, it returns the font as java.awt.Font
Possible string fonts are:
small, large
or fontname or fontname|fontsize (ex: Serif|18)

replaceTags
public static String replaceTags(String ligne,
Vector Values,
TagArrays tc)
Given a string containing variables such as (3.1+$d1/2*(3+$d4)), it will
replace the variables in the string by their values.
If d1 holds 2.3 and d4 holds 1, then it will return something like
(3.1+2.3/2*(3+1))
The values can be passed to the method in the Values Vector. The vector
contains n couples of string: one couple consists of the name of the variable
and its value. Ex: Values may contain {d1,2.3,d4,1}
If the variable is not found in the Vector, the method will attempt
In case of failure, a null is returned.

getTagNames
public String getTagNames()
- This method returns the list of the variables (tags) in the parameter.
The names of the variables are separated by commas in the returned String.
ex: d1,d2,d3

getTagNamesAsVector
public Vector getTagNamesAsVector()
- This method returns the list of the variables (tags) in the parameter.

getType
public int getType()
- returns the type of the parameter. The type is one of the following constant: (final
static int) INTEGER DOUBLE STRING COLOR IMAGE SOUND FONT

isConstant
public boolean isConstant()
- if the parameter doesn't contain any variable, it will return true.
In the other case, it will return false.
Ex: (1+$d1) -> false
32 -> true
(32+2) -> true

get_load_value
public boolean get_load_value()
- if an error happens during the evaluation of the parameter or during
the setting of one of
the variables used in the parameter, then the method returns false.
If all the variables are correctly set or if the parameter
is constant, then it returns true.
This method must absolutely be called prior to get the evaluated
value of the parameter with one of the getXXXValue

getIntValue
public int getIntValue()
- the method will return the evaluated value as an int. It assumes a call to
get_load_value has been made.

getDoubleValue
public double getDoubleValue()
- the method will return the evaluated value as a double. It assumes a call to
get_load_value has been made.

getStringValue
public String getStringValue()
- the method will return the evaluated value as a String It assumes a call to
get_load_value has been made.

getColorValue
public Color getColorValue()
- the method will return the evaluated value as a java.awt.Color It assumes a call to
get_load_value has been made.

getFontValue
public Font getFontValue()
- the method will return the evaluated value as a java.awt.Font It assumes a call to
get_load_value has been made.

getImageValue
public Image getImageValue()
- the method will return the evaluated value as a java.awt.Image It assumes a call to
get_load_value has been made.

getSoundValue
public SoundPlayer getSoundValue()
- the method will return the evaluated value as a symantec.itools.multimedia.SoundPlayer
It assumes a call to get_load_value has been made.

getOutputStreamNb
public int getOutputStreamNb()
- returns the number of output streams present in the parameter

getInput_params
public Vector getInput_params()
- This method returns the list of variables starting with "input" present in the
parameter. It returns this list in the form of a Vector of Strings.

setValues
public void setValues(Vector Values)
- If there are any output stream, this method will evaluate the streams and send the
result to the tc TagArrays. The variables values can be passed to the method in the Values
Vector.
The vector contains n couples of string: one couple consists of the name of the variable
and its value. Ex: Values may contain {d1,2.3,d4,1}
If the variable is not found in the Vector, the method will attempt to retrieve it from
the tc TagArrays (if tc is not null).

getOValidity
public String getOValidity()
- returns the validity String. If the validity string contains a variable, it will be
replaced first by the content of this variable