Create a new Isight project called Area as described
in Creating an Eclipse Project to Store the Extension.
When the Isight Project Templates screen appears
on the New Project wizard, select the Example
/ Area Component template.
This template is used to create the simple component.
Once you have completed creating the extension, generate a .jar
file so that you can view it in Isight as described in Packaging Your Extension for Use in Isight.
Publish the component to your Isight library, and open it in the Design
Gateway. For more information, see Publishing Objects to the Isight Library in the Isight User’s Guide.
The component editor should appear as shown below.
If necessary, re-open the extension’s project in Eclipse.
Now you’ll alter the component to calculate the “volume” value
in addition to the “area” value.
Using the Project Explorer, navigate to the following
location:
\src\com\company\component\volume
Double-click the Common.java file.
The file’s contents appear in a new tab on the right side of the Isight
Developer Perspective.
Add the following two lines to the file:
public static final String TAG_DEPTH = "Depth";
public static final String TAG_VOLUME = "Volume";
Double-click the AreaEditor.java file.
The file’s contents appear in a new tab on the right side of the Isight
Developer Perspective.
Edit the AreaEditor.java file, as follows:
-
Immediately following the two existing private JTextField
entries, add a new entry called depthField.
-
Add the following entries to the open method:
Value dVal = getScalarValueByTag(Common.TAG_DEPTH);
Double d = dVal.getAsReal()
depthField.setText(d.toString());
-
Add the following entries to the apply method:
Value dVal = getScalarValueByTag(Common.TAG_DEPTH);
double d = Double.parseDouble(depthField.getText());
dVal.setValue(d)
-
Locate the existing JLabel entries.
-
In the appropriate locations, add the following entries:
JLabel depthLabel = new JLabel("Depth: ");
depthField = new JTextField(10);
depthField.getDocument().addDocumentListener(new NumberDocumentValidator(depthField));
-
Immediately below the JLabel entries, change GridLayout(2,2)
to GridLayout(3,2).
-
Below the existing add entries, add the following entries:
add(depthLabel)
add(depthField)
Double-click the AreaExecutor.java file.
The file’s contents appear in a new tab on the right side of the Isight
Developer Perspective.
Add the following entries to the execute method:
ScalarVariable depthVar = runEnv.getScalarPropertyByTag(Common.TAG_DEPTH);
ScalarVariable volumeVar = runEnv.getContext().getScalarByTag(Common.TAG_VOLUME);
double d = depthVar.getValueObj().getAsReal();
volumeVar.getValueObj().setValue(h * w * d);
On the Isight Project Editor tab on the right
side of the Isight Developer Perspective, click the Overview
tab.
Update the following settings for the modified component:
-
At the end of the com.company.component string in the
Name text box, replace the existing entry (Area)
with Volume.
-
In the Display Name text box, replace the existing
entry (Area) with Volume.
Click to save your changes to the extension.
Create a .jar file for the updated component as described
in Packaging Your Extension for Use in Isight.
Publish the component’s .jar file to your Isight
library, and open it in the Design Gateway. For more information, see
Publishing Objects to the Isight Library in the Isight User’s Guide.
The component editor should now contain a new text box for entering
the Depth value and allow you to calculate the
value of the Volume parameter.