You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ju...@apache.org on 2008/11/24 12:25:27 UTC
svn commit: r720167 - in /incubator/pdfbox/trunk/src/main:
java/org/apache/pdfbox/util/operator/ resources/Resources/
Author: jukka
Date: Mon Nov 24 03:25:24 2008
New Revision: 720167
URL: http://svn.apache.org/viewvc?rev=720167&view=rev
Log:
PDFBOX-380: Limited support for SC and SCN operator
Patch by Andreas Lehmkühler.
Added:
incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetNonStrokingColor.java (with props)
incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetNonStrokingICCBasedColor.java (with props)
incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetStrokingColor.java (with props)
incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetStrokingICCBasedColor.java (with props)
Modified:
incubator/pdfbox/trunk/src/main/resources/Resources/PageDrawer.properties
Added: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetNonStrokingColor.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetNonStrokingColor.java?rev=720167&view=auto
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetNonStrokingColor.java (added)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetNonStrokingColor.java Mon Nov 24 03:25:24 2008
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.util.operator;
+
+import java.util.List;
+
+import org.apache.pdfbox.pdmodel.graphics.color.*;
+import org.apache.pdfbox.util.*;
+import java.io.IOException;
+
+/**
+ * <p>Set the non stroking color space.</p>
+ *
+ * @author <a href="mailto:andreas@lehmi.de">Andreas Lehmkühler</a>
+ * @version $Revision: 1.0 $
+ */
+public class SetNonStrokingColor extends OperatorProcessor
+{
+ /**
+ * sc,scn Set color space for non stroking operations.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If an error occurs while processing the font.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ PDColorSpace colorSpace = context.getGraphicsState().getNonStrokingColorSpace().getColorSpace();
+ if (colorSpace != null)
+ {
+ OperatorProcessor newOperator = null;
+ if (colorSpace instanceof PDDeviceGray)
+ newOperator = new SetNonStrokingGrayColor();
+ else if (colorSpace instanceof PDDeviceRGB)
+ newOperator = new SetNonStrokingRGBColor();
+ else if (colorSpace instanceof PDDeviceCMYK)
+ newOperator = new SetNonStrokingCMYKColor();
+ else if (colorSpace instanceof PDICCBased)
+ newOperator = new SetNonStrokingICCBasedColor();
+ if (newOperator != null)
+ {
+ newOperator.setContext(getContext());
+ newOperator.process(operator, arguments);
+ }
+ else
+ logger().info("Not supported colorspace "+colorSpace.getName() + " within operator "+operator.getOperation());
+ }
+ else
+ logger().warning("Colorspace not found in "+getClass().getName()+".process!!");
+ }
+}
Propchange: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetNonStrokingColor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetNonStrokingICCBasedColor.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetNonStrokingICCBasedColor.java?rev=720167&view=auto
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetNonStrokingICCBasedColor.java (added)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetNonStrokingICCBasedColor.java Mon Nov 24 03:25:24 2008
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.util.operator;
+
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.pdmodel.graphics.color.*;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.pdfviewer.PageDrawer;
+
+import java.io.IOException;
+
+/**
+ *
+ * @author <a href="mailto:andreas@lehmi.de">Andreas Lehmkühler</a>
+ * @version $Revision: 1.0 $
+ */
+public class SetNonStrokingICCBasedColor extends OperatorProcessor
+{
+ /**
+ * scn Set color space for non stroking operations.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If an error occurs while processing the font.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ PDColorSpaceInstance colorInstance = context.getGraphicsState().getNonStrokingColorSpace();
+ PDColorSpace cs = colorInstance.getColorSpace();
+ int numberOfComponents = cs.getNumberOfComponents();
+ float[] values = new float[numberOfComponents];
+ for( int i=0; i<numberOfComponents; i++ )
+ {
+ values[i] = ((COSNumber)arguments.get( i )).floatValue();
+ }
+ colorInstance.setColorSpaceValue( values );
+
+ if (context instanceof PageDrawer){
+ PageDrawer drawer = (PageDrawer)context;
+ drawer.ColorChanged (true);
+ }
+ }
+}
Propchange: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetNonStrokingICCBasedColor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetStrokingColor.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetStrokingColor.java?rev=720167&view=auto
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetStrokingColor.java (added)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetStrokingColor.java Mon Nov 24 03:25:24 2008
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.util.operator;
+
+import java.util.List;
+
+import org.apache.pdfbox.pdmodel.graphics.color.*;
+import org.apache.pdfbox.util.PDFOperator;
+import java.io.IOException;
+
+/**
+ * <p>Set the stroking color space.</p>
+ *
+ * @author <a href="mailto:andreas@lehmi.de">Andreas Lehmkühler</a>
+ * @version $Revision: 1.0 $
+ */
+public class SetStrokingColor extends OperatorProcessor
+{
+ /**
+ * SC,SCN Set color space for stroking operations.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If an error occurs while processing the font.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ PDColorSpace colorSpace = context.getGraphicsState().getStrokingColorSpace().getColorSpace();
+ if (colorSpace != null)
+ {
+ OperatorProcessor newOperator = null;
+ if (colorSpace instanceof PDDeviceGray)
+ newOperator = new SetStrokingGrayColor();
+ else if (colorSpace instanceof PDDeviceRGB)
+ newOperator = new SetStrokingRGBColor();
+ else if (colorSpace instanceof PDDeviceCMYK)
+ newOperator = new SetStrokingCMYKColor();
+ else if (colorSpace instanceof PDICCBased)
+ newOperator = new SetStrokingICCBasedColor();
+ if (newOperator != null)
+ {
+ newOperator.setContext(getContext());
+ newOperator.process(operator, arguments);
+ }
+ else
+ logger().info("Not supported colorspace "+colorSpace.getName() + " within operator "+operator.getOperation());
+ }
+ else
+ logger().warning("Colorspace not found in "+getClass().getName()+".process!!");
+
+ }
+
+}
Propchange: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetStrokingColor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetStrokingICCBasedColor.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetStrokingICCBasedColor.java?rev=720167&view=auto
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetStrokingICCBasedColor.java (added)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetStrokingICCBasedColor.java Mon Nov 24 03:25:24 2008
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.util.operator;
+
+import java.util.List;
+
+import org.apache.pdfbox.cos.COSNumber;
+import org.apache.pdfbox.pdmodel.graphics.color.*;
+import org.apache.pdfbox.util.PDFOperator;
+import org.apache.pdfbox.pdfviewer.PageDrawer;
+
+import java.io.IOException;
+
+/**
+ *
+ * @author <a href="mailto:andreas@lehmi.de">Andreas Lehmkühler</a>
+ * @version $Revision: 1.0 $
+ */
+public class SetStrokingICCBasedColor extends OperatorProcessor
+{
+ /**
+ * scn Set color space for stroking operations.
+ * @param operator The operator that is being executed.
+ * @param arguments List
+ * @throws IOException If an error occurs while processing the font.
+ */
+ public void process(PDFOperator operator, List arguments) throws IOException
+ {
+ PDColorSpaceInstance colorInstance = context.getGraphicsState().getStrokingColorSpace();
+ PDColorSpace cs = colorInstance.getColorSpace();
+ int numberOfComponents = cs.getNumberOfComponents();
+ float[] values = new float[numberOfComponents];
+ for( int i=0; i<numberOfComponents; i++ )
+ {
+ values[i] = ((COSNumber)arguments.get( i )).floatValue();
+ }
+ colorInstance.setColorSpaceValue( values );
+
+ if (context instanceof PageDrawer){
+ PageDrawer drawer = (PageDrawer)context;
+ drawer.ColorChanged (true);
+ }
+ }
+}
Propchange: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/util/operator/SetStrokingICCBasedColor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/pdfbox/trunk/src/main/resources/Resources/PageDrawer.properties
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/resources/Resources/PageDrawer.properties?rev=720167&r1=720166&r2=720167&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/resources/Resources/PageDrawer.properties (original)
+++ incubator/pdfbox/trunk/src/main/resources/Resources/PageDrawer.properties Mon Nov 24 03:25:24 2008
@@ -50,10 +50,10 @@
#ri org.apache.pdfbox.util.operator.NotImplemented
s=org.apache.pdfbox.util.operator.CloseAndStrokePath
S=org.apache.pdfbox.util.operator.pagedrawer.StrokePath
-#SC org.apache.pdfbox.util.operator.NotImplemented
-#sc org.apache.pdfbox.util.operator.NotImplemented
-#SCN org.apache.pdfbox.util.operator.NotImplemented
-#scn org.apache.pdfbox.util.operator.NotImplemented
+SC org.apache.pdfbox.util.operator.SetStrokingColor
+sc org.apache.pdfbox.util.operator.SetNonStrokingColor
+SCN org.apache.pdfbox.util.operator.SetStrokingColor
+scn org.apache.pdfbox.util.operator.SetNonStrokingColor
#sh org.apache.pdfbox.util.operator.NotImplemented
T*=org.apache.pdfbox.util.operator.NextLine
Tc=org.apache.pdfbox.util.operator.SetCharSpacing