Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: lopata on March 30, 2004, 01:16:13 am
-
Hi again!
Is it possibly possible :-) to layout a diagram through the automation interface?
Also, I would like to somehow control the "Parameter Detail".
Any plans to add these features in the following releases?
Thanks guys!
Hynek Cihlar, www.alsoft.cz
-
AFAIK you have to come up with your own layout algorithm. (I assume you want your diagrams to look "pretty")
I'm struggling with the same issue - more at the level of deciding if I want to bother. I've done a bit of this before for another app.
Probably best to come up with a basic relaxation process that iterates over all artifacts. Simple rules that control how much space should be around each item.
Then add rules to control which sort of object want to rise to the top of the diagram &etc. Can modify the space rules to help with the layering.
If you want to share the output with all here I'll make a bit of non-work time available to work the thing through.
Perhaps we could come up with an add-in for "straightening up" diagrams....
-
Do you realy think we should reinvent the wheel? The code for laying out diagrams is already in EA, it's only matter of exposing it.
-
But I agree with you that it wouldn't be difficult to implement.
-
Ahh! - You're ahead of me there. I thought the automation interface provided calls to create diagrams and add object to them, but it was left as "a problem for the user" to decide where the object should be placed.
What's the interface for layout
-
It is already exposed, there is a method LayoutDiagram on a ProjectInterface. It has two parameters, DIagramGUID and LayoutStyle. I am having problems finding an explanation of the LayoutStyle though.
Bruno
-
Right - Haven't looked at Project, thought it was just for xmi handling.
Hmmm, quite a bit to catch up on...
Thanks Bruno! :)
-
No problem! :-)
I would have logically thought this would be on the Diagram level...
If you figure out the values for LayoutStyle, please share! :-)
Bruno
-
There are lots of options from the GUI aren't there.
Can't find any obvious data tables to store the values in, nor anything in the registry, yet they can be stored for each diagram... must be in the database.
I wonder if they're encoded into a single database field...
Even so I've yet to find a layout that "adds value" for me as a user. Only benefit appears to be that the diagram objects won't overlap.
Have you tried any values?
Stephen
-
Yes, I have, more or les randomly - none seemed to make any difference :-(
Bruno
-
Looks like you're right.
Just tried all values 0 - 128 and all powers of 2.
All diagrams laid out according to settings I set by hand in the GUI.
Me thinks the feature doesn't work...! ;)
-
Or there is a secret.... like the LayoutStyle has to be multiplied by PI or something like that :-)
-
Just tried all bits set as well - powers of two minus one.
Still no effect.
I'm trying this on a class diagram with three classes on it.
When I change the Direction setting in the diagram layout options for this diagram it significantly affects the layout. I was hoping to see the same change when I hit on a useful value.
Ok - one last test while I write this message.
Changed the layout settings in the GUI.
Didn't say apply to whole project.
Re-running the all bit set test.....
And the result is...
All diagrams same in revised layout.
Damn - just thought of another test.
Change the direction in the GUI, but don't manually apply the layout....
Ok - running that with all powers of two and the all bits set tests.....
All output as per the settings I made by hand in the GUI
And the diagram has changed in the Model...
But I don't think LayoutStyle has much of an impact.
Should we raise a bug?? Or do you think this will be noticed anyway...
-
Let's raise a bug, this is actually quite important to me.
You sure are a thorough tester!
Bruno
-
Not a very good tester, but as I said in another thread, bit too much of hacker (1980's game programming background).
I wasn't testing, I was reverse engineering!
(I've raised the bug)
-
Hi all,
Looks like you're right.
Just tried all values 0 - 128 and all powers of 2.
All diagrams laid out according to settings I set by hand in the GUI.
Me thinks the feature doesn't work...!
This is because the LayoutStyle parameter in the Project.LayoutDiagram() method is not actually used anywhere in the automated layout process, so yes, it doesn't work. :o
Thanks for pointing out the design omission we'll be implementing a set of LayoutStyle options for this parameter for use in diagram layout. We endeavour to provide this within the next build or two of EA (during the next fortnight).
I will post an announcement here in this thread once we have made this layout customisation available.
Watch this space, ;)
Sam Mancarella
- Sparx Systems
-
Thanks, Sam. Can't wait! :-)
Bruno
-
As promised, we have made the necessary changes fo the AI to make use of the LayoutStyle parameter in the Project.LayoutDiagram() method.
Using this parameter, one can pass in all relevant layout options as would be found in the Diagram Properties->Set Layout Style dialog box using the constants defined in ConstLayoutStyles.
An example use of these parameters is shown below as a VB Function:
Private Function LayoutDiagram _
(ByRef oProj As EA.Project, _
ByVal sDiagramGUID As String) As Boolean
Dim lLayoutStyle As Long
If sDiagramGUID = "" Then
LayoutDiagram = False
Exit Function
End If
' Set some styles using ConstLayoutStyles values
' Depth First Search Cycle Removal, Optimal Link Length Layering
' Naive Initialize, Default Spacing, Up Layout Direction
' Aggressive crossing reduction (8 iterations)
lLayoutStyle = ConstLayoutStyles.lsCycleRemoveDFS Or _
ConstLayoutStyles.lsLayeringOptimalLinkLength Or _
ConstLayoutStyles.lsInitializeNaive Or _
ConstLayoutStyles.lsCrossReduceAggressive Or _
ConstLayoutStyles.lsLayoutDirectionDown Or _
ConstLayoutStyles.lsCrossReduceIteration Or _
CByte(8)
LayoutDiagram = oProj.LayoutDiagram(sDiagramGUID, lLayoutStyle)
End Function
A couple of points to be aware of:
- Using ConstLayoutStyles.lsDiagramDefault will layout the given diagram using the layout styles defined for it
- ConstLayoutStyles.lsProgramDefault will layout the given diagram using EA's layout defaults
- The three layout options requiring numerical values to be set are not mutually exclusive - ie: you can only set one numerical value to the parameter to define Layer Spacing, Column Spacing or the Cross Reduce Iterations values - this will be rectified in a later release of EA.
Hope this change proves useful for you in the meantime!
Best Regards
Sam Mancarella - Sparx Systems
[/list]