mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
finalizing pdf and record support, preparing 0100 release
This commit is contained in:
+16
-29
@@ -8,22 +8,9 @@ import com.lowagie.text.pdf.*;
|
||||
|
||||
import processing.core.*;
|
||||
|
||||
// need to concatenate the first two frames together..
|
||||
// that a begin/endFrame when frameCount == 0 shouldn't really count
|
||||
|
||||
// may need an alternative version of this so that
|
||||
// recordFrame(pgpdf, "filename.pdf") would work
|
||||
// this would also help the savePath() situation
|
||||
// since it would be a call inside PApplet
|
||||
|
||||
|
||||
public class PGraphicsPDF extends PGraphics2 {
|
||||
|
||||
// recording api.. allow multiple frames per file?
|
||||
// would be the case for video, or for pdf
|
||||
|
||||
//static public String filename;
|
||||
|
||||
File temp;
|
||||
int frameCount;
|
||||
File file;
|
||||
@@ -33,7 +20,6 @@ public class PGraphicsPDF extends PGraphics2 {
|
||||
PdfTemplate tp;
|
||||
DefaultFontMapper mapper;
|
||||
|
||||
|
||||
// BaseFont baseFont = mapper.awtToPdf(java.awt.Font awtFont)
|
||||
|
||||
|
||||
@@ -56,9 +42,9 @@ public class PGraphicsPDF extends PGraphics2 {
|
||||
"for the location of the output file.");
|
||||
}
|
||||
|
||||
if (applet != null) {
|
||||
applet.registerDispose(this);
|
||||
}
|
||||
//if (applet != null) {
|
||||
// applet.registerDispose(this);
|
||||
//}
|
||||
|
||||
//System.out.println("making " + path);
|
||||
|
||||
@@ -95,17 +81,6 @@ public class PGraphicsPDF extends PGraphics2 {
|
||||
}
|
||||
|
||||
|
||||
public void dispose() {
|
||||
//System.out.println("calling dispose");
|
||||
if (document != null) {
|
||||
g2.dispose();
|
||||
document.close(); // can't be done in finalize, not always called
|
||||
document = null;
|
||||
}
|
||||
//new Exception().printStackTrace(System.out);
|
||||
}
|
||||
|
||||
|
||||
// create a temporary file and put the graphics crap there
|
||||
// don't start a fresh page if frameCount is zero (setup isn't its own page)
|
||||
|
||||
@@ -181,7 +156,6 @@ public class PGraphicsPDF extends PGraphics2 {
|
||||
//g2 = content.createGraphics(width, height);
|
||||
g2 = content.createGraphicsShapes(width, height);
|
||||
}
|
||||
|
||||
super.beginFrame();
|
||||
}
|
||||
|
||||
@@ -239,6 +213,17 @@ public class PGraphicsPDF extends PGraphics2 {
|
||||
}
|
||||
|
||||
|
||||
public void dispose() {
|
||||
//System.out.println("calling dispose");
|
||||
if (document != null) {
|
||||
g2.dispose();
|
||||
document.close(); // can't be done in finalize, not always called
|
||||
document = null;
|
||||
}
|
||||
//new Exception().printStackTrace(System.out);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
protected void finalize() throws Throwable {
|
||||
System.out.println("calling finalize");
|
||||
@@ -250,6 +235,7 @@ public class PGraphicsPDF extends PGraphics2 {
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*
|
||||
public void endRecord() {
|
||||
super.endRecord();
|
||||
dispose();
|
||||
@@ -263,6 +249,7 @@ public class PGraphicsPDF extends PGraphics2 {
|
||||
dispose();
|
||||
System.out.println("done");
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user