private void writeChar(char ch, StringBuffer sb) {
if (!useMultiByte) {
if (ch < 32 || ch > 127) {
- sb.append("\\").append(Integer.toOctalString((int)ch));
+ sb.append("\\").append(Integer.toOctalString(ch));
} else {
switch (ch) {
case '(':
this.textRenderingMode = TR_FILL;
}
- /**
- * Creates a "q" command, pushing a copy of the entire graphics state onto the stack.
- */
- public void saveGraphicsState() {
- write("q\n");
- }
-
- /**
- * Creates a "Q" command, restoring the entire graphics state to its former value by popping
- * it from the stack.
- */
- public void restoreGraphicsState() {
- write("Q\n");
- }
-
/**
* Creates a "cm" command.
* @param at the transformation matrix
&& !trans.isIdentity();
if (newClip || newTransform) {
- currentStream.write("q\n");
- paintingState.save();
+ saveGraphicsState();
if (newTransform) {
concatMatrix(tranvals);
}
applyUnknownPaint(paint, ss);
if (newClip || newTransform) {
- currentStream.write("Q\n");
- paintingState.restore();
+ restoreGraphicsState();
}
return;
}
processPathIterator(iter);
doDrawing(false, true, false);
if (newClip || newTransform) {
- currentStream.write("Q\n");
- paintingState.restore();
+ restoreGraphicsState();
}
}
&& !trans.isIdentity();
if (newClip || newTransform) {
- currentStream.write("q\n");
- paintingState.save();
+ saveGraphicsState();
if (newTransform) {
concatMatrix(tranvals);
}
applyUnknownPaint(paint, s);
if (newClip || newTransform) {
- currentStream.write("Q\n");
- paintingState.restore();
+ restoreGraphicsState();
}
return;
}
iter.getWindingRule() == PathIterator.WIND_EVEN_ODD);
}
if (newClip || newTransform) {
- currentStream.write("Q\n");
- paintingState.restore();
+ restoreGraphicsState();
}
}
+ void saveGraphicsState() {
+ currentStream.write("q\n");
+ paintingState.save();
+ }
+
+ void restoreGraphicsState() {
+ currentStream.write("Q\n");
+ paintingState.restore();
+ }
+
/** Checks whether the use of transparency is allowed. */
protected void checkTransparencyAllowed() {
pdfDoc.getProfile().verifyTransparencyAllowed("Java2D graphics");
}
/** {@inheritDoc} */
+ @Override
protected boolean isSupported(Graphics2D g2d) {
return g2d instanceof PDFGraphics2D;
}
/** {@inheritDoc} */
+ @Override
protected void paintTextRun(TextRun textRun, Graphics2D g2d) {
AttributedCharacterIterator runaci = textRun.getACI();
runaci.first();
runaci.first(); //Reset ACI
final PDFGraphics2D pdf = (PDFGraphics2D)g2d;
+
PDFTextUtil textUtil = new PDFTextUtil(pdf.fontInfo) {
+ @Override
protected void write(String code) {
pdf.currentStream.write(code);
}
return;
}
- textUtil.saveGraphicsState();
+ pdf.saveGraphicsState();
textUtil.concatMatrix(g2d.getTransform());
Shape imclip = g2d.getClip();
pdf.writeClip(imclip);
}
textUtil.writeTJ();
textUtil.endTextObject();
- textUtil.restoreGraphicsState();
+ pdf.restoreGraphicsState();
if (DEBUG) {
g2d.setStroke(new BasicStroke(0));
g2d.setColor(Color.LIGHT_GRAY);