private Canvas createCanvas(final Graphics graphic, final Rectangle paintArea) { final int w = internalDisplaySize.getWidth(); final int h = internalDisplaySize.getHeight(); if (doubleBuffering) { if ((doubleBuffer == null) || (bufferGraphics == null) || (doubleBuffer.getWidth(null) < w) || (doubleBuffer.getHeight(null) < h)) { doubleBuffer = renderingArea.createImage(w, h); LOG.debug( "buffer sized to " + doubleBuffer.getWidth(null) + "x" + doubleBuffer.getHeight(null)); } bufferGraphics = doubleBuffer.getGraphics().create(); } else { bufferGraphics = graphic; } bufferGraphics.clearRect(paintArea.x, paintArea.y, paintArea.width, paintArea.height); bufferGraphics.clearRect(0, 0, w, h); bufferGraphics.setClip(paintArea.x, paintArea.y, paintArea.width, paintArea.height); final Canvas c = new AwtCanvas( bufferGraphics, renderingArea, paintArea.x, paintArea.y, paintArea.width, paintArea.height); // Canvas c = new Canvas(bufferGraphics, 0, 0, w, h); return c; }
@Override public void showInOverlay(final Content content, final Location location) { View view; view = Toolkit.getViewFactory().createView(new ViewRequirement(content, ViewRequirement.OPEN)); view = new LineBorder( 2, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2), new BackgroundBorder(Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY3), view)); final Size size = view.getRequiredSize(Size.createMax()); location.subtract(size.getWidth() / 2, size.getHeight() / 2); view.setLocation(location); setOverlayView(view); }
public void initSize() { internalDisplaySize = createSize(renderingArea.getSize()); insets = renderingArea.getInsets(); LOG.debug(" insets " + insets); internalDisplaySize.contract(insets.left + insets.right, insets.top + insets.bottom); LOG.debug(" internal " + internalDisplaySize); final Size rootViewSize = new Size(internalDisplaySize); final Text text = Toolkit.getText(ColorsAndFonts.TEXT_STATUS); statusBarHeight = text.getLineHeight() + text.getDescent(); rootViewSize.contractHeight(statusBarHeight); statusBarArea = new Bounds( insets.left, insets.top + rootViewSize.getHeight(), rootViewSize.getWidth(), statusBarHeight); rootView.setSize(rootViewSize); }
private Location center(final View workspace, final View view) { final Size rootSize = workspace.getSize(); final Location location = new Location(rootSize.getWidth() / 2, rootSize.getHeight() / 2); final Size dialogSize = view.getRequiredSize(new Size(rootSize)); location.subtract(dialogSize.getWidth() / 2, dialogSize.getHeight() / 2); return location; }
private void paintStatus(final Graphics graphic) { final int height = internalDisplaySize.getHeight(); final int top = height - statusBarHeight; if (refreshStatus || graphic.getClip().getBounds().getY() + graphic.getClip().getBounds().getHeight() > top) { refreshStatus = false; UI_LOG.debug("changed user status " + status + " " + statusBarArea); final int width = internalDisplaySize.getWidth(); graphic.setClip(0, top, width, statusBarHeight); graphic.setColor( ((AwtColor) Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY3)).getAwtColor()); final AwtText textStyle = (AwtText) Toolkit.getText(ColorsAndFonts.TEXT_STATUS); graphic.setFont(textStyle.getAwtFont()); final int baseline = top + textStyle.getAscent(); graphic.fillRect(0, top, width, statusBarHeight); graphic.setColor( ((AwtColor) Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1)).getAwtColor()); graphic.drawLine(0, top, internalDisplaySize.getWidth(), top); // graphic.drawRect(0, top, width - 1, statusBarHeight - 1); graphic.setColor(((AwtColor) Toolkit.getColor(ColorsAndFonts.COLOR_BLACK)).getAwtColor()); graphic.drawString(status, 5, baseline + ViewConstants.VPADDING); } }
@Override public void doLayout(final Size maximumSize) { LOG.debug("doLayout() " + maximumSize + " " + getSize()); final View toolbar = getSubviews()[0]; maximumSize.contract(getPadding()); final Size toolbarSize = toolbar.getRequiredSize(maximumSize); LOG.debug(" toolbar " + toolbarSize); Bounds bounds = new Bounds(toolbarSize); toolbar.setBounds(bounds); final View grid = getSubviews()[1]; final Size gridSize = getRequiredSize(Size.createMax()); gridSize.contract(getPadding()); gridSize.contractHeight(toolbarSize.getHeight()); bounds = new Bounds(new Location(0, toolbarSize.getHeight()), gridSize); grid.setBounds(bounds); LOG.debug(" grid " + toolbarSize); }
@Override public Size requiredSize(final Size availableSpace) { final Size workspace = getWorkspace().getSize(); return new Size((int) (workspace.getWidth() * 0.8), (int) (workspace.getHeight() * 0.8)); }