dimension = horizontal ? width : height
If you're not familiar with ternary operations, what this says is "if horizontal is true, use the width, otherwise use the height".
horizontal ? node.getWidth() : node.getHeight()
getImportant(node)
getUnimportant(node)
Cool! We initialize it with horizontal, and the bodies of those methods are exactly that ternary.
maxImportant
minImportant
preferredImportant
And we can create just one of these, right at the moment(s) where horizontal is set, we instantiate a DimensionGetter, pass it the flag, and use that one guy all over.
Some notes to help you think about it all.
geepawhill.org
It's free and spam-free, and it helps support me, so subscribe now!