Color Views in Archi

Started by tgfranck, June 06, 2017, 10:06:11 AM

Previous topic - Next topic

tgfranck

Hi Phil,

My hope was that you were using some sort of 'color overlay' to change the appearance of the view components. Although looking at your code, it seems that the appearance is managed by eclipse instead. Is this indeed the case?

I have also started to create a nicer legend. The current approach of using a Note object is rather limited for several reasons. I would like to create a legend that uses graphics (e.g. a colored box) to reference a particular color, alongside some text explaining the meaning. Similar to the legend e.g. in Excel.

As I understand it, the right approach is to extend the Ecore model (from my plugin) and register a new UI provider with the Archi UI provider factory class. The UI provider supplies an EditPart, which in turn should supply my custom legend figure. Is this correct?

Andreas and I have briefly discussed using this mechanism to also provide view components for our color views. Maybe it would be possible to define a figure delegate that adds a rectangle on top of the original figure, which we could use for coloring. Do you think this is feasible?

tgfranck

Hi all,

Attached is a picture of the new version of the legend. I'm no longer using a note, but a custom figure. I still want to use colored squares in front of the text to improve readability. The custom figure allows for much more freedom, so if any of you have suggestions on how to improve the legend, please let me know!

Thijs

tgfranck

I have started to try an alternative way to color the views. As I mentioned, I would like to add some colors without affecting the state of the model. My new approach involves a custom figure delegate. It wraps around the figure delegate that is currently used to draw the view component, and adds a switch for the background color. This preserves the original background color and allows me the flexibility I need.

I have written the custom figure delegate, but I am struggling with applying it to the views. I know how figures and figure delegates are initially created (I used the same approach to draw my legend). However, I have not yet found a way to reference the figure once it is created. I need this reference to replace the figure delegate with my custom wrapper. I have a reference to the view component, is there any way to retrieve the associated figure?

Furthermore, the current way in which delegates are selected does not seem very flexible. E.g. looking at ProcessFigure:


    @Override
    public IFigureDelegate getFigureDelegate() {
        int type = getDiagramModelObject().getType();
        return type == 0 ? fFigureDelegate1 : fFigureDelegate2;
    }


This behavior seems inconsistent as it does not use the same variable as is set by setFigureDelegate() in AbstractDiagramModelObjectFigure:


    public void setFigureDelegate(IFigureDelegate figureDelegate) {
        fFigureDelegate = figureDelegate;
    }


Is there a way to work around this, or should I make a change request on the github page?

Phil Beauvoir

Quoteis there any way to retrieve the associated figure?

It's really hard to fully understand what you are doing without seeing the code. So I can't answer this.

in the case of:


    @Override
    public IFigureDelegate getFigureDelegate() {
        int type = getDiagramModelObject().getType();
        return type == 0 ? fFigureDelegate1 : fFigureDelegate2;
    }


Some ArchiMate figures can have two representations, so this is returning the one that the user has chosen.

Of course, the proper solution to the overall problem is to create an extension point for rendering figures and is discussed here:

https://github.com/archimatetool/archi/issues/170

So, maybe the effort should be spent on that first, otherwise your customisation is only ever going to be a hack into the main code.

If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

tgfranck

Hi Phil,

That solution looks very promising. You mentioned having a look at this after the release of Achi 4. Have you already made any progress? If feasible, I would love to help you implement the extension point. Do you have any estimate on the complexity (i.e. development time) of such an extension?

Thijs

Phil Beauvoir

Hi Thijs,

I'm busy with other development things at the moment so it won't be for some time. But if anyone else wants to implement it that would be good. As for development time, it depends on who is doing it. Could take a couple of weeks, maybe more. Might require a lot of deep refactoring.

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Hervé

Hi guys,

Sorry for not having replied earlier, but I've been very busy and quite far from Archi these last days.

I'm coming back to one of the first questions asked: would this plugin useful to you ?

The answer is yes if the comparison could be parameterized My aim would be to compare a view to a referential (let say compare an implementation to a SBB) and highlight differences would definitively be a nice to have.


By the way, if you find a way to apply your figure delegate, I'd be very interested to have information on how you did it because I'm trying to develop a plugin that will allow to change the figures icons and color depending on properties. My objective is to distinguish more easily servers, routers, firewalls, storage, ... on technical views.

Best regards
Hervé


tgfranck

Hi all, hope you had a good weekend.

