renderOutline(outline.getSubData(i), pdfOutline);
}
}
-
+
+ /** Saves the graphics state of the rendering engine. */
+ protected void saveGraphicsState() {
+ currentStream.add("q\n");
+ }
+
+ /** Restores the last graphics state of the rendering engine. */
+ protected void restoreGraphicsState() {
+ currentStream.add("Q\n");
+ }
+
+ /** Indicates the beginning of a text object. */
+ protected void beginTextObject() {
+ currentStream.add("BT\n");
+ }
+
+ /** Indicates the end of a text object. */
+ protected void endTextObject() {
+ currentStream.add("ET\n");
+ }
+
/**
* Start the next page sequence.
* For the pdf renderer there is no concept of page sequences
currentState.setTransform(
new AffineTransform(CTMHelper.toPDFArray(ctm)));
- currentStream.add("q\n");
+ saveGraphicsState();
// multiply with current CTM
currentStream.add(CTMHelper.toPDFString(ctm) + " cm\n");
// Set clip?
- currentStream.add("BT\n");
+ beginTextObject();
}
protected void endVParea() {
- currentStream.add("ET\n");
- currentStream.add("Q\n");
+ endTextObject();
+ restoreGraphicsState();
currentState.pop();
}
Rectangle2D viewArea = region.getViewArea();
float width = (float)(viewArea.getWidth() / 1000f);
float height = (float)(viewArea.getHeight() / 1000f);
+ /*
Trait.Background back;
back = (Trait.Background)region.getTrait(Trait.BACKGROUND);
+ */
drawBackAndBorders(region, startx, starty, width, height);
}
if(back != null) {
started = true;
closeText();
- currentStream.add("ET\n");
- //currentStream.add("q\n");
+ endTextObject();
+ //saveGraphicsState();
if (back.color != null) {
updateColor(back.color, true, null);
if(!started) {
started = true;
closeText();
- currentStream.add("ET\n");
- //currentStream.add("q\n");
+ endTextObject();
+ //saveGraphicsState();
}
float bwidth = bps.width / 1000f;
if(!started) {
started = true;
closeText();
- currentStream.add("ET\n");
- //currentStream.add("q\n");
+ endTextObject();
+ //saveGraphicsState();
}
float bwidth = bps.width / 1000f;
if(!started) {
started = true;
closeText();
- currentStream.add("ET\n");
- //currentStream.add("q\n");
+ endTextObject();
+ //saveGraphicsState();
}
float bwidth = bps.width / 1000f;
if(!started) {
started = true;
closeText();
- currentStream.add("ET\n");
- //currentStream.add("q\n");
+ endTextObject();
+ //saveGraphicsState();
}
float bwidth = bps.width / 1000f;
drawLine(sx - bwidth / 2, starty, sx - bwidth / 2, endy);
}
if(started) {
- //currentStream.add("Q\n");
- currentStream.add("BT\n");
+ //restoreGraphicsState();
+ beginTextObject();
// font last set out of scope in text section
currentFontName = "";
}
currentBPPosition = 0;
closeText();
- currentStream.add("ET\n");
+ endTextObject();
if (bv.getClip()) {
- currentStream.add("q\n");
+ saveGraphicsState();
float x = (float)(bv.getXOffset() + containingIPPosition) / 1000f;
float y = (float)(bv.getYOffset() + containingBPPosition) / 1000f;
float width = (float)bv.getWidth() / 1000f;
endVParea();
if (bv.getClip()) {
- currentStream.add("Q\n");
+ restoreGraphicsState();
}
- currentStream.add("BT\n");
+ beginTextObject();
// clip if necessary
currentBPPosition = 0;
closeText();
- currentStream.add("ET\n");
+ endTextObject();
double[] vals = ctm.toArray();
- boolean aclock = vals[2] == 1.0;
+ //boolean aclock = vals[2] == 1.0;
if (vals[2] == 1.0) {
ctm = ctm.translate(-saveBP - bv.getHeight(), -saveIP);
} else if (vals[0] == -1.0) {
if (bv.getClip()) {
if (ctm == null) {
closeText();
- currentStream.add("ET\n");
+ endTextObject();
}
- currentStream.add("q\n");
+ saveGraphicsState();
float x = (float)bv.getXOffset() / 1000f;
float y = (float)bv.getYOffset() / 1000f;
float width = (float)bv.getWidth() / 1000f;
}
if (bv.getClip()) {
- currentStream.add("Q\n");
+ restoreGraphicsState();
if (ctm == null) {
- currentStream.add("BT\n");
+ beginTextObject();
}
}
if (ctm != null) {
- currentStream.add("BT\n");
+ beginTextObject();
}
currentIPPosition = saveIP;
}
protected void placeImage(int x, int y, int w, int h, int xobj) {
- currentStream.add("q\n" + ((float) w) + " 0 0 "
+ saveGraphicsState();
+ currentStream.add(((float) w) + " 0 0 "
+ ((float) -h) + " "
+ (((float) currentBlockIPPosition) / 1000f + x) + " "
+ (((float)(currentBPPosition + 1000 * h)) / 1000f
- + y) + " cm\n" + "/Im" + xobj + " Do\nQ\n");
+ + y) + " cm\n" + "/Im" + xobj + " Do\n");
+ restoreGraphicsState();
}
float height = viewport.getHeight() / 1000f;
drawBackAndBorders(viewport, x, y, width, height);
- currentStream.add("ET\n");
+ endTextObject();
if (viewport.getClip()) {
- currentStream.add("q\n");
+ saveGraphicsState();;
clip(x, y, width, height);
}
super.renderViewport(viewport);
if (viewport.getClip()) {
- currentStream.add("Q\n");
+ restoreGraphicsState();
}
- currentStream.add("BT\n");
+ beginTextObject();
}
/**
*/
public void renderLeader(Leader area) {
closeText();
- currentStream.add("ET\n");
- currentStream.add("q\n");
+ endTextObject();
+ saveGraphicsState();
int style = area.getRuleStyle();
boolean alt = false;
switch(style) {
}
}
-
- currentStream.add("Q\n");
- currentStream.add("BT\n");
+
+ restoreGraphicsState();
+ beginTextObject();
super.renderLeader(area);
}
}