Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree Layout with vertical position constraints #960

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8eefe55
spaeter commit
ClaasN Aug 18, 2023
18646ba
ein zwischenstand
ClaasN Sep 15, 2023
9314139
ein paar checks
ClaasN Sep 16, 2023
b7394d8
neuere version aufs gitlab bringen
ClaasN Oct 2, 2023
1854fb9
Merge remote-tracking branch 'cln/master' into cln/tree-algo
Eddykasp Oct 11, 2023
3e4fa44
remove remaining force alg references
Eddykasp Oct 11, 2023
426e6e4
Update Copyright notices
Eddykasp Oct 12, 2023
45a4edc
Documentation and Cleanup
Eddykasp Oct 12, 2023
21ba60a
Support nodeNode spacing property
Eddykasp Oct 12, 2023
973ff09
Remove unnecessary try catch blocks
Eddykasp Oct 12, 2023
103836e
remove wrongly committed files
Eddykasp Oct 12, 2023
aa26fcc
Use enum for layout strategy
Eddykasp Oct 12, 2023
2da37e1
update build.properties
Eddykasp Oct 12, 2023
fdacded
Extract property
Eddykasp Oct 12, 2023
ec0d332
clean up
Eddykasp Oct 12, 2023
a48f53d
Rename algorithm to VertiFlex
Eddykasp Oct 13, 2023
7c851b2
rename to vertiflex in ELK feature
Eddykasp Oct 13, 2023
e1605f4
rename to vertiflex in ELK pom
Eddykasp Oct 13, 2023
1f968f4
Graph size calculation
Eddykasp Oct 19, 2023
9204ddd
Check for invalid vertical constraints
Eddykasp Oct 19, 2023
625b72c
Remove magic number offset
Eddykasp Oct 19, 2023
2e1f8e6
Refactor phase packages
Eddykasp Oct 19, 2023
96b118d
Fix graph size calculation
Eddykasp Oct 19, 2023
07fbbee
Clean up imports
Eddykasp Oct 19, 2023
d5718f2
Add bend edge router
Eddykasp Oct 19, 2023
b06244c
Fix issues
Eddykasp Oct 20, 2023
d024b5d
Update documentation
Eddykasp Oct 20, 2023
9afabc1
Refactor unclear variable names
Eddykasp Oct 23, 2023
2430094
Documentation
Eddykasp Oct 23, 2023
59c9f66
Document TODO
Eddykasp Oct 23, 2023
f60f1bc
Add consider model order option for straightline layouts
Eddykasp Oct 24, 2023
16e0564
Update build.properties
Eddykasp Nov 3, 2023
9a928ef
tidy up formatting
Eddykasp Nov 3, 2023
26f9216
Refactor variable usage and map access
Eddykasp Nov 3, 2023
7d2b3ed
Documentation
Eddykasp Nov 3, 2023
0fa7c23
Remove unused variable
Eddykasp Nov 3, 2023
288e0f8
Add comments
Eddykasp Nov 3, 2023
192a8d2
Document outline node better
Eddykasp Nov 3, 2023
8940da0
Merge NodeComparator and InverseYNodeComparator classes
Eddykasp Nov 3, 2023
8b02497
Refactor method names
Eddykasp Nov 6, 2023
d4dc7de
Improve Javadoc
Eddykasp Nov 6, 2023
567c0c7
Merge branch 'master' into cln/tree-algo
Eddykasp Aug 28, 2024
8410c2d
update test files
Eddykasp Aug 28, 2024
9e4f9ee
Update plugins/org.eclipse.elk.alg.vertiflex/META-INF/MANIFEST.MF
Eddykasp Aug 28, 2024
4de0be9
add calculation of node micro layout
Eddykasp Aug 28, 2024
019c2a8
Merge branch 'cln/tree-algo' of [email protected]:Eddykasp/elk.git into …
Eddykasp Aug 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions features/org.eclipse.elk.algorithms.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,12 @@ SPDX-License-Identifier: EPL-2.0
install-size="0"
version="0.0.0"
unpack="false"/>

<plugin
id="org.eclipse.elk.alg.vertiflex"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

