Skip to content

Commit

Permalink
Optimize expand all children. Was taking too much time.
Browse files Browse the repository at this point in the history
  • Loading branch information
LABSARI committed Sep 26, 2023
1 parent c147d92 commit d49190e
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 49 deletions.
8 changes: 8 additions & 0 deletions src/Hierarchical-Model-Events/HExpandChildrenEvent.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"
Event signaling that all chidren in the canvas.
"
Class {
#name : #HExpandChildrenEvent,
#superclass : #HEvent,
#category : #'Hierarchical-Model-Events'
}
9 changes: 8 additions & 1 deletion src/Hierarchical-Model/HNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ HNode >> expand [

{ #category : #public }
HNode >> expandChildren [
children do: [ :child | child expand ].
children do: [ :child | child isExpanded: true ].
self announce: HExpandChildrenEvent new
]

{ #category : #public }
Expand Down Expand Up @@ -381,6 +382,12 @@ HNode >> isExpanded [
^ isExpanded
]

{ #category : #testing }
HNode >> isExpanded: aBoolean [

isExpanded := aBoolean
]

{ #category : #testing }
HNode >> isLinksExpanded [
^ isLinksExpanded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Class {

{ #category : #execution }
HExpandCanvasChildrenMenuItem >> execute [
visualization rootNode expandChildren
[visualization rootNode expandChildren] timeProfile
]

{ #category : #accessing }
Expand Down
30 changes: 0 additions & 30 deletions src/Hierarchical-Roassal3-Menu/HExportasPDF.class.st

This file was deleted.

1 change: 1 addition & 0 deletions src/Hierarchical-Roassal3/HDefaultStyle.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ HDefaultStyle >> buildCompositeFullNodeIn: shape [
shape schildren: childrenShapes.
childrenShapes do: [ :child | child sparent: shape ].
children := childrenShapes asShape padding: 10.
children useRTree.
childrenShapes do: [ :child | child model position: child position ].
title width < children width
ifTrue: [
Expand Down
28 changes: 22 additions & 6 deletions src/Hierarchical-Roassal3/HSimpleVisualizationBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@ HSimpleVisualizationBuilder >> elasticBoxFor: aRSCanvas [
^ elastic
]

{ #category : #hooks }
HSimpleVisualizationBuilder >> expandChildren [

self container shapes do: #remove.
self renderIn: self container
]

{ #category : #hooks }
HSimpleVisualizationBuilder >> fixShadowForSelectedShape: shape and: newShape [
| canvas selectedShapes border |
Expand Down Expand Up @@ -487,35 +494,44 @@ HSimpleVisualizationBuilder >> removeShapeWithAllChildren: shape [

]

{ #category : #hooks }
{ #category : #rendering }
HSimpleVisualizationBuilder >> renderIn: aCanvas [

| rootShapes |
aCanvas color: Smalltalk ui theme backgroundColor.

rootShapes := self childrenShapes: aCanvas.
shapes := rootShapes flatCollect: [ :s | s withAllSChildren ].
self addInteractions: shapes.
aCanvas schildren: rootShapes.
aCanvas addAll: rootShapes.
aCanvas @ self menuInteraction.
rootNode when: HNodeAddedEvent send: #addNewNode: to: self.

aCanvas useRTree.
(aCanvas hasInteraction: RSMenuActivable) ifFalse: [
aCanvas @ self menuInteraction ].
(aCanvas hasInteraction: self) ifFalse: [
rootNode
when: HNodeAddedEvent send: #addNewNode: to: self;
when: HExpandChildrenEvent
do: [ :evt | self expandChildren ]
for: self] .
self renderLinesIn: aCanvas.
self layoutOn: rootShapes parent: rootNode
]

{ #category : #hooks }
HSimpleVisualizationBuilder >> renderLinesIn: aCanvas [

| announcer high |
self lineBuilder
canvas: aCanvas;
shapes: shapes;
connectFromAll: #dependentsFromLinks.
connectFromAll: [ :n | n dependentsFromLinks ].
announcer := Announcer new.
high := RSHighlightable red.
high onShape: announcer.
self menuInteraction onShape: announcer.
aCanvas lines do: [ :line| line announcer: announcer ].
aCanvas lines do: [ :line | line announcer: announcer ]
]

{ #category : #accessing }
Expand Down
11 changes: 0 additions & 11 deletions src/Hierarchical-Roassal3/RSCanvas.extension.st

This file was deleted.

0 comments on commit d49190e

Please sign in to comment.