git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1058988 13f79535-47bb-0310-9956-ffa450edef68tags/fop-1_1rc1old
@@ -38,7 +38,7 @@ public class Event extends EventObject { | |||
private String eventKey; | |||
private EventSeverity severity; | |||
private Map params; | |||
private Map<String, Object> params; | |||
/** | |||
* Creates a new Event. | |||
@@ -47,7 +47,8 @@ public class Event extends EventObject { | |||
* @param severity the severity level | |||
* @param params the event parameters (a map of name/value pairs) | |||
*/ | |||
public Event(Object source, String eventID, EventSeverity severity, Map params) { | |||
public Event(Object source, String eventID, EventSeverity severity, Map<String, Object> params) | |||
{ | |||
super(source); | |||
int pos = eventID.lastIndexOf('.'); | |||
if (pos < 0 || pos == eventID.length() - 1) { | |||
@@ -122,7 +123,7 @@ public class Event extends EventObject { | |||
* Returns an unmodifiable {@link java.util.Map} with all event parameters. | |||
* @return the parameter map | |||
*/ | |||
public Map getParams() { | |||
public Map<String, Object> getParams() { | |||
return Collections.unmodifiableMap(this.params); | |||
} | |||
@@ -138,7 +139,7 @@ public class Event extends EventObject { | |||
* This class is a fluent builder class for building up the parameter map. | |||
*/ | |||
public static class ParamsBuilder { | |||
private Map params; | |||
private Map<String, Object> params; | |||
/** | |||
* Adds a new parameter (a name/value pair). | |||
@@ -148,7 +149,7 @@ public class Event extends EventObject { | |||
*/ | |||
public ParamsBuilder param(String name, Object value) { | |||
if (this.params == null) { | |||
this.params = new java.util.HashMap(); | |||
this.params = new java.util.HashMap<String, Object>(); | |||
} | |||
this.params.put(name, value); | |||
return this; | |||
@@ -158,7 +159,7 @@ public class Event extends EventObject { | |||
* Returns the accumulated parameter map. | |||
* @return the accumulated parameter map | |||
*/ | |||
public Map build() { | |||
public Map<String, Object> build() { | |||
return this.params; | |||
} | |||
} |
@@ -32,11 +32,12 @@ public final class EventExceptionManager { | |||
private EventExceptionManager() { | |||
} | |||
private static final Map EXCEPTION_FACTORIES = new java.util.HashMap(); | |||
private static final Map<String, ExceptionFactory> EXCEPTION_FACTORIES | |||
= new java.util.HashMap<String, ExceptionFactory>(); | |||
static { | |||
Iterator iter; | |||
iter = Service.providers(ExceptionFactory.class, true); | |||
Iterator<Object> iter; | |||
iter = Service.providers(ExceptionFactory.class); | |||
while (iter.hasNext()) { | |||
ExceptionFactory factory = (ExceptionFactory)iter.next(); | |||
EXCEPTION_FACTORIES.put(factory.getExceptionClass().getName(), factory); | |||
@@ -63,7 +64,7 @@ public final class EventExceptionManager { | |||
String msg = EventFormatter.format(event); | |||
//Get original exception as cause if it is given as one of the parameters | |||
Throwable t = null; | |||
Iterator iter = event.getParams().values().iterator(); | |||
Iterator<Object> iter = event.getParams().values().iterator(); | |||
while (iter.hasNext()) { | |||
Object o = iter.next(); | |||
if (o instanceof Throwable) { | |||
@@ -96,6 +97,6 @@ public final class EventExceptionManager { | |||
* Returns the {@link Exception} class created by this factory. | |||
* @return the exception class | |||
*/ | |||
Class getExceptionClass(); | |||
Class<? extends Exception> getExceptionClass(); | |||
} | |||
} |
@@ -40,7 +40,7 @@ public class PropertyExceptionFactory implements ExceptionFactory { | |||
} | |||
/** {@inheritDoc} */ | |||
public Class getExceptionClass() { | |||
public Class<PropertyException> getExceptionClass() { | |||
return PropertyException.class; | |||
} | |||
@@ -36,7 +36,7 @@ public class UnsupportedOperationExceptionFactory implements ExceptionFactory { | |||
} | |||
/** {@inheritDoc} */ | |||
public Class getExceptionClass() { | |||
public Class<UnsupportedOperationException> getExceptionClass() { | |||
return UnsupportedOperationException.class; | |||
} | |||
@@ -43,7 +43,7 @@ public class ValidationExceptionFactory implements ExceptionFactory { | |||
} | |||
/** {@inheritDoc} */ | |||
public Class getExceptionClass() { | |||
public Class<ValidationException> getExceptionClass() { | |||
return ValidationException.class; | |||
} | |||
@@ -98,7 +98,7 @@ public class PageProductionException extends RuntimeException { | |||
} | |||
/** {@inheritDoc} */ | |||
public Class getExceptionClass() { | |||
public Class<PageProductionException> getExceptionClass() { | |||
return PageProductionException.class; | |||
} | |||
@@ -97,7 +97,7 @@ public class LayoutException extends RuntimeException { | |||
} | |||
/** {@inheritDoc} */ | |||
public Class getExceptionClass() { | |||
public Class<LayoutException> getExceptionClass() { | |||
return LayoutException.class; | |||
} | |||
@@ -148,7 +148,10 @@ public abstract class AbstractGraphics2DAdapter implements Graphics2DAdapter { | |||
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); | |||
} | |||
/** {@inheritDoc} */ | |||
/** | |||
* {@inheritDoc} | |||
* @deprecated | |||
*/ | |||
public void paintImage(Graphics2DImagePainter painter, | |||
RendererContext context, | |||
int x, int y, int width, int height) throws IOException { |
@@ -208,15 +208,17 @@ public abstract class AbstractRenderer | |||
return sb.toString(); | |||
} | |||
/** {@inheritDoc} */ | |||
/** | |||
* {@inheritDoc} | |||
* @deprecated | |||
*/ | |||
public void startPageSequence(LineArea seqTitle) { | |||
//do nothing | |||
} | |||
/** {@inheritDoc} */ | |||
public void startPageSequence(PageSequence pageSequence) { | |||
//TODO Discuss removing old deprecated method startPageSequence(LineArea) | |||
startPageSequence(pageSequence.getTitle()); | |||
// do nothing | |||
} | |||
// normally this would be overriden to create a page in the |
@@ -92,8 +92,8 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { | |||
protected PageReference currentPageRef; | |||
/** Used for bookmarks/outlines. */ | |||
protected Map<Integer, PageReference> pageReferences = | |||
new java.util.HashMap<Integer, PageReference>(); | |||
protected Map<Integer, PageReference> pageReferences | |||
= new java.util.HashMap<Integer, PageReference>(); | |||
private final PDFDocumentNavigationHandler documentNavigationHandler | |||
= new PDFDocumentNavigationHandler(this); |
@@ -27,6 +27,7 @@ import java.util.Map; | |||
import org.apache.commons.logging.Log; | |||
import org.apache.commons.logging.LogFactory; | |||
import org.apache.xmlgraphics.java2d.color.ColorSpaces; | |||
import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace; | |||
import org.apache.fop.apps.FOUserAgent; | |||
@@ -50,7 +51,7 @@ public final class ColorUtil { | |||
* This map is used to predefine given colors, as well as speeding up | |||
* parsing of already parsed colors. | |||
*/ | |||
private static Map colorMap = null; | |||
private static Map<String, Color> colorMap = null; | |||
/** Logger instance */ | |||
protected static final Log log = LogFactory.getLog(ColorUtil.class); | |||
@@ -328,7 +329,7 @@ public final class ColorUtil { | |||
String iccProfileSrc = null; | |||
if (isPseudoProfile(iccProfileName)) { | |||
if (CMYK_PSEUDO_PROFILE.equalsIgnoreCase(iccProfileName)) { | |||
colorSpace = DeviceCMYKColorSpace.getInstance(); | |||
colorSpace = ColorSpaces.getDeviceCMYKColorSpace(); | |||
} else { | |||
assert false : "Incomplete implementation"; | |||
} | |||
@@ -453,7 +454,7 @@ public final class ColorUtil { | |||
+ "Arguments to cmyk() must be in the range [0%-100%] or [0.0-1.0]"); | |||
} | |||
float[] cmyk = new float[] {cyan, magenta, yellow, black}; | |||
DeviceCMYKColorSpace cmykCs = DeviceCMYKColorSpace.getInstance(); | |||
DeviceCMYKColorSpace cmykCs = ColorSpaces.getDeviceCMYKColorSpace(); | |||
float[] rgb = cmykCs.toRGB(cmyk); | |||
parsedColor = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2], | |||
CMYK_PSEUDO_PROFILE, null, cmykCs, cmyk); | |||
@@ -521,7 +522,7 @@ public final class ColorUtil { | |||
* Initializes the colorMap with some predefined values. | |||
*/ | |||
private static void initializeColorMap() { // CSOK: MethodLength | |||
colorMap = Collections.synchronizedMap(new java.util.HashMap()); | |||
colorMap = Collections.synchronizedMap(new java.util.HashMap<String, Color>()); | |||
colorMap.put("aliceblue", new Color(240, 248, 255)); | |||
colorMap.put("antiquewhite", new Color(250, 235, 215)); | |||
@@ -710,7 +711,7 @@ public final class ColorUtil { | |||
*/ | |||
public static Color toCMYKGrayColor(float black) { | |||
float[] cmyk = new float[] {0f, 0f, 0f, 1.0f - black}; | |||
DeviceCMYKColorSpace cmykCs = DeviceCMYKColorSpace.getInstance(); | |||
DeviceCMYKColorSpace cmykCs = ColorSpaces.getDeviceCMYKColorSpace(); | |||
float[] rgb = cmykCs.toRGB(cmyk); | |||
return ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2], | |||
CMYK_PSEUDO_PROFILE, null, cmykCs, cmyk); |
@@ -46,24 +46,27 @@ public class AdvancedMessageFormat { | |||
/** Regex that matches "," but not "\," (escaped comma) */ | |||
static final Pattern COMMA_SEPARATOR_REGEX = Pattern.compile("(?<!\\\\),"); | |||
private static final Map PART_FACTORIES = new java.util.HashMap(); | |||
private static final List OBJECT_FORMATTERS = new java.util.ArrayList(); | |||
private static final Map FUNCTIONS = new java.util.HashMap(); | |||
private static final Map<String, PartFactory> PART_FACTORIES | |||
= new java.util.HashMap<String, PartFactory>(); | |||
private static final List<ObjectFormatter> OBJECT_FORMATTERS | |||
= new java.util.ArrayList<ObjectFormatter>(); | |||
private static final Map<Object, Function> FUNCTIONS | |||
= new java.util.HashMap<Object, Function>(); | |||
private CompositePart rootPart; | |||
static { | |||
Iterator iter; | |||
iter = Service.providers(PartFactory.class, true); | |||
Iterator<Object> iter; | |||
iter = Service.providers(PartFactory.class); | |||
while (iter.hasNext()) { | |||
PartFactory factory = (PartFactory)iter.next(); | |||
PART_FACTORIES.put(factory.getFormat(), factory); | |||
} | |||
iter = Service.providers(ObjectFormatter.class, true); | |||
iter = Service.providers(ObjectFormatter.class); | |||
while (iter.hasNext()) { | |||
OBJECT_FORMATTERS.add((ObjectFormatter)iter.next()); | |||
} | |||
iter = Service.providers(Function.class, true); | |||
iter = Service.providers(Function.class); | |||
while (iter.hasNext()) { | |||
Function function = (Function)iter.next(); | |||
FUNCTIONS.put(function.getName(), function); | |||
@@ -189,7 +192,7 @@ public class AdvancedMessageFormat { | |||
* @param params a Map of named parameters (Contents: <String, Object>) | |||
* @return the formatted message | |||
*/ | |||
public String format(Map params) { | |||
public String format(Map<String, Object> params) { | |||
StringBuffer sb = new StringBuffer(); | |||
format(params, sb); | |||
return sb.toString(); | |||
@@ -200,7 +203,7 @@ public class AdvancedMessageFormat { | |||
* @param params a Map of named parameters (Contents: <String, Object>) | |||
* @param target the target StringBuffer to write the formatted message to | |||
*/ | |||
public void format(Map params, StringBuffer target) { | |||
public void format(Map<String, Object> params, StringBuffer target) { | |||
rootPart.write(target, params); | |||
} | |||
@@ -215,14 +218,14 @@ public class AdvancedMessageFormat { | |||
* @param sb the target string buffer | |||
* @param params the parameters to work with | |||
*/ | |||
void write(StringBuffer sb, Map params); | |||
void write(StringBuffer sb, Map<String, Object> params); | |||
/** | |||
* Indicates whether there is any content that is generated by this message part. | |||
* @param params the parameters to work with | |||
* @return true if the part has content | |||
*/ | |||
boolean isGenerated(Map params); | |||
boolean isGenerated(Map<String, Object> params); | |||
} | |||
/** | |||
@@ -277,7 +280,7 @@ public class AdvancedMessageFormat { | |||
* @param params the message parameters | |||
* @return the function result | |||
*/ | |||
Object evaluate(Map params); | |||
Object evaluate(Map<String, Object> params); | |||
/** | |||
* Returns the name of the function. | |||
@@ -294,11 +297,11 @@ public class AdvancedMessageFormat { | |||
this.text = text; | |||
} | |||
public void write(StringBuffer sb, Map params) { | |||
public void write(StringBuffer sb, Map<String, Object> params) { | |||
sb.append(text); | |||
} | |||
public boolean isGenerated(Map params) { | |||
public boolean isGenerated(Map<String, Object> params) { | |||
return true; | |||
} | |||
@@ -316,7 +319,7 @@ public class AdvancedMessageFormat { | |||
this.fieldName = fieldName; | |||
} | |||
public void write(StringBuffer sb, Map params) { | |||
public void write(StringBuffer sb, Map<String, Object> params) { | |||
if (!params.containsKey(fieldName)) { | |||
throw new IllegalArgumentException( | |||
"Message pattern contains unsupported field name: " + fieldName); | |||
@@ -325,7 +328,7 @@ public class AdvancedMessageFormat { | |||
formatObject(obj, sb); | |||
} | |||
public boolean isGenerated(Map params) { | |||
public boolean isGenerated(Map<String, Object> params) { | |||
Object obj = params.get(fieldName); | |||
return obj != null; | |||
} | |||
@@ -349,9 +352,9 @@ public class AdvancedMessageFormat { | |||
target.append(obj); | |||
} else { | |||
boolean handled = false; | |||
Iterator iter = OBJECT_FORMATTERS.iterator(); | |||
Iterator<ObjectFormatter> iter = OBJECT_FORMATTERS.iterator(); | |||
while (iter.hasNext()) { | |||
ObjectFormatter formatter = (ObjectFormatter)iter.next(); | |||
ObjectFormatter formatter = iter.next(); | |||
if (formatter.supportsObject(obj)) { | |||
formatter.format(target, obj); | |||
handled = true; | |||
@@ -375,12 +378,12 @@ public class AdvancedMessageFormat { | |||
} | |||
} | |||
public void write(StringBuffer sb, Map params) { | |||
public void write(StringBuffer sb, Map<String, Object> params) { | |||
Object obj = this.function.evaluate(params); | |||
formatObject(obj, sb); | |||
} | |||
public boolean isGenerated(Map params) { | |||
public boolean isGenerated(Map<String, Object> params) { | |||
Object obj = this.function.evaluate(params); | |||
return obj != null; | |||
} | |||
@@ -393,7 +396,7 @@ public class AdvancedMessageFormat { | |||
private static class CompositePart implements Part { | |||
protected List parts = new java.util.ArrayList(); | |||
protected List<Part> parts = new java.util.ArrayList<Part>(); | |||
private boolean conditional; | |||
private boolean hasSections = false; | |||
@@ -401,7 +404,7 @@ public class AdvancedMessageFormat { | |||
this.conditional = conditional; | |||
} | |||
private CompositePart(List parts) { | |||
private CompositePart(List<Part> parts) { | |||
this.parts.addAll(parts); | |||
this.conditional = true; | |||
} | |||
@@ -411,7 +414,7 @@ public class AdvancedMessageFormat { | |||
throw new NullPointerException("part must not be null"); | |||
} | |||
if (hasSections) { | |||
CompositePart composite = (CompositePart)this.parts.get(this.parts.size() - 1); | |||
CompositePart composite = (CompositePart) this.parts.get(this.parts.size() - 1); | |||
composite.addChild(part); | |||
} else { | |||
this.parts.add(part); | |||
@@ -420,20 +423,20 @@ public class AdvancedMessageFormat { | |||
public void newSection() { | |||
if (!hasSections) { | |||
List p = this.parts; | |||
List<Part> p = this.parts; | |||
//Dropping into a different mode... | |||
this.parts = new java.util.ArrayList(); | |||
this.parts = new java.util.ArrayList<Part>(); | |||
this.parts.add(new CompositePart(p)); | |||
hasSections = true; | |||
} | |||
this.parts.add(new CompositePart(true)); | |||
} | |||
public void write(StringBuffer sb, Map params) { | |||
public void write(StringBuffer sb, Map<String, Object> params) { | |||
if (hasSections) { | |||
Iterator iter = this.parts.iterator(); | |||
Iterator<Part> iter = this.parts.iterator(); | |||
while (iter.hasNext()) { | |||
CompositePart part = (CompositePart)iter.next(); | |||
Part part = iter.next(); | |||
if (part.isGenerated(params)) { | |||
part.write(sb, params); | |||
break; | |||
@@ -441,20 +444,20 @@ public class AdvancedMessageFormat { | |||
} | |||
} else { | |||
if (isGenerated(params)) { | |||
Iterator iter = this.parts.iterator(); | |||
Iterator<Part> iter = this.parts.iterator(); | |||
while (iter.hasNext()) { | |||
Part part = (Part)iter.next(); | |||
Part part = iter.next(); | |||
part.write(sb, params); | |||
} | |||
} | |||
} | |||
} | |||
public boolean isGenerated(Map params) { | |||
public boolean isGenerated(Map<String, Object> params) { | |||
if (hasSections) { | |||
Iterator iter = this.parts.iterator(); | |||
Iterator<Part> iter = this.parts.iterator(); | |||
while (iter.hasNext()) { | |||
Part part = (Part)iter.next(); | |||
Part part = iter.next(); | |||
if (part.isGenerated(params)) { | |||
return true; | |||
} | |||
@@ -462,9 +465,9 @@ public class AdvancedMessageFormat { | |||
return false; | |||
} else { | |||
if (conditional) { | |||
Iterator iter = this.parts.iterator(); | |||
Iterator<Part> iter = this.parts.iterator(); | |||
while (iter.hasNext()) { | |||
Part part = (Part)iter.next(); | |||
Part part = iter.next(); | |||
if (!part.isGenerated(params)) { | |||
return false; | |||
} |
@@ -23,6 +23,7 @@ import java.awt.Color; | |||
import junit.framework.TestCase; | |||
import org.apache.xmlgraphics.java2d.color.ColorSpaces; | |||
import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace; | |||
import org.apache.fop.fo.Constants; | |||
@@ -50,7 +51,7 @@ public class BorderPropsTestCase extends TestCase { | |||
assertEquals(b1, b2); | |||
float[] cmyk = new float[] {1.0f, 1.0f, 0.5f, 1.0f}; | |||
DeviceCMYKColorSpace cmykCs = DeviceCMYKColorSpace.getInstance(); | |||
DeviceCMYKColorSpace cmykCs = ColorSpaces.getDeviceCMYKColorSpace(); | |||
float[] rgb = cmykCs.toRGB(cmyk); | |||
col = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2], | |||
"#CMYK", null, cmykCs, cmyk); |
@@ -24,7 +24,7 @@ import java.awt.color.ColorSpace; | |||
import junit.framework.TestCase; | |||
import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace; | |||
import org.apache.xmlgraphics.java2d.color.ColorSpaces; | |||
import org.apache.fop.apps.FOUserAgent; | |||
import org.apache.fop.apps.FopFactory; | |||
@@ -156,7 +156,7 @@ public class ColorUtilTestCase extends TestCase { | |||
assertEquals(255, colActual.getRed()); | |||
assertEquals(255, colActual.getGreen()); | |||
assertEquals(0, colActual.getBlue()); | |||
assertEquals(DeviceCMYKColorSpace.getInstance(), colActual.getColorSpace()); | |||
assertEquals(ColorSpaces.getDeviceCMYKColorSpace(), colActual.getColorSpace()); | |||
float[] comps = colActual.getColorComponents(null); | |||
assertEquals(4, comps.length); | |||
assertEquals(0f, comps[0], 0); | |||
@@ -171,7 +171,7 @@ public class ColorUtilTestCase extends TestCase { | |||
assertEquals(248, colActual.getRed()); | |||
assertEquals(199, colActual.getGreen()); | |||
assertEquals(172, colActual.getBlue()); | |||
assertEquals(DeviceCMYKColorSpace.getInstance(), colActual.getColorSpace()); | |||
assertEquals(ColorSpaces.getDeviceCMYKColorSpace(), colActual.getColorSpace()); | |||
comps = colActual.getColorComponents(null); | |||
assertEquals(0.0274f, comps[0], 0.001); | |||
assertEquals(0.2196f, comps[1], 0.001); | |||
@@ -185,7 +185,7 @@ public class ColorUtilTestCase extends TestCase { | |||
assertEquals(255, colActual.getRed()); | |||
assertEquals(255, colActual.getGreen()); | |||
assertEquals(0, colActual.getBlue()); | |||
assertEquals(DeviceCMYKColorSpace.getInstance(), colActual.getColorSpace()); | |||
assertEquals(ColorSpaces.getDeviceCMYKColorSpace(), colActual.getColorSpace()); | |||
comps = colActual.getColorComponents(null); | |||
assertEquals(4, comps.length); | |||
assertEquals(0f, comps[0], 0); | |||
@@ -200,7 +200,7 @@ public class ColorUtilTestCase extends TestCase { | |||
assertEquals(127, colActual.getRed()); | |||
assertEquals(127, colActual.getGreen()); | |||
assertEquals(127, colActual.getBlue()); | |||
assertEquals(DeviceCMYKColorSpace.getInstance(), colActual.getColorSpace()); | |||
assertEquals(ColorSpaces.getDeviceCMYKColorSpace(), colActual.getColorSpace()); | |||
comps = colActual.getColorComponents(null); | |||
assertEquals(4, comps.length); | |||
assertEquals(0f, comps[0], 0); |