51 lines
1.2 KiB
Smalltalk
51 lines
1.2 KiB
Smalltalk
Class {
|
|
#name : #GrafoscopioTrunkNode,
|
|
#superclass : #GrafoscopioAbstractNode,
|
|
#instVars : [
|
|
'children'
|
|
],
|
|
#category : #'Grafoscopio-Model'
|
|
}
|
|
|
|
{ #category : #testing }
|
|
GrafoscopioTrunkNode class >> isAbstract [
|
|
^ self = GrafoscopioTrunkNode
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioTrunkNode >> children [
|
|
"Returns the receivers list of children"
|
|
|
|
^ children ifNil: [ children := OrderedCollection new ]
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioTrunkNode >> children: aCollection [
|
|
"Sets the receivers children"
|
|
|
|
aCollection do: [:currentNode | currentNode parent: self ].
|
|
children := aCollection.
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
GrafoscopioTrunkNode >> isLeaf [
|
|
^ false
|
|
]
|
|
|
|
{ #category : #movement }
|
|
GrafoscopioTrunkNode >> moveDown: aNode [
|
|
| index |
|
|
"Moves the current node a place before in the children collection where is located"
|
|
index := (children indexOf: aNode) max: 1 .
|
|
|
|
children swap: index with: (index + 1 min: children size)
|
|
]
|
|
|
|
{ #category : #movement }
|
|
GrafoscopioTrunkNode >> moveUp: aNode [
|
|
| index |
|
|
"Moves the current node a place before in the children collection where is located"
|
|
index := children indexOf: aNode.
|
|
children swap: index with: (index - 1 max: 1)
|
|
]
|