Hervé, thanks for your suggestion. I agree that it should be possible to parameterize the color views. Currently, the plugin allows you to make such a comparison either by:

  • Selecting two views and coloring the elements that are in view A, view B or in both views
  • Selecting two plateaus and coloring the elements in a single view based on whether they belong to plateau A, plateau B or both
Is this in line with your thoughts?

Phil, I will start looking into creating the extension point. I think this is the best way to properly move forward with the plugin. My aim is to allow figure delegates to be associated with view components in the same way UI providers can be associated with an Archimate concept. I will probably also be touching existing Archi code. I will continue to update you on my progress through this thread. I would also like to pass my work by you, so you can verify the quality. Would you allow me to create a separate branch off the github project?

Best regards,
Thijs

Phil Beauvoir

#23
Hi Thijs,

you can clone the code in GitHub and work on your own branch. May I suggest also that, before you dive into the code, do an analysis of what is required. I'm not sure how much time I can spend on it at the moment as I'm working on the model repository plug-in for a few more weeks.

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Hervé

Hi Thijs,

If the comparison takes the name, then it won't help me, as what I'm looking for is to compare something which is implemented (so using real names) to building blocs (so using generic names).

To be honest, I do not know (yet) how I would do this comparison. Probably on some properties.

Best regards
Hervé

Hervé

Hi Thijs,

Did you find a way to implement your figure delegate ? And if yes, would you be ready to share your code ?

Thanks and regards
Hervé

tgfranck

Hi Herve,

Yes, I did! I'm done with the base functionality, but want to formalize the documentation a bit before I share anything. Hopefully I can share something by tonight, otherwise you will hear from me tomorrow.

Thijs

Hervé


tgfranck

#28
Hi everyone,

I managed to extend the code for adding additional figure delegates. Since I had to do some refactoring of the existing code, I want to take this post to explain what I did in some detail.

Goal
My goal was to be able to add any number of figure delegates for any view element (excluding relationships). Currently, Archi has implemented a 'binary' switch between a default delegate and an alternative delegate. This switch is furthermore only supported for a few elements (e.g. business process). Some elements don't even use a delegate to define their shape.

For elements that have an alternative delegate, an additional tab appears in the properties window. Here, a preview is rendered of each alternative shape, and the user can select the shape that they want to use. My goal was to not change this behaviour towards the user. Furthermore, I also wanted to be able to assign any delegate to any element programatically (e.g. for my color views).

Implementation
As mentioned, I had to touch some of the existing Archi code to reach my goal. Specifically, I had to remove the binary delegate switch and replace it with a more extensible system. Furthermore, the new system should apply to all figures. I summarized my changes by means of the attached class diagram.

The most important change is the inclusion of two new extension points:

Figure Delegate Provider
As the name implies, a Figure Delegate Provider ensures that the right type of shape is supplied to a view element. The extension point requires a class that implements the provider for a particular figure type (e.g. ApplicationComponentFigureDelegateProvider provides delegates for ApplicationComponentFigure). Furthermore, a figure delegate provider must have a default figure delegate. This mimics the way Archi currently operates (with the binary switch always initially set to 0).

Figure Delegate
This extension point allows for the definition of new figure delegates. A figure delegate does not need to be registered with this extension point before it can be used. Rather, registering a figure delegate helps define alternative shapes for a particular figure. For example, by registering two shapes for Business Process (e.g. a block and an arrow), the figure delegate provider will know that an alternate shape is available. These two shapes will in turn show up as options to the user in the properties window. This also works for three shapes, four shapes etc. The same delegate can also be reused for another figure.

Aside from the extension points, I made one small change to the metamodel. For the DiagramModelArchimateObject, I removed the 'type' variable that was used for the binary switch and replaced it with a variable that stores the class name (i.e. type) of the figure delegate. If this value is set, the figure delegate provider gives it priority over the default delegate type. This means that individual view elements can still have different shapes. Furthermore, since the value is stored in the model, it is persisted when the model is saved.

I pushed the plugins to which I have made changes to my github:
https://github.com/tgfranck/archifiguredelegates.

I have not yet defined alternate shapes for all concepts, but for e.g. business process it should work fine. Feel free to have a look or even try it for yourself.

Looking forward to hearing your thoughts, or if you have any questions please let me know!

Thijs

I received some comments that the svg cannot properly be viewed with Internet Explorer. Should work fine in Chrome.

Hervé

Hi Thijs,

I was hoping that you would succeed without updating Archi's core code (what I failed to do myself  :-[), using Eclipse framework or something like that.

Nevertheless I will definitively have a look.

Thanks and regards
Hervé