</feature>
8 changes: 8 additions & 0 deletions plugins/org.eclipse.elk.alg.vertiflex/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
46 changes: 46 additions & 0 deletions plugins/org.eclipse.elk.alg.vertiflex/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.elk.alg.vertiflex</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
formatter_profile=_Elk
formatter_settings_version=12
org.eclipse.jdt.ui.javadoc=true
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************\n * Copyright (c) ${year} ${user} and others.\n * \n * This program and the accompanying materials are made available under the\n * terms of the Eclipse Public License 2.0 which is available at\n * http://www.eclipse.org/legal/epl-2.0.\n * \n * SPDX-License-Identifier: EPL-2.0 \n *******************************************************************************/</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
14 changes: 14 additions & 0 deletions plugins/org.eclipse.elk.alg.vertiflex/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Manifest-Version: 1.0
Automatic-Module-Name: org.eclipse.elk.alg.vertiflex
Bundle-ManifestVersion: 2
Bundle-Name: VertiFlex Tree Layout Algorithm
Bundle-SymbolicName: org.eclipse.elk.alg.vertiflex;singleton:=true
Bundle-Version: 0.9.0.qualifier
Eddykasp marked this conversation as resolved.
Show resolved Hide resolved
Bundle-Vendor: Eclipse Modeling Project
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: com.google.guava,
org.eclipse.elk.alg.common,
org.eclipse.elk.core,
org.eclipse.elk.graph
Export-Package: org.eclipse.elk.alg.vertiflex,
org.eclipse.elk.alg.vertiflex.options
36 changes: 36 additions & 0 deletions plugins/org.eclipse.elk.alg.vertiflex/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>

<p>October 11, 2023</p>
<h3>License</h3>

<p>
The Eclipse Foundation makes available all content in this plug-in
(&quot;Content&quot;). Unless otherwise indicated below, the Content
is provided to you under the terms and conditions of the Eclipse
Public License Version 2.0 (&quot;EPL&quot;). A copy of the EPL is
available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.
</p>

