public Bounds getOverlayBounds() { final Bounds bounds = new Bounds(createSize(renderingArea.getSize())); final Insets in = renderingArea.getInsets(); bounds.contract(in.left + in.right, in.top + in.bottom); bounds.contract(0, statusBarHeight); return bounds; }
public void sizeChange() { initSize(); final View subviews[] = rootView.getSubviews(); for (final View subview : subviews) { subview.invalidateLayout(); } final Bounds bounds = new Bounds(internalDisplaySize); markDamaged(bounds); scheduleRepaint(); Properties.saveSizeOption(Properties.PROPERTY_BASE + "initial.size", bounds.getSize()); }
@Override public void markDamaged(final Bounds bounds) { if (spy != null) { spy.addDamagedArea(bounds); } synchronized (redrawArea) { if (redrawArea.equals(NO_REDRAW)) { redrawArea.setBounds(bounds); UI_LOG.debug("damage - new area " + redrawArea); } else { if (!bounds.getSize().equals(NO_SIZE)) { redrawArea.union(bounds); UI_LOG.debug("damage - extend area " + redrawArea + " - to include " + bounds); } } } }
/** Force a repaint of the damaged area of the viewer. */ @Override public void scheduleRepaint() { updateNotifier.invalidateViewsForChangedObjects(); synchronized (redrawArea) { if (!redrawArea.equals(NO_REDRAW) || refreshStatus) { UI_LOG.debug("repaint viewer " + redrawArea); final Bounds area = new Bounds(redrawArea); area.translate(insets.left, insets.top); renderingArea.repaint(area.getX(), area.getY(), area.getWidth(), area.getHeight()); redrawArea.setBounds(NO_REDRAW); } } }
/** Lays out the invalid views and returns the area to be repainted. */ private Rectangle layoutViews() { if (!Thread.currentThread().getName().startsWith("AWT-EventQueue") && !isDotNet()) { // REVIEW remove this check and exception when problem with multiple // field drawing is resolved // (Bug 1) throw new IsisException("Drawing with wrong thread: " + Thread.currentThread()); } // overlayView.layout(new Size(rootView.getSize())); // rootView.layout(new Size(rootView.getSize())); final Size rootViewSize = rootView.getSize(); overlayView.layout(); rootView.layout(); synchronized (redrawArea) { if (!redrawArea.equals(NO_REDRAW)) { final Rectangle r2 = new Rectangle( redrawArea.getX(), redrawArea.getY(), redrawArea.getWidth(), redrawArea.getHeight()); redrawArea.setBounds(NO_REDRAW); return r2; } } return null; }
public void paint(final Graphics graphic) { redrawCount++; graphic.translate(insets.left, insets.top); final Rectangle paintArea = graphic.getClipBounds(); final Rectangle layoutArea = layoutViews(); if (layoutArea != null) { paintArea.union(layoutArea); } if (spy != null) { spy.redraw(paintArea.toString(), redrawCount); } if (UI_LOG.isDebugEnabled()) { UI_LOG.debug( "------ repaint viewer #" + redrawCount + " " + paintArea.x + "," + paintArea.y + " " + paintArea.width + "x" + paintArea.height); } final Canvas c = createCanvas(graphic, paintArea); if (background != null) { background.draw(c.createSubcanvas(), rootView.getSize()); } // paint views if (rootView != null) { rootView.draw(c.createSubcanvas()); } // paint overlay final Bounds bounds = overlayView.getBounds(); if (paintArea.intersects( new Rectangle(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()))) { overlayView.draw(c.createSubcanvas(bounds)); } /* * for (int i = 0; i < panes.length; i++) { * panes[i].draw(c.createSubcanvas()); } */ // paint status // paintUserStatus(bufferGraphics); // blat to screen if (doubleBuffering) { graphic.drawImage(doubleBuffer, 0, 0, null); } if (showRepaintArea) { graphic.setColor( ((AwtColor) Toolkit.getColor(ColorsAndFonts.COLOR_DEBUG_BOUNDS_REPAINT)).getAwtColor()); graphic.drawRect(paintArea.x, paintArea.y, paintArea.width - 1, paintArea.height - 1); graphic.drawString("#" + redrawCount, paintArea.x + 3, paintArea.y + 15); } // paint status paintStatus(graphic); }