use of edu.cmu.cs.hcii.cogtool.model.DoubleSize in project cogtool by cogtool.
the class DesignExportToHTML method buildFrameImage.
/**
* Builds the actual image object from the frame.
* Does this by creating an image object the size of the frame, and
* passes it as the canvas for drawing by the FrameDemoUI.
*
* Needs to pass it through a few SWT layers for it to work nicely though.
*
* NOTE: User of this class must dispose of the image themselves
* @param frame
* @return
*/
protected static Image buildFrameImage(Frame frame) {
// Need the View of the frame before I can build an image for it
FrameUIModel frameUI = new FrameUIModel(frame, false, WindowUtil.SELECT_CURSOR, 1.0, false, // Don't display color overlays
0, 0, // No attribute override
null);
DoubleSize size = frameUI.getPreferredSize();
// from DesignUImodel.. but not sure how to take advantage of that
if (size.height < 100) {
size.height = 100;
}
if (size.width < 100) {
size.width = 100;
}
byte[] bgImg = frame.getBackgroundImage();
Image image;
if (bgImg == null) {
image = new Image(null, PrecisionUtilities.ceiling(size.width), PrecisionUtilities.ceiling(size.height));
} else {
image = new Image(null, new ByteArrayInputStream(bgImg));
}
return image;
}
use of edu.cmu.cs.hcii.cogtool.model.DoubleSize in project cogtool by cogtool.
the class FrameEditorUI method resetVisibleArea.
public void resetVisibleArea() {
// TODO:mlh at least on PC, performUpdate screws up previous locn assignment
StandardDrawingEditor e = view.getEditor();
e.getLWS().getUpdateManager().performUpdate();
DoubleSize extent = frameUI.getPreferredSize();
e.setMinVisibleArea(PrecisionUtilities.round(extent.width), PrecisionUtilities.round(extent.height), false);
}
Aggregations