processing.pdf
Class PGraphicsPDF

java.lang.Object
  extended byprocessing.core.PImage
      extended byprocessing.core.PGraphics
          extended byprocessing.core.PGraphicsJava2D
              extended byprocessing.pdf.PGraphicsPDF
All Implemented Interfaces:
java.lang.Cloneable, PConstants

public class PGraphicsPDF
extends PGraphicsJava2D


Field Summary
 
Fields inherited from class processing.core.PGraphicsJava2D
fillGradient, fillGradientObject, g2, strokeGradient, strokeGradientObject
 
Fields inherited from class processing.core.PGraphics
A, AB, AG, ambientB, ambientG, ambientR, AR, AUTO_NORMAL, B, backgroundColor, BEEN_LIT, bezierDetail, camera, cameraAspect, cameraFar, cameraFOV, cameraInv, cameraNear, cameraX, cameraY, cameraZ, colorMode, colorModeA, colorModeX, colorModeY, colorModeZ, currentLightFalloffConstant, currentLightFalloffLinear, currentLightFalloffQuadratic, currentLightSpecular, curveTightness, DA, DB, DG, DR, EB, EG, ellipseMode, emissiveB, emissiveG, emissiveR, ER, fill, fillColor, G, height1, image, INDEX, lightCount, lightDiffuse, lightFalloffConstant, lightFalloffLinear, lightFalloffQuadratic, lightNormal, lightPosition, lightSpecular, lightSpotAngle, lightSpotAngleCos, lightSpotConcentration, lightType, LINE_FIELD_COUNT, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33, MANUAL_SHAPE_NORMAL, MANUAL_VERTEX_NORMAL, MAX_LIGHTS, modelview, modelviewInv, MX, MY, MZ, normalCount, normalMode, normalX, normalY, normalZ, NX, NY, NZ, pixelCount, projection, R, raw, rectMode, SA, SB, SG, SHINE, shininess, SPA, SPB, specularA, specularB, specularG, specularR, SPG, sphereDetail, SPR, SR, stencil, stroke, STROKE_MODE, STROKE_WEIGHT, strokeCap, strokeColor, strokeJoin, strokeWeight, SW, textAlign, textAlignY, textFont, textFontNative, textFontNativeMetrics, textLeading, textMode, textSize, TEXTURE_INDEX, textureImage, textureMode, textureU, textureV, textX, textY, textZ, tint, tintColor, TRI_DIFFUSE_A, TRI_DIFFUSE_B, TRI_DIFFUSE_G, TRI_DIFFUSE_R, TRI_SPECULAR_A, TRI_SPECULAR_B, TRI_SPECULAR_G, TRI_SPECULAR_R, TRIANGLE_COLOR_COUNT, TRIANGLE_FIELD_COUNT, U, V, VERTEX1, VERTEX2, VERTEX3, VW, VX, VY, VZ, width1, X, Y, Z, zbuffer
 
Fields inherited from class processing.core.PImage
cache, format, height, imageMode, modified, mx1, mx2, my1, my2, parent, pixels, smooth, width
 
Fields inherited from interface processing.core.PConstants
ADD, ALPHA, ALPHA_MASK, ALT, AMBIENT, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BURN, CENTER, CENTER_RADIUS, CHATTER, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_AUTO_GZIP, DISABLE_DEPTH_TEST, DISABLE_ERROR_REPORT, DISABLE_TEXT_SMOOTH, DODGE, DOWN, DXF, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_NATIVE_FONTS, ENTER, EPSILON, ERODE, ESC, EXCLUSION, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINES, LINUX, MACOS9, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NO_FLYING_POO, NORMALIZED, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PDF, PERSPECTIVE, PI, PIXEL_CENTER, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD_STRIP, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPOT, SQUARE, SUBTRACT, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, WAIT, WHITESPACE, WINDOWS
 
Constructor Summary
PGraphicsPDF(int width, int height, PApplet applet)
           
