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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.modca;
  19. import java.io.IOException;
  20. import java.io.OutputStream;
  21. import org.apache.fop.afp.util.BinaryUtils;
  22. /**
  23. * The Presentation Text Descriptor specifies the units of measure for the
  24. * Presentation Text object space, the size of the Presentation Text object
  25. * space, and the initial values for modal parameters, called initial text
  26. * conditions. Initial values not provided are defaulted by the controlling
  27. * environment or the receiving device.
  28. *
  29. * The Presentation Text Descriptor provides the following initial values:
  30. * - Unit base
  31. * - Xp-units per unit base
  32. * - Yp-units per unit base
  33. * - Xp-extent of the presentation space
  34. * - Yp-extent of the presentation space
  35. * - Initial text conditions.
  36. *
  37. * The initial text conditions are values provided by the Presentation Text
  38. * Descriptor to initialize the modal parameters of the control sequences.
  39. * Modal control sequences typically are characterized by the word set in
  40. * the name of the control sequence. Modal parameters are identified as such
  41. * in their semantic descriptions.
  42. *
  43. */
  44. public class PresentationTextDescriptor extends AbstractDescriptor {
  45. /**
  46. * Constructor a PresentationTextDescriptor for the specified
  47. * width and height.
  48. *
  49. * @param width The width of the page.
  50. * @param height The height of the page.
  51. * @param widthRes The width resolution of the page.
  52. * @param heightRes The height resolution of the page.
  53. */
  54. public PresentationTextDescriptor(int width, int height,
  55. int widthRes, int heightRes) {
  56. super(width, height, widthRes, heightRes);
  57. }
  58. /** {@inheritDoc} */
  59. public void writeToStream(OutputStream os) throws IOException {
  60. byte[] data = new byte[23];
  61. copySF(data, Type.MIGRATION, Category.PRESENTATION_TEXT);
  62. data[1] = 0x00; // length
  63. data[2] = 0x16;
  64. data[9] = 0x00;
  65. data[10] = 0x00;
  66. byte[] xdpi = BinaryUtils.convert(widthRes * 10, 2);
  67. data[11] = xdpi[0]; // xdpi
  68. data[12] = xdpi[1];
  69. byte[] ydpi = BinaryUtils.convert(heightRes * 10, 2);
  70. data[13] = ydpi[0]; // ydpi
  71. data[14] = ydpi[1];
  72. byte[] x = BinaryUtils.convert(width, 3);
  73. data[15] = x[0];
  74. data[16] = x[1];
  75. data[17] = x[2];
  76. byte[] y = BinaryUtils.convert(height, 3);
  77. data[18] = y[0];
  78. data[19] = y[1];
  79. data[20] = y[2];
  80. data[21] = 0x00;
  81. data[22] = 0x00;
  82. os.write(data);
  83. }
  84. }