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 7.2KB

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