Hi,

Long story, but the short summary is that a change request is created that adds

<property name="_highlightColor" class="ptolemy.actor.gui.ColorAttribute" value="{1.0,0.0,0.0,1.0}">
</property>

to model in a non-persistent manner.

Try searching for _hightlightColor in the kepler/ptolemy directory.


ptolemy/vergil/basic/BasicGraphController.java has this method, which is probably what does the highlighting:
    /** Highlight the specified object and all its containers to
     *  indicate that it is the source of an error.
     *  @param culprit The culprit.
     */
    public void highlightError(final Nameable culprit) {
        if (culprit instanceof NamedObj) {
ChangeRequest request = new ChangeRequest(this, "Error Highlighter") {
                @Override
                protected void _execute() throws Exception {
                    _addErrorHighlightIfNeeded(culprit);
                    NamedObj container = culprit.getContainer();
                    while (container != null) {
                        _addErrorHighlightIfNeeded(container);
                        container = container.getContainer();
                    }
                }
            };
            request.setPersistent(false);
            ((NamedObj) culprit).requestChange(request);
        }
    }

The above method creates a change request and executes it. The body of the change request invokes this method:

    /** Add an error highlight color to the specified culprit if it is
     *  not already present.
     *  @param culprit The culprit to highlight.
* @exception IllegalActionException If the highlight cannot be added.
     *  @exception NameDuplicationException Should not be thrown.
     */
    private void _addErrorHighlightIfNeeded(Nameable culprit)
            throws IllegalActionException, NameDuplicationException {
        Attribute highlightColor = ((NamedObj) culprit)
                .getAttribute("_highlightColor");
        if (highlightColor == null) {
            highlightColor = new ColorAttribute((NamedObj) culprit,
                    "_highlightColor");
            ((ColorAttribute) highlightColor)
            .setExpression("{1.0, 0.0, 0.0, 1.0}");
            highlightColor.setPersistent(false);
((ColorAttribute) highlightColor).setVisibility(Settable.EXPERT);
            _errorHighlights.add(highlightColor);
        }
    }


See also ptolemy/vergil/basic/DependencyHighlighter.java for code that does highlighting.

_Christopher


On 11/5/14 12:30 AM, 陈军 wrote:
Hi,

I want to mark actors with custom colours.

Entities in a workflow will be encircled with red colour when errors occur. So I construct a bad workflow and run in debug mode trying to see how actors are rendered red. But I still can not figure out it.

Can anyone give some advice?
Thanks

--
陈军
School of Computer Science , Fudan University


_______________________________________________
Kepler-dev mailing list
[email protected]
http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-dev


--
Christopher Brooks, PMP                       University of California
Academic Program Manager & Software Engineer  US Mail: 337 Cory Hall
CHESS/iCyPhy/Ptolemy/TerraSwarm               Berkeley, CA 94720-1774
[email protected], 707.332.0670           (Office: 545Q Cory)

_______________________________________________
Kepler-dev mailing list
[email protected]
http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-dev

Reply via email to