(float)posInt.getHeight()
};
int[] coords = mpts2units(srcPts);
- String mimeType = info.getMimeType();
+
// create image object parameters
ImageObjectInfo imageObjectInfo = new ImageObjectInfo();
imageObjectInfo.setBuffered(false);
imageObjectInfo.setUri(uri);
- imageObjectInfo.setMimeType(mimeType);
+
+ String mimeType = info.getMimeType();
+ if (mimeType != null) {
+ imageObjectInfo.setMimeType(mimeType);
+ }
ObjectAreaInfo objectAreaInfo = new ObjectAreaInfo();
objectAreaInfo.setX(coords[X]);
/** {@inheritDoc} */
protected void updateRendererContext(RendererContext context) {
//Work around a problem in Batik: Gradients cannot be done in ColorSpace.CS_GRAY
- context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE,
- Boolean.FALSE);
+ context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE, Boolean.FALSE);
}
}
* @return a cache record
*/
public Record store(DataObjectInfo dataObjectInfo) {
- Registry.ObjectType objectType = dataObjectInfo.getObjectType();
Record record = null;
- if (!objectType.canBeIncluded()) {
+ Registry.ObjectType objectType = dataObjectInfo.getObjectType();
+ if (objectType == null || !objectType.canBeIncluded()) {
AbstractNamedAFPObject dataObj = factory.createObject(dataObjectInfo);
if (dataObj == null) {
log.error("Failed to create object: " + dataObjectInfo);
String overlayName = "OVL"
+ StringUtils.lpad(String.valueOf(++overlayCount), '0', 5);
- DataObjectCache cache = DataObjectCache.getInstance();
DataObjectFactory factory = cache.getFactory();
this.currentOverlay = factory.createOverlay(
overlayName, width, height, widthRes, heightRes, overlayRotation);
if (objectType.canBeIncluded()) {
// Create and return include
- DataObjectFactory factory = cache.getFactory();
- IncludeObject includeObj = factory.createInclude(
- record.getObjectName(), dataObjectInfo);
+ DataObjectFactory factory = cache.getFactory();
+ String objectName = record.getObjectName();
+ IncludeObject includeObj = factory.createInclude(objectName, dataObjectInfo);
getCurrentPage().addObject(includeObj);
// Record the resource cache key (uri) in the ResourceGroup
if (includeObj == null) {
includeObj = new IncludeObject(name);
- Registry.ObjectType objectType = dataObjectInfo.getObjectType();
- if (objectType.isImage()) {
+ if (dataObjectInfo instanceof ImageObjectInfo) {
includeObj.setDataObjectType(IncludeObject.TYPE_IMAGE);
- } else if (objectType.isGraphic()) {
+ } else if (dataObjectInfo instanceof GraphicsObjectInfo) {
includeObj.setDataObjectType(IncludeObject.TYPE_GRAPHIC);
- // } else if (dataObject instanceof PageSegment) {
- // includeObj.setDataObjectType(IncludeObject.TYPE_PAGE_SEGMENT);
} else {
includeObj.setDataObjectType(IncludeObject.TYPE_OTHER);
- // Strip any object container
- // AbstractNamedAFPObject dataObject = dataObjectAccessor.getDataObject();
- // if (dataObject instanceof ObjectContainer) {
- // ObjectContainer objectContainer = (ObjectContainer)dataObject;
- // dataObject = objectContainer.getDataObject();
- // }
}
-// includeObj.setFullyQualifiedName(
-// FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME,
-// FullyQualifiedNameTriplet.FORMAT_CHARSTR,
-// dataObjectInfo.getUri());
-
- includeObj.setObjectClassification(
- ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
- objectType);
+ Registry.ObjectType objectType = dataObjectInfo.getObjectType();
+ if (objectType != null) {
+ includeObj.setObjectClassification(
+ ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
+ objectType);
+ }
ObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fop.render.afp.DataObjectInfo;
-import org.apache.fop.render.afp.ImageObjectInfo;
import org.apache.xmlgraphics.util.MimeConstants;
/**
* MOD:CA Registry of object types
*/
public final class Registry {
- /** logging instance */
- private static final Log log = LogFactory.getLog("org.apache.fop.afp");
-
/** IOB supported object types */
private static final byte COMPID_GIF = 22;
private static final byte COMPID_JFIF = 23; // jpeg file interchange format
true,
MimeConstants.MIME_PCL
)
- );
-
- // Entries without component and object ids
- mimeObjectTypeMap.put(
- MimeConstants.MIME_SVG,
- new ObjectType(
- "Scaleable Vector Graphics",
- MimeConstants.MIME_SVG
- )
- );
- mimeObjectTypeMap.put(
- MimeConstants.MIME_PNG,
- new ObjectType(
- "Portable Network Graphics",
- MimeConstants.MIME_PNG
- )
- );
+ );
}
/**
* Returns the Registry ObjectType for a given data object info
+ * or null if not registered
*
* @param dataObjectInfo the data object info
* @return the Registry ObjectType for a given data object info
+ * or null if not registered
*/
public Registry.ObjectType getObjectType(DataObjectInfo dataObjectInfo) {
String mimeType = dataObjectInfo.getMimeType();
- ObjectType objectType = (Registry.ObjectType)mimeObjectTypeMap.get(mimeType);
- return objectType;
+ if (mimeType != null) {
+ return (Registry.ObjectType)mimeObjectTypeMap.get(mimeType);
+ }
+ return null;
}
/**
private boolean canBeIncluded;
private String mimeType;
- /**
- * Constructor
- *
- * @param name the object type name
- * @param canBeIncluded true if this object can be included with an IOB structured field
- * @param mimeType the mime type associated with this object type
- */
- private ObjectType(String name, boolean canBeIncluded, String mimeType) {
- this.name = name;
- this.canBeIncluded = canBeIncluded;
- this.mimeType = mimeType;
- }
-
- /**
- * Constructor
- *
- * @param name the object type name
- * @param mimeType the mime type associated with this object type
- */
- private ObjectType(String name, String mimeType) {
- this(name, false, mimeType);
- }
-
/**
* Main constructor
*
*/
public ObjectType(byte componentId, byte[] oid, String name,
boolean canBeIncluded, String mimeType) {
- this(name, canBeIncluded, mimeType);
+ this.name = name;
+ this.canBeIncluded = canBeIncluded;
+ this.mimeType = mimeType;
this.componentId = componentId;
this.oid = oid;
}
public boolean isImage() {
return mimeType == MimeConstants.MIME_TIFF
|| mimeType == MimeConstants.MIME_GIF
- || mimeType == MimeConstants.MIME_PNG
|| mimeType == MimeConstants.MIME_JPEG;
}