private String eventKey;
private EventSeverity severity;
- private Map params;
+ private Map<String, Object> params;
/**
* Creates a new Event.
* @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) {
* 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);
}
* 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).
*/
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;
* Returns the accumulated parameter map.
* @return the accumulated parameter map
*/
- public Map build() {
+ public Map<String, Object> build() {
return this.params;
}
}
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);
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) {
* Returns the {@link Exception} class created by this factory.
* @return the exception class
*/
- Class getExceptionClass();
+ Class<? extends Exception> getExceptionClass();
}
}
}
/** {@inheritDoc} */
- public Class getExceptionClass() {
+ public Class<PropertyException> getExceptionClass() {
return PropertyException.class;
}
}
/** {@inheritDoc} */
- public Class getExceptionClass() {
+ public Class<UnsupportedOperationException> getExceptionClass() {
return UnsupportedOperationException.class;
}
}
/** {@inheritDoc} */
- public Class getExceptionClass() {
+ public Class<ValidationException> getExceptionClass() {
return ValidationException.class;
}
}
/** {@inheritDoc} */
- public Class getExceptionClass() {
+ public Class<PageProductionException> getExceptionClass() {
return PageProductionException.class;
}
}
/** {@inheritDoc} */
- public Class getExceptionClass() {
+ public Class<LayoutException> getExceptionClass() {
return LayoutException.class;
}
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 {
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
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);
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;
* 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);
String iccProfileSrc = null;
if (isPseudoProfile(iccProfileName)) {
if (CMYK_PSEUDO_PROFILE.equalsIgnoreCase(iccProfileName)) {
- colorSpace = DeviceCMYKColorSpace.getInstance();
+ colorSpace = ColorSpaces.getDeviceCMYKColorSpace();
} else {
assert false : "Incomplete implementation";
}
+ "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);
* 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));
*/
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);
/** 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);
* @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();
* @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);
}
* @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);
}
/**
* @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.
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;
}
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);
formatObject(obj, sb);
}
- public boolean isGenerated(Map params) {
+ public boolean isGenerated(Map<String, Object> params) {
Object obj = params.get(fieldName);
return obj != null;
}
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;
}
}
- 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;
}
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;
this.conditional = conditional;
}
- private CompositePart(List parts) {
+ private CompositePart(List<Part> parts) {
this.parts.addAll(parts);
this.conditional = true;
}
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);
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;
}
} 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;
}
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;
}
import junit.framework.TestCase;
+import org.apache.xmlgraphics.java2d.color.ColorSpaces;
import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace;
import org.apache.fop.fo.Constants;
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);
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;
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);
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);
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);
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);