You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AFPDataObjectInfo.java 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.afp;
  19. import org.apache.fop.afp.modca.Registry;
  20. import org.apache.fop.afp.modca.triplets.MappingOptionTriplet;
  21. /**
  22. * A list of parameters associated with an AFP data objects
  23. */
  24. public class AFPDataObjectInfo {
  25. /** the object area info */
  26. private AFPObjectAreaInfo objectAreaInfo;
  27. /** resource info */
  28. private AFPResourceInfo resourceInfo;
  29. /** the data object width */
  30. private int dataWidth;
  31. /** the data object height */
  32. private int dataHeight;
  33. /** the object registry mimetype */
  34. private String mimeType;
  35. /** the object data in a byte array */
  36. private byte[] data;
  37. /** the object data height resolution */
  38. private int dataHeightRes;
  39. /** the object data width resolution */
  40. private int dataWidthRes;
  41. /** controls whether to create a page segment or a simple object */
  42. private boolean createPageSegment;
  43. /** controls the mapping of the image data into the image area */
  44. private byte mappingOption = MappingOptionTriplet.SCALE_TO_FILL;
  45. public static final byte DEFAULT_MAPPING_OPTION = 0x00;
  46. /**
  47. * Default constructor
  48. */
  49. public AFPDataObjectInfo() {
  50. }
  51. /**
  52. * Sets the image mime type
  53. *
  54. * @param mimeType the image mime type
  55. */
  56. public void setMimeType(String mimeType) {
  57. this.mimeType = mimeType;
  58. }
  59. /**
  60. * Returns the mime type of this data object
  61. *
  62. * @return the mime type of this data object
  63. */
  64. public String getMimeType() {
  65. return mimeType;
  66. }
  67. /**
  68. * Convenience method to return the object type
  69. *
  70. * @return the object type
  71. */
  72. public Registry.ObjectType getObjectType() {
  73. return Registry.getInstance().getObjectType(getMimeType());
  74. }
  75. /**
  76. * Returns the resource level at which this data object should reside
  77. *
  78. * @return the resource level at which this data object should reside
  79. */
  80. public AFPResourceInfo getResourceInfo() {
  81. if (resourceInfo == null) {
  82. this.resourceInfo = new AFPResourceInfo();
  83. }
  84. return resourceInfo;
  85. }
  86. /**
  87. * Sets the resource level at which this object should reside
  88. *
  89. * @param resourceInfo the resource level at which this data object should reside
  90. */
  91. public void setResourceInfo(AFPResourceInfo resourceInfo) {
  92. this.resourceInfo = resourceInfo;
  93. }
  94. /**
  95. * Sets the object area info
  96. *
  97. * @param objectAreaInfo the object area info
  98. */
  99. public void setObjectAreaInfo(AFPObjectAreaInfo objectAreaInfo) {
  100. this.objectAreaInfo = objectAreaInfo;
  101. }
  102. /**
  103. * Returns the object area info
  104. *
  105. * @return the object area info
  106. */
  107. public AFPObjectAreaInfo getObjectAreaInfo() {
  108. return this.objectAreaInfo;
  109. }
  110. /**
  111. * Returns the uri of this data object
  112. *
  113. * @return the uri of this data object
  114. */
  115. public String getUri() {
  116. return getResourceInfo().getUri();
  117. }
  118. /**
  119. * Sets the data object uri
  120. *
  121. * @param uri the data object uri
  122. */
  123. public void setUri(String uri) {
  124. getResourceInfo().setUri(uri);
  125. }
  126. /**
  127. * Returns the image data width
  128. *
  129. * @return the image data width
  130. */
  131. public int getDataWidth() {
  132. return dataWidth;
  133. }
  134. /**
  135. * Sets the image data width
  136. *
  137. * @param imageDataWidth the image data width
  138. */
  139. public void setDataWidth(int imageDataWidth) {
  140. this.dataWidth = imageDataWidth;
  141. }
  142. /**
  143. * Returns the image data height
  144. *
  145. * @return the image data height
  146. */
  147. public int getDataHeight() {
  148. return dataHeight;
  149. }
  150. /**
  151. * Sets the image data height
  152. *
  153. * @param imageDataHeight the image data height
  154. */
  155. public void setDataHeight(int imageDataHeight) {
  156. this.dataHeight = imageDataHeight;
  157. }
  158. /**
  159. * Returns the data height resolution
  160. *
  161. * @return the data height resolution
  162. */
  163. public int getDataHeightRes() {
  164. return this.dataHeightRes;
  165. }
  166. /**
  167. * Sets the data height resolution
  168. *
  169. * @param dataHeightRes the data height resolution
  170. */
  171. public void setDataHeightRes(int dataHeightRes) {
  172. this.dataHeightRes = dataHeightRes;
  173. }
  174. /**
  175. * Returns the data width resolution
  176. *
  177. * @return the data width resolution
  178. */
  179. public int getDataWidthRes() {
  180. return this.dataWidthRes;
  181. }
  182. /**
  183. * Sets the data width resolution
  184. *
  185. * @param dataWidthRes the data width resolution
  186. */
  187. public void setDataWidthRes(int dataWidthRes) {
  188. this.dataWidthRes = dataWidthRes;
  189. }
  190. /**
  191. * Sets the object data
  192. *
  193. * @param data the object data
  194. */
  195. public void setData(byte[] data) {
  196. this.data = data;
  197. }
  198. /**
  199. * Returns the object data
  200. *
  201. * @return the object data
  202. */
  203. public byte[] getData() {
  204. return this.data;
  205. }
  206. /**
  207. * Controls whether to create a page segment or a normal object.
  208. * @param value true for page segments, false for objects
  209. */
  210. public void setCreatePageSegment(boolean value) {
  211. this.createPageSegment = value;
  212. }
  213. /**
  214. * Indicates whether a page segment or a normal object shall be created.
  215. * @return true for page segments, false for objects
  216. */
  217. public boolean isCreatePageSegment() {
  218. return this.createPageSegment;
  219. }
  220. /**
  221. * Sets the way an image is mapped into its target area.
  222. * @param mappingOption the mapping option (Valid values: see Mapping Option Triplet)
  223. */
  224. public void setMappingOption(byte mappingOption) {
  225. this.mappingOption = mappingOption;
  226. }
  227. /**
  228. * Returns the way an image is mapped into its target area. By default, this is "scale to fill"
  229. * behavior.
  230. * @return the mapping option value from the Mapping Option Triplet
  231. */
  232. public byte getMappingOption() {
  233. return mappingOption;
  234. }
  235. /** {@inheritDoc} */
  236. public String toString() {
  237. return "AFPDataObjectInfo{"
  238. + "mimeType=" + mimeType
  239. + ", dataWidth=" + dataWidth
  240. + ", dataHeight=" + dataHeight
  241. + ", dataWidthRes=" + dataWidthRes
  242. + ", dataHeightRes=" + dataHeightRes
  243. + (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "")
  244. + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : "");
  245. }
  246. }