You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by vh...@apache.org on 2012/04/05 16:36:23 UTC
svn commit: r1309884 [4/4] - in
/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript: ./
examples/java/java2d/ps/ src/documentation/ src/documentation/content/xdocs/
src/java/org/apache/xmlgraphics/image/codec/png/
src/java/org/apache/xmlgraphics/im...
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/TextHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/TextHandler.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/TextHandler.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/TextHandler.java Thu Apr 5 14:36:20 2012
@@ -37,13 +37,4 @@ public interface TextHandler {
*/
void drawString(Graphics2D g2d, String text, float x, float y) throws IOException;
- /**
- * Draw some text.
- * @param text the text to paint
- * @param x the x-coordinate where the <code>String</code> should be rendered
- * @param y the y-coordinate where the <code>String</code> should be rendered
- * @throws IOException In case of an I/O error
- * @deprecated Use {@code #drawString(Graphics2D, String, float, float)} instead.
- */
- void drawString(String text, float x, float y) throws IOException;
}
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorConverter.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorConverter.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorConverter.java Thu Apr 5 14:36:20 2012
@@ -1,36 +1,36 @@
-/*
- * 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.
- */
-
-/* $Id:$ */
-
-package org.apache.xmlgraphics.java2d.color;
-
-import java.awt.Color;
-
-/**
- * Utility for implementing a color conversion scheme.
- */
-public interface ColorConverter {
-
- /**
- * @param color to convert
- * @return converted color
- */
-
- Color convert(Color color);
-
-}
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.java2d.color;
+
+import java.awt.Color;
+
+/**
+ * Utility for implementing a color conversion scheme.
+ */
+public interface ColorConverter {
+
+ /**
+ * @param color to convert
+ * @return converted color
+ */
+
+ Color convert(Color color);
+
+}
Propchange: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorConverter.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorUtil.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorUtil.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorUtil.java Thu Apr 5 14:36:20 2012
@@ -1,74 +1,165 @@
-/*
- * 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.
- */
-
-/* $Id: ColorUtil.java 815938 2009-09-16 19:38:13Z jeremias $ */
-
-package org.apache.xmlgraphics.java2d.color;
-
-import java.awt.Color;
-
-
-/**
- * Generic Color helper class.
- * <p>
- * This class supports parsing string values into color values and creating
- * color values for strings. It provides a list of standard color names.
- */
-public final class ColorUtil {
-
- /**
- * Private constructor since this is an utility class.
- */
- private ColorUtil() {
- }
-
-
- /**
- * Lightens up a color for groove, ridge, inset and outset border effects.
- * @param col the color to lighten up
- * @param factor factor by which to lighten up (negative values darken the color)
- * @return the modified color
- */
- public static Color lightenColor(Color col, float factor) {
- // TODO: This function converts the color into the sRGB namespace.
- // This should be avoided if possible.
- float[] cols = new float[4];
- cols = col.getRGBComponents(cols);
- if (factor > 0) {
- cols[0] += (1.0 - cols[0]) * factor;
- cols[1] += (1.0 - cols[1]) * factor;
- cols[2] += (1.0 - cols[2]) * factor;
- } else {
- cols[0] -= cols[0] * -factor;
- cols[1] -= cols[1] * -factor;
- cols[2] -= cols[2] * -factor;
- }
- return new Color(cols[0], cols[1], cols[2], cols[3]);
- }
-
-
-
- /**
- * Indicates whether the color is a gray value.
- * @param col the color
- * @return true if it is a gray value
- */
- public static boolean isGray(Color col) {
- return (col.getRed() == col.getBlue() && col.getRed() == col.getGreen());
- }
-
-}
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.java2d.color;
+
+import java.awt.Color;
+
+
+/**
+ * Generic Color helper class.
+ * <p>
+ * This class supports parsing string values into color values and creating
+ * color values for strings. It provides a list of standard color names.
+ */
+public final class ColorUtil {
+
+ /**
+ * Private constructor since this is an utility class.
+ */
+ private ColorUtil() {
+ }
+
+
+ /**
+ * Lightens up a color for groove, ridge, inset and outset border effects.
+ * @param col the color to lighten up
+ * @param factor factor by which to lighten up (negative values darken the color)
+ * @return the modified color
+ */
+ public static Color lightenColor(Color col, float factor) {
+ // TODO: This function converts the color into the sRGB namespace.
+ // This should be avoided if possible.
+ float[] cols = new float[4];
+ cols = col.getRGBComponents(cols);
+ if (factor > 0) {
+ cols[0] += (1.0 - cols[0]) * factor;
+ cols[1] += (1.0 - cols[1]) * factor;
+ cols[2] += (1.0 - cols[2]) * factor;
+ } else {
+ cols[0] -= cols[0] * -factor;
+ cols[1] -= cols[1] * -factor;
+ cols[2] -= cols[2] * -factor;
+ }
+ return new Color(cols[0], cols[1], cols[2], cols[3]);
+ }
+
+
+
+ /**
+ * Indicates whether the color is a gray value.
+ * @param col the color
+ * @return true if it is a gray value
+ */
+ public static boolean isGray(Color col) {
+ return (col.getRed() == col.getBlue() && col.getRed() == col.getGreen());
+ }
+
+ /**
+ * Creates an uncalibrated CMYK color with the given gray value.
+ * @param black the gray component (0 - 1)
+ * @return the CMYK color
+ */
+ public static Color toCMYKGrayColor(float black) {
+ //Calculated color components
+ float[] cmyk = new float[] {0f, 0f, 0f, 1.0f - black};
+ //Create native color
+ return DeviceCMYKColorSpace.createCMYKColor(cmyk);
+ }
+
+ /**
+ * Converts an arbitrary {@link Color} to a plain sRGB color doing the conversion at the
+ * best possible conversion quality.
+ * @param col the original color
+ * @return the sRGB equivalent
+ */
+ public static Color toSRGBColor(Color col) {
+ if (col.getColorSpace().isCS_sRGB()) {
+ return col; //Don't convert if already sRGB to avoid conversion differences
+ }
+ float[] comps = col.getColorComponents(null);
+ float[] srgb = col.getColorSpace().toRGB(comps);
+ comps = col.getComponents(null);
+ float alpha = comps[comps.length - 1];
+ return new Color(srgb[0], srgb[1], srgb[2], alpha);
+ }
+
+ /**
+ * Checks if two colors are the same color. This check is much more restrictive than
+ * {@link Color#equals(Object)} in that it doesn't only check if both colors result in the
+ * same sRGB value. For example, if two colors not of the same exact class are compared,
+ * they are treated as not the same.
+ * <p>
+ * Note: At the moment, this method only supports {@link Color} and
+ * {@link ColorWithAlternatives} only. Other subclasses of {@link Color} are checked only using
+ * the {@link Color#equals(Object)} method.
+ * @param col1 the first color
+ * @param col2 the second color
+ * @return true if both colors are the same color
+ */
+ public static boolean isSameColor(Color col1, Color col2) {
+ //Check fallback sRGB values first, then go into details
+ if (!col1.equals(col2)) {
+ return false;
+ }
+
+ //Consider same-ness only between colors of the same class (not subclasses)
+ //but consider a ColorWithAlternatives without alternatives to be the same as a Color.
+ Class<?> cl1 = col1.getClass();
+ if (col1 instanceof ColorWithAlternatives
+ && !((ColorWithAlternatives) col1).hasAlternativeColors()) {
+ cl1 = Color.class;
+ }
+ Class<?> cl2 = col2.getClass();
+ if (col2 instanceof ColorWithAlternatives
+ && !((ColorWithAlternatives) col2).hasAlternativeColors()) {
+ cl2 = Color.class;
+ }
+ if (cl1 != cl2) {
+ return false;
+ }
+
+ //Check color space
+ if (!col1.getColorSpace().equals(col2.getColorSpace())) {
+ return false;
+ }
+
+ //Check native components
+ float[] comps1 = col1.getComponents(null);
+ float[] comps2 = col2.getComponents(null);
+ if (comps1.length != comps2.length) {
+ return false;
+ }
+ for (int i = 0, c = comps1.length; i < c; i++) {
+ if (comps1[i] != comps2[i]) {
+ return false;
+ }
+ }
+
+ //Compare alternative colors, order is relevant
+ if (col1 instanceof ColorWithAlternatives && col2 instanceof ColorWithAlternatives) {
+ ColorWithAlternatives ca1 = (ColorWithAlternatives) col1;
+ ColorWithAlternatives ca2 = (ColorWithAlternatives) col2;
+ return ca1.hasSameAlternativeColors(ca2);
+ }
+
+ return true;
+ }
+
+}
Propchange: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/ColorUtil.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DefaultColorConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DefaultColorConverter.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DefaultColorConverter.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DefaultColorConverter.java Thu Apr 5 14:36:20 2012
@@ -1,52 +1,52 @@
-/*
- * 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.
- */
-
-/* $Id:$ */
-
-package org.apache.xmlgraphics.java2d.color;
-
-import java.awt.Color;
-
-import org.apache.xmlgraphics.java2d.color.ColorConverter;
-
-/**
- * A default implementation that does not apply any conversion
- */
-public final class DefaultColorConverter implements ColorConverter {
-
- /**
- * private constructor to support singleton pattern
- */
- private static final DefaultColorConverter SINGLETON = new DefaultColorConverter();
-
- private DefaultColorConverter() {
- }
-
- /**
- * static factory
- *
- * @return singleton instance of DefaultColorConverter
- */
- public static DefaultColorConverter getInstance() {
- return SINGLETON;
- }
-
- /** {@inheritDoc} */
- public Color convert(Color color) {
- return color;
- }
-}
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.java2d.color;
+
+import java.awt.Color;
+
+import org.apache.xmlgraphics.java2d.color.ColorConverter;
+
+/**
+ * A default implementation that does not apply any conversion
+ */
+public final class DefaultColorConverter implements ColorConverter {
+
+ /**
+ * private constructor to support singleton pattern
+ */
+ private static final DefaultColorConverter SINGLETON = new DefaultColorConverter();
+
+ private DefaultColorConverter() {
+ }
+
+ /**
+ * static factory
+ *
+ * @return singleton instance of DefaultColorConverter
+ */
+ public static DefaultColorConverter getInstance() {
+ return SINGLETON;
+ }
+
+ /** {@inheritDoc} */
+ public Color convert(Color color) {
+ return color;
+ }
+}
Propchange: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DefaultColorConverter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DefaultColorConverter.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DeviceCMYKColorSpace.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DeviceCMYKColorSpace.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DeviceCMYKColorSpace.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/color/DeviceCMYKColorSpace.java Thu Apr 5 14:36:20 2012
@@ -19,38 +19,41 @@
package org.apache.xmlgraphics.java2d.color;
+import java.awt.Color;
import java.awt.color.ColorSpace;
/**
* This class represents an uncalibrated CMYK color space.
*/
-public class DeviceCMYKColorSpace extends ColorSpace {
+public class DeviceCMYKColorSpace extends AbstractDeviceSpecificColorSpace
+ implements ColorSpaceOrigin {
private static final long serialVersionUID = 2925508946083542974L;
- private static DeviceCMYKColorSpace instance;
+ /** The name for the uncalibrated CMYK pseudo-profile */
+ public static final String PSEUDO_PROFILE_NAME = "#CMYK";
/**
* Constructs an uncalibrated CMYK ColorSpace object with {@link ColorSpace#TYPE_CMYK} and
* 4 components.
* @see java.awt.color.ColorSpace#ColorSpace(int, int)
*/
- protected DeviceCMYKColorSpace() {
+ public DeviceCMYKColorSpace() {
super(TYPE_CMYK, 4);
}
/**
* Returns an instance of an uncalibrated CMYK color space.
* @return CMYKColorSpace the requested color space object
+ * @deprecated Use {@link ColorSpaces#getDeviceCMYKColorSpace()} instead.
*/
+ @Deprecated
public static DeviceCMYKColorSpace getInstance() {
- if (instance == null) {
- instance = new DeviceCMYKColorSpace();
- }
- return instance;
+ return ColorSpaces.getDeviceCMYKColorSpace();
}
/** {@inheritDoc} */
+ @Override
public float[] toRGB(float[] colorvalue) {
return new float [] {
(1 - colorvalue[0]) * (1 - colorvalue[3]),
@@ -59,18 +62,57 @@ public class DeviceCMYKColorSpace extend
}
/** {@inheritDoc} */
+ @Override
public float[] fromRGB(float[] rgbvalue) {
- throw new UnsupportedOperationException("NYI");
+ assert rgbvalue.length == 3;
+ //Note: this is an arbitrary conversion, not a color-managed one!
+ float r = rgbvalue[0];
+ float g = rgbvalue[1];
+ float b = rgbvalue[2];
+ if (r == g && r == b) {
+ return new float[] {0, 0, 0, 1 - r};
+ } else {
+ float c = 1 - r;
+ float m = 1 - g;
+ float y = 1 - b;
+ float k = Math.min(c, Math.min(m, y));
+ return new float[] {c, m, y, k};
+ }
}
/** {@inheritDoc} */
+ @Override
public float[] toCIEXYZ(float[] colorvalue) {
throw new UnsupportedOperationException("NYI");
}
/** {@inheritDoc} */
+ @Override
public float[] fromCIEXYZ(float[] colorvalue) {
throw new UnsupportedOperationException("NYI");
}
+ /**
+ * Creates a color instance representing a device-specific CMYK color. An sRGB value
+ * is calculated from the CMYK colors but it may not correctly represent the given CMYK
+ * values.
+ * @param cmykComponents the CMYK components
+ * @return the device-specific color
+ */
+ public static Color createCMYKColor(float[] cmykComponents) {
+ DeviceCMYKColorSpace cmykCs = ColorSpaces.getDeviceCMYKColorSpace();
+ Color cmykColor = new ColorWithAlternatives(cmykCs, cmykComponents, 1.0f, null);
+ return cmykColor;
+ }
+
+ /** {@inheritDoc} */
+ public String getProfileName() {
+ return PSEUDO_PROFILE_NAME;
+ }
+
+ /** {@inheritDoc} */
+ public String getProfileURI() {
+ return null; //No URI
+ }
+
}
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java Thu Apr 5 14:36:20 2012
@@ -28,7 +28,6 @@ import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Paint;
import java.awt.Rectangle;
@@ -67,6 +66,10 @@ public class PSGraphics2D extends Abstra
private static final boolean DEBUG = false;
+ /**
+ * The G2D instance that represents the root instance
+ * (used in context with create()/dispose()). Null if this instance is the root instance.
+ */
protected PSGraphics2D rootG2D;
/** the PostScript generator being created */
@@ -532,8 +535,7 @@ public class PSGraphics2D extends Abstra
gen.write(psTilingPattern.toString());
gen.writeln("/Pattern " + gen.mapCommand("setcolorspace"));
gen.writeln(psTilingPattern.getName() + " " + gen.mapCommand("setcolor"));
- }
- catch (IOException ioe) {
+ } catch (IOException ioe) {
handleIOException(ioe);
}
}
@@ -821,8 +823,7 @@ public class PSGraphics2D extends Abstra
* @return the device configuration
*/
public GraphicsConfiguration getDeviceConfiguration() {
- return GraphicsEnvironment.getLocalGraphicsEnvironment().
- getDefaultScreenDevice().getDefaultConfiguration();
+ return new PSGraphicsConfiguration();
}
/**
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSTextHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSTextHandler.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSTextHandler.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSTextHandler.java Thu Apr 5 14:36:20 2012
@@ -21,10 +21,12 @@ package org.apache.xmlgraphics.java2d.ps
import java.io.IOException;
+import org.apache.xmlgraphics.java2d.TextHandler;
+
/**
* Interface which the Graphics2D class delegates text painting to for Postscript.
*/
-public interface PSTextHandler extends org.apache.xmlgraphics.java2d.TextHandler {
+public interface PSTextHandler extends TextHandler {
/**
* Is called by when the "Setup" or "Prolog" of the PostScript document is generated.
* Subclasses can do font registration, for example.
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java Thu Apr 5 14:36:20 2012
@@ -51,7 +51,7 @@ public class PSTilingPattern {
protected String patternName = null;
/**
- * The XUID is an extended unique ID an array of integers that provides for
+ * The XUID is an extended unique ID -- an array of integers that provides for
* distributed, hierarchical management of the space of unique ID numbers
* (optional)
*/
@@ -65,7 +65,7 @@ public class PSTilingPattern {
/**
* An array of four numbers in the pattern coordinate system, giving
* the coordinates of the left, bottom, right, and top edges, respectively, of the
- * pattern cells bounding box
+ * pattern cell's bounding box
*/
protected Rectangle2D bBox = null;
@@ -108,7 +108,7 @@ public class PSTilingPattern {
* the name is null, the pattern should be stored in PSPatternStorage, where the pattern
* gets a name (the pattern without name cannot be use in PS file)
* @param paintProc a postscript procedure for painting the pattern cell
- * @param bBox a pattern cells bounding box
+ * @param bBox a pattern cell's bounding box
* @param xStep the desired horizontal spacing between pattern cells
* @param yStep the desired vertical spacing between pattern cells
* @param paintType 1 for colored pattern, 2 for uncolored pattern
@@ -192,7 +192,7 @@ public class PSTilingPattern {
/**
* Returns the bounding box.
*
- * @return a pattern cells bounding box
+ * @return a pattern cell's bounding box
*/
public Rectangle2D getBoundingBox() {
return (this.bBox);
@@ -201,7 +201,7 @@ public class PSTilingPattern {
/**
* Sets the bounding box.
*
- * @param bBox a pattern cells bounding box
+ * @param bBox a pattern cell's bounding box
*/
public void setBoundingBox(Rectangle2D bBox) {
if (bBox == null) {
@@ -392,9 +392,9 @@ public class PSTilingPattern {
}
// define color image: width height bits/comp matrix
- // datasrc0
datasrcncomp-1 multi ncomp colorimage
+ // datasrc0 � datasrcncomp-1 multi ncomp colorimage
sb.append(width + " " + height + " 8 " + "matrix\n"); // width height bits/comp matrix
- int [] argb = new int[width * height]; // datasrc0
datasrcncomp-1
+ int [] argb = new int[width * height]; // datasrc0 � datasrcncomp-1
sb.append("{<");
texture.getImage().getRGB(0, 0, width, height, argb, 0, width);
int count = 0;
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/DSCConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/DSCConstants.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/DSCConstants.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/DSCConstants.java Thu Apr 5 14:36:20 2012
@@ -146,7 +146,6 @@ public class DSCConstants {
// ----==== Requirements Conventions ====----
- /**@todo Add the missing comments */
/**
* This comment indicates all types of paper media (paper sizes, weight, color)
* this document requires.
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSGenerator.java Thu Apr 5 14:36:20 2012
@@ -37,6 +37,11 @@ import javax.xml.transform.Source;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.java2d.color.ColorUtil;
+import org.apache.xmlgraphics.java2d.color.ColorWithAlternatives;
import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
/**
@@ -57,6 +62,7 @@ public class PSGenerator implements PSCo
* later in the document (mostly in the %%Trailer section).
* @deprecated Please use DSCConstants.ATEND. This constant was in the wrong place.
*/
+ @Deprecated
public static final Object ATEND = DSCConstants.ATEND;
/** Line feed used by PostScript */
@@ -64,13 +70,14 @@ public class PSGenerator implements PSCo
private static final String IDENTITY_H = "Identity-H";
+ private Log log = LogFactory.getLog(getClass());
private OutputStream out;
private int psLevel = DEFAULT_LANGUAGE_LEVEL;
private boolean commentsEnabled = true;
private boolean compactMode = true;
private PSCommandMap commandMap = PSProcSets.STD_COMMAND_MAP;
- private Stack graphicsStateStack = new Stack();
+ private Stack<PSState> graphicsStateStack = new Stack<PSState>();
private PSState currentState;
//private DecimalFormat df3 = new DecimalFormat("0.000", new DecimalFormatSymbols(Locale.US));
private DecimalFormat df3 = new DecimalFormat("0.###", new DecimalFormatSymbols(Locale.US));
@@ -209,7 +216,7 @@ public class PSGenerator implements PSCo
* @exception IOException In case of an I/O problem
*/
public void write(String cmd) throws IOException {
- /* @todo Check disabled until clarification.
+ /* TODO Check disabled until clarification.
if (cmd.length() > 255) {
throw new RuntimeException("PostScript command exceeded limit of 255 characters");
} */
@@ -470,7 +477,7 @@ public class PSGenerator implements PSCo
public boolean restoreGraphicsState() throws IOException {
if (this.graphicsStateStack.size() > 0) {
writeln(mapCommand("grestore"));
- this.currentState = (PSState)this.graphicsStateStack.pop();
+ this.currentState = this.graphicsStateStack.pop();
return true;
} else {
return false;
@@ -643,6 +650,7 @@ public class PSGenerator implements PSCo
* @exception IOException In case of an I/O problem
* @deprecated use useColor method instead
*/
+ @Deprecated
public void useRGBColor(Color col) throws IOException {
useColor(col);
}
@@ -658,47 +666,81 @@ public class PSGenerator implements PSCo
}
}
- private String convertColorToPS(Color col) {
- StringBuffer p = new StringBuffer();
- float[] comps = col.getColorComponents(null);
-
- if (col.getColorSpace().getType() == ColorSpace.TYPE_RGB) {
- // according to pdfspec 12.1 p.399
- // if the colors are the same then just use the g or G operator
- boolean same = (comps[0] == comps[1]
- && comps[0] == comps[2]);
- // output RGB
- if (same) {
- p.append(formatDouble(comps[0]));
- } else {
- for (int i = 0; i < col.getColorSpace().getNumComponents(); i++) {
- if (i > 0) {
- p.append(" ");
- }
- p.append(formatDouble(comps[i]));
+ private String convertColorToPS(Color color) {
+ StringBuffer codeBuffer = new StringBuffer();
+
+ //Important: Right now, CMYK colors are treated as device colors (DeviceCMYK) irrespective
+ //of any associated color profile. All other colors are converted to sRGB (if necessary)
+ //and the resulting RGB components are treated as DeviceRGB colors.
+ //If all three RGB components are the same, DeviceGray is used.
+
+ boolean established = false;
+ if (color instanceof ColorWithAlternatives) {
+ ColorWithAlternatives colExt = (ColorWithAlternatives)color;
+ //Alternative colors have priority
+ Color[] alt = colExt.getAlternativeColors();
+ for (int i = 0, c = alt.length; i < c; i++) {
+ Color col = alt[i];
+ established = establishColorFromColor(codeBuffer, col);
+ if (established) {
+ break;
}
}
- if (same) {
- p.append(" ").append(mapCommand("setgray"));
- } else {
- p.append(" ").append(mapCommand("setrgbcolor"));
+ if (log.isDebugEnabled() && alt.length > 0) {
+ log.debug("None of the alternative colors are supported. Using fallback: "
+ + color);
}
- } else if (col.getColorSpace().getType() == ColorSpace.TYPE_CMYK) {
+ }
+
+ //Fallback
+ if (!established) {
+ established = establishColorFromColor(codeBuffer, color);
+ }
+ if (!established) {
+ establishFallbackRGB(codeBuffer, color);
+ }
+
+ return codeBuffer.toString();
+ }
+
+ private boolean establishColorFromColor(StringBuffer codeBuffer, Color color) {
+ //Important: see above note about color handling!
+ float[] comps = color.getColorComponents(null);
+ if (color.getColorSpace().getType() == ColorSpace.TYPE_CMYK) {
// colorspace is CMYK
- for (int i = 0; i < col.getColorSpace().getNumComponents(); i++) {
- if (i > 0) {
- p.append(" ");
- }
- p.append(formatDouble(comps[i]));
+ writeSetColor(codeBuffer, comps, "setcmykcolor");
+ return true;
+ }
+ return false;
+ }
+
+ private void writeSetColor(StringBuffer codeBuffer, float[] comps, String command) {
+ for (int i = 0, c = comps.length; i < c; i++) {
+ if (i > 0) {
+ codeBuffer.append(" ");
}
- p.append(" ").append(mapCommand("setcmykcolor"));
+ codeBuffer.append(formatDouble(comps[i]));
+ }
+ codeBuffer.append(" ").append(mapCommand(command));
+ }
+
+ private void establishFallbackRGB(StringBuffer codeBuffer, Color color) {
+ float[] comps;
+ if (color.getColorSpace().isCS_sRGB()) {
+ comps = color.getColorComponents(null);
} else {
- // means we're in DeviceGray or Unknown.
- // assume we're in DeviceGray, because otherwise we're screwed.
- p.append(formatDouble(comps[0]));
- p.append(" ").append(mapCommand("setgray"));
+ if (log.isDebugEnabled()) {
+ log.debug("Converting color to sRGB as a fallback: " + color);
+ }
+ ColorSpace sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+ comps = color.getColorComponents(sRGB, null);
+ }
+ assert comps.length == 3;
+ boolean gray = ColorUtil.isGray(color);
+ if (gray) {
+ comps = new float[] {comps[0]};
}
- return p.toString();
+ writeSetColor(codeBuffer, comps, gray ? "setgray" : "setrgbcolor");
}
/**
@@ -736,6 +778,7 @@ public class PSGenerator implements PSCo
* set can be cleared.
* @deprecated Use the notifyStartNewPage() on ResourceTracker instead.
*/
+ @Deprecated
public void notifyStartNewPage() {
getResourceTracker().notifyStartNewPage();
}
@@ -746,6 +789,7 @@ public class PSGenerator implements PSCo
* @param needed true if this is a needed resource, false for a supplied resource
* @deprecated Use the notifyResourceUsageOnPage() on ResourceTracker instead
*/
+ @Deprecated
public void notifyResourceUsage(PSResource res, boolean needed) {
getResourceTracker().notifyResourceUsageOnPage(res);
}
@@ -758,6 +802,7 @@ public class PSGenerator implements PSCo
* @exception IOException In case of an I/O problem
* @deprecated Use the writeResources() on ResourceTracker instead.
*/
+ @Deprecated
public void writeResources(boolean pageLevel) throws IOException {
getResourceTracker().writeResources(pageLevel, this);
}
@@ -768,6 +813,7 @@ public class PSGenerator implements PSCo
* @return true if the resource is registered as being supplied.
* @deprecated Use the isResourceSupplied() on ResourceTracker instead.
*/
+ @Deprecated
public boolean isResourceSupplied(PSResource res) {
return getResourceTracker().isResourceSupplied(res);
}
@@ -834,4 +880,4 @@ public class PSGenerator implements PSCo
public void includeProcsetCIDInitResource() throws IOException {
writeDSCComment(DSCConstants.INCLUDE_RESOURCE, getProcsetCIDInitResource());
}
- }
\ No newline at end of file
+ }
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSState.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSState.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSState.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/ps/PSState.java Thu Apr 5 14:36:20 2012
@@ -25,6 +25,8 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.List;
+import org.apache.xmlgraphics.java2d.color.ColorUtil;
+
/**
* This class holds the current state of the PostScript interpreter.
*
@@ -184,7 +186,7 @@ public class PSState implements Serializ
* @return true if the color changed compared to the previous setting
*/
public boolean useColor(Color value) {
- if (!color.equals(value)) {
+ if (!ColorUtil.isSameColor(color, value)) {
color = value;
return true;
} else {
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/Service.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/Service.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/Service.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/util/Service.java Thu Apr 5 14:36:20 2012
@@ -47,8 +47,8 @@ import org.apache.commons.io.IOUtils;
public class Service {
// Remember providers we have looked up before.
- static Map classMap = new java.util.HashMap();
- static Map instanceMap = new java.util.HashMap();
+ static Map<String, List<String>> classMap = new java.util.HashMap<String, List<String>>();
+ static Map<String, List<Object>> instanceMap = new java.util.HashMap<String, List<Object>>();
/**
* Returns an iterator where each element should implement the
@@ -61,98 +61,118 @@ public class Service {
*
* @param cls The class/interface to search for providers of.
*/
- public static synchronized Iterator providers(Class cls) {
- return providers(cls, true);
+ public static synchronized Iterator<Object> providers(Class<?> cls) {
+ String serviceFile = getServiceFilename(cls);
+
+ List<Object> l = instanceMap.get(serviceFile);
+ if (l != null) {
+ return l.iterator();
+ }
+
+ l = new java.util.ArrayList<Object>();
+ instanceMap.put(serviceFile, l);
+
+ ClassLoader cl = getClassLoader(cls);
+ if (cl != null) {
+ List<String> names = getProviderNames(cls, cl);
+ for (String name : names) {
+ try {
+ // Try and load the class
+ Object obj = cl.loadClass(name).newInstance();
+ // stick it into our vector...
+ l.add(obj);
+ } catch (Exception ex) {
+ // Just try the next name
+ }
+ }
+ }
+ return l.iterator();
}
/**
- * Returns an iterator where each element should implement the
+ * Returns an iterator where each element should be the name
+ * of a class that implements the
* interface (or subclass the baseclass) described by cls. The
* Classes are found by searching the classpath for service files
* named: 'META-INF/services/<fully qualified classname> that list
- * fully qualifted classnames of classes that implement the
- * service files classes interface. These classes must have
- * default constructors if returnInstances is true.
+ * fully qualified classnames of classes that implement the
+ * service files classes interface.
*
* @param cls The class/interface to search for providers of.
- * @param returnInstances true if the iterator should return instances rather than class names.
*/
- public static synchronized Iterator providers(Class cls, boolean returnInstances) {
- String serviceFile = "META-INF/services/" + cls.getName();
- Map cacheMap = (returnInstances ? instanceMap : classMap);
+ public static synchronized Iterator<String> providerNames(Class<?> cls) {
+ String serviceFile = getServiceFilename(cls);
- List l = (List)cacheMap.get(serviceFile);
+ List<String> l = classMap.get(serviceFile);
if (l != null) {
return l.iterator();
}
- l = new java.util.ArrayList();
- cacheMap.put(serviceFile, l);
+ l = new java.util.ArrayList<String>();
+ classMap.put(serviceFile, l);
+ l.addAll(getProviderNames(cls));
+ return l.iterator();
+ }
- ClassLoader cl = null;
- try {
- cl = cls.getClassLoader();
- } catch (SecurityException se) {
- // Ooops! can't get his class loader.
- }
- // Can always request your own class loader. But it might be 'null'.
- if (cl == null) {
- cl = Service.class.getClassLoader();
- }
- if (cl == null) {
- cl = ClassLoader.getSystemClassLoader();
- }
+ /**
+ * Returns an iterator where each element should implement the
+ * interface (or subclass the baseclass) described by cls. The
+ * Classes are found by searching the classpath for service files
+ * named: 'META-INF/services/<fully qualified classname> that list
+ * fully qualified classnames of classes that implement the
+ * service files classes interface. These classes must have
+ * default constructors if returnInstances is true.
+ *
+ * This is a deprecated, type-unsafe legacy method.
+ *
+ * @param cls The class/interface to search for providers of.
+ * @param returnInstances true if the iterator should return instances rather than class names.
+ * @deprecated use the type-safe methods providers(Class<?>) or providerNames(Class<?>) instead.
+ */
+ public static Iterator<?> providers(Class<?> cls, boolean returnInstances) {
+ return (returnInstances ? providers(cls) : providerNames(cls));
+ }
+
+ private static List<String> getProviderNames(Class<?> cls) {
+ return getProviderNames(cls, getClassLoader(cls));
+ }
+
+ private static List<String> getProviderNames(Class<?> cls, ClassLoader cl) {
+ List<String> l = new java.util.ArrayList<String>();
// No class loader so we can't find 'serviceFile'.
if (cl == null) {
- return l.iterator();
+ return l;
}
- Enumeration e;
+ Enumeration<URL> e;
try {
- e = cl.getResources(serviceFile);
+ e = cl.getResources(getServiceFilename(cls));
} catch (IOException ioe) {
- return l.iterator();
+ return l;
}
while (e.hasMoreElements()) {
try {
- URL u = (URL)e.nextElement();
+ URL u = e.nextElement();
InputStream is = u.openStream();
Reader r = new InputStreamReader(is, "UTF-8");
BufferedReader br = new BufferedReader(r);
try {
- String line = br.readLine();
- while (line != null) {
- try {
- // First strip any comment...
- int idx = line.indexOf('#');
- if (idx != -1) {
- line = line.substring(0, idx);
- }
-
- // Trim whitespace.
- line = line.trim();
-
- // If nothing left then loop around...
- if (line.length() == 0) {
- line = br.readLine();
- continue;
- }
-
- if (returnInstances) {
- // Try and load the class
- Object obj = cl.loadClass(line).newInstance();
- // stick it into our vector...
- l.add(obj);
- } else {
- l.add(line);
- }
- } catch (Exception ex) {
- // Just try the next line
+ for (String line = br.readLine(); line != null; line = br.readLine()) {
+ // First strip any comment...
+ int idx = line.indexOf('#');
+ if (idx != -1) {
+ line = line.substring(0, idx);
+ }
+
+ // Trim whitespace.
+ line = line.trim();
+
+ if (line.length() != 0) {
+ l.add(line);
}
- line = br.readLine();
}
} finally {
IOUtils.closeQuietly(br);
@@ -160,11 +180,30 @@ public class Service {
}
} catch (Exception ex) {
// Just try the next file...
- } catch (LinkageError le) {
- // Just try the next file...
}
}
- return l.iterator();
+ return l;
+ }
+
+ private static ClassLoader getClassLoader(Class<?> cls) {
+ ClassLoader cl = null;
+ try {
+ cl = cls.getClassLoader();
+ } catch (SecurityException se) {
+ // Ooops! can't get his class loader.
+ }
+ // Can always request your own class loader. But it might be 'null'.
+ if (cl == null) {
+ cl = Service.class.getClassLoader();
+ }
+ if (cl == null) {
+ cl = ClassLoader.getSystemClassLoader();
+ }
+ return cl;
+ }
+
+ private static String getServiceFilename(Class<?> cls) {
+ return "META-INF/services/" + cls.getName();
}
}
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/Metadata.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/Metadata.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/Metadata.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/Metadata.java Thu Apr 5 14:36:20 2012
@@ -132,7 +132,7 @@ public class Metadata implements XMLizab
handler.startPrefixMapping(prefix, ns);
}
handler.startElement(XMPConstants.RDF_NAMESPACE,
- "RDF", "rdf:Description", atts);
+ "Description", "rdf:Description", atts);
empty = false;
first = false;
}
@@ -140,7 +140,7 @@ public class Metadata implements XMLizab
}
}
if (!empty) {
- handler.endElement(XMPConstants.RDF_NAMESPACE, "RDF", "rdf:Description");
+ handler.endElement(XMPConstants.RDF_NAMESPACE, "Description", "rdf:Description");
if (prefix != null) {
handler.endPrefixMapping(prefix);
}
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPArray.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPArray.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPArray.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPArray.java Thu Apr 5 14:36:20 2012
@@ -27,9 +27,9 @@ import org.xml.sax.helpers.AttributesImp
/**
* Represents an XMP array as defined by the XMP specification.
- * @todo Property qualifiers are currently not supported, yet.
*/
public class XMPArray extends XMPComplexValue {
+ //TODO Property qualifiers are currently not supported, yet.
private XMPArrayType type;
private List values = new java.util.ArrayList();
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPConstants.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPConstants.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPConstants.java Thu Apr 5 14:36:20 2012
@@ -54,13 +54,6 @@ public interface XMPConstants {
*/
String PDF_A_IDENTIFICATION = "http://www.aiim.org/pdfa/ns/id/";
- /**
- * Namespace URI for the PDF/A Identification Schema
- * (from an older draft of ISO 19005-1, used by Adobe Acrobat)
- * @deprecated Outdated, please use PDF_A_IDENTIFICATION instead.
- */
- String PDF_A_IDENTIFICATION_OLD = "http://www.aiim.org/pdfa/ns/id.html";
-
/** Default language for the xml:lang property */
String DEFAULT_LANGUAGE = "x-default";
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPSchemaAdapter.java Thu Apr 5 14:36:20 2012
@@ -196,7 +196,7 @@ public class XMPSchemaAdapter {
} else {
sb.append('-');
}
- if (zoneOffsetHours < 10) {
+ if (Math.abs(zoneOffsetHours) < 10) {
sb.append('0');
}
sb.append(Math.abs(zoneOffsetHours));
@@ -214,9 +214,9 @@ public class XMPSchemaAdapter {
* Parses an ISO 8601 date and time value.
* @param dt the date and time value as an ISO 8601 string
* @return the parsed date/time
- * @todo Parse formats other than yyyy-mm-ddThh:mm:ssZ
*/
public static Date parseISO8601Date(final String dt) {
+ //TODO Parse formats other than yyyy-mm-ddThh:mm:ssZ
int offset = 0;
String parsablePart;
if (dt.endsWith("Z")) {
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPSchemaRegistry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPSchemaRegistry.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPSchemaRegistry.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/java/org/apache/xmlgraphics/xmp/XMPSchemaRegistry.java Thu Apr 5 14:36:20 2012
@@ -24,7 +24,6 @@ import java.util.Map;
import org.apache.xmlgraphics.xmp.schemas.DublinCoreSchema;
import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFSchema;
-import org.apache.xmlgraphics.xmp.schemas.pdf.PDFAOldXMPSchema;
import org.apache.xmlgraphics.xmp.schemas.pdf.PDFAXMPSchema;
/**
@@ -51,7 +50,6 @@ public class XMPSchemaRegistry {
private void init() {
addSchema(new DublinCoreSchema());
addSchema(new PDFAXMPSchema());
- addSchema(new PDFAOldXMPSchema());
addSchema(new XMPBasicSchema());
addSchema(new AdobePDFSchema());
}
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/META-INF/services/org.apache.xmlgraphics.image.writer.ImageWriter
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/META-INF/services/org.apache.xmlgraphics.image.writer.ImageWriter?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/META-INF/services/org.apache.xmlgraphics.image.writer.ImageWriter (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/META-INF/services/org.apache.xmlgraphics.image.writer.ImageWriter Thu Apr 5 14:36:20 2012
@@ -1,6 +1,5 @@
org.apache.xmlgraphics.image.writer.internal.PNGImageWriter
org.apache.xmlgraphics.image.writer.internal.TIFFImageWriter
-org.apache.xmlgraphics.image.writer.internal.JPEGImageWriter
org.apache.xmlgraphics.image.writer.imageio.ImageIOPNGImageWriter
org.apache.xmlgraphics.image.writer.imageio.ImageIOTIFFImageWriter
org.apache.xmlgraphics.image.writer.imageio.ImageIOJPEGImageWriter
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/org/apache/xmlgraphics/image/writer/default-preferred-order.properties
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/org/apache/xmlgraphics/image/writer/default-preferred-order.properties?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/org/apache/xmlgraphics/image/writer/default-preferred-order.properties (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/src/resources/org/apache/xmlgraphics/image/writer/default-preferred-order.properties Thu Apr 5 14:36:20 2012
@@ -1,2 +1,2 @@
-org.apache.xmlgraphics.image.writer.internal=1000
-org.apache.xmlgraphics.image.writer.imageio=2000
\ No newline at end of file
+org.apache.xmlgraphics.image.writer.internal=-2000
+org.apache.xmlgraphics.image.writer.imageio=-1000
\ No newline at end of file
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/status.xml?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/status.xml (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/status.xml Thu Apr 5 14:36:20 2012
@@ -40,6 +40,25 @@
</contexts>
<changes>
<release version="Trunk" date="n/a">
+ <action context="Code" dev="PH" type="fix" fixes-bug="51911" due-to="JM and Mehdi Houshmand">
+ Support for T.4 Group 3 1D encoding.
+ </action>
+ <action context="Code" dev="JM" type="fix" fixes-bug="51039" due-to="Florian Barbera Vila Bollain">
+ Fixed a bug formatting ISO 8601 dates with negative two-digit time zones.
+ </action>
+ <action context="Code" dev="JM" type="remove">
+ Removed dependency on com.sun classes to achieve compatibility with Apache Harmony,
+ OpenJDK and possibly other JVMs.
+ </action>
+ <action context="Code" dev="JM" type="remove">
+ Removal of the deprecated <code>TextHandler.drawString(String, float, float)</code> method.
+ </action>
+ <action context="Code" dev="JM" type="update" fixes-bug="49703" due-to="Glenn Adams">
+ Various code style fixes
+ </action>
+ <action context="Code" dev="JM" type="fix" fixes-bug="49696" due-to="Joshua Marquart">
+ Allow to override priority when registering an ImageWriter on the ImageWriterRegistry.
+ </action>
<action context="Code" dev="JM" type="fix">
Fix for TIFFs which report zero as their resolution. This resulted in an exception.
</action>
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/test/java/org/apache/xmlgraphics/xmp/DateFormattingTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/test/java/org/apache/xmlgraphics/xmp/DateFormattingTest.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/test/java/org/apache/xmlgraphics/xmp/DateFormattingTest.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/test/java/org/apache/xmlgraphics/xmp/DateFormattingTest.java Thu Apr 5 14:36:20 2012
@@ -56,6 +56,10 @@ public class DateFormattingTest extends
s = XMPSchemaAdapter.formatISO8601Date(dt, TimeZone.getTimeZone("GMT-08:00"));
assertEquals("2008-02-07T07:11:07-08:00", s);
assertEquals(dt, XMPSchemaAdapter.parseISO8601Date(s));
+
+ s = XMPSchemaAdapter.formatISO8601Date(dt, TimeZone.getTimeZone("GMT-11:00"));
+ assertEquals("2008-02-07T04:11:07-11:00", s);
+ assertEquals(dt, XMPSchemaAdapter.parseISO8601Date(s));
}
}
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java Thu Apr 5 14:36:20 2012
@@ -1,186 +1,186 @@
-/*
- * 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.
- */
-
-/* $Id$ */
-
-package org.apache.xmlgraphics.xmp;
-
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Set;
-import java.util.TimeZone;
-
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import junit.framework.TestCase;
-
-import org.apache.xmlgraphics.util.QName;
-import org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter;
-import org.apache.xmlgraphics.xmp.schemas.DublinCoreSchema;
-import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter;
-import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
-
-/**
- * Tests property access methods.
- */
-public class XMPPropertyTest extends TestCase {
-
- public void testPropertyAccess() throws Exception {
- Metadata xmp = new Metadata();
- DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
- assertNull(dc.getContributors());
-
- dc.addContributor("Contributor1");
- assertEquals(1, dc.getContributors().length);
- assertEquals("Contributor1", dc.getContributors()[0]);
- dc.removeContributor("Contributor1");
- assertNull(dc.getContributors());
-
- dc.addContributor("Contributor1");
- assertEquals(1, dc.getContributors().length);
- dc.addContributor("Contributor2");
- assertEquals(2, dc.getContributors().length);
- assertFalse(dc.removeContributor("DoesNotExist"));
- assertTrue(dc.removeContributor("Contributor1"));
- assertEquals(1, dc.getContributors().length);
- assertTrue(dc.removeContributor("Contributor2"));
- assertFalse(dc.removeContributor("Contributor2"));
- assertNull(dc.getContributors());
- }
-
- public void testPropertyRemovalLangAlt() throws Exception {
- Metadata xmp = new Metadata();
- DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
-
- //dc:title is a "Lang Alt"
- dc.setTitle("en", "The title");
- String title = dc.removeTitle("en");
- assertEquals("The title", title);
- dc.setTitle("en", "The title");
- dc.setTitle("de", "Der Titel");
- title = dc.removeTitle("en");
- assertEquals("The title", title);
- title = dc.removeTitle("en");
- assertNull(title);
-
- title = dc.removeTitle("de");
- assertEquals("Der Titel", title);
- title = dc.removeTitle("de");
- assertNull(title);
- }
-
- public void testReplaceLangAlt() throws Exception {
- Metadata xmp = new Metadata();
- DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
- dc.setTitle("Default title");
- StringWriter writer = new StringWriter();
- XMPSerializer.writeXML(xmp, new StreamResult(writer));
- String xmpString = writer.toString();
- xmp = XMPParser.parseXMP(new StreamSource(new java.io.StringReader(xmpString)));
- dc = DublinCoreSchema.getAdapter(xmp);
- assertEquals("Default title", dc.getTitle());
- dc.setTitle("Updated title");
- XMPProperty prop = xmp.getProperty(new QName(DublinCoreSchema.NAMESPACE, "title"));
- XMPArray array = prop.getArrayValue();
- assertNotNull(array);
- //Check that only one title is present. There used to be a bug that didn't set the
- //non-qualified value equal to the value qualified with "x-default".
- assertEquals(1, array.getSize());
- assertEquals("Updated title", array.getValue(0));
- }
-
- public void testPropertyValues() throws Exception {
- Metadata xmp = new Metadata();
- DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
-
- String format = dc.getFormat();
- assertNull(format);
-
- dc.setFormat("application/pdf");
- format = dc.getFormat();
- assertEquals("application/pdf", format);
-
- dc.setFormat("image/jpeg");
- format = dc.getFormat();
- assertEquals("image/jpeg", format);
-
- dc.setFormat(null);
- format = dc.getFormat();
- assertNull(format);
-
- dc.setFormat(""); //Empty string same as null value
- format = dc.getFormat();
- assertNull(format);
-
- dc.setTitle("title");
- String title = dc.getTitle();
- assertEquals("title", title);
-
- dc.setTitle("Titel");
- title = dc.getTitle();
- assertEquals("Titel", title);
-
- dc.setTitle(null);
- title = dc.getTitle();
- assertNull(title);
-
- dc.setTitle("");
- title = dc.getTitle();
- assertNull(title);
- }
-
- public void testDates() throws Exception {
- Metadata xmp = new Metadata();
- XMPBasicAdapter basic = XMPBasicSchema.getAdapter(xmp);
-
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
- cal.set(2008, Calendar.FEBRUARY, 07, 15, 11, 07);
- cal.set(Calendar.MILLISECOND, 0);
- Date dt = cal.getTime();
-
- assertNull(basic.getCreateDate());
- basic.setCreateDate(dt);
- Date dt2 = basic.getCreateDate();
- assertEquals(dt2, dt);
- }
-
- public void testQualifiers() throws Exception {
- Metadata xmp = new Metadata();
- XMPBasicAdapter basic = XMPBasicSchema.getAdapter(xmp);
-
- basic.addIdentifier("x123");
- basic.setIdentifier("id1", "system1");
- basic.setIdentifier("12345", "system2");
-
- String[] ids = basic.getIdentifiers();
- assertEquals(3, ids.length);
- Set set = new java.util.HashSet(Arrays.asList(ids));
- assertTrue(set.contains("x123"));
- assertTrue(set.contains("id1"));
- assertTrue(set.contains("12345"));
-
- assertEquals("id1", basic.getIdentifier("system1"));
- basic.setIdentifier("id2", "system1");
- assertEquals("id2", basic.getIdentifier("system1"));
- assertEquals(3, basic.getIdentifiers().length);
- }
-
-}
+/*
+ * 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.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.xmp;
+
+import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Set;
+import java.util.TimeZone;
+
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.xmlgraphics.util.QName;
+import org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter;
+import org.apache.xmlgraphics.xmp.schemas.DublinCoreSchema;
+import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter;
+import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
+
+/**
+ * Tests property access methods.
+ */
+public class XMPPropertyTest extends TestCase {
+
+ public void testPropertyAccess() throws Exception {
+ Metadata xmp = new Metadata();
+ DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
+ assertNull(dc.getContributors());
+
+ dc.addContributor("Contributor1");
+ assertEquals(1, dc.getContributors().length);
+ assertEquals("Contributor1", dc.getContributors()[0]);
+ dc.removeContributor("Contributor1");
+ assertNull(dc.getContributors());
+
+ dc.addContributor("Contributor1");
+ assertEquals(1, dc.getContributors().length);
+ dc.addContributor("Contributor2");
+ assertEquals(2, dc.getContributors().length);
+ assertFalse(dc.removeContributor("DoesNotExist"));
+ assertTrue(dc.removeContributor("Contributor1"));
+ assertEquals(1, dc.getContributors().length);
+ assertTrue(dc.removeContributor("Contributor2"));
+ assertFalse(dc.removeContributor("Contributor2"));
+ assertNull(dc.getContributors());
+ }
+
+ public void testPropertyRemovalLangAlt() throws Exception {
+ Metadata xmp = new Metadata();
+ DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
+
+ //dc:title is a "Lang Alt"
+ dc.setTitle("en", "The title");
+ String title = dc.removeTitle("en");
+ assertEquals("The title", title);
+ dc.setTitle("en", "The title");
+ dc.setTitle("de", "Der Titel");
+ title = dc.removeTitle("en");
+ assertEquals("The title", title);
+ title = dc.removeTitle("en");
+ assertNull(title);
+
+ title = dc.removeTitle("de");
+ assertEquals("Der Titel", title);
+ title = dc.removeTitle("de");
+ assertNull(title);
+ }
+
+ public void testReplaceLangAlt() throws Exception {
+ Metadata xmp = new Metadata();
+ DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
+ dc.setTitle("Default title");
+ StringWriter writer = new StringWriter();
+ XMPSerializer.writeXML(xmp, new StreamResult(writer));
+ String xmpString = writer.toString();
+ xmp = XMPParser.parseXMP(new StreamSource(new java.io.StringReader(xmpString)));
+ dc = DublinCoreSchema.getAdapter(xmp);
+ assertEquals("Default title", dc.getTitle());
+ dc.setTitle("Updated title");
+ XMPProperty prop = xmp.getProperty(new QName(DublinCoreSchema.NAMESPACE, "title"));
+ XMPArray array = prop.getArrayValue();
+ assertNotNull(array);
+ //Check that only one title is present. There used to be a bug that didn't set the
+ //non-qualified value equal to the value qualified with "x-default".
+ assertEquals(1, array.getSize());
+ assertEquals("Updated title", array.getValue(0));
+ }
+
+ public void testPropertyValues() throws Exception {
+ Metadata xmp = new Metadata();
+ DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
+
+ String format = dc.getFormat();
+ assertNull(format);
+
+ dc.setFormat("application/pdf");
+ format = dc.getFormat();
+ assertEquals("application/pdf", format);
+
+ dc.setFormat("image/jpeg");
+ format = dc.getFormat();
+ assertEquals("image/jpeg", format);
+
+ dc.setFormat(null);
+ format = dc.getFormat();
+ assertNull(format);
+
+ dc.setFormat(""); //Empty string same as null value
+ format = dc.getFormat();
+ assertNull(format);
+
+ dc.setTitle("title");
+ String title = dc.getTitle();
+ assertEquals("title", title);
+
+ dc.setTitle("Titel");
+ title = dc.getTitle();
+ assertEquals("Titel", title);
+
+ dc.setTitle(null);
+ title = dc.getTitle();
+ assertNull(title);
+
+ dc.setTitle("");
+ title = dc.getTitle();
+ assertNull(title);
+ }
+
+ public void testDates() throws Exception {
+ Metadata xmp = new Metadata();
+ XMPBasicAdapter basic = XMPBasicSchema.getAdapter(xmp);
+
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
+ cal.set(2008, Calendar.FEBRUARY, 07, 15, 11, 07);
+ cal.set(Calendar.MILLISECOND, 0);
+ Date dt = cal.getTime();
+
+ assertNull(basic.getCreateDate());
+ basic.setCreateDate(dt);
+ Date dt2 = basic.getCreateDate();
+ assertEquals(dt2, dt);
+ }
+
+ public void testQualifiers() throws Exception {
+ Metadata xmp = new Metadata();
+ XMPBasicAdapter basic = XMPBasicSchema.getAdapter(xmp);
+
+ basic.addIdentifier("x123");
+ basic.setIdentifier("id1", "system1");
+ basic.setIdentifier("12345", "system2");
+
+ String[] ids = basic.getIdentifiers();
+ assertEquals(3, ids.length);
+ Set set = new java.util.HashSet(Arrays.asList(ids));
+ assertTrue(set.contains("x123"));
+ assertTrue(set.contains("id1"));
+ assertTrue(set.contains("12345"));
+
+ assertEquals("id1", basic.getIdentifier("system1"));
+ basic.setIdentifier("id2", "system1");
+ assertEquals("id2", basic.getIdentifier("system1"));
+ assertEquals(3, basic.getIdentifiers().length);
+ }
+
+}
Propchange: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/xmlgraphics-commons-pom-template.pom
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/xmlgraphics-commons-pom-template.pom?rev=1309884&r1=1309883&r2=1309884&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/xmlgraphics-commons-pom-template.pom (original)
+++ xmlgraphics/commons/branches/Temp_TrueTypeInPostScript/xmlgraphics-commons-pom-template.pom Thu Apr 5 14:36:20 2012
@@ -55,12 +55,17 @@ http://maven.apache.org/maven-v4_0_0.xsd
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/xmlgraphics/commons/trunk</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/xmlgraphics/commons/trunk</developerConnection>
- <url>http://svn.apache.org/viewcvs.cgi/xmlgraphics/commons/trunk/?root=Apache-SVN</url>
+ <url>http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/?root=Apache-SVN</url>
</scm>
<organization>
<name>Apache Software Foundation</name>
<url>http://www.apache.org/</url>
</organization>
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>7</version>
+ </parent>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org