Bug #5266
closedTwo empty boxes inside Sinewave actor and other icon problems for attributes
0%
Description
While testing http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5146 , this bug was found.
From the Reporting suite, if you drag a Sinewave actor to canvas, and then right-click Open Actor to see the insides of the composite, you'll see two blank boxes in this workflow. One is a ptolemy.kernel.util.Attribute (for the text that should be appearing - "Generate a sine wave."), and another is a ptolemy.kernel.util.SingletonAttribute. This problem starts happening when you're using the Reporting module.
Files
Updated by Christopher Brooks over 12 years ago
The reported problem here is that if a Sinewave actor is dragged onto the
canvas in Kepler, then two blank boxes appear.
One is an attribute that is actually an old-style annotation that is supposed
to say "Generate a sine wave".
The second is a SingletonAttribute that when clicked is supposed to bring
up the documentation for the composite.
The contents of the Sinewave actor appear fine inside Ptolemy II, the problem
is with Kepler.
For the first one, we could just substitute in a more recent TextAttribute,
but the real fix would be to make it so that Kepler would properly display
these because presumably there are other models that have these old annotations.
In ptII, the code that possibly displays these annotations might be in
ptolemy/vergil/icon/XMLIcon.java
For the second one, we need to look at how Kepler displays the SingletonAttribute.
Updated by Christopher Brooks over 12 years ago
There are problems with singleton attributes.
See also bug #4903.
Updated by Sean Riddle over 12 years ago
I get this behavior under kepler trunk, reporting suite is not needed.
Updated by Christopher Brooks over 12 years ago
Hi Sean,
If I were you, I'd focus on the other bug because the Sinewave icon bug may be tricky because Sinewave is an actor-oriented class. If there clone(Workspace) method is not implemented properly, then there will be problems.
Ptolemy is not affected by this bug.
To run Ptolemy from the Kepler tree:
cd build-area
java -classpath ../ptolemy/target/classes:../ptolemy/src ptolemy.vergil.VergilApplication -ptiny ../ptolemy/src/ptolemy/actor/lib/Sinewave.xml
The SingletonAttribute is a yellow box, if you double click on it, then the Documentation comes up.
I'll attach screenshots of both to the bug.
On 8/7/12 4:00 PM, Sean Riddle wrote:
Hi all,
I'm currently looking at a bug with the sinewave composite that comes bundled with Ptolemy. Basically, two of the actors in the composite that need special graphics rendered (like text in an attribute) are instead rendered as plain green boxes. Could anyone who used this actor before or who has a version of Kepler (or Ptolemy) unaffected by this bug please tell me what these two actors are intended for? One appears to be a SingletonAttribute that contains documentation, and one is a DocViewerAttribute.
- Sean
Updated by Christopher Brooks over 12 years ago
Edward writes:
This sort of bug usually arises from something being
done outside the Swing event thread that should be done inside
the Swing event thread. Perhaps the reporting suite has
a bug here?
BTW - the bug happens in regular Kepler, the reporting suite is not required.
Updated by Christopher Brooks over 12 years ago
Redispatching to myself so that I can create a non-Actor Oriented Class version
of Sinewave.
Updated by Christopher Brooks over 12 years ago
I've uploaded a Sinewave that is not an actor oriented composite and the
screen shot.
The problem persists.
I've reassigned this to Sean.
Updated by Sean Riddle about 12 years ago
Adding _icon properties to the problem attributes allows the SVG attached to the attributes to be attached to a ValueIcon. For instance, the property 'annotation' had properties '_iconDescription' and '_smallIconDescription', which contain SVG definitions of the full-size icon and the icon displayed in the library tree, respectively. These alone, though, will not cause a custom icon to be displayed.
The following declaration is needed:
<property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
<property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
</property>
</property>
This specifies that the icon is going to be an instance of ValueIcon, and ValueIcon presumably gets the definitions from _iconDescription and _smallIconDescription and instantiates and displays the SVG appropriately.
This change has been sent to Christopher for review prior to commit.
Updated by Christopher Brooks about 12 years ago
Sean's patch is below.
The issue here is that this will fix it for one actor.
There are no doubt many other actors that have the same issue.
To close this bug requires fixing the underlying problem, perhaps
with a MoMLFilter.
However, I don't see how we could have filter know that the icon
should be updated?
It could be that when this actor was created, it was not created with an _icon
attribute. One solution would be modify MoMLParser so that if _icon was not
present in the appropriate context then it would be added.
Index: src/ptolemy/actor/lib/Sinewave.xml
===================================================================
--- src/ptolemy/actor/lib/Sinewave.xml (revision 64734)
++ src/ptolemy/actor/lib/Sinewave.xml (working copy) @ -22,6 +22,10
@
<property name="_iconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
<configure><svg><text x="20" y="20" style="font-size:14; font-family:SansSerif; fill:blue">Generate a sine wave.</text></svg></c\
onfigure>
</property>
<property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+ <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+ </property>
+ </property>
<property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
<configure>
<svg> @ -75,6 +79,10
@
</svg>
</configure>
</property>
+ <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
+ <property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{1.0, 0.0, 0.0, 1.0}">
+ </property>
+ </property>
<property name="_location" class="ptolemy.kernel.util.Location" value="[240.0, 100.0]">
</property>
</property>
Updated by Christopher Brooks about 12 years ago
Note that the change to ValueIcon was backed out because of bug #5719, see
http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5719#c2
Updated by Sean Riddle about 12 years ago
(In reply to comment #13)
Note that the change to ValueIcon was backed out because of bug #5719, see
http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5719#c2
I have a minor alteration of my earlier patch that I think would fix the problem. The part of code that generates the label would be changed to:
String truncated = StringUtilities.truncateString(value, width, 1);
LabelFigure label;
if (container instanceof Parameter) {
label = new LabelFigure(truncated, _labelFont, 1.0, SwingConstants.SOUTH_WEST);
}
else {
label = new LabelFigure(name + ": " + truncated, _labelFont, 1.0, SwingConstants.SOUTH_WEST);
}
This prevents the label from being displayed as 'ParameterType: ParameterValue'.
The reason that my patch caused all parameter labels to disappear is that inexplicably all parameters declare _hideName. So simply removing the _hideName property will make the labels visible. The above refinement to the patch is only to make the resulting names in line with what they were originally.
Is this an acceptable solution?
Updated by Christopher Brooks about 12 years ago
Could you post the entire file as an attachment? I'm not sure where your changes would go.
Updated by Sean Riddle about 12 years ago
This revised ValueIcon class should fix the problem. Any parameters that have invisible labels probably need _hideName to be removed from their XML declaration in actors.
Updated by Christopher Brooks about 12 years ago
The Revised ValueIcon.java file at
http://bugzilla.ecoinformatics.org/attachment.cgi?id=440
still has the problem where when I drag in a Parameter, the Parameter
name is not shown.
Indeed, the xml has _hideName set:
<property name="Parameter" class="ptolemy.data.expr.Parameter">
<property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
</property>
<property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
<property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{0.0, 0.0, 1.0, 1.0}">
</property>
</property>
<property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
<configure>
<svg>
<text x="20" style="font-size:14; font-family:SansSerif; fill:blue" y="20">-P-</text>
</svg>
</configure>
ptolemy/configs/utilityParameter.xml defines the Parameter that is dragged
in and indeed, it defines _hideName.
This change would require that almost every model be updated.
In addition, the names and values of PortParameters are not shown,
For example, see $PTII/ptolemy/actor/lib/Sinewave.xml
I'm not sure how to proceed. Sean has offered a solution, but the solution
would require updating many models. Even before Sean's solution,
it seems like _hideName in Parameters was being set as a hacky fix to a problem.
Updated by Daniel Crawl about 12 years ago
The change to ValueIcon.java in r64716 was reverted, leaving ShowTypes and MonitorReceiverContents with titles. The documentation for ValueIcon describes it as: "An icon that displays a bullet, the name, and, ... its value." These attributes should not be displayed as bullets, so I changed the _icon class from ValueIcon to XMLIcon in these attributes' XML files in actors/resources/kar/CoreActors/, and they are now displayed correctly.
MonitorManager also had a title. I fixed this by adding a _hideName attribute in its constructor.
I updated ComponentEntityConfig to not use the default green box icon for attributes. This fixed the author attribute in the MatlabExpression demo and the "Generate a sine wave" attribute in the Sinewave actor.
The "Documentation" attribute in Sinewave was still not displayed, which was due to the SVG x and y having negative values. Batik does not appear to render icons with negative x and y.
Kepler uses batik for SVG, but Ptolemy does not. As far as I can tell, all Kepler icons have positive x and y, and most Ptolemy icons have negative x and y. Conveniently, there are no attributes other than directors with Kepler-specific icons, so I changed KeplerXMLIcon to use diva instead of batik to render attributes. If Kepler icons are created for attributes in the future, we'll need to find a better solution.
As far as I can tell, all the icon problems are now fixed; reassigning to Christopher to test.
By the way, it appears that diva.util.java2d.svg.SVGPaintedObject is only referenced by Kepler, and is the only Ptolemy class using the batik jar...