Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: misterk on April 22, 2013, 11:31:35 pm
-
Hello,
I'm using this code to layout a diagram:
rep.GetProjectInterface().LayoutDiagramEx(diagram.GetDiagramGUID(), 0, 4, 20, 20, true);
rep.RefreshModelView(1);
diagram.Update();
This is working great, except I don't how to use the ConstLayoutStyles Enum in java
http://www.sparxsystems.com/enterprise_architect_user_guide/9.0/automation/constlayoutstylesenum.html
The LayoutDiagramEx methods takes these parameters:
LayoutDiagramEx (string
DiagramGUID, long
LayoutStyle, long Iterations,
long LayerSpacing, long
ColumnSpacing, boolean
SaveToDiagram)
The LayoutStyle which is a long, can take the values of the ConstLayoutStyles Enum, yet I don't know what are those values.
In the sdk documentation, it is said:
LayoutStyleaccepts the following options (also see
ConstLayoutStyles Enum ):
· Default Options:
lsDiagramDefault
lsProgramDefault.
· Cycle Removal Options:
lsCycleRemoveGreedy
lsCycleRemoveDFS.
· Layering Options:
lsLayeringLongestPathSink
lsLayeringLongestPathSource
lsLayeringOptimalLinkLength.
· Initialize Options:
IsInitializeNaive
IsInitializeDFSOut
IsInitializeDFSIn.
· Crossing Reduction Option:
lsCrossReduceAggressive.
· Layout Options - Direction
lsLayoutDirectionUp
lsLayoutDirectionDown
lsLayoutDirectionLeft
lsLayoutDirectionRight.
For example, if I want to have the option "lsLayoutDirectionLeft", what will be the value of the long LayoutStyle in LayoutDiagramEx, and how do you find this value.
Thanks in advance,
Kevin
-
Look into the EAConstants-Jscript in the scripting window.
q.
-
Unfortunately this enumeration is not currently in the Java API. There are a number of things currently missing from the Java API which we hope to fix in a future update.
As per qwerty's response - you can find the specific values for this enum in the Scripting window, Local Scripts > EAConstants-JScript.
Based on the values from the 'EAConstants-JScript' script file, i think the following code should give you the appropriate constants in Java.
final int lsDiagramDefault = 0x00000000;
final int lsProgramDefault = 0xFFFFFFFF;
final int lsCycleRemoveGreedy = 0x80000000;
final int lsCycleRemoveDFS = 0x40000000;
final int lsLayeringLongestPathSink = 0x30000000;
final int lsLayeringLongestPathSource = 0x20000000;
final int lsLayeringOptimalLinkLength = 0x10000000;
final int lsInitializeNaive = 0x08000000;
final int lsInitializeDFSOut = 0x04000000;
final int lsInitializeDFSIn = 0x0C000000;
final int lsCrossReduceAggressive = 0x02000000;
final int lsLayoutDirectionUp = 0x00010000;
final int lsLayoutDirectionDown = 0x00020000;
final int lsLayoutDirectionLeft = 0x00040000;
final int lsLayoutDirectionRight = 0x00080000;
-
Thanks a lot for these values, it's working great :-).
I didn't know, there was a scripting window... I will look at it later.
Thanks for the answers.