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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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.commons.logging.Log;
  20. import org.apache.commons.logging.LogFactory;
  21. import org.apache.fop.afp.modca.Registry;
  22. import org.apache.fop.afp.modca.triplets.MappingOptionTriplet;
  23. /**
  24. * A list of parameters associated with an AFP data objects
  25. */
  26. public class AFPDataObjectInfo {
  27. private static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp");
  28. /** the object area info */
  29. private AFPObjectAreaInfo objectAreaInfo;
  30. /** resource info */
  31. private AFPResourceInfo resourceInfo;
  32. /** the data object width */
  33. private int dataWidth;
  34. /** the data object height */
  35. private int dataHeight;
  36. /** the object registry mimetype */
  37. private String mimeType;
  38. /** the object data in a byte array */
  39. private byte[] data;
  40. /** the object data height resolution */
  41. private int dataHeightRes;
  42. /** the object data width resolution */
  43. private int dataWidthRes;
  44. /** controls whether to create a page segment or a simple object */
  45. private boolean createPageSegment;
  46. /** controls the mapping of the image data into the image area */
  47. private byte mappingOption = MappingOptionTriplet.SCALE_TO_FILL;
  48. /**
  49. * Default constructor
  50. */
  51. public AFPDataObjectInfo() {
  52. }
  53. /**
  54. * Sets the image mime type
  55. *
  56. * @param mimeType the image mime type
  57. */
  58. public void setMimeType(String mimeType) {
  59. this.mimeType = mimeType;
  60. }
  61. /**
  62. * Returns the mime type of this data object
  63. *
  64. * @return the mime type of this data object
  65. */
  66. public String getMimeType() {
  67. return mimeType;
  68. }
  69. /**
  70. * Convenience method to return the object type
  71. *
  72. * @return the object type
  73. */
  74. public Registry.ObjectType getObjectType() {
  75. return Registry.getInstance().getObjectType(getMimeType());
  76. }
  77. /**
  78. * Returns the resource level at which this data object should reside
  79. *
  80. * @return the resource level at which this data object should reside
  81. */
  82. public AFPResourceInfo getResourceInfo() {
  83. if (resourceInfo == null) {
  84. this.resourceInfo = new AFPResourceInfo();
  85. }
  86. return resourceInfo;
  87. }
  88. /**
  89. * Sets the resource level at which this object should reside
  90. *
  91. * @param resourceInfo the resource level at which this data object should reside
  92. */
  93. public void setResourceInfo(AFPResourceInfo resourceInfo) {
  94. this.resourceInfo = resourceInfo;
  95. }
  96. /**
  97. * Sets the object area info
  98. *
  99. * @param objectAreaInfo the object area info
  100. */
  101. public void setObjectAreaInfo(AFPObjectAreaInfo objectAreaInfo) {
  102. this.objectAreaInfo = objectAreaInfo;
  103. }
  104. /**
  105. * Returns the object area info
  106. *
  107. * @return the object area info
  108. */
  109. public AFPObjectAreaInfo getObjectAreaInfo() {
  110. return this.objectAreaInfo;
  111. }
  112. /**
  113. * Returns the uri of this data object
  114. *
  115. * @return the uri of this data object
  116. */
  117. public String getUri() {
  118. return getResourceInfo().getUri();
  119. }
  120. /**
  121. * Sets the data object uri
  122. *
  123. * @param uri the data object uri
  124. */
  125. public void setUri(String uri) {
  126. getResourceInfo().setUri(uri);
  127. }
  128. /**
  129. * Returns the image data width
  130. *
  131. * @return the image data width
  132. */
  133. public int getDataWidth() {
  134. return dataWidth;
  135. }
  136. /**
  137. * Sets the image data width
  138. *
  139. * @param imageDataWidth the image data width
  140. */
  141. public void setDataWidth(int imageDataWidth) {
  142. this.dataWidth = imageDataWidth;
  143. }
  144. /**
  145. * Returns the image data height
  146. *
  147. * @return the image data height
  148. */
  149. public int getDataHeight() {
  150. return dataHeight;
  151. }
  152. /**
  153. * Sets the image data height
  154. *
  155. * @param imageDataHeight the image data height
  156. */
  157. public void setDataHeight(int imageDataHeight) {
  158. this.dataHeight = imageDataHeight;
  159. }
  160. /**
  161. * Returns the data height resolution
  162. *
  163. * @return the data height resolution
  164. */
  165. public int getDataHeightRes() {
  166. return this.dataHeightRes;
  167. }
  168. /**
  169. * Sets the data width resolution
  170. *
  171. * @param dataWidthRes the data width resolution
  172. */
  173. public void setDataHeightRes(int dataHeightRes) {
  174. this.dataHeightRes = dataHeightRes;
  175. }
  176. /**
  177. * Returns the data width resolution
  178. *
  179. * @return the data width resolution
  180. */
  181. public int getDataWidthRes() {
  182. return this.dataWidthRes;
  183. }
  184. /**
  185. * Sets the data width resolution
  186. *
  187. * @param dataWidthRes the data width resolution
  188. */
  189. public void setDataWidthRes(int dataWidthRes) {
  190. this.dataWidthRes = dataWidthRes;
  191. }
  192. /**
  193. * Sets the object data
  194. *
  195. * @param data the object data
  196. */
  197. public void setData(byte[] data) {
  198. this.data = data;
  199. }
  200. /**
  201. * Returns the object data
  202. *
  203. * @return the object data
  204. */
  205. public byte[] getData() {
  206. return this.data;
  207. }
  208. /**
  209. * Controls whether to create a page segment or a normal object.
  210. * @param value true for page segments, false for objects
  211. */
  212. public void setCreatePageSegment(boolean value) {
  213. this.createPageSegment = value;
  214. }
  215. /**
  216. * Indicates whether a page segment or a normal object shall be created.
  217. * @return true for page segments, false for objects
  218. */
  219. public boolean isCreatePageSegment() {
  220. return this.createPageSegment;
  221. }
  222. /**
  223. * Sets the way an image is mapped into its target area.
  224. * @param mappingOption the mapping option (Valid values: see Mapping Option Triplet)
  225. */
  226. public void setMappingOption(byte mappingOption) {
  227. this.mappingOption = mappingOption;
  228. }
  229. /**
  230. * Returns the way an image is mapped into its target area. By default, this is "scale to fill"
  231. * behavior.
  232. * @return the mapping option value from the Mapping Option Triplet
  233. */
  234. public byte getMappingOption() {
  235. return mappingOption;
  236. }
  237. /** {@inheritDoc} */
  238. public String toString() {
  239. return "AFPDataObjectInfo{"
  240. + "mimeType=" + mimeType
  241. + ", dataWidth=" + dataWidth
  242. + ", dataHeight=" + dataHeight
  243. + ", dataWidthRes=" + dataWidthRes
  244. + ", dataHeightRes=" + dataHeightRes
  245. + (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "")
  246. + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : "");
  247. }
  248. }