https://issues.apache.org/bugzilla/show_bug.cgi?id=49355

--- Comment #1 from Vu <vu_k_t...@yahoo.com> 2010-05-28 11:24:00 EDT ---
Looking at the source file, I've noticed the following:

- The TXTRenderer uses TXTState as graphic state and TXTState implements as a
stack (LinkedList)
- The CTM is pushed on to this graphic state in 2 cases:
   1) TXTRenderer.startVPArea()
   2) TXTRenderer.concatenateTransformationMatrix()

- But the CTM is popped out from this graphic state only when:
   1) TXTRenderer.endVPArea() is called

- There is no counterpart for TXTRenderer.concatenateTransformationMatrix() to
popped the CTM out of the graphic state and that state accumulates all CTM and
causes issue when rendering content.

My proposed approach is:
In TXTRenderer, create a new variable to keep a stack trace of when CTM is
pushed, popped from the stack and whether it is pushed using the
concatenateTransformationMatrix() method call.  When it is time for popping the
CTM, check this new stack and pop the CTM out of the stack when the CTM is
pushed on it using the concatenateTransformationMatrix() call.

-- Code example:

private LinkedList ctmTransformStack = new LinkedList();

protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
    currentState.push(ctm);
    ctmTransformStack.addLast(Boolean.FALSE);
}

protected void endVParea() {
    currentState.pop();
    Boolean transformMatrix = (Boolean) ctmTransformStack.removeLast();

    /*
     * Perform compensation pop for concatenateTransformationMatrix()'s push
     */
    while (transformMatrix.booleanValue()) {
         currentState.pop();
          transformMatrix = (Boolean) ctmTransformStack.removeLast();
   }
}

protected void concatenateTransformationMatrix(AffineTransform at) {
   currentState.push(new CTM(ptToMpt(at)));
   ctmTransformStack.addLast(Boolean.TRUE);
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to