Routed Systems Designer
Example Java Classes
February 2003
The description about how the classes are loaded and called
is given in the Routed Systems Designer Manual, under the section: About the Java User Interface Extension.
Class CheckConnection
implements rsdesigner.uiextension.Connection
Methods:
canConnectBetween
postConnect
Class ExampleValidateProperties
implements
rsdesigner.uiextension.ValidateProperties
Methods:
canSet
Class ExampleUpdateProperties
implements
rsdesigner.uiextension.UpdateProperties
Methods:
update
This class provides methods to check two situations: firstly whether connections can be made between (or to) objects and also to set extra properties when a connection has been made.
The canConnectBetween method is used to check whether a
connection can be made between two objects. It returns a Boolean, where true means that the connection is
allowed. The canConnectBetween method in the supplied example will
check to see if the FibreShape that is being used to connect the
Shapes has the name Purple_Wire.
If it does then the example will only allow connection between the shapes if it
the date is such that the moon is new.
The postConnect method is used to modify the properties of objects that are connected (either using a fiber or direct connections between components). The postConnect method in the supplied example will check set the max_current property of the fiber that connects two components. The value of max_current will be the maximum of the max_current properties on the components. It is possible that neither of the components have the property max_current, in which case the getValue call for each will return 0.0, in which case the max_current property will not be set.
This class provides the method canSet and is used to determine
if a set of properties can be applied to a newly created Artifact. The example
in the ExampleValidateProperties class will first list the set of
properties that are to be set, along with their type and value. It will
subsequently perform an example check: if the object to be created is a fiber
then the example will check that the fiber is of type CONNECTION!WIRE!WIRING_WIRE and the property min_bend_radius is set. If the
supplied min_bend_radius
is less that 2.0 then the method returns false, with the message "Cannot
set this min_bend_radius". The method returns a Boolean,
if the returned value is false then a message explaining why the validation
failed can be included by using properties.setMessage.
This class provides the method update that allows the setting of properties on an Artifact after it has been created. It is useful for adding extra properties, such as a timestamp of when the object was created, or who created it. The example method checks whether the newly-created component has a property category and, if so, whether its value is "lamps". If that is the case the method adds the properties model (with value "softone") and description (with value "flashing monochrome"). This method demonstrates the techniques for querying the Properties class