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.

PresentationTextDescriptor.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright 2006 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.render.afp.modca;
  18. import java.io.IOException;
  19. import java.io.OutputStream;
  20. import org.apache.fop.render.afp.tools.BinaryUtils;
  21. /**
  22. * The Presentation Text Descriptor specifies the units of measure for the
  23. * Presentation Text object space, the size of the Presentation Text object
  24. * space, and the initial values for modal parameters, called initial text
  25. * conditions. Initial values not provided are defaulted by the controlling
  26. * environment or the receiving device.
  27. *
  28. * The Presentation Text Descriptor provides the following initial values:
  29. * - Unit base
  30. * - Xp-units per unit base
  31. * - Yp-units per unit base
  32. * - Xp-extent of the presentation space
  33. * - Yp-extent of the presentation space
  34. * - Initial text conditions.
  35. *
  36. * The initial text conditions are values provided by the Presentation Text
  37. * Descriptor to initialize the modal parameters of the control sequences.
  38. * Modal control sequences typically are characterized by the word set in
  39. * the name of the control sequence. Modal parameters are identified as such
  40. * in their semantic descriptions.
  41. *
  42. */
  43. public class PresentationTextDescriptor extends AbstractAFPObject {
  44. private int _width = 0;
  45. private int _height = 0;
  46. /**
  47. * Constructor a PresentationTextDescriptor for the specified
  48. * width and height.
  49. * @param width The width of the page.
  50. * @param height The height of the page.
  51. */
  52. public PresentationTextDescriptor(int width, int height) {
  53. _width = width;
  54. _height = height;
  55. }
  56. /**
  57. * Accessor method to write the AFP datastream for the Presentation Text Descriptor
  58. * @param os The stream to write to
  59. * @throws java.io.IOException
  60. */
  61. public void writeDataStream(OutputStream os)
  62. throws IOException {
  63. byte[] data = new byte[] {
  64. 0x5A,
  65. 0x00,
  66. 0x16,
  67. (byte) 0xD3,
  68. (byte) 0xB1,
  69. (byte) 0x9B,
  70. 0x00,
  71. 0x00,
  72. 0x00,
  73. 0x00,
  74. 0x00,
  75. 0x09,
  76. 0x60,
  77. 0x09,
  78. 0x60,
  79. 0x00,
  80. 0x00,
  81. 0x00,
  82. 0x00,
  83. 0x00,
  84. 0x00,
  85. 0x00,
  86. 0x00,
  87. };
  88. byte[] x = BinaryUtils.convert(_width, 3);
  89. data[15] = x[0];
  90. data[16] = x[1];
  91. data[17] = x[2];
  92. byte[] y = BinaryUtils.convert(_height, 3);
  93. data[18] = y[0];
  94. data[19] = y[1];
  95. data[20] = y[2];
  96. os.write(data);
  97. }
  98. }