JMRI
JMRI copied to clipboard
Rotated BlockContentsIcon do require a predefined size
This is related to #11208
The current implementation requires the size to be specified for BlockContentsIcon that are displayed with a rotation. #11208 does create an icon for BlockContentsIcon that are not displayed horizontally (rotation deg=0)
However, the order in which the individual attributes (such as text, icon, ..) are set in the MemoryIcon.displayState(Object key) destroys the icon almost immediately and cause the size to collapse to its minimum values. Consequently not displaying the label. A small change
original:
} else if (val instanceof jmri.IdTag){
// most IdTags are Reportable objects, so
// this needs to be before Reportable
_icon = false;
_text = true;
setText(((jmri.IdTag)val).getDisplayName());
setIcon(null);
new:
} else if (val instanceof jmri.IdTag){
// most IdTags are Reportable objects, so
// this needs to be before Reportable
_icon = false;
_text = true;
setIcon(null);
setText(((jmri.IdTag)val).getDisplayName());
did resolve the issue.
@arthkl Do you have a panel file demonstrating this issue? I have created PR #11305 with your fix, but I'm not sure on how to test it.
Hi @danielb987,

The BlockContentsIcons on the left (270 deg angle) and on the right (90 deg angle) were not visible prior to that change.
I've attached the panel file. (as txt) Moorbach.xml.txt
@danielb987 Just wanted to point out that the fix only addresses cases where the key passed into displayState(Object key) is an instance of IdTag. I haven't had time to test other cases like Sting, Reportable but would imagine that the order needs to be changed for those instances too.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. JMRI is governed by a small group of maintainers which means not all opened issues may receive direct feedback.
This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the maintainers may elect to reopen this issue at a later date if deemed necessary.