Project

General

Profile

Actions

Bug #5266

closed

Two empty boxes inside Sinewave actor and other icon problems for attributes

Added by Derik Barseghian about 13 years ago. Updated over 11 years ago.

Status:
Resolved
Priority:
Normal
Category:
general
Target version:
Start date:
01/05/2011
Due date:
% Done:

0%

Estimated time:
Bugzilla-Id:
5266

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

Sinewave.png (13.7 KB) Sinewave.png Christopher Brooks, 08/07/2012 04:17 PM
SinewaveKepler.png (14.4 KB) SinewaveKepler.png Christopher Brooks, 08/07/2012 04:18 PM
SinewaveComposite.xml (11.3 KB) SinewaveComposite.xml Christopher Brooks, 08/23/2012 03:44 PM
SinewaveCompositeInKepler.png (25.5 KB) SinewaveCompositeInKepler.png Christopher Brooks, 08/23/2012 03:45 PM
ValueIcon.java (6.57 KB) ValueIcon.java Sean Riddle, 10/17/2012 04:10 PM
Actions #1

Updated by Christopher Brooks almost 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.

Actions #2

Updated by Christopher Brooks almost 12 years ago

There are problems with singleton attributes.
See also bug #4903.

Actions #3

Updated by Sean Riddle over 11 years ago

I get this behavior under kepler trunk, reporting suite is not needed.

Actions #4

Updated by Christopher Brooks over 11 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

Actions #6

Updated by Christopher Brooks over 11 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.

Actions #7

Updated by Christopher Brooks over 11 years ago

Redispatching to myself so that I can create a non-Actor Oriented Class version
of Sinewave.

Actions #10

Updated by Christopher Brooks over 11 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.

Actions #11

Updated by Sean Riddle over 11 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.

Actions #12

Updated by Christopher Brooks over 11 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>

Actions #13

Updated by Christopher Brooks over 11 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

Actions #14

Updated by Sean Riddle over 11 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?

Actions #15

Updated by Christopher Brooks over 11 years ago

Could you post the entire file as an attachment? I'm not sure where your changes would go.

Actions #16

Updated by Sean Riddle over 11 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.

Actions #17

Updated by Christopher Brooks over 11 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:

&lt;property name="Parameter" class="ptolemy.data.expr.Parameter"&gt;
&lt;property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute"&gt;
&lt;/property&gt;
&lt;property name="_icon" class="ptolemy.vergil.icon.ValueIcon"&gt;
&lt;property name="_color" class="ptolemy.actor.gui.ColorAttribute" value="{0.0, 0.0, 1.0, 1.0}"&gt;
&lt;/property&gt;
&lt;/property&gt;
&lt;property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute"&gt;
&lt;configure&gt;
&lt;svg&gt;
&lt;text x="20" style="font-size:14; font-family:SansSerif; fill:blue" y="20"&gt;-P-&lt;/text&gt;
&lt;/svg&gt;
&lt;/configure&gt;

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.

Actions #18

Updated by Daniel Crawl over 11 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...

Actions #19

Updated by Christopher Brooks over 11 years ago

Fixed by Daniel!

Actions #20

Updated by Redmine Admin about 11 years ago

Original Bugzilla ID was 5266

Actions

Also available in: Atom PDF