Skip to content

Commit

Permalink
Add a better layout for the nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyan11 committed Dec 5, 2024
1 parent d978894 commit a7e23e8
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/Molecule-IDE/MolComponentToRoassal.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ MolComponentToRoassal class >> associationsAllUsedServicesAndTargetsFor: aMolCom
{ #category : #'instance creation' }
MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfComponents [

| canvas componentShapes allEventShapes allContracts allContractSources allContractTargets lineBuilder |
| canvas componentShapes allEventShapes allContracts allContractSources allContractTargets lineBuilder ghostLineBuilder |
canvas := RSCanvas new.
componentShapes := aCollectionOfComponents collect: [ :comp |
comp asRSMoleculeShape ].
Expand All @@ -114,21 +114,46 @@ MolComponentToRoassal class >> canvasFromMultipleComponents: aCollectionOfCompon
canvas: canvas;
shapes: allEventShapes;
withBorderAttachPoint.
ghostLineBuilder := RSLineBuilder line
canvas: canvas;
shapes: componentShapes;
color: Color transparent;
withBorderAttachPoint.

allContractSources do: [ :source |
| allAssociatedTargets |
allAssociatedTargets := allContractTargets select: [ :target |
target eventClass = source eventClass and: [
target name = source name ] ].
allAssociatedTargets do: [ :target |
lineBuilder useAssociation: source -> target ] ].
lineBuilder useAssociation: source -> target.
ghostLineBuilder useAssociation: source component -> target component ] ].

RSForceBasedLayout new
"RSForceBasedLayout new
doNotUseProgressBar;
length: 3000;
charge: -1000;
on: canvas nodes."

"RSGridLayout new
lineItemsCount: 10;
gapSize: 1;
on: canvas nodes."
"RSHorizontalTreeLayout new
horizontalGap: 500;
on: canvas nodes;
yourself."

RSConditionalLayout new
ifNotConnectedThen: RSVerticalLineLayout new;
else: (RSClusteringLayout new
clustersLayout: RSGridLayout new;
forEachLayout: (RSHorizontalTreeLayout new horizontalGap: 500; yourself));
on: canvas nodes.

"RSHorizontalTreeLayout new on: canvas nodes."
"RSClusterRadialTreeLayout new on: canvas nodes."

canvas @ RSCanvasController.
canvas zoomToFit.
^ canvas
Expand Down

0 comments on commit a7e23e8

Please sign in to comment.