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.

Sizeable.java 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.itmill.toolkit.terminal;
  5. /**
  6. * Interface to be implemented by components wishing to display some object that
  7. * may be dynamically resized during runtime.
  8. *
  9. * @author IT Mill Ltd.
  10. * @version
  11. * @VERSION@
  12. * @since 3.0
  13. */
  14. public interface Sizeable {
  15. /**
  16. * Unit code representing pixels.
  17. */
  18. public static final int UNITS_PIXELS = 0;
  19. /**
  20. * Unit code representing points (1/72nd of an inch).
  21. */
  22. public static final int UNITS_POINTS = 1;
  23. /**
  24. * Unit code representing picas (12 points).
  25. */
  26. public static final int UNITS_PICAS = 2;
  27. /**
  28. * Unit code representing the font-size of the relevant font.
  29. */
  30. public static final int UNITS_EM = 3;
  31. /**
  32. * Unit code representing the x-height of the relevant font.
  33. */
  34. public static final int UNITS_EX = 4;
  35. /**
  36. * Unit code representing millimeters.
  37. */
  38. public static final int UNITS_MM = 5;
  39. /**
  40. * Unit code representing centimeters.
  41. */
  42. public static final int UNITS_CM = 6;
  43. /**
  44. * Unit code representing inches.
  45. */
  46. public static final int UNITS_INCH = 7;
  47. /**
  48. * Unit code representing in percentage of the containing element defined by
  49. * terminal.
  50. */
  51. public static final int UNITS_PERCENTAGE = 8;
  52. /**
  53. * Unit code representing in rows of text. This unit is only applicable to
  54. * some components can it's meaning is specified by component
  55. * implementation.
  56. */
  57. public static final int UNITS_ROWS = 9;
  58. public static final int SIZE_UNDEFINED = -1;
  59. /**
  60. * Textual representations of units symbols. Supported units and their
  61. * symbols are:
  62. * <ul>
  63. * <li><code>UNITS_PIXELS</code>: "px"</li>
  64. * <li><code>UNITS_POINTS</code>: "pt"</li>
  65. * <li><code>UNITS_PICAS</code>: "pc"</li>
  66. * <li><code>UNITS_EM</code>: "em"</li>
  67. * <li><code>UNITS_EX</code>: "ex"</li>
  68. * <li><code>UNITS_MM</code>: "mm"</li>
  69. * <li><code>UNITS_CM</code>. "cm"</li>
  70. * <li><code>UNITS_INCH</code>: "in"</li>
  71. * <li><code>UNITS_PERCENTAGE</code>: "%"</li>
  72. * <li><code>UNITS_ROWS</code>: "rows"</li>
  73. * </ul>
  74. * These can be used like <code>Sizeable.UNIT_SYMBOLS[UNITS_PIXELS]</code>.
  75. */
  76. public static final String[] UNIT_SYMBOLS = { "px", "pt", "pc", "em", "ex",
  77. "mm", "cm", "in", "%", "rows" };
  78. /**
  79. * Gets the width of the object. Negative number implies unspecified size
  80. * (terminal is free to set the size).
  81. *
  82. * @return width of the object in units specified by widthUnits property.
  83. */
  84. public int getWidth();
  85. /**
  86. * Sets the width of the object. Negative number implies unspecified size
  87. * (terminal is free to set the size).
  88. *
  89. * @param width
  90. * the width of the object in units specified by widthUnits
  91. * property.
  92. * @deprecated Consider using {@link #setWidth(String)} instead. This method
  93. * works, but is error-prone since the unit must be set
  94. * separately (and components might have different default
  95. * unit).
  96. */
  97. public void setWidth(int width);
  98. /**
  99. * Gets the height of the object. Negative number implies unspecified size
  100. * (terminal is free to set the size).
  101. *
  102. * @return height of the object in units specified by heightUnits property.
  103. */
  104. public int getHeight();
  105. /**
  106. * Sets the height of the object. Negative number implies unspecified size
  107. * (terminal is free to set the size).
  108. *
  109. * @param height
  110. * the height of the object in units specified by heightUnits
  111. * property.
  112. * @deprecated Consider using {@link #setHeight(String)} instead. This
  113. * method works, but is error-prone since the unit must be set
  114. * separately (and components might have different default
  115. * unit).
  116. */
  117. public void setHeight(int height);
  118. /**
  119. * Gets the width property units.
  120. *
  121. * @return units used in width property.
  122. */
  123. public int getWidthUnits();
  124. /**
  125. * Sets the width property units.
  126. *
  127. * @param units
  128. * the units used in width property.
  129. * @deprecated Consider setting width and unit simultaneously using
  130. * {@link #setWidth(String)}, which is less error-prone.
  131. */
  132. public void setWidthUnits(int units);
  133. /**
  134. * Gets the height property units.
  135. *
  136. * @return units used in height property.
  137. */
  138. public int getHeightUnits();
  139. /**
  140. * Sets the height property units.
  141. *
  142. * @param units
  143. * the units used in height property.
  144. * @deprecated Consider setting height and unit simultaneously using
  145. * {@link #setHeight(String)}, which is less error-prone.
  146. */
  147. public void setHeightUnits(int units);
  148. /**
  149. * Sets the height of the component using String presentation.
  150. *
  151. * String presentation is similar to what is used in Cascading Style Sheets.
  152. * Size can be length or percentage of available size.
  153. *
  154. * The empty string ("") or null will unset the height and set the units to
  155. * pixels.
  156. *
  157. * See <a
  158. * href="http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-length">CSS
  159. * specification</a> for more details.
  160. *
  161. * @param height
  162. * in CSS style string representation
  163. */
  164. public void setHeight(String height);
  165. /**
  166. * Sets the width of the component using String presentation.
  167. *
  168. * String presentation is similar to what is used in Cascading Style Sheets.
  169. * Size can be length or percentage of available size.
  170. *
  171. * The empty string ("") or null will unset the width and set the units to
  172. * pixels.
  173. *
  174. * See <a
  175. * href="http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-length">CSS
  176. * specification</a> for more details.
  177. *
  178. * @param width
  179. * in CSS style string representation, null or empty string to
  180. * reset
  181. */
  182. public void setWidth(String width);
  183. /**
  184. * Sets the size to 100% x 100%.
  185. */
  186. public void setSizeFull();
  187. /**
  188. * Clears any size settings.
  189. */
  190. public void setSizeUndefined();
  191. }