Author Topic: How to draw the object of class diagram in EA?  (Read 4784 times)

Xuxin

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
How to draw the object of class diagram in EA?
« on: June 17, 2013, 08:16:01 am »
Hello everyone,

I have created my user interface to collect input data. Then my add-in can analyze the class diagram in EA. Now my question is that how to show the class diagram where the selected class/object is drawn to yellow/red color.

I think I could use EA API to export XMI file. Then I use C# window designer to show the drawn class diagram image.

Is it feasible? Otherwise, could anyone give me any suggestion? Thanks for help.  ::)
« Last Edit: June 17, 2013, 08:17:26 am by xuxin83816 »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to draw the object of class diagram in EA?
« Reply #1 on: June 17, 2013, 09:34:56 am »
How about Repository.OpenDiagram(id) ?

q.

Xuxin

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: How to draw the object of class diagram in EA?
« Reply #2 on: June 19, 2013, 07:01:49 am »
The Repository.OpenDiagram(id) might be useful. But that need my add-in create a new diagram in EA, then open it using its ID.

I found a solution. Use Repository.GetCurrentDiagram() to get the diagram to be drawn. Then call Diagram.DiagramObjects property to get a collection of DiagramObject. Then give the value for DiagramObject.Style property. For example:

BCol=n;BFol=n;LCol=n;LWth=n;

where:
· BCol = Background Color
· BFol = Font Color
· LCol = Line Color
· LWth = Line Width

Using this approach, I suppose that we could draw the specific elements in a class diagram. I will test it later. :D

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13241
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to draw the object of class diagram in EA?
« Reply #3 on: June 19, 2013, 10:51:28 pm »
Its still not clear to me what you are trying to achieve.

Please explain in more detail.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to draw the object of class diagram in EA?
« Reply #4 on: June 19, 2013, 11:10:12 pm »
Quote
Its still not clear to me what you are trying to achieve.

Please explain in more detail.

Geert
You really must have too much spare time :-)

q.

Xuxin

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: How to draw the object of class diagram in EA?
« Reply #5 on: June 21, 2013, 04:13:47 am »
Thank you to be interested in my topic.

My project is to draw the class diagram in EA. Then let users enter some input data. My add-in will do some analysis for the diagram using input data. Finally, the add-in output the class diagram with drawing colors to some elements.

I have created my user interface. Now I concentrate on the analysis implementation. After it, I will make the add-in draw the class diagram in EA.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13241
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to draw the object of class diagram in EA?
« Reply #6 on: June 21, 2013, 03:47:06 pm »
Ok, I think I understand.
If you want to create a new class diagram you'll need to add one to the element or package you want to create it under.
You'll need something like Package.Diagrams.AddNew()
Then you need to add elements to your diagram using the DiagramObjects collection, so Diagram.DiagramObjects.AddNew().

Make sure you link the diagramObject to the element in your model you want to show.

Then you can indeed play with the Style field to change color etc..

Regards

Geert

Xuxin

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: How to draw the object of class diagram in EA?
« Reply #7 on: June 21, 2013, 07:40:59 pm »
Hi Geert,

Thank you to validate this approach. I will use Diagram.DiagramObjects.AddNew() and DiagramObject.Style to draw the diagram.

Regards,
Xuxin