<p>
If you did not receive this Content directly from the Eclipse
Foundation, the Content is being redistributed by another party
(&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the
Redistributor's license that was provided with the Content. If no such
license exists, contact the Redistributor. Unless otherwise indicated
below, the terms and conditions of the EPL still apply to any source
code in the Content and such source code may be obtained at <a
href="http://www.eclipse.org/">http://www.eclipse.org</a>.
</p>

</body>
</html>
16 changes: 16 additions & 0 deletions plugins/org.eclipse.elk.alg.vertiflex/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
###############################################################################
# Copyright (c) 2023 Kiel University and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0.
#
# SPDX-License-Identifier: EPL-2.0
###############################################################################
source.. = src/,\
src-gen/
output.. = bin/
bin.includes = META-INF/,\
.,\
about.html
src.includes = about.html
49 changes: 49 additions & 0 deletions plugins/org.eclipse.elk.alg.vertiflex/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2023 Kiel University and others.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.

SPDX-License-Identifier: EPL-2.0
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.elk</groupId>
<artifactId>parent</artifactId>
<version>0.10.0-SNAPSHOT</version>
<relativePath>../../build/pom.xml</relativePath>
</parent>

<groupId>org.eclipse.elk</groupId>
<artifactId>org.eclipse.elk.alg.vertiflex</artifactId>
<name>ELK Y Constraint Tree Layout Algorithm</name>
<version>0.10.0-SNAPSHOT</version>
<description>Tree drawing algorithm with y-level constraints.</description>
<packaging>eclipse-plugin</packaging>

<dependencies>
<dependency>
<groupId>org.eclipse.elk</groupId>
<artifactId>org.eclipse.elk.core</artifactId>
<version>0.10.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.elk</groupId>
<artifactId>org.eclipse.elk.alg.common</artifactId>
<version>0.10.0-SNAPSHOT</version>
</dependency>
</dependencies>

<build>
<plugins>
<!-- Generate code from .melk files. -->
<plugin>
<groupId>org.eclipse.xtext</groupId>
<artifactId>xtext-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.eclipse.elk.alg.vertiflex.options.VertiFlexMetaDataProvider
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2023 Kiel University and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.elk.alg.vertiflex;

/**
* Strategies for routing edges in the tree layout.
*
*/
public enum EdgeRoutingStrategy {

/**
* Straight lines between nodes.
*/
STRAIGHT,

/**
* Allow one bend point in edges to enable more compact layouts while also maintaining the node model order.
*/
BEND

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (c) 2023 Kiel University and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.elk.alg.vertiflex;

import org.eclipse.elk.alg.vertiflex.p2relative.OutlineNode;
import org.eclipse.elk.graph.ElkNode;
import org.eclipse.elk.graph.properties.IProperty;
import org.eclipse.elk.graph.properties.Property;

/**
* The internal properties of the tree layouter. Properties that are used internally
* but do not need to be public are stored here.
*
*/
public final class InternalProperties {

/**
* Private constructor to prevent initialization.
*/
private InternalProperties() { }

/**
* Defines the left outline of this subtree.
*/
public static final IProperty<OutlineNode> LEFT_OUTLINE = new Property<OutlineNode>("LEFT_OUTLINE");

/**
* Defines the right outline of this subtree.
*/
public static final IProperty<OutlineNode> RIGHT_OUTLINE = new Property<OutlineNode>("RIGHT_OUTLINE");

/**
* Defines the maximum depth of outlines. This is the lowest point of the outline in the tree layout.
*/
public static final IProperty<Double> OUTLINE_MAX_DEPTH = new Property<Double>("OUTLINE_MAX_DEPTH");

/** Defines the canvas of the tree. */
public static final IProperty<Double> MIN_X = new Property<Double>("MIN_X");

/** Defines the canvas of the tree. */
public static final IProperty<Double> MAX_X = new Property<Double>("MAX_X");

/** Defines the canvas of the tree. */
public static final IProperty<Double> MIN_Y = new Property<Double>("MIN_Y");

/** Defines the canvas of the tree. */
public static final IProperty<Double> MAX_Y = new Property<Double>("MAX_Y");

/** The root node of the graph. */
public static final IProperty<ElkNode> ROOT_NODE = new Property<ElkNode>("root");

/**
* Defines the bendpoint of an edge.
*/
public static final IProperty<Double> EDGE_BEND_HEIGHT = new Property<Double>("EDGE_BEND_HEIGHT");

/**
* Stores the model order of nodes. Smaller values come before larger values.
*/
public static final IProperty<Integer> NODE_MODEL_ORDER = new Property<Integer>("Node Model Order");

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2023 Kiel University and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.elk.alg.vertiflex

import org.eclipse.elk.alg.vertiflex.EdgeRoutingStrategy
import org.eclipse.elk.alg.vertiflex.VertiFlexLayoutProvider
import org.eclipse.elk.core.math.ElkPadding

/**
* Declarations for the ELK VertiFlex tree layout algorithm.
*/
bundle {
metadataClass options.VertiFlexMetaDataProvider
idPrefix org.eclipse.elk.vertiflex
}

algorithm vertiflex(VertiFlexLayoutProvider) {
label "ELK VertiFlex"
description
"Tree layout algorithm that allows defining set vertical positions for nodes
rather than automatically placing nodes on levels according to their topology."
metadataClass options.VertiFlexOptions
category org.eclipse.elk.tree
features multi_edges, edge_labels
supports org.eclipse.elk.spacing.nodeNode = 20
supports org.eclipse.elk.padding = new ElkPadding(5)
supports org.eclipse.elk.interactive
supports org.eclipse.elk.portConstraints
supports org.eclipse.elk.edgeLabels.inline = false
// Common node micro layout
supports org.eclipse.elk.omitNodeMicroLayout
supports org.eclipse.elk.margins
// Algorithm specific properties
supports verticalConstraint
supports layoutStrategy
supports layerDistance
supports considerNodeModelOrder

}

option verticalConstraint: double {
label "Fixed vertical position"
description
"The Y position that the node should be fixed at."
targets nodes
}

option layoutStrategy: EdgeRoutingStrategy {
label "Edge layout strategy"
description
"Strategy for the layout of the children. 'straight' for straight line drawings, 'bend' for a possible bend.
When straight edges are prioritized the nodes will be reordered in order to guarantee that straight edges are
possible. If bend points are enabled on the other hand, the given model order of the nodes is maintained and
bend points are introduced to prevent edge node overlaps."
targets nodes
default = EdgeRoutingStrategy.STRAIGHT
}

option layerDistance: double {
label "Layer distance"
description
"The distance to use between nodes of different layers if no vertical constraints are set."
targets parents
default = 50.0
}

option considerNodeModelOrder: boolean {
label "Consider node model order"
description
"Consider node model as a secondary criterion when using straight line routing."
targets parents
default = true
}
Loading
Loading