Пример #1
0
  /**
   * Creates and returns a new include object.
   *
   * @param includeName the include name
   * @param dataObjectInfo a data object info
   * @return a new include object
   */
  public IncludeObject createInclude(String includeName, AFPDataObjectInfo dataObjectInfo) {
    IncludeObject includeObj = factory.createInclude(includeName);

    if (dataObjectInfo instanceof AFPImageObjectInfo) {
      // IOCA image object
      includeObj.setObjectType(IncludeObject.TYPE_IMAGE);
    } else if (dataObjectInfo instanceof AFPGraphicsObjectInfo) {
      // graphics object
      includeObj.setObjectType(IncludeObject.TYPE_GRAPHIC);
    } else {
      // object container
      includeObj.setObjectType(IncludeObject.TYPE_OTHER);

      // set mandatory object classification (type other)
      Registry.ObjectType objectType = dataObjectInfo.getObjectType();
      if (objectType != null) {
        // set object classification
        final boolean dataInContainer = true;
        final boolean containerHasOEG = false; // environment parameters set in include
        final boolean dataInOCD = true;
        includeObj.setObjectClassification(
            // object scope not defined
            ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT,
            objectType,
            dataInContainer,
            containerHasOEG,
            dataInOCD);
      } else {
        throw new IllegalStateException(
            "Failed to set Object Classification Triplet on Object Container.");
      }
    }

    AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();

    int xOffset = objectAreaInfo.getX();
    int yOffset = objectAreaInfo.getY();
    includeObj.setObjectAreaOffset(xOffset, yOffset);

    int width = objectAreaInfo.getWidth();
    int height = objectAreaInfo.getHeight();
    includeObj.setObjectAreaSize(width, height);

    int rotation = objectAreaInfo.getRotation();
    includeObj.setObjectAreaOrientation(rotation);

    int widthRes = objectAreaInfo.getWidthRes();
    int heightRes = objectAreaInfo.getHeightRes();
    includeObj.setMeasurementUnits(widthRes, heightRes);

    includeObj.setMappingOption(MappingOptionTriplet.SCALE_TO_FIT);

    return includeObj;
  }
Пример #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;
  }