Class Diagram

Started by Farmer John, May 03, 2018, 11:20:24 AM

Previous topic - Next topic

Farmer John

Hello everyone! A new Archi user here. I have read the documentation and used the software a little, but I have not been able to find a way to create a Class Diagram with Archi. I tried to use "Data object" element and "Application component" element to represent Class, and that's fine, but how could I get class attributes displayed underneath the name?

Is it even possible? So, to clarify, I'd like to have an element that would have Class name on top, and beneath that there would be Class attributes listed and their type.

For example - we could have a "Server" class, and "Hostname" would be one of the attributes of this class, and attribute type would be "String".

Thank you!

Alberto

I'm also new here, but I think you are referring to two different things, a Naming Convention for your elements and also Specialization.

I don't think you can use an element's property as part of your naming attributes, I don't think that is in the archimate specs nor built into Archi. That would be cool thou.

On the other hand, the specs do allow for specializations, where you can define a property "Class" as part of your elements.  Also the Specialization plugin allows you to change the icons in Archi, you could leverage that to at least visually represent your Class attributes.  I use Specialization to differentiate OS in my Nodes elements.

Hervé

#2
Hi,

Actually, it is possible to add properties in objects labels, using my specialization plugin (https://github.com/archi-contribs/specialization-plugin).

You might create your Data Object with the following label: ${name}\n${property:field1}\n${property:field2}


I know this is not ideal, but it may do the trick.

I can easily update my specialization plugin to simplify the syntax to something like ${name}\n${property:field*} that will allow to take in account all the properties that start with "field", but at the moment, the label position is controlled by Archi, so I may not be able to move the object name above the horizontal line.

Best regards
Hervé

Farmer John

Excellent! Thank you very much Hervé! I'm on a business trip at the moment, but once back at home I'll give it a try and report back here.

Hervé

Hi,

The new version 1.0.6 now allows to specify two new variables in a component label:

  • ${properties:separator:regexp}: this concats the values of all properties that matches the regexp, separated by the separator (you may use "\n" for a new line, "\t" for a tab or "\:" for a colon). The properties are taken in the order they've been defined
  • ${sortedproperties:separator:regexp}: same as above, but properties are alphabetically sorted before

For instance, ${sortedproperties:\n:field.*} sorts the properties and concats all the properties that start with "field" using a newline separator.

Best regards
Hervé