From 3b6ecefad276b4b487961ea4079886e2e7a96277 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Tue, 23 Jul 2002 11:00:26 +0000 Subject: [PATCH] handles clip better added method to restore to a level git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195022 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/pdf/PDFState.java | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/org/apache/fop/pdf/PDFState.java b/src/org/apache/fop/pdf/PDFState.java index ef5e73885..d9500c1b2 100644 --- a/src/org/apache/fop/pdf/PDFState.java +++ b/src/org/apache/fop/pdf/PDFState.java @@ -11,6 +11,8 @@ import java.awt.Shape; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.awt.geom.GeneralPath; +import java.awt.geom.Area; import java.awt.Color; import java.awt.Paint; @@ -125,6 +127,16 @@ public class PDFState { return stateStack.size(); } + public void restoreLevel(int stack) { + int pos = stack; + while(stateStack.size() > pos + 1) { + stateStack.remove(stateStack.size() - 1); + } + if(stateStack.size() > pos) { + pop(); + } + } + public boolean setLineDash(int[] array, int offset) { return false; } @@ -158,19 +170,28 @@ public class PDFState { return false; } + /** + * For clips it can start a new state + */ public boolean checkClip(Shape cl) { if(clip == null) { if(cl != null) { return true; } - } else if(!clip.equals(cl)) { + } else if(!new Area(clip).equals(new Area(cl))) { return true; } return false; } public void setClip(Shape cl) { - clip = cl; + if (clip != null) { + Area newClip = new Area(clip); + newClip.intersect(new Area(cl)); + clip = new GeneralPath(newClip); + } else { + clip = cl; + } } public boolean checkTransform(AffineTransform tf) { -- 2.39.5