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

Improve layout options #1015

Merged
merged 7 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 1 addition & 8 deletions oomph/LinguaFranca.setup
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,7 @@
targetURL="${git.clone.lingua.franca.location|uri}/org.lflang.ui.tests/src-gen/.dummy">
<content></content>
</setupTask>
<setupTask
xsi:type="setup:ResourceCreationTask"
excludedTriggers="BOOTSTRAP"
predecessor="git.clone.lingua.franca"
targetURL="${git.clone.lingua.franca.location|uri}/org.lflang.ui.tests/xtend-gen/.dummy">
<content></content>
</setupTask>
<description>The git repository does not contain the required src-gen and xtend-gen folders, hence they are created here.</description>
<description>The git repository does not contain the required src-gen folders, hence they are created here.</description>
</setupTask>
<setupTask
xsi:type="projects:ProjectsImportTask">
Expand Down
1 change: 0 additions & 1 deletion org.lflang.diagram/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
3 changes: 1 addition & 2 deletions org.lflang.diagram/build.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
source.. = src/,\
xtend-gen/
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@
import javax.inject.Inject;
import org.eclipse.elk.alg.layered.options.EdgeStraighteningStrategy;
import org.eclipse.elk.alg.layered.options.FixedAlignment;
import org.eclipse.elk.alg.layered.options.GreedySwitchType;
import org.eclipse.elk.alg.layered.options.LayerConstraint;
import org.eclipse.elk.alg.layered.options.LayeredOptions;
import org.eclipse.elk.alg.layered.options.NodePlacementStrategy;
import org.eclipse.elk.core.math.ElkMargin;
import org.eclipse.elk.core.math.ElkPadding;
import org.eclipse.elk.core.math.KVector;
Expand All @@ -90,7 +92,6 @@
import org.eclipse.xtext.xbase.lib.Pair;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.lflang.ASTUtils;
import org.lflang.FileConfig;
import org.lflang.diagram.synthesis.action.CollapseAllReactorsAction;
import org.lflang.diagram.synthesis.action.ExpandAllReactorsAction;
import org.lflang.diagram.synthesis.action.FilterCycleAction;
Expand Down Expand Up @@ -524,18 +525,26 @@ private Collection<KNode> createReactorNode(
}

private KNode configureReactorNodeLayout(KNode node) {
KNode retNode;
setLayoutOption(node, CoreOptions.NODE_SIZE_CONSTRAINTS, SizeConstraint.minimumSizeWithPorts());
setLayoutOption(node, CoreOptions.PORT_CONSTRAINTS, PortConstraints.FIXED_ORDER);
retNode = setLayoutOption(node, LayeredOptions.CROSSING_MINIMIZATION_SEMI_INTERACTIVE, true);
// Allows to freely shuffle ports on each side
setLayoutOption(node, CoreOptions.PORT_CONSTRAINTS, PortConstraints.FIXED_SIDE);
// Balanced placement with straight long edges.
setLayoutOption(node, LayeredOptions.NODE_PLACEMENT_STRATEGY, NodePlacementStrategy.NETWORK_SIMPLEX);
// Otherwise nodes are not sorted if they are not connected
setLayoutOption(node, CoreOptions.SEPARATE_CONNECTED_COMPONENTS, false);
// Needed to enforce node positions.
setLayoutOption(node, LayeredOptions.CROSSING_MINIMIZATION_SEMI_INTERACTIVE, true);
// Costs a little more time but layout is quick, therefore, we can do that.
setLayoutOption(node, LayeredOptions.THOROUGHNESS, 100);
setLayoutOption(node, LayeredOptions.CROSSING_MINIMIZATION_GREEDY_SWITCH_TYPE, GreedySwitchType.TWO_SIDED);
if (!getBooleanValue(SHOW_HYPERLINKS)) {
setLayoutOption(node, CoreOptions.PADDING, new ElkPadding(2, 6, 6, 6));
setLayoutOption(node, LayeredOptions.SPACING_NODE_NODE, LayeredOptions.SPACING_NODE_NODE.getDefault() * 0.75f);
setLayoutOption(node, LayeredOptions.SPACING_NODE_NODE_BETWEEN_LAYERS, LayeredOptions.SPACING_NODE_NODE_BETWEEN_LAYERS.getDefault() * 0.75f);
setLayoutOption(node, LayeredOptions.SPACING_EDGE_NODE, LayeredOptions.SPACING_EDGE_NODE.getDefault() * 0.75f);
retNode = setLayoutOption(node, LayeredOptions.SPACING_EDGE_NODE_BETWEEN_LAYERS, LayeredOptions.SPACING_EDGE_NODE_BETWEEN_LAYERS.getDefault() * 0.75f);
setLayoutOption(node, LayeredOptions.SPACING_EDGE_NODE_BETWEEN_LAYERS, LayeredOptions.SPACING_EDGE_NODE_BETWEEN_LAYERS.getDefault() * 0.75f);
}
return retNode;
return node;
}

private KNode detectAndAnnotateCycles(KNode node, ReactorInstance reactorInstance, Map<ReactorInstance, KNode> allReactorNodes) {
Expand Down
5 changes: 0 additions & 5 deletions org.lflang.tests/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="test-bin" path="xtend-gen">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="test-bin" path="src-gen">
<attributes>
<attribute name="test" value="true"/>
Expand Down
3 changes: 1 addition & 2 deletions org.lflang.tests/build.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
source.. = src/,\
src-gen/,\
xtend-gen/
src-gen/
bin.includes = .,\
META-INF/,\
about.html
Expand Down
3 changes: 1 addition & 2 deletions org.lflang.ui.tests/build.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
source.. = src/,\
src-gen/,\
xtend-gen/
src-gen/
bin.includes = .,\
META-INF/,\
about.html
Expand Down
1 change: 0 additions & 1 deletion org.lflang.ui/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
3 changes: 1 addition & 2 deletions org.lflang.ui/build.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
source.. = src/,\
src-gen/,\
xtend-gen/
src-gen/
bin.includes = .,\
META-INF/,\
plugin.xml,\
Expand Down