Examples of PGraphicsJava2D


Examples of processing.core.PGraphicsJava2D

        Color endColor = new Color(startColor.getRed(), startColor.getGreen(), startColor.getBlue(), 0);
        float radius = size * 6;

        //Get processing Java2D canvas, as its easier to use a RadialGradientPaint
        //here but we could do a 100% processing solution as well
        PGraphicsJava2D graphics = (PGraphicsJava2D) target.getGraphics();
        Graphics2D g2 = graphics.g2;
       
       
        RadialGradientPaint p = new RadialGradientPaint(new Point2D.Double(x, y), radius,
                new float[]{
View Full Code Here

Examples of processing.core.PGraphicsJava2D

        target = (ProcessingTarget) controller.getRenderTarget(RenderTarget.PROCESSING_TARGET, workspace);

        try {
            target.refresh();

            PGraphicsJava2D pg2 = (PGraphicsJava2D) target.getGraphics();
            BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            img.setRGB(0, 0, width, height, pg2.pixels, 0, width);
            ImageIO.write(img, "jpg", stream);
            stream.close();
View Full Code Here

Examples of processing.core.PGraphicsJava2D

   * @return a PGraphics object showing current state of the control (ignoring rotation)
   */
  public PGraphics getSnapshot(){
    if(buffer != null){
      updateBuffer();
      PGraphicsJava2D snap = (PGraphicsJava2D) winApp.createGraphics(buffer.width, buffer.height, PApplet.JAVA2D);
      snap.beginDraw();
      snap.image(buffer,0,0);
      return snap;
    }
    return null;
  }
View Full Code Here

Examples of processing.core.PGraphicsJava2D

    winApp.popStyle();
  }

  public PGraphics getSnapshot(){
    updateBuffer();
    PGraphicsJava2D snap = (PGraphicsJava2D) winApp.createGraphics(buffer.width, buffer.height, PApplet.JAVA2D);
    snap.beginDraw();
    snap.image(buffer,0,0);
    if(hsb != null){
      snap.pushMatrix();
      snap.translate(hsb.getX(), hsb.getY());
      snap.image(hsb.getBuffer(), 0, 0);
      snap.popMatrix();
    }
    if(vsb != null){
      snap.pushMatrix();
      snap.translate(vsb.getX(), vsb.getY());
      snap.rotate(PApplet.PI/2);
      snap.image(vsb.getBuffer(), 0, 0);
      snap.popMatrix();
    }
    snap.endDraw();
    return snap;
  }
View Full Code Here

Examples of processing.core.PGraphicsJava2D

    bufferInvalid = true;
  }

  public PGraphics getSnapshot(){
    updateBuffer();
    PGraphicsJava2D snap = (PGraphicsJava2D) winApp.createGraphics(buffer.width, buffer.height, PApplet.JAVA2D);
    snap.beginDraw();
    snap.image(buffer,0,0);
    if(hsb != null){
      snap.pushMatrix();
      snap.translate(hsb.getX(), hsb.getY());
      snap.image(hsb.getBuffer(), 0, 0);
      snap.popMatrix();
    }
    snap.endDraw();
    return snap;
  }
View Full Code Here

Examples of processing.core.PGraphicsJava2D

      canvas.textAlign(PConstants.LEFT, PConstants.BOTTOM);
      canvas.textSize(textSize);
      canvas.text(n.getLabel(), 0, 0 + dFont);
    } else
    {
      PGraphicsJava2D pgj = (PGraphicsJava2D) canvas;
      Graphics2D g2 = pgj.g2;
      /*
       * If it's not a leaf, then draw the white background.
       */
//      if (!tree.isLeaf(n))
View Full Code Here

Examples of processing.core.PGraphicsJava2D

  public void size(int w, int h) {
    if (width != w || h != h) size(w, h, JAVA2D);
    // size(w,h,P3D);
    // size(w,h,OPENGL);
    if (g.getClass() == PGraphicsJava2D.class) {
      PGraphicsJava2D pg = (PGraphicsJava2D) g;
      hint(PConstants.ENABLE_NATIVE_FONTS); // Native fonts are nice!
      usingNativeFonts = true;
      pg.g2.setRenderingHint(
        RenderingHints.KEY_FRACTIONALMETRICS,
        RenderingHints.VALUE_FRACTIONALMETRICS_ON);
View Full Code Here

Examples of processing.core.PGraphicsJava2D

    canvas.pushMatrix();
    canvas.translate(getX(n) + dotWidth / 2 + textSize / 3, getY(n));
    canvas.rotate(PApplet.radians(textRotation));

    PGraphicsJava2D pgj = (PGraphicsJava2D) canvas;
    Graphics2D g2 = pgj.g2;
    g2.setFont(font.font.deriveFont(textSize));
    g2.setPaint(style.foregroundColor);
    if (!alignRight)
      g2.drawString(n.getLabel(), 0, 0 + dFont);
View Full Code Here

Examples of processing.core.PGraphicsJava2D

      preprocess(t);
      File f = p.outputFile("Save image as...");
      p.noLoop();
      int width = Math.min(1600, p.width * 4);
      int height = Math.min(1200, p.height * 4);
      PGraphicsJava2D canvas = (PGraphicsJava2D) p.createGraphics(width,
          height, PConstants.JAVA2D);
      canvas.beginDraw();
      prettyHints(canvas);
      canvas.background(255);
      r.render(canvas, 0, 0, canvas.width, canvas.height,true);
      canvas.endDraw();
      canvas.loadPixels();
      PImage img = canvas.get();
      canvas.dispose();
      img.loadPixels();
      img.save(f.getAbsolutePath());
    } catch (RuntimeException e)
    {
    } finally
View Full Code Here

Examples of processing.core.PGraphicsJava2D

  }

  public static synchronized void drawBackgroundRoundRect(MenuItem item,
      float x, float y, float width, float height)
  {
    PGraphicsJava2D buff = item.menu.buff;
    StyleSet style = item.menu.style;
    Menu menu = item.menu;

    roundRect.setRoundRect(x, y, width, height, style.roundOff,
        style.roundOff);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.