Search in sources :

Example 16 with DoubleSize

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;
}
Also used : FrameUIModel(edu.cmu.cs.hcii.cogtool.uimodel.FrameUIModel) ByteArrayInputStream(java.io.ByteArrayInputStream) Image(org.eclipse.swt.graphics.Image) DoubleSize(edu.cmu.cs.hcii.cogtool.model.DoubleSize)

Example 17 with DoubleSize

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);
}
Also used : StandardDrawingEditor(edu.cmu.cs.hcii.cogtool.view.StandardDrawingEditor) DoubleSize(edu.cmu.cs.hcii.cogtool.model.DoubleSize)

Aggregations

DoubleSize (edu.cmu.cs.hcii.cogtool.model.DoubleSize)17 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)8 AParentWidget (edu.cmu.cs.hcii.cogtool.model.AParentWidget)4 ChildWidget (edu.cmu.cs.hcii.cogtool.model.ChildWidget)4 StandardDrawingEditor (edu.cmu.cs.hcii.cogtool.view.StandardDrawingEditor)4 Rectangle (org.eclipse.draw2d.geometry.Rectangle)4 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)3 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)3 MenuHeader (edu.cmu.cs.hcii.cogtool.model.MenuHeader)3 SimpleWidgetGroup (edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)3 ListItem (edu.cmu.cs.hcii.cogtool.model.ListItem)2 ScalableFrameFigure (edu.cmu.cs.hcii.cogtool.view.ScalableFrameFigure)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 XYLayout (org.eclipse.draw2d.XYLayout)2 Image (org.eclipse.swt.graphics.Image)2 CogToolWorkThread (edu.cmu.cs.hcii.cogtool.CogToolWorkThread)1 AShape (edu.cmu.cs.hcii.cogtool.model.AShape)1 FrameUIModel (edu.cmu.cs.hcii.cogtool.uimodel.FrameUIModel)1 GraphicalChildWidget (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalChildWidget)1 GraphicalMenuItem (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalMenuItem)1