Sparx Systems Forum

Discussion => Automation Interface, Add-Ins and Tools => Topic started by: MaXyM on December 05, 2017, 01:48:31 am

Title: DiagramLink and Connectors
Post by: MaXyM on December 05, 2017, 01:48:31 am
Hello guys
I spent half a day searching for information but at the end I have to ask for it.
I need to change color of DiagramLink in relation to labels. But:

1. don't know how to get labels directly from DiagramLink
2. don't know how to find Connector which is represented by DiagramLink

BTW I found funny thing trying to set LineColor (attribute of DiagramLink). It seems to be BGR instead of RGB. So 255 is red (hex 00 00 FF), respectively blue is 16711680 (hex FF 00 00).

with regards

Title: Re: DiagramLink and Connectors
Post by: qwerty on December 05, 2017, 09:30:40 am
I don't know what you want to do. Is it the color of a connector you want to change? And I guess you want to do that programmatically

q.
Title: Re: DiagramLink and Connectors
Post by: MaXyM on December 05, 2017, 10:08:21 am
Bravo... your conclusion is perfect. I hope the name of this subforum didn't help you much ;)

Actually I figured it out on my own by analysing Geert's code from: https://community.sparxsystems.com/community-resources/906-set-all-line-styles-in-an-enterprise-architect-diagram-automatically

Code: [Select]
connector = Repository.GetConnectorByID(link.ConnectorID); // where link comes from diagram.DiagramLinks
if (selectedConnector.ClientEnd.Role.match('^FK_') || selectedConnector.SupplierEnd.Role.match('^FK_'))
{
    connector.Color = 255; // for red
    connector.Update();
}

What is really interesting, that there are 2 methods of how to set color. 
The first one I tries was
Code: [Select]
link.LineColour. But this way overwrites possibility to change this colour by using Appearance option from context menu over particular connector. In this case the color chooser shows the last color set by this tool (not current one show on diagram). Color tool just doesn't work until we set link.LineColour to -1. Then Appearance takes control over line color again.


Title: Re: DiagramLink and Connectors
Post by: qwerty on December 05, 2017, 11:18:53 am
Sorry, I still don't know what your issue is. I can only guess. There are 2 colors: one is a global connector color and another is the per diagram color. But my glass bowl fell in the fountain and the frog told me it's too heavy to lift it.

q.
Title: Re: DiagramLink and Connectors
Post by: Simon M on December 05, 2017, 12:36:48 pm
There are multiple levels in which a connector line color can be specified. Only two are available via the API.

Diagram legend auto colour - Colour specified in legend rule matching the connector

DiagramLink.LineColor - The colour for a single diagram only.
Connector.Color - Default for all places this connector appears on a diagram

Stereotype line colour - Default for all connectors with this stereotype applied.
User connector colour - Default for all connectors for the logged in user. (Can be altered using diagram themes)

It sounds like you're wondering why the default colour for a connector isn't applied unless you don't specify a diagram override for that colour.
Title: Re: DiagramLink and Connectors
Post by: MaXyM on December 05, 2017, 07:22:48 pm
@querty at the beginning I was looking for way how to change connector color in relation to connector labels (Actually how to find related connector having diagramlink). The rest are just findings I wanted to share with community (because I've found no information about it)

@Simon thanx for answer. I supposed this is multi-level. But I didn't know there is possibility to set a color of connector (actually diagramlink), which cannot be overriden by diagram specific option available in GUI (Appearance option). Also I found no option in GUI to change colour of the diagramlink. Appearance option refers to connector.color.
Title: Re: DiagramLink and Connectors
Post by: qwerty on December 05, 2017, 07:27:07 pm
Ah, ok. Now it's clear. I wasn't aware of using different colors for connectors and labels. Will have a look later then.

q.
Title: Re: DiagramLink and Connectors
Post by: qwerty on December 05, 2017, 08:32:58 pm
So here are the details:

Colors in EA:
Quote from: p. 100 of my Scripting book
Coloring values in EA have simple RGB values without transparency. Each red, blue and green value can take an intensity from 0 to 255. The RGB itself is calculated by

RGB = (blue * 256 + green) * 256 + red

The default coloring is equal to -1.
I should put that piece of information also in my Inside book.

Look into t_diagram.geometry. The different labels can be found the in semi-colon separated list under the according tag. LMB e.g stands for Label Middle Bottom and it might look like

Code: [Select]
LMB=CX=27:CY=16:OX=8:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=65408:ALN=1:DIR=0:ROT=0;Here the CLR is the RGB value  of the label. A complete list of those acronyms can be found on p. 14 of my Inside book.

The line color itself is stored in t_connector.LineColor. It will be overridden if t_diagamlinks.Style has a Color tag in the CSV.

q.


Title: Re: DiagramLink and Connectors
Post by: MaXyM on December 06, 2017, 07:31:02 pm
Just out of curiosity. If I set color using link.LineColor, how can user affect the color using GUI?

BTW I ended up with setting TaggedValue instead of color, and using Legend feature. It seems to be more flexible solution.
Title: Re: DiagramLink and Connectors
Post by: qwerty on December 06, 2017, 09:46:37 pm
The GUI has TWO ways of setting the color. LineColor is set from the context menu.

q.