Ejemplo n.º 1
0
 /** 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;
 }
Ejemplo n.º 2
0
 /** 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);
     }
   }
 }
Ejemplo n.º 3
0
  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);
  }