Book a Demo

Author Topic: v16RC - SetFontColor anomalous behaviour?  (Read 4113 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
v16RC - SetFontColor anomalous behaviour?
« on: February 17, 2022, 06:07:59 pm »
You may be aware of the setfontcolor() command. The Help defines this as:
setfontcolor(int red, int green, int blue) or setfontcolor(Color newColor)
Sets the font color of a text string.
You can specify the required color by defining RGB values or using a color value returned by any of the Color Queries such as:
     GetUserFontColor() or GetUserFillColor()
You can use this command with any of the text print commands.

 
In your use of the setfontcolor you may have noticed that unlike the setpencolor command (with which one can say "draw a blue line, then a red line etc"), the setfontcolor command applies to the entire subshape (and in behaviour typical of Sparxian coding, "the last man standing gets the guernsey").
Notwithstanding this unintuitive behaviour, that's not the reason for this post (although it may save some poor users from scratching their head when their shapescript doesn't behave as expected).
What I'm writing about is an even more anomalous behaviour.
We recently "solved" (actually only partially) a problem that we've had for nearly a decade.  We have an extensive piece of automation that allows us to place one of many names for a given element on a diagram on a per-diagram basis using the Label shape.  However, that only works in the non-rectangular form.  In rectangular form, the name compartment value can't be suppressed.  Last week, we realised that if we set the font colour to the user fill colour, the name field effectively "disappears".  We can then deploy our automation in rectangular mode!

So far so good!  We could use shape Label both in rectangular and non-rectangular mode. We have two setfontcolor commands one in shape Main (setfontcolor(getUserFillcolor()) ;) to suppress the Name field.  And one in shape Label (setfontcolor(getuserfontcolor()) ;) The intent being that the user can control the colour of the font in the label (simulating the Set Label Color menu item).

So further so good!  Font colour seems right, we can change the default font colour using [F4] and the colour changes!

BUT (there had to be a but) if we set the local font colour using the Paintbrush Widget, both the Label AND the Name fields take on the colour (Notwithstanding the instruction in shape Main to use the fill colour)!  The only way to avoid this is to set the local colour to the default colour in which case the rendering returns to the expected.

Some really weird behaviour.  Is there some rational explanation for this or is it (as it appears) a defect?

Reported,
Paolo
« Last Edit: February 17, 2022, 06:46:04 pm by Paolo F Cantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: v16RC - SetFontColor anomalous behaviour?
« Reply #1 on: February 18, 2022, 08:27:36 am »
When you say rectangular notation, do you mean the native shape?

There is a rule that the local colour overrides the values set in the shape script. At some point in the past I described here the full order for colours used in drawing. I'm not actually sure of why it was implemented that way, but I know it's intentional.

If you're not describing the native shape... I don't know what you're describing.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: v16RC - SetFontColor anomalous behaviour?
« Reply #2 on: February 18, 2022, 09:10:58 am »
When you say rectangular notation, do you mean the native shape?

There is a rule that the local colour overrides the values set in the shape script. At some point in the past, I described here the full order for colours used in drawing. I'm not actually sure of why it was implemented that way, but I know it's intentional.

If you're not describing the native shape... I don't know what you're describing.
Yes, I'm describing the notation that uses native shape.  You know, the one named as "Rectangular Notation" in the Widget Menu.   ;)

Would it be possible to get the full order you mentioned?

Paolo
« Last Edit: February 18, 2022, 09:15:05 am by Paolo F Cantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: v16RC - SetFontColor anomalous behaviour?
« Reply #3 on: February 18, 2022, 10:29:22 am »
Yes, I'm describing the notation that uses native shape.  You know, the one named as "Rectangular Notation" in the Widget Menu.   ;)
They aren't equivalent. You can put any logic you want in the rectangle notation logic branch that you want. I asked because I wasn't sure what you were talking about.

Would it be possible to get the full order you mentioned?

Paolo

Took a little bit to find, but here is the full order again, updated to include auto color legends which didn't exist when it was first written. (And my last time quoting it I just said somewhere near the top)

This is to my knowledge, the complete list of overrides for the drawing style of elements.

  • Print in Color - User option for black and white only during printing.
  • Whiteboard mode - Suppresses fill colours and gradients. Set for a diagram
  • Shape Script Rendering - Any drawing properties explicitly set in a shape script before explicit draw commands.
  • Auto Color Legends - The color specified in a legend for elements matching the specified filter.
  • Local Appearance - The user configured appearance of the object on this particular diagram. Set on the toolbar.
  • Shape Script Defaults - Any drawing properties explicitly set in a shape script before drawing the native shape.
  • Default Appearance - The user configured default appearance for this object on any diagram.
  • Stereotype Appearance - The appearance for any objects created with this stereotype as configured by the profile order.
  • Element Group Colours - (Optional) Fill colours for different element types configured by Sparx. Enabled in local diagram theme or user settings
  • Local Diagram Theme - Theme override set by a user for an individual diagram.
  • User Style Settings - Defaults set for appearance of all elements for a user. Can be set via a theme.
  • Global Defaults - Defaults for the user settings defined by Sparx.

PS. It looks like my previous prediction was accurate.
Learn something new every day!
Or the same thing once every couple of years.  ;)
« Last Edit: February 18, 2022, 10:47:07 am by Eve »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: v16RC - SetFontColor anomalous behaviour?
« Reply #4 on: February 18, 2022, 11:12:18 am »
Thanks for that Eve,

Is that list anywhere in the Help?  I think it probably should be.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!