use of net.miginfocom.layout.ComponentWrapper in project Terasology by MovingBlocks.
the class MigLayout method onDraw.
@Override
public void onDraw(Canvas canvas) {
int[] bounds = { 0, 0, canvas.size().x, canvas.size().y };
layoutContainer(canvas, bounds);
for (ComponentWrapper wrapper : wrappers.values()) {
UIWidget component = (UIWidget) wrapper.getComponent();
Rect2i region = Rect2i.createFromMinAndSize(wrapper.getX(), wrapper.getY(), wrapper.getWidth(), wrapper.getHeight());
canvas.drawWidget(component, region);
}
if (debug) {
grid.paintDebug();
}
for (Rect2i region : debugRects) {
canvas.drawLine(region.minX(), region.minY(), region.maxX(), region.minY(), Color.WHITE);
canvas.drawLine(region.maxX(), region.minY(), region.maxX(), region.maxY(), Color.WHITE);
canvas.drawLine(region.maxX(), region.maxY(), region.minX(), region.maxY(), Color.WHITE);
canvas.drawLine(region.minX(), region.maxY(), region.minX(), region.minY(), Color.WHITE);
}
}
use of net.miginfocom.layout.ComponentWrapper in project Terasology by MovingBlocks.
the class MigLayout method addWidget.
@Override
public void addWidget(UIWidget element, CCHint hint) {
final ComponentWrapper cw = getWrapper(element);
final String cStr = ConstraintParser.prepare(hint != null ? hint.cc : "");
CC constraint = AccessController.doPrivileged((PrivilegedAction<CC>) () -> ConstraintParser.parseComponentConstraint(cStr));
ccMap.put(cw, constraint);
wrappers.put(element, cw);
children.add(cw);
dirty = true;
}
use of net.miginfocom.layout.ComponentWrapper in project Terasology by MovingBlocks.
the class MigLayout method removeWidget.
@Override
public void removeWidget(UIWidget element) {
ComponentWrapper cw = wrappers.remove(element);
ccMap.remove(cw);
children.remove(cw);
invalidate();
}
use of net.miginfocom.layout.ComponentWrapper in project Terasology by MovingBlocks.
the class MigLayout method layoutContainer.
public void layoutContainer(Canvas canvas, int[] bounds) {
for (ComponentWrapper wrapper : children) {
if (wrapper instanceof MigLayout) {
MigLayout layout = (MigLayout) wrapper;
layout.layoutContainer(canvas, bounds);
} else if (wrapper instanceof MigComponent) {
MigComponent migComponent = (MigComponent) wrapper;
migComponent.calculatePreferredSize(canvas, canvas.size());
}
}
checkCache();
if (grid.layout(bounds, lc.getAlignX(), lc.getAlignY(), debug, true)) {
grid = null;
checkCache();
grid.layout(bounds, lc.getAlignX(), lc.getAlignY(), debug, false);
}
}
use of net.miginfocom.layout.ComponentWrapper in project Terasology by MovingBlocks.
the class MigLayout method getWrapper.
private ComponentWrapper getWrapper(UIWidget comp) {
ComponentWrapper cw;
if (comp instanceof MigLayout) {
MigLayout migLayout = (MigLayout) comp;
migLayout.setParent(this);
cw = migLayout;
} else {
cw = new MigComponent(this, comp);
}
return cw;
}
Aggregations