use of edu.cmu.cs.hcii.cogtool.model.AShape in project cogtool by cogtool.
the class GraphicalWidgetBase method updateShape.
public synchronized void updateShape() {
// Mark the caches as dirty so that no one will use them
synchronized (this.flagLock) {
this.cachedMidgroundDirty = true;
this.cachedBackgroundDirty = true;
}
// Keep track of some properties that we need later
Dimension oldSize = getSize();
GraphicalWidgetClipper oldClipper = this.clipper;
AShape s = model.getShape();
DoubleRectangle shapeBds = s.getBounds();
Rectangle figBds = PrecisionUtilities.getDraw2DRectangle(shapeBds);
// Inherit properties from our model's shape
setBounds(figBds);
if ((figBds.width == 0) || (figBds.height == 0)) {
if (figBds.width == 0) {
figBds.width = 1;
}
if (figBds.height == 0) {
figBds.height = 1;
}
super.setSize(figBds.width, figBds.height);
}
this.renderer.setSize(figBds.width, figBds.height);
setPreferredSize(figBds.width, figBds.height);
this.clipper = getClipperForShape(s);
// Decide whether the caches are really dirty
if (this.clipper.equals(oldClipper) && getSize().equals(oldSize)) {
synchronized (this.flagLock) {
this.cachedMidgroundDirty = false;
this.cachedBackgroundDirty = false;
}
}
regenerateCaches(figBds.width, figBds.height);
}
use of edu.cmu.cs.hcii.cogtool.model.AShape in project cogtool by cogtool.
the class DesignEditorCmd method getFirstChildPosition.
private static DoublePoint getFirstChildPosition(AParentWidget parent) {
AShape parentShape = parent.getShape();
DoublePoint pos = parentShape.getOrigin();
DoubleSize extent = parentShape.getSize();
switch(parent.getChildrenLocation()) {
case AParentWidget.CHILDREN_BELOW:
{
pos.y += extent.height;
break;
}
case AParentWidget.CHILDREN_RIGHT:
{
pos.x += extent.width;
break;
}
case AParentWidget.CHILDREN_CENTER:
{
pos.x += extent.width / 2.0;
pos.y += extent.height / 2.0;
break;
}
}
return pos;
}
Aggregations