You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2020/05/01 10:14:06 UTC
svn commit: r1877254 - in /pdfbox/trunk/pdfbox/src:
main/java/org/apache/pdfbox/pdmodel/PDAbstractContentStream.java
main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java
test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java
Author: tilman
Date: Fri May 1 10:14:06 2020
New Revision: 1877254
URL: http://svn.apache.org/viewvc?rev=1877254&view=rev
Log:
PDFBOX-3709: delete deprecated color methods
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDAbstractContentStream.java
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java
pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDAbstractContentStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDAbstractContentStream.java?rev=1877254&r1=1877253&r2=1877254&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDAbstractContentStream.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDAbstractContentStream.java Fri May 1 10:14:06 2020
@@ -715,28 +715,6 @@ abstract class PDAbstractContentStream i
}
/**
- * Set the stroking color in the DeviceRGB color space. Range is 0..255.
- *
- * @param r The red value
- * @param g The green value.
- * @param b The blue value.
- * @throws IOException If an IO error occurs while writing to the stream.
- * @throws IllegalArgumentException If the parameters are invalid.
- * @deprecated use
- * {@link #setStrokingColor(float, float, float) setStrokingColor(r/255f, g/255f, b/255f)}
- */
- @Deprecated
- public void setStrokingColor(int r, int g, int b) throws IOException
- {
- if (isOutside255Interval(r) || isOutside255Interval(g) || isOutside255Interval(b))
- {
- throw new IllegalArgumentException("Parameters must be within 0..255, but are "
- + String.format("(%d,%d,%d)", r, g, b));
- }
- setStrokingColor(r / 255f, g / 255f, b / 255f);
- }
-
- /**
* Set the stroking color in the DeviceCMYK color space. Range is 0..1
*
* @param c The cyan value.
@@ -856,48 +834,6 @@ abstract class PDAbstractContentStream i
}
/**
- * Set the non stroking color in the DeviceRGB color space. Range is 0..255.
- *
- * @param r The red value
- * @param g The green value.
- * @param b The blue value.
- * @throws IOException If an IO error occurs while writing to the stream.
- * @throws IllegalArgumentException If the parameters are invalid.
- * @deprecated use
- * {@link #setNonStrokingColor(float, float, float) setNonStrokingColor(r/255f, g/255f, b/255f)}
- */
- @Deprecated
- public void setNonStrokingColor(int r, int g, int b) throws IOException
- {
- if (isOutside255Interval(r) || isOutside255Interval(g) || isOutside255Interval(b))
- {
- throw new IllegalArgumentException("Parameters must be within 0..255, but are "
- + String.format("(%d,%d,%d)", r, g, b));
- }
- setNonStrokingColor(r / 255f, g / 255f, b / 255f);
- }
-
- /**
- * Set the non-stroking color in the DeviceCMYK color space. Range is 0..255.
- *
- * @param c The cyan value.
- * @param m The magenta value.
- * @param y The yellow value.
- * @param k The black value.
- * @throws IOException If an IO error occurs while writing to the stream.
- * @throws IllegalArgumentException If the parameters are invalid.
- */
- public void setNonStrokingColor(int c, int m, int y, int k) throws IOException
- {
- if (isOutside255Interval(c) || isOutside255Interval(m) || isOutside255Interval(y) || isOutside255Interval(k))
- {
- throw new IllegalArgumentException("Parameters must be within 0..255, but are "
- + String.format("(%d,%d,%d,%d)", c, m, y, k));
- }
- setNonStrokingColor(c / 255f, m / 255f, y / 255f, k / 255f);
- }
-
- /**
* Set the non-stroking color in the DeviceCMYK color space. Range is 0..1.
*
* @param c The cyan value.
@@ -922,24 +858,6 @@ abstract class PDAbstractContentStream i
}
/**
- * Set the non-stroking color in the DeviceGray color space. Range is 0..255.
- *
- * @param g The gray value.
- * @throws IOException If an IO error occurs while writing to the stream.
- * @throws IllegalArgumentException If the parameter is invalid.
- * @deprecated use {@link #setNonStrokingColor(float) setNonStrokingColor(g/255f)}
- */
- @Deprecated
- public void setNonStrokingColor(int g) throws IOException
- {
- if (isOutside255Interval(g))
- {
- throw new IllegalArgumentException("Parameter must be within 0..255, but is " + g);
- }
- setNonStrokingColor(g / 255f);
- }
-
- /**
* Set the non-stroking color in the DeviceGray color space. Range is 0..1.
*
* @param g The gray value.
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java?rev=1877254&r1=1877253&r2=1877254&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPageContentStream.java Fri May 1 10:14:06 2020
@@ -32,11 +32,6 @@ import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.common.PDStream;
import org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDPropertyList;
import org.apache.pdfbox.pdmodel.graphics.PDXObject;
-import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
-import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
-import org.apache.pdfbox.pdmodel.graphics.color.PDICCBased;
-import org.apache.pdfbox.pdmodel.graphics.color.PDPattern;
-import org.apache.pdfbox.pdmodel.graphics.color.PDSeparation;
import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
import org.apache.pdfbox.pdmodel.graphics.image.PDInlineImage;
@@ -464,146 +459,6 @@ public final class PDPageContentStream e
}
/**
- * Set the stroking color space. This will add the colorspace to the PDResources
- * if necessary.
- *
- * @param colorSpace The colorspace to write.
- * @throws IOException If there is an error writing the colorspace.
- * @deprecated Use {@link #setStrokingColor} instead.
- */
- @Deprecated
- public void setStrokingColorSpace(PDColorSpace colorSpace) throws IOException
- {
- setStrokingColorSpaceStack(colorSpace);
- writeOperand(getName(colorSpace));
- writeOperator(OperatorName.STROKING_COLORSPACE);
- }
-
- /**
- * Set the stroking color space. This will add the colorspace to the PDResources
- * if necessary.
- *
- * @param colorSpace The colorspace to write.
- * @throws IOException If there is an error writing the colorspace.
- * @deprecated Use {@link #setNonStrokingColor(PDColor)} instead.
- */
- @Deprecated
- public void setNonStrokingColorSpace(PDColorSpace colorSpace) throws IOException
- {
- setNonStrokingColorSpaceStack(colorSpace);
- writeOperand(getName(colorSpace));
- writeOperator(OperatorName.NON_STROKING_COLORSPACE);
- }
-
- /**
- * Set the color components of current stroking color space.
- *
- * @param components The components to set for the current color.
- * @throws IOException If there is an error while writing to the stream.
- * @deprecated Use {@link #setStrokingColor(PDColor)} instead.
- */
- @Deprecated
- public void setStrokingColor(float[] components) throws IOException
- {
- if (strokingColorSpaceStack.isEmpty())
- {
- throw new IllegalStateException("The color space must be set before setting a color");
- }
-
- for (float component : components)
- {
- writeOperand(component);
- }
-
- PDColorSpace currentStrokingColorSpace = strokingColorSpaceStack.peek();
-
- if (currentStrokingColorSpace instanceof PDSeparation ||
- currentStrokingColorSpace instanceof PDPattern ||
- currentStrokingColorSpace instanceof PDICCBased)
- {
- writeOperator(OperatorName.STROKING_COLOR_N);
- }
- else
- {
- writeOperator(OperatorName.STROKING_COLOR);
- }
- }
-
- /**
- * Set the stroking color in the DeviceCMYK color space. Range is 0..255.
- *
- * @param c The cyan value.
- * @param m The magenta value.
- * @param y The yellow value.
- * @param k The black value.
- * @throws IOException If an IO error occurs while writing to the stream.
- * @throws IllegalArgumentException If the parameters are invalid.
- * @deprecated Use {@link #setStrokingColor(float, float, float, float)} instead.
- */
- @Deprecated
- public void setStrokingColor(int c, int m, int y, int k) throws IOException
- {
- if (isOutside255Interval(c) || isOutside255Interval(m) || isOutside255Interval(y) || isOutside255Interval(k))
- {
- throw new IllegalArgumentException("Parameters must be within 0..255, but are "
- + String.format("(%d,%d,%d,%d)", c, m, y, k));
- }
- setStrokingColor(c / 255f, m / 255f, y / 255f, k / 255f);
- }
-
- /**
- * Set the stroking color in the DeviceGray color space. Range is 0..255.
- *
- * @param g The gray value.
- * @throws IOException If an IO error occurs while writing to the stream.
- * @throws IllegalArgumentException If the parameter is invalid.
- * @deprecated Use {@link #setStrokingColor(float)} instead.
- */
- @Deprecated
- public void setStrokingColor(int g) throws IOException
- {
- if (isOutside255Interval(g))
- {
- throw new IllegalArgumentException("Parameter must be within 0..255, but is " + g);
- }
- setStrokingColor(g / 255f);
- }
-
- /**
- * Set the color components of current non-stroking color space.
- *
- * @param components The components to set for the current color.
- * @throws IOException If there is an error while writing to the stream.
- * @deprecated Use {@link #setNonStrokingColor(PDColor)} instead.
- */
- @Deprecated
- public void setNonStrokingColor(float[] components) throws IOException
- {
- if (nonStrokingColorSpaceStack.isEmpty())
- {
- throw new IllegalStateException("The color space must be set before setting a color");
- }
-
- for (float component : components)
- {
- writeOperand(component);
- }
-
- PDColorSpace currentNonStrokingColorSpace = nonStrokingColorSpaceStack.peek();
-
- if (currentNonStrokingColorSpace instanceof PDSeparation ||
- currentNonStrokingColorSpace instanceof PDPattern ||
- currentNonStrokingColorSpace instanceof PDICCBased)
- {
- writeOperator(OperatorName.NON_STROKING_COLOR_N);
- }
- else
- {
- writeOperator(OperatorName.NON_STROKING_COLOR);
- }
- }
-
- /**
* Fill a rectangle on the page using the current non stroking color.
*
* @param x The lower left x coordinate.
Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java?rev=1877254&r1=1877253&r2=1877254&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java Fri May 1 10:14:06 2020
@@ -96,9 +96,7 @@ public class TestPDPageContentStream ext
{
// pass a non-stroking color in RGB and Gray color space
contentStream.setNonStrokingColor(0.1f, 0.2f, 0.3f);
- contentStream.setNonStrokingColor(1, 2, 3);
contentStream.setNonStrokingColor(0.8f);
- contentStream.setNonStrokingColor(8);
}
// now read the PDF stream and verify that the values are correct
@@ -108,14 +106,8 @@ public class TestPDPageContentStream ext
assertEquals(0.2f, ((COSNumber) pageTokens.get(1)).floatValue());
assertEquals(0.3f, ((COSNumber) pageTokens.get(2)).floatValue());
assertEquals(OperatorName.NON_STROKING_RGB, ((Operator) pageTokens.get(3)).getName());
- assertEquals(1 / 255f, ((COSNumber) pageTokens.get(4)).floatValue(), 0.00001d);
- assertEquals(2 / 255f, ((COSNumber) pageTokens.get(5)).floatValue(), 0.00001d);
- assertEquals(3 / 255f, ((COSNumber) pageTokens.get(6)).floatValue(), 0.00001d);
- assertEquals(OperatorName.NON_STROKING_RGB, ((Operator) pageTokens.get(7)).getName());
- assertEquals(0.8f, ((COSNumber) pageTokens.get(8)).floatValue());
- assertEquals(OperatorName.NON_STROKING_GRAY, ((Operator) pageTokens.get(9)).getName());
- assertEquals(8 / 255f, ((COSNumber) pageTokens.get(10)).floatValue(), 0.00001d);
- assertEquals(OperatorName.NON_STROKING_GRAY, ((Operator) pageTokens.get(11)).getName());
+ assertEquals(0.8f, ((COSNumber) pageTokens.get(4)).floatValue());
+ assertEquals(OperatorName.NON_STROKING_GRAY, ((Operator) pageTokens.get(5)).getName());
// same as above but for PDPageContentStream#setStrokingColor
page = new PDPage();
@@ -125,9 +117,7 @@ public class TestPDPageContentStream ext
{
// pass a non-stroking color in RGB and Gray color space
contentStream.setStrokingColor(0.5f, 0.6f, 0.7f);
- contentStream.setStrokingColor(5, 6, 7);
contentStream.setStrokingColor(0.8f);
- contentStream.setStrokingColor(8);
}
// now read the PDF stream and verify that the values are correct
@@ -137,14 +127,8 @@ public class TestPDPageContentStream ext
assertEquals(0.6f, ((COSNumber) pageTokens.get(1)).floatValue());
assertEquals(0.7f, ((COSNumber) pageTokens.get(2)).floatValue());
assertEquals(OperatorName.STROKING_COLOR_RGB, ((Operator) pageTokens.get(3)).getName());
- assertEquals(5 / 255f, ((COSNumber) pageTokens.get(4)).floatValue(), 0.00001d);
- assertEquals(6 / 255f, ((COSNumber) pageTokens.get(5)).floatValue(), 0.00001d);
- assertEquals(7 / 255f, ((COSNumber) pageTokens.get(6)).floatValue(), 0.00001d);
- assertEquals(OperatorName.STROKING_COLOR_RGB, ((Operator) pageTokens.get(7)).getName());
- assertEquals(0.8f, ((COSNumber) pageTokens.get(8)).floatValue());
- assertEquals(OperatorName.STROKING_COLOR_GRAY, ((Operator) pageTokens.get(9)).getName());
- assertEquals(8 / 255f, ((COSNumber) pageTokens.get(10)).floatValue(), 0.00001d);
- assertEquals(OperatorName.STROKING_COLOR_GRAY, ((Operator) pageTokens.get(11)).getName());
+ assertEquals(0.8f, ((COSNumber) pageTokens.get(4)).floatValue());
+ assertEquals(OperatorName.STROKING_COLOR_GRAY, ((Operator) pageTokens.get(5)).getName());
}
}