throw new RuntimeException("unknown constraint: "+constraint.getClass().getName());
}
DefaultLayoutConstraint cstr = (DefaultLayoutConstraint)constraint;
Rectangle prefSize = widget.getPreferredSize();
int prefWidth = prefSize.getWidth();
int prefHeight = prefSize.getHeight();
/**
* Negativ oder 0 bedeutet, da� keine bevorzugte Gr�sse angegeben wurde
*/
if (prefWidth<=0) {
prefWidth = cstr.width;
}
if (prefHeight<=0) {
prefHeight = cstr.height;
}
int width = 0;
int height = 0;
if (prefWidth < cstr.width) {
widget.setX(getAlignedCoordinate(prefWidth, cstr.width, cstr.x, cstr.horizontalConstraint));
width = prefWidth;
} else {
widget.setX(cstr.x);
width = cstr.width;
}
if (prefHeight < cstr.height) {
widget.setY(getAlignedCoordinate(prefHeight, cstr.height, cstr.y, cstr.verticalConstraint));
height = prefHeight;
} else {
widget.setY(cstr.y);
height = cstr.height;
}
widget.setSize(new Rectangle(width, height));
}