示例#1
0
  /**
   * Creates a resource object wrapper for named includable data objects
   *
   * @param namedObj an named object
   * @param resourceInfo resource information
   * @param objectType the object type
   * @return a new resource object wrapper
   */
  public ResourceObject createResource(
      AbstractNamedAFPObject namedObj,
      AFPResourceInfo resourceInfo,
      Registry.ObjectType objectType) {
    ResourceObject resourceObj = null;
    String resourceName = resourceInfo.getName();
    if (resourceName != null) {
      resourceObj = factory.createResource(resourceName);
    } else {
      resourceObj = factory.createResource();
    }

    if (namedObj instanceof Document) {
      resourceObj.setType(ResourceObject.TYPE_DOCUMENT);
    } else if (namedObj instanceof PageSegment) {
      resourceObj.setType(ResourceObject.TYPE_PAGE_SEGMENT);
    } else if (namedObj instanceof Overlay) {
      resourceObj.setType(ResourceObject.TYPE_OVERLAY_OBJECT);
    } else if (namedObj instanceof AbstractDataObject) {
      AbstractDataObject dataObj = (AbstractDataObject) namedObj;
      if (namedObj instanceof ObjectContainer) {
        resourceObj.setType(ResourceObject.TYPE_OBJECT_CONTAINER);

        // set object classification
        final boolean dataInContainer = true;
        final boolean containerHasOEG = false; // must be included
        final boolean dataInOCD = true;
        // mandatory triplet for object container
        resourceObj.setObjectClassification(
            ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
            objectType,
            dataInContainer,
            containerHasOEG,
            dataInOCD);
      } else if (namedObj instanceof ImageObject) {
        // ioca image type
        resourceObj.setType(ResourceObject.TYPE_IMAGE);
      } else if (namedObj instanceof GraphicsObject) {
        resourceObj.setType(ResourceObject.TYPE_GRAPHIC);
      } else {
        throw new UnsupportedOperationException(
            "Unsupported resource object for data object type " + dataObj);
      }
    } else {
      throw new UnsupportedOperationException("Unsupported resource object type " + namedObj);
    }

    // set the resource information/classification on the data object
    resourceObj.setDataObject(namedObj);
    return resourceObj;
  }
示例#2
0
  /**
   * Creates and configures an ObjectContainer.
   *
   * @param dataObjectInfo the object container info
   * @return a newly created Object Container
   */
  public ObjectContainer createObjectContainer(AFPDataObjectInfo dataObjectInfo) {
    ObjectContainer objectContainer = factory.createObjectContainer();

    // set data object viewport (i.e. position, rotation, dimension, resolution)
    objectContainer.setViewport(dataObjectInfo);

    // set object classification
    Registry.ObjectType objectType = dataObjectInfo.getObjectType();
    AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
    AFPResourceLevel resourceLevel = resourceInfo.getLevel();
    final boolean dataInContainer = true;
    final boolean containerHasOEG = resourceLevel.isInline();
    final boolean dataInOCD = true;
    objectContainer.setObjectClassification(
        ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
        objectType,
        dataInContainer,
        containerHasOEG,
        dataInOCD);

    objectContainer.setData(dataObjectInfo.getData());
    return objectContainer;
  }