I just made a small ‘library’ (~3 hours), that helps laying out objects (rectangles) on screen in a hirarchy of objects.
Have a screenshot:
I made a small typo there with “written Java”: It should be “written IN Java”.
Here is how to create a bunch of boxes, using the library:
void makeBoxes(ContainerNode root);
{
ContainerNode cnode = new ContainerNode(root);
cnode.setPreferredBounds(new RectangleF(64, 96));
cnode.addAttribute(LayoutAttribute.compassLayout());
cnode.addAttribute(CompassAligmentAttribute.south("vertical-align"));
cnode.addAttribute(CompassAligmentAttribute.west("horizontal-align"));
{
RectangleNode node = new RectangleNode(cnode);
node.setPreferredBounds(new RectangleF(16, 64));
node.addAttribute(CompassAligmentAttribute.north("vertical-align"));
node.addAttribute(CompassAligmentAttribute.west("horizontal-align"));
}
{
RectangleNode node = new RectangleNode(cnode);
node.setPreferredBounds(new RectangleF(24, 24));
node.addAttribute(CompassAligmentAttribute.center("vertical-align"));
node.addAttribute(CompassAligmentAttribute.east("horizontal-align"));
node.addAttribute(SizeAttribute.createPercentage("height", 50));
}
}
The entire thing doesn’t care about pixels/inches/centimeters or anything. It just says ‘units’, and thats it.
Its up to oneself how to use the values/rectangles the layout-library generates.
Have a nice day!
- Longor1996