Open olekscode opened 5 years ago
Your method looks like this:
attributeColorsTo: aCollectionOfRootClasses | arrayOfColors index | arrayOfColors := {#red . #blue . #pink . #purple . #tan . #yellow. #orange . #magenta . #green . #gray . #cyan . #brown . #darkGray. #lightBlue . #lightBrown . #lightCyan . #lightGray . #lightGreen. #lightMagenta . #lightOrange . #lightRed . #lightYellow . #paleBuff. #paleGreen . #paleMagenta . #paleOrange . #palePeach . #paleRed . #paleTan. #paleYellow . #black}. index := 0. rootClassesColors := (aCollectionOfRootClasses asBag sortedCounts) collect: [ :anAssociation | (index == arrayOfColors size) ifFalse: [ index := index + 1 ] . (anAssociation value -> (arrayOfColors at: index)). ]. ^ rootClassesColors
I suggest that you use some function of Color to get an array of colors. For example:
Color
Color wheel: 10.
If you still want to have colors hardcoded, put that array into a separate method that can be overriden by subclass:
palette ^ {#red . #blue . #pink . #purple . #tan . #yellow. #orange . #magenta . #green . #gray . #cyan . #brown . #darkGray. #lightBlue . #lightBrown . #lightCyan . #lightGray . #lightGreen. #lightMagenta . #lightOrange . #lightRed . #lightYellow . #paleBuff. #paleGreen . #paleMagenta . #paleOrange . #palePeach . #paleRed . #paleTan. #paleYellow . #black}.
attributeColorsTo: aCollectionOfRootClasses | arrayOfColors index | arrayOfColors := self palette. index := 0. rootClassesColors := (aCollectionOfRootClasses asBag sortedCounts) collect: [ :anAssociation | (index == arrayOfColors size) ifFalse: [ index := index + 1 ] . (anAssociation value -> (arrayOfColors at: index)). ]. ^ rootClassesColors
Your method looks like this:
I suggest that you use some function of
Color
to get an array of colors. For example:If you still want to have colors hardcoded, put that array into a separate method that can be overriden by subclass: