use of org.eclipse.draw2d.geometry.Rectangle in project cogtool by cogtool.
the class InteractionDrawingEditor method resizeContents.
public void resizeContents(int width, int height, boolean resizeMin) {
// Get the size of the view in unscaled coordinates
Rectangle viewSize = contents.getChildrenUtilizedAreaScaled();
// We need the TOTAL size starting from 0,0. Not just the actual size.
int viewUIWidth = viewSize.width + viewSize.x;
int viewUIHeight = viewSize.height + viewSize.y;
// If the area grows, then we want to use the LARGER area
if (viewUIWidth > width) {
width = viewUIWidth;
}
if (viewUIHeight > height) {
height = viewUIHeight;
}
Dimension prefSize = new Dimension(width, height);
contents.setPreferredSize(prefSize);
contents.setSize(width, height);
interactionLayer.setPreferredSize(prefSize);
interactionLayer.setSize(width, height);
backgroundColorFigure.setPreferredSize(prefSize);
backgroundColorFigure.setSize(width, height);
if (resizeMin) {
setMinVisibleArea(width, height, false);
// Check to see if the area was enlarged if so grow to match
int editorWidth = editorComposite.getSize().x;
int editorHeight = editorComposite.getSize().y;
if (editorWidth > width) {
width = editorWidth;
}
if (editorHeight > height) {
height = editorHeight;
}
contents.setSize(width, height);
interactionLayer.setSize(width, height);
backgroundColorFigure.setSize(width, height);
}
}
use of org.eclipse.draw2d.geometry.Rectangle in project cogtool by cogtool.
the class InteractionDrawingEditor method computeZoomToFit.
public double computeZoomToFit() {
// Put the origin of the scrollable region back to 0,0
scrollComposite.setOrigin(0, 0);
// Ensures that both width and height will fit in available space
org.eclipse.swt.graphics.Rectangle visibleBounds = getVisibleBounds();
// Need to get the UNSCALEd version of currentFrame
Rectangle neededBounds = contents.getChildrenUtilizedAreaUnscaled();
double scalingToFit = 1.0;
// Need a fudge factor for some reason.
double neededWidth = neededBounds.width + 5.0;
double neededHeight = neededBounds.height + 5.0;
if (neededBounds.x > 0) {
neededWidth += neededBounds.x;
}
if (neededBounds.y > 0) {
neededHeight += neededBounds.y;
}
// If it doesn't fit then resize by height.
if ((neededWidth != 0.0) && (neededHeight != 0.0)) {
if (((visibleBounds.width) / neededWidth) * neededHeight < visibleBounds.height) {
scalingToFit = (visibleBounds.width) / neededWidth;
} else {
scalingToFit = (visibleBounds.height) / neededHeight;
}
}
return scalingToFit;
}
use of org.eclipse.draw2d.geometry.Rectangle in project cogtool by cogtool.
the class InteractionDrawingEditor method getContentSize.
@Override
public org.eclipse.swt.graphics.Rectangle getContentSize() {
Rectangle viewSize = contents.getChildrenUtilizedAreaScaled();
// We need the TOTAL size starting from 0,0. Not just the actual size.
viewSize.width += viewSize.x;
viewSize.height += viewSize.y;
// use 0,0 as origin
return new org.eclipse.swt.graphics.Rectangle(0, 0, viewSize.width, viewSize.height);
}
use of org.eclipse.draw2d.geometry.Rectangle in project cogtool by cogtool.
the class ScalableGraphicalFigure method getChildrenUtilizedAreaUnscaled.
/**
* Returns the area occupied by the children in UNSCALED coordinates
*/
public Rectangle getChildrenUtilizedAreaUnscaled() {
Rectangle r = null;
Iterator<?> iter = getChildren().iterator();
while (iter.hasNext()) {
IFigure fi = (IFigure) iter.next();
if (r == null) {
r = new Rectangle(fi.getBounds());
} else {
r.union(fi.getBounds());
}
}
return (r == null) ? new Rectangle(0, 0, 0, 0) : r;
}
use of org.eclipse.draw2d.geometry.Rectangle in project cogtool by cogtool.
the class MoveHalo method setScale.
@Override
public void setScale(double newScale) {
scale = newScale;
Rectangle scaled = PrecisionUtilities.getDraw2DRectangle(bds.x * scale, bds.y * scale, bds.width * scale, bds.height * scale);
scaled.x -= (ResizeThumb.WIDTH_HEIGHT / 2) + 2;
scaled.y -= (ResizeThumb.WIDTH_HEIGHT / 2) + 2;
scaled.width += ResizeThumb.WIDTH_HEIGHT + 4;
scaled.height += ResizeThumb.WIDTH_HEIGHT + 4;
setBounds(scaled);
}
Aggregations