-
Notifications
You must be signed in to change notification settings - Fork 7
Add a synthesis hook to configure top-down layout for SCCharts #127
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
Draft
Eddykasp
wants to merge
3
commits into
master
Choose a base branch
from
mka/topdown-layout
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
...eler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/TopdownLayoutHook.xtend
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| /* | ||
| * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient | ||
| * | ||
| * http://rtsys.informatik.uni-kiel.de/kieler | ||
| * | ||
| * Copyright 2024 by | ||
| * + Kiel University | ||
| * + Department of Computer Science | ||
| * + Real-Time and Embedded Systems Group | ||
| * | ||
| * This code is provided under the terms of the Eclipse Public License (EPL). | ||
| */ | ||
| package de.cau.cs.kieler.sccharts.ui.synthesis.hooks | ||
|
|
||
| import de.cau.cs.kieler.klighd.SynthesisOption | ||
| import de.cau.cs.kieler.klighd.kgraph.KNode | ||
| import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared | ||
| import de.cau.cs.kieler.sccharts.Region | ||
| import de.cau.cs.kieler.sccharts.Scope | ||
| import de.cau.cs.kieler.sccharts.State | ||
| import de.cau.cs.kieler.sccharts.ui.synthesis.GeneralSynthesisOptions | ||
| import java.util.EnumSet | ||
| import org.eclipse.elk.core.options.ContentAlignment | ||
| import org.eclipse.elk.core.options.CoreOptions | ||
| import org.eclipse.elk.core.options.SizeConstraint | ||
| import org.eclipse.elk.core.options.TopdownNodeTypes | ||
|
|
||
| import static extension de.cau.cs.kieler.klighd.syntheses.DiagramSyntheses.* | ||
|
|
||
| /** | ||
| * Hook that configures SCCharts to be laid out using top-down layout instead of bottom-up layout. | ||
| * | ||
| * @author mka | ||
| * | ||
| */ | ||
| @ViewSynthesisShared | ||
| class TopdownLayoutHook extends SynthesisHook { | ||
|
|
||
| /** Action ID */ | ||
| public static final String ID = "de.cau.cs.kieler.sccharts.ui.synthesis.hooks.TopdownLayoutHook"; | ||
|
|
||
| public static final SynthesisOption USE_TOPDOWN_LAYOUT = | ||
| SynthesisOption.createCheckOption(TopdownLayoutHook, "Topdown Layout", false) | ||
| .setCategory(GeneralSynthesisOptions::LAYOUT) | ||
|
|
||
| public static final SynthesisOption TOPDOWN_HIERARCHICAL_NODE_WIDTH = | ||
| SynthesisOption.createRangeOption("Topdown Hierarchical Node Width", 50.0f, 5000.0f, 1.0f, 150.0f) | ||
| .setCategory(GeneralSynthesisOptions::LAYOUT) | ||
|
|
||
| public static final SynthesisOption TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO = | ||
| SynthesisOption.createRangeOption("Topdown Hierarchical Node Aspect Ratio", 0.2f, 5.0f, 0.01f, 1.41f) | ||
| .setCategory(GeneralSynthesisOptions::LAYOUT) | ||
|
|
||
| public static final SynthesisOption SCALE_CAP = | ||
| SynthesisOption.createCheckOption(TopdownLayoutHook, "Enable Scale Cap", true) | ||
| .setCategory(GeneralSynthesisOptions::LAYOUT) | ||
|
|
||
|
|
||
| // public static final SynthesisOption | ||
|
||
|
|
||
| override getDisplayedSynthesisOptions() { | ||
| return #[ | ||
| USE_TOPDOWN_LAYOUT, SCALE_CAP, TOPDOWN_HIERARCHICAL_NODE_WIDTH, TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO | ||
| ] | ||
| } | ||
|
|
||
| override processState(State state, KNode node) { | ||
|
|
||
| node.setProperty(CoreOptions::TOPDOWN_LAYOUT, USE_TOPDOWN_LAYOUT.booleanValue) | ||
| if (USE_TOPDOWN_LAYOUT.booleanValue) { | ||
| node.setLayoutOption(CoreOptions::NODE_SIZE_CONSTRAINTS, EnumSet.noneOf(SizeConstraint)) | ||
| node.setLayoutOption(CoreOptions::NODE_SIZE_FIXED_GRAPH_SIZE, true) | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_NODE_TYPE, TopdownNodeTypes.HIERARCHICAL_NODE) | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_HIERARCHICAL_NODE_WIDTH, TOPDOWN_HIERARCHICAL_NODE_WIDTH.floatValue as double) | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO.floatValue as double) | ||
| node.setLayoutOption(CoreOptions::CONTENT_ALIGNMENT, EnumSet.of(ContentAlignment.V_CENTER, ContentAlignment.H_CENTER)) | ||
|
|
||
| if (SCALE_CAP.booleanValue) { | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_SCALE_CAP, 1.0) | ||
| } else { | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_SCALE_CAP, Double.MAX_VALUE) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override processRegion(Region region, KNode node) { | ||
| node.setProperty(CoreOptions::TOPDOWN_LAYOUT, USE_TOPDOWN_LAYOUT.booleanValue) | ||
|
|
||
| if (USE_TOPDOWN_LAYOUT.booleanValue) { | ||
| node.setLayoutOption(CoreOptions::NODE_SIZE_FIXED_GRAPH_SIZE, true) | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_NODE_TYPE, TopdownNodeTypes.HIERARCHICAL_NODE) | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_HIERARCHICAL_NODE_WIDTH, TOPDOWN_HIERARCHICAL_NODE_WIDTH.floatValue as double) | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO.floatValue as double) | ||
| node.setLayoutOption(CoreOptions::CONTENT_ALIGNMENT, EnumSet.of(ContentAlignment.V_CENTER, ContentAlignment.H_CENTER)) | ||
| if (SCALE_CAP.booleanValue) { | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_SCALE_CAP, 1.0) | ||
| } else { | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_SCALE_CAP, Double.MAX_VALUE) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override start(Scope scope, KNode node) { | ||
| node.setProperty(CoreOptions::TOPDOWN_LAYOUT, USE_TOPDOWN_LAYOUT.booleanValue) | ||
| if (USE_TOPDOWN_LAYOUT.booleanValue) { | ||
| node.setLayoutOption(CoreOptions::NODE_SIZE_FIXED_GRAPH_SIZE, true) | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_NODE_TYPE, TopdownNodeTypes.ROOT_NODE) | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_HIERARCHICAL_NODE_WIDTH, TOPDOWN_HIERARCHICAL_NODE_WIDTH.floatValue as double) | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO, TOPDOWN_HIERARCHICAL_NODE_ASPECT_RATIO.floatValue as double) | ||
| if (SCALE_CAP.booleanValue) { | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_SCALE_CAP, 1.0) | ||
| } else { | ||
| node.setLayoutOption(CoreOptions::TOPDOWN_SCALE_CAP, Double.MAX_VALUE) | ||
| } | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create...method using the class, that causes better IDs for the options to be generated.setDescriptionmethod for each new option: This creates a hover-feedback popup for all options better describing what the option does. For example, I don't really get just from the name what "Enable Scale Cap" in the layout category should do.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please order the options the same way as they are used in the displayed synthesis options, or at least alphabetical