PGraphicsPDF(int width, int height, PApplet applet, java.lang.String path)
           
 
Method Summary
 void addFonts(java.lang.String directory)
          Add a directory that should be searched for font data.
 void beginDraw()
          Prepares the PGraphics for drawing.
 void blend(int sx, int sy, int dx, int dy, int mode)
           
 void blend(int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2, int mode)
          Blends one area of this image to another area.
 void blend(PImage src, int sx, int sy, int dx, int dy, int mode)
           
 void blend(PImage src, int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2, int mode)
          Copies area of one image into another PImage object.
 void copy(int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2)
          Copy things from one area of this image to another area in the same image.
 void copy(PImage src, int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2)
          Copies area of one image into another PImage object.
 boolean displayable()
          Don't open a window for this renderer, it won't be used.
 void dispose()
          Handle any takedown for this graphics context.
 void endDraw()
          This will finalize rendering so that it can be shown on-screen.
 void filter(int kind)
          Method to apply a variety of basic filters to this image.
 void filter(int kind, float param)
          Method to apply a variety of basic filters to this image.
 PImage get()
          Grab a copy of the current pixel buffer.
 int get(int x, int y)
          Returns an ARGB "color" type (a packed 32 bit int with the color.
 PImage get(int x, int y, int c, int d)
          Grab a subsection of a PImage, and copy it into a fresh PImage.
 java.lang.String[] listFonts()
          List the fonts known to the PDF renderer.
 void loadPixels()
          Call this when you want to mess with the pixels[] array.
 void mask(int[] alpha)
          Use with caution on PGraphics.
 void mask(PImage alpha)
          Use with caution on PGraphics.
 void nextPage()
          Call to explicitly go to the next page from within a single draw().
 void save(java.lang.String filename)
          Save this image to disk.
 void set(int x, int y, int argb)
          Silently ignores if the coordinate is outside the image.
 void set(int x, int y, PImage image)
           
 void setMainDrawingSurface()
          Set this as the main drawing surface.
 void textMode(int mode)
          Change the textMode() to either SHAPE or MODEL.
 void updatePixels()
          Update the pixels[] buffer to the PGraphics image.
 void updatePixels(int x, int y, int c, int d)
          Update the pixels[] buffer to the PGraphics image.
 
Methods inherited from class processing.core.PGraphicsJava2D
applyMatrix, background, beginRaw, beginShape, bezierDetail, bezierVertex, breakShape, clear, curveDetail, curveVertex, endRaw, endShape, line, loadMatrix, noSmooth, point, popMatrix, pushMatrix, quad, resetMatrix, resize, rotate, scale, scale, screenX, screenY, smooth, strokeCap, strokeJoin, strokeWeight, textAscent, textDescent, textSize, texture, textureMode, translate, triangle, vertex, vertex, vertex, vertex
 
Methods inherited from class processing.core.PGraphics
alpha, ambient, ambient, ambient, ambientLight, ambientLight, applyMatrix, arc, background, background, background, background, background, background, beginCamera, beginShape, bezier, bezier, bezierPoint, bezierTangent, bezierVertex, blue, box, box, brightness, camera, camera, color, color, color, color, color, color, color, color, color, colorMode, colorMode, colorMode, colorMode, curve, curve, curvePoint, curveTangent, curveTightness, curveVertex, defaults, directionalLight, ellipse, ellipseMode, emissive, emissive, emissive, endCamera, endShape, fill, fill, fill, fill, fill, fill, frustum, green, hint, hue, image, image, image, lerpColor, lerpColor, lightFalloff, lights, lightSpecular, line, modelX, modelY, modelZ, noFill, noHint, normal, noStroke, noTint, ortho, ortho, perspective, perspective, point, pointLight, printCamera, printMatrix, printProjection, rect, rectMode, red, requestDisplay, rotate, rotateX, rotateY, rotateZ, saturation, scale, screenX, screenY, screenZ, shininess, specular, specular, specular, specular, specular, sphere, sphereDetail, spotLight, stroke, stroke, stroke, stroke, stroke, stroke, text, text, text, text, text, text, text, text, text, text, text, text, textAlign, textAlign, textFont, textFont, textLeading, textWidth, textWidth, tint, tint, tint, tint, tint, tint, translate
 
Methods inherited from class processing.core.PImage
blendColor, clone, imageMode, init
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PGraphicsPDF

public PGraphicsPDF(int width,
                    int height,
                    PApplet applet)

PGraphicsPDF

public PGraphicsPDF(int width,
                    int height,
                    PApplet applet,
                    java.lang.String path)
Method Detail

setMainDrawingSurface

public void setMainDrawingSurface()
Description copied from class: PGraphics
Set this as the main drawing surface. Meaning that it can safely be set to opaque (given a default gray background) and listeners for the mouse and keyboard added.

This should only be used by subclasses of PGraphics.

Overrides:
setMainDrawingSurface in class PGraphics

beginDraw

public void beginDraw()
Description copied from class: PGraphics
Prepares the PGraphics for drawing.

When creating your own PGraphics, you should call this before drawing anything.

Overrides:
beginDraw in class PGraphicsJava2D

textMode

public void textMode(int mode)
Change the textMode() to either SHAPE or MODEL.
This resets all renderer settings, and should therefore be called before any other commands that set the fill() or the textFont() or anything. Unlike other renderers, use textMode() directly after the size() command.

Overrides:
textMode in class PGraphics

nextPage

public void nextPage()
Call to explicitly go to the next page from within a single draw().


endDraw

public void endDraw()
Description copied from class: PGraphics
This will finalize rendering so that it can be shown on-screen.

When creating your own PGraphics, you should call this when you're finished drawing.

Overrides:
endDraw in class PGraphicsJava2D

dispose

public void dispose()
Description copied from class: PGraphics
Handle any takedown for this graphics context.

This is called when a sketch is shut down and this renderer was specified using the size() command, or inside endRecord() and endRaw(), in order to shut things off.

Overrides:
dispose in class PGraphics

displayable

public boolean displayable()
Don't open a window for this renderer, it won't be used.

Overrides:
displayable in class PGraphics

loadPixels

public void loadPixels()
Description copied from class: PImage
Call this when you want to mess with the pixels[] array.

For subclasses where the pixels[] buffer isn't set by default, this should copy all data into the pixels[] array

Overrides:
loadPixels in class PGraphicsJava2D

updatePixels

public void updatePixels()
Description copied from class: PGraphicsJava2D
Update the pixels[] buffer to the PGraphics image.

Unlike in PImage, where updatePixels() only requests that the update happens, in PGraphicsJava2D, this will happen immediately.

Overrides:
updatePixels in class PGraphicsJava2D

updatePixels

public void updatePixels(int x,
                         int y,
                         int c,
                         int d)
Description copied from class: PGraphicsJava2D
Update the pixels[] buffer to the PGraphics image.

Unlike in PImage, where updatePixels() only requests that the update happens, in PGraphicsJava2D, this will happen immediately.

Overrides:
updatePixels in class PGraphicsJava2D

get

public int get(int x,
               int y)
Description copied from class: PImage
Returns an ARGB "color" type (a packed 32 bit int with the color. If the coordinate is outside the image, zero is returned (black, but completely transparent).

If the image is in RGB format (i.e. on a PVideo object), the value will get its high bits set, just to avoid cases where they haven't been set already.

If the image is in ALPHA format, this returns a white with its alpha value set.

This function is included primarily for beginners. It is quite slow because it has to check to see if the x, y that was provided is inside the bounds, and then has to check to see what image type it is. If you want things to be more efficient, access the pixels[] array directly.

Overrides:
get in class PGraphicsJava2D

get

public PImage get(int x,
                  int y,
                  int c,
                  int d)
Description copied from class: PImage
Grab a subsection of a PImage, and copy it into a fresh PImage. This honors imageMode() for the coordinates.

Overrides:
get in class PGraphicsJava2D

get

public PImage get()
Description copied from class: PGraphicsJava2D
Grab a copy of the current pixel buffer.

Overrides:
get in class PGraphicsJava2D

set

public void set(int x,
                int y,
                int argb)
Description copied from class: PImage
Silently ignores if the coordinate is outside the image.

Overrides:
set in class PGraphicsJava2D

set

public void set(int x,
                int y,
                PImage image)
Overrides:
set in class PImage

mask

public void mask(int[] alpha)
Description copied from class: PGraphics
Use with caution on PGraphics. This should not be used with the base PGraphics that's tied to a PApplet, but it can be used with user-created PGraphics objects that are drawn to the screen.

Overrides:
mask in class PGraphicsJava2D

mask

public void mask(PImage alpha)
Description copied from class: PGraphics
Use with caution on PGraphics. This should not be used with the base PGraphics that's tied to a PApplet, but it can be used with user-created PGraphics objects that are drawn to the screen.

Overrides:
mask in class PGraphicsJava2D

filter

public void filter(int kind)
Description copied from class: PImage
Method to apply a variety of basic filters to this image.

Luminance conversion code contributed by toxi

Gaussian blur code contributed by Mario Klingemann

Overrides:
filter in class PGraphicsJava2D

filter

public void filter(int kind,
                   float param)
Description copied from class: PImage
Method to apply a variety of basic filters to this image. These filters all take a parameter.

Gaussian blur code contributed by Mario Klingemann and later updated by toxi for better speed.

Overrides:
filter in class PGraphicsJava2D

copy

public void copy(int sx1,
                 int sy1,
                 int sx2,
                 int sy2,
                 int dx1,
                 int dy1,
                 int dx2,
                 int dy2)
Description copied from class: PImage
Copy things from one area of this image to another area in the same image.

Overrides:
copy in class PGraphicsJava2D

copy

public void copy(PImage src,
                 int sx1,
                 int sy1,
                 int sx2,
                 int sy2,
                 int dx1,
                 int dy1,
                 int dx2,
                 int dy2)
Description copied from class: PImage
Copies area of one image into another PImage object.

Overrides:
copy in class PGraphicsJava2D

blend

public void blend(int sx,
                  int sy,
                  int dx,
                  int dy,
                  int mode)

blend

public void blend(PImage src,
                  int sx,
                  int sy,
                  int dx,
                  int dy,
                  int mode)

blend

public void blend(int sx1,
                  int sy1,
                  int sx2,
                  int sy2,
                  int dx1,
                  int dy1,
                  int dx2,
                  int dy2,
                  int mode)
Description copied from class: PImage
Blends one area of this image to another area.

Overrides:
blend in class PGraphicsJava2D

blend

public void blend(PImage src,
                  int sx1,
                  int sy1,
                  int sx2,
                  int sy2,
                  int dx1,
                  int dy1,
                  int dx2,
                  int dy2,
                  int mode)
Description copied from class: PImage
Copies area of one image into another PImage object.

Overrides:
blend in class PGraphicsJava2D

save

public void save(java.lang.String filename)
Description copied from class: PImage
Save this image to disk.

As of revision 0100, this function requires an absolute path, in order to avoid confusion. To save inside the sketch folder, use the function savePath() from PApplet, or use saveFrame() instead.

As of revision 0115, when using Java 1.4 and later, you can write to several formats besides tga and tiff. If Java 1.4 is installed and the extension used is supported (usually png, jpg, jpeg, bmp, and tiff), then those methods will be used to write the image. To get a list of the supported formats for writing, use:
println(javax.imageio.ImageIO.getReaderFormatNames())

To use the original built-in image writers, use .tga as the extension, or don't include an extension, in which case .tif will be added.

The ImageIO API claims to support wbmp files, however they probably require a black and white image. Basic testing produced a zero-length file with no error.

As of revision 0116, savePath() is not needed if this object has been created (as recommended) via createImage() or createGraphics() or one of its neighbors.

Overrides:
save in class PGraphicsJava2D

addFonts

public void addFonts(java.lang.String directory)
Add a directory that should be searched for font data.
On Mac OS X, the following directories are added by default: On Windows, all drive letters are searched for WINDOWS\Fonts or WINNT\Fonts, any that exists is added.

On Linux or any other platform, you'll need to add the directories by hand. (If there are actual standards here that we can use as a starting point, please file a bug to make a note of it)


listFonts

public java.lang.String[] listFonts()
List the fonts known to the PDF renderer. This is like PFont.list(), however not all those fonts are available by default.