Пример #1
0
 /**
  * Render this offscreen canvas to the specified graphics.
  *
  * @param graphics graphics to render this offscreen canvas to, must not be null
  */
 public void render(final Graphics2D graphics) {
   if (graphics == null) {
     throw new IllegalArgumentException("graphics must not be null");
   }
   final PPaintContext paintContext = new PPaintContext(graphics);
   paintContext.setRenderQuality(renderQuality);
   camera.fullPaint(paintContext);
 }
Пример #2
0
  @Override
  protected void paint(PPaintContext pc) {
    Graphics2D g2 = pc.getGraphics();
    g2.setColor(Color.BLACK);
    g2.setStroke(STROKE_ARROW);
    g2.draw(line);

    g2.draw(arrowHead);
    g2.fill(arrowHead);
  }
Пример #3
0
  protected void paint(PPaintContext paintContext) {
    Graphics2D g2 = paintContext.getGraphics();

    g2.setPaint(getPaint());
    g2.draw(getBoundsReference());
    g2.setFont(CalendarNode.DEFAULT_FONT);

    float y = (float) getY() + CalendarNode.TEXT_Y_OFFSET;
    paintContext
        .getGraphics()
        .drawString(dayOfMonthString, (float) getX() + CalendarNode.TEXT_X_OFFSET, y);

    if (hasWidthFocus && hasHeightFocus) {
      paintContext.pushClip(getBoundsReference());
      for (int i = 0; i < lines.size(); i++) {
        y += 10;
        g2.drawString((String) lines.get(i), (float) getX() + CalendarNode.TEXT_X_OFFSET, y);
      }
      paintContext.popClip(getBoundsReference());
    }
  }
Пример #4
0
 @Override
 protected void paint(PPaintContext paintContext) {
   layoutManager.updateZoomLayout(paintContext.getScale());
   if (layoutManager.isZUIVisibleChanged()) {
     if (getParent() instanceof ElementView) {
       ((ElementView) getParent()).getLayoutManager().updateLayout();
     }
     for (ConnectionView cv : getConnections()) {
       cv.updateLine();
     }
   }
   if (layoutManager.isZUIVisible()) {
     super.paint(paintContext);
   }
 }
Пример #5
0
  /**
   * Paints the region specified of the canvas onto the given Graphics Context.
   *
   * @param gc graphics onto within painting should occur
   * @param x left of the dirty region
   * @param y top of the dirty region
   * @param w width of the dirty region
   * @param h height of the dirty region
   */
  public void paintComponent(final GC gc, final int x, final int y, final int w, final int h) {
    PDebug.startProcessingOutput();

    GC imageGC = null;
    Graphics2D g2 = null;
    if (doubleBuffered) {
      imageGC = new GC(backBuffer);
      g2 = new SWTGraphics2D(imageGC, getDisplay());
    } else {
      g2 = new SWTGraphics2D(gc, getDisplay());
    }

    g2.setColor(Color.white);
    g2.setBackground(Color.white);

    final Rectangle rect = getBounds();
    g2.fillRect(0, 0, rect.width, rect.height);

    // This fixes a problem with standard debugging of region management in
    // SWT
    if (PDebug.debugRegionManagement) {
      final Rectangle r = gc.getClipping();
      final Rectangle2D r2 = new Rectangle2D.Double(r.x, r.y, r.width, r.height);
      g2.setBackground(PDebug.getDebugPaintColor());
      g2.fill(r2);
    }

    // create new paint context and set render quality
    final PPaintContext paintContext = new PPaintContext(g2);
    if (getInteracting() || getAnimating()) {
      if (interactingRenderQuality > animatingRenderQuality) {
        paintContext.setRenderQuality(interactingRenderQuality);
      } else {
        paintContext.setRenderQuality(animatingRenderQuality);
      }
    } else {
      paintContext.setRenderQuality(defaultRenderQuality);
    }

    // paint Piccolo2D
    camera.fullPaint(paintContext);

    // if switched state from animating to not animating invalidate
    // the entire screen so that it will be drawn with the default instead
    // of animating render quality.
    if (animatingOnLastPaint && !getAnimating()) {
      repaint();
    }
    animatingOnLastPaint = getAnimating();

    final boolean region = PDebug.debugRegionManagement;
    PDebug.debugRegionManagement = false;
    PDebug.endProcessingOutput(g2);
    PDebug.debugRegionManagement = region;

    if (doubleBuffered) {
      gc.drawImage(backBuffer, 0, 0);

      // Dispose of the allocated image gc
      imageGC.dispose();
    }
  }