[kepler-dev] Dynamicalling adding properties (attributes) to the relation ......
Christopher Brooks
cxh at eecs.berkeley.edu
Mon Jun 6 17:59:48 PDT 2005
Hi,
I might be misunderstanding the question, but I don't see the bug in
Ptolemy II 5.0-beta.
I put your code in to ptolemy/actor/lib/JTypedCompositeActor.java
I had to modify the top part:
--start--
package ptolemy.actor;
import ptolemy.kernel.util.*;
import ptolemy.kernel.*;
import ptolemy.data.expr.*;
public class JTypedCompositeActor extends TypedCompositeActor{
--end--
I then modified $PTII/ptolemy/configs/basicActorLibrary.xml
and added
<entity name="JComposite Actor" class="ptolemy.actor.JTypedCompositeActor">
</entity>
When I compile the JTypedCompositeActor class and start up vergil,
the JComposite Actor icon is present in vergil.
File -> New -> Graph
Drag the JComposite Actor into the graph editor
Add a Const and a Display
Connect the Const and Display
Right click on the background of the graph editor, I can change the
relation parameter.
The resulting model is below:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE entity PUBLIC "-//UC Berkeley//DTD MoML 1//EN"
"http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd">
<entity name="relation2" class="ptolemy.actor.TypedCompositeActor">
<property name="_createdBy"
class="ptolemy.kernel.attributes.VersionAttribute"
value="5.0-beta">
</property>
<property name="_windowProperties"
class="ptolemy.actor.gui.WindowPropertiesAttribute"
value="{bounds={104, 125, 815, 518}, maximized=false}">
</property>
<property name="_vergilSize"
class="ptolemy.actor.gui.SizeAttribute" value="[600, 400]">
</property>
<property name="_vergilZoomFactor"
class="ptolemy.data.expr.ExpertParameter" value="1.0">
</property>
<property name="_vergilCenter"
class="ptolemy.data.expr.ExpertParameter" value="{300.0, 200.0}">
</property>
<entity name="JComposite Actor"
class="ptolemy.actor.JTypedCompositeActor">
<property name="_location"
class="ptolemy.kernel.util.Location" value="{160.0, 125.0}">
</property>
<property name="relation"
class="ptolemy.data.expr.StringParameter" value="foo">
</property>
<property name="_windowProperties"
class="ptolemy.actor.gui.WindowPropertiesAttribute"
value="{bounds={104, 125, 815, 518}, maximized=false}">
</property>
<property name="_vergilSize"
class="ptolemy.actor.gui.SizeAttribute" value="[600, 400]">
</property>
<property name="_vergilZoomFactor"
class="ptolemy.data.expr.ExpertParameter" value="1.0">
</property>
<property name="_vergilCenter"
class="ptolemy.data.expr.ExpertParameter" value="{300.0,
200.0}">
</property>
<entity name="Const" class="ptolemy.actor.lib.Const">
<doc>Create a constant sequence.</doc>
<property name="_icon"
class="ptolemy.vergil.icon.BoxedValueIcon">
<property name="attributeName"
class="ptolemy.kernel.util.StringAttribute"
value="value">
</property>
<property name="displayWidth"
class="ptolemy.data.expr.Parameter" value="60">
</property>
</property>
<property name="_location"
class="ptolemy.kernel.util.Location" value="{240, 135}">
</property>
</entity>
<entity name="Display" class="ptolemy.actor.lib.gui.Display">
<property name="_windowProperties"
class="ptolemy.actor.gui.WindowPropertiesAttribute">
</property>
<property name="_location"
class="ptolemy.kernel.util.Location" value="{320, 180}">
</property>
</entity>
<relation name="relation"
class="ptolemy.actor.TypedIORelation">
</relation>
<link port="Const.output" relation="relation"/>
<link port="Display.input" relation="relation"/>
</entity>
</entity>
What behavior are you expecting to see?
_Christopher
--------
Hello Edward,
I have made the following changes for creating property to the relation
and I worked before, and it not working now,
Could you mind to advise please?.
1. I did subclass the TpedCompisiteActor and I have overridden
newRelation method which is as floows,
==========================================================================
package griddles;
//////////////////////////////////////////////////////////////////////////
//// JTypedCompositeActor
public class JTypedCompositeActor extends TypedCompositeActor{
public JTypedCompositeActor() {
super();
}
public JTypedCompositeActor(Workspace workspace) {
super(workspace);
}
public JTypedCompositeActor(CompositeEntity container, String name)
throws IllegalActionException, NameDuplicationException {
super(container, name);
}
public ComponentRelation newRelation(String name) throws
NameDuplicationException {
try {
workspace().getWriteAccess();
TypedIORelation relation = new TypedIORelation(this, name);
StringParameter param = new StringParameter(this, name);
param.setExpression("Enter "+name);
return relation;
}
catch (IllegalActionException ex) {
// This exception should not occur, so we throw a runtime
// exception.
throw new InternalErrorException(this, ex, null);
}
finally {
workspace().doneWriting();
}
}
}
===========================================================================
===
2. I made the following changes to the configuration file,
basicKeplerActorLibrary.xml
<entity name="Composite Actor" class="griddles.JTypedCompositeActor">
<property name="entityId"
class="org.ecoinformatics.seek.util.NamedObjId"
value="urn:lsid:ecoinformatics.org:kepler.118.1"/>
</entity>
3. I checked the new configuration file that was loaded while running
kepler has loaded the updated configuration file,
[java] *sys-package-mgr*: processing modified jar,
'C:\kepler\build\kepler-configs.jar'.
4. When I connect two actors with a relation, I am not able see any new
property that was created in the JTypedCompositeActor.
5. Whereas when I do same thing few months back I was able to see
property when ever I create new relation.
with regards,
Jagan Kommineni
Edward A. Lee wrote:
>
> The easiest way to do this, I think, would be to subclass
> TypedCompositeActor and override the newRelation() method to
> return a relation that contains the parameter you are interested in.
> You would then want to create a new configuration that uses
> your subclass rather than TypedCompositeActor.
>
> Edward
>
> At 12:12 PM 12/22/2004 +1100, jagan wrote:
>
>> References: <200412211640.iBLGeCRR028721 at maury.eecs.berkeley.edu>
>> <1103669339.6784.174.camel at kyoto>
>> In-Reply-To: <1103669339.6784.174.camel at kyoto>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>> Content-Transfer-Encoding: 7bit
>>
>> Hi Ilkay, Christpher,
>>
>> Would you mind to give me some information for adding
>> properties (attributes) to the relation at the time when actrs
>> connecting graphically. I know it is possible to add properties
>> dynamically by right clicking during the design phase. In the GriddLeS
>> project I need to pass some information which is more integrated to
>> the relation rather than actor. I want this happen automatically when
>> user tries to connect actors. I will appreciate if you could give some
>> clues in this aspect.
>>
>> with regards,
>>
>> Jagan Kommineni
>>
>>
>> _______________________________________________
>> kepler-dev mailing list
>> kepler-dev at ecoinformatics.org
>> http://www.ecoinformatics.org/mailman/listinfo/kepler-dev
>
>
> ------------
> Edward A. Lee, Professor
> 518 Cory Hall, UC Berkeley, Berkeley, CA 94720
> phone: 510-642-0455, fax: 510-642-2718
> eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal
>
> _______________________________________________
> kepler-dev mailing list
> kepler-dev at ecoinformatics.org
> http://www.ecoinformatics.org/mailman/listinfo/kepler-dev
--------
More information about the Kepler-dev
mailing list