Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

AFPDataObjectInfo.java 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. /**
  23. * A list of parameters associated with an AFP data objects
  24. */
  25. public class AFPDataObjectInfo {
  26. private static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp");
  27. /** the object area info */
  28. private AFPObjectAreaInfo objectAreaInfo;
  29. /** resource info */
  30. private AFPResourceInfo resourceInfo;
  31. /** the data object width */
  32. private int dataWidth;
  33. /** the data object height */
  34. private int dataHeight;
  35. /** the object registry mimetype */
  36. private String mimeType;
  37. /** the object data in a byte array */
  38. private byte[] data;
  39. /** the object data height resolution */
  40. private int dataHeightRes;
  41. /** the object data width resolution */
  42. private int dataWidthRes;
  43. /**
  44. * Default constructor
  45. */
  46. public AFPDataObjectInfo() {
  47. }
  48. /**
  49. * Sets the image mime type
  50. *
  51. * @param mimeType the image mime type
  52. */
  53. public void setMimeType(String mimeType) {
  54. this.mimeType = mimeType;
  55. }
  56. /**
  57. * Returns the mime type of this data object
  58. *
  59. * @return the mime type of this data object
  60. */
  61. public String getMimeType() {
  62. return mimeType;
  63. }
  64. /**
  65. * Convenience method to return the object type
  66. *
  67. * @return the object type
  68. */
  69. public Registry.ObjectType getObjectType() {
  70. return Registry.getInstance().getObjectType(getMimeType());
  71. }
  72. /**
  73. * Returns the resource level at which this data object should reside
  74. *
  75. * @return the resource level at which this data object should reside
  76. */
  77. public AFPResourceInfo getResourceInfo() {
  78. if (resourceInfo == null) {
  79. this.resourceInfo = new AFPResourceInfo();
  80. }
  81. return resourceInfo;
  82. }
  83. /**
  84. * Sets the resource level at which this object should reside
  85. *
  86. * @param resourceInfo the resource level at which this data object should reside
  87. */
  88. public void setResourceInfo(AFPResourceInfo resourceInfo) {
  89. this.resourceInfo = resourceInfo;
  90. }
  91. /**
  92. * Sets the object area info
  93. *
  94. * @param objectAreaInfo the object area info
  95. */
  96. public void setObjectAreaInfo(AFPObjectAreaInfo objectAreaInfo) {
  97. this.objectAreaInfo = objectAreaInfo;
  98. }
  99. /**
  100. * Returns the object area info
  101. *
  102. * @return the object area info
  103. */
  104. public AFPObjectAreaInfo getObjectAreaInfo() {
  105. return this.objectAreaInfo;
  106. }
  107. /**
  108. * Returns the uri of this data object
  109. *
  110. * @return the uri of this data object
  111. */
  112. public String getUri() {
  113. return getResourceInfo().getUri();
  114. }
  115. /**
  116. * Sets the data object uri
  117. *
  118. * @param uri the data object uri
  119. */
  120. public void setUri(String uri) {
  121. getResourceInfo().setUri(uri);
  122. }
  123. /**
  124. * Returns the image data width
  125. *
  126. * @return the image data width
  127. */
  128. public int getDataWidth() {
  129. return dataWidth;
  130. }
  131. /**
  132. * Sets the image data width
  133. *
  134. * @param imageDataWidth the image data width
  135. */
  136. public void setDataWidth(int imageDataWidth) {
  137. this.dataWidth = imageDataWidth;
  138. }
  139. /**
  140. * Returns the image data height
  141. *
  142. * @return the image data height
  143. */
  144. public int getDataHeight() {
  145. return dataHeight;
  146. }
  147. /**
  148. * Sets the image data height
  149. *
  150. * @param imageDataHeight the image data height
  151. */
  152. public void setDataHeight(int imageDataHeight) {
  153. this.dataHeight = imageDataHeight;
  154. }
  155. /**
  156. * Returns the data height resolution
  157. *
  158. * @return the data height resolution
  159. */
  160. public int getDataHeightRes() {
  161. return this.dataHeightRes;
  162. }
  163. /**
  164. * Sets the data width resolution
  165. *
  166. * @param dataWidthRes the data width resolution
  167. */
  168. public void setDataHeightRes(int dataHeightRes) {
  169. this.dataHeightRes = dataHeightRes;
  170. }
  171. /**
  172. * Returns the data width resolution
  173. *
  174. * @return the data width resolution
  175. */
  176. public int getDataWidthRes() {
  177. return this.dataWidthRes;
  178. }
  179. /**
  180. * Sets the data width resolution
  181. *
  182. * @param dataWidthRes the data width resolution
  183. */
  184. public void setDataWidthRes(int dataWidthRes) {
  185. this.dataWidthRes = dataWidthRes;
  186. }
  187. /**
  188. * Sets the object data
  189. *
  190. * @param data the object data
  191. */
  192. public void setData(byte[] data) {
  193. this.data = data;
  194. }
  195. /**
  196. * Returns the object data
  197. *
  198. * @return the object data
  199. */
  200. public byte[] getData() {
  201. return this.data;
  202. }
  203. /** {@inheritDoc} */
  204. public String toString() {
  205. return "AFPDataObjectInfo{"
  206. + "mimeType=" + mimeType
  207. + ", dataWidth=" + dataWidth
  208. + ", dataHeight=" + dataHeight
  209. + ", dataWidthRes=" + dataWidthRes
  210. + ", dataHeightRes=" + dataHeightRes
  211. + (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "")
  212. + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : "");
  213. }
  214. }