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.

HwmfMapMode.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hwmf.record;
  16. /**
  17. * A 16-bit unsigned integer that defines the mapping mode.
  18. *
  19. * The MapMode defines how logical units are mapped to physical units;
  20. * that is, assuming that the origins in both the logical and physical coordinate systems
  21. * are at the same point on the drawing surface, what is the physical coordinate (x',y')
  22. * that corresponds to logical coordinate (x,y).
  23. *
  24. * For example, suppose the mapping mode is MM_TEXT. Given the following definition of that
  25. * mapping mode, and an origin (0,0) at the top left corner of the drawing surface, logical
  26. * coordinate (4,5) would map to physical coordinate (4,5) in pixels.
  27. *
  28. * Now suppose the mapping mode is MM_LOENGLISH, with the same origin as the previous
  29. * example. Given the following definition of that mapping mode, logical coordinate (4,-5)
  30. * would map to physical coordinate (0.04,0.05) in inches.
  31. */
  32. public enum HwmfMapMode {
  33. /**
  34. * Each logical unit is mapped to one device pixel.
  35. * Positive x is to the right; positive y is down.
  36. */
  37. MM_TEXT(0x0001, 0),
  38. /**
  39. * Each logical unit is mapped to 0.1 millimeter.
  40. * Positive x is to the right; positive y is up.
  41. */
  42. MM_LOMETRIC(0x0002, 254),
  43. /**
  44. * Each logical unit is mapped to 0.01 millimeter.
  45. * Positive x is to the right; positive y is up.
  46. */
  47. MM_HIMETRIC(0x0003, 2540),
  48. /**
  49. * Each logical unit is mapped to 0.01 inch.
  50. * Positive x is to the right; positive y is up.
  51. */
  52. MM_LOENGLISH(0x0004, 100),
  53. /**
  54. * Each logical unit is mapped to 0.001 inch.
  55. * Positive x is to the right; positive y is up.
  56. */
  57. MM_HIENGLISH(0x0005, 1000),
  58. /**
  59. * Each logical unit is mapped to one twentieth (1/20) of a point.
  60. * In printing, a point is 1/72 of an inch; therefore, 1/20 of a point is 1/1440 of an inch.
  61. * This unit is also known as a "twip".
  62. * Positive x is to the right; positive y is up.
  63. */
  64. MM_TWIPS(0x0006, 1440),
  65. /**
  66. * Logical units are mapped to arbitrary device units with equally scaled axes;
  67. * that is, one unit along the x-axis is equal to one unit along the y-axis.
  68. * The META_SETWINDOWEXT and META_SETVIEWPORTEXT records specify the units and the
  69. * orientation of the axes.
  70. * The processing application SHOULD make adjustments as necessary to ensure the x and y
  71. * units remain the same size. For example, when the window extent is set, the viewport
  72. * SHOULD be adjusted to keep the units isotropic.
  73. */
  74. MM_ISOTROPIC(0x0007, -1),
  75. /**
  76. * Logical units are mapped to arbitrary units with arbitrarily scaled axes.
  77. */
  78. MM_ANISOTROPIC(0x0008, -1);
  79. /**
  80. * native flag
  81. */
  82. public final int flag;
  83. /**
  84. * transformation units - usually scale relative to current dpi.
  85. * when scale == 0, then don't scale
  86. * when scale == -1, then scale relative to window dimension.
  87. */
  88. public final int scale;
  89. HwmfMapMode(int flag, int scale) {
  90. this.flag = flag;
  91. this.scale = scale;
  92. }
  93. public static HwmfMapMode valueOf(int flag) {
  94. for (HwmfMapMode mm : values()) {
  95. if (mm.flag == flag) return mm;
  96. }
  97. return MM_ISOTROPIC;
  98. }
  99. }