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.

Paintable.java 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.itmill.toolkit.terminal;
  5. import java.util.EventObject;
  6. /**
  7. * Interface implemented by all classes that can be painted. Classes
  8. * implementing this interface know how to output themselves to a UIDL stream
  9. * and that way describing to the terminal how it should be displayed in the UI.
  10. *
  11. * @author IT Mill Ltd.
  12. * @version
  13. * @VERSION@
  14. * @since 3.0
  15. */
  16. public interface Paintable extends java.util.EventListener {
  17. /**
  18. * <p>
  19. * Paints the paintable into a UIDL stream. This method creates the UIDL
  20. * sequence describing it and outputs it to the given UIDL stream.
  21. * </p>
  22. *
  23. * <p>
  24. * It is called when the contents of the component should be painted in
  25. * response to the component first being shown or having been altered so
  26. * that its visual representation is changed.
  27. * </p>
  28. *
  29. * @param target
  30. * the target UIDL stream where the component should paint
  31. * itself to.
  32. * @throws PaintException
  33. * if the paint operation failed.
  34. */
  35. public void paint(PaintTarget target) throws PaintException;
  36. /**
  37. * Requests that the paintable should be repainted as soon as possible.
  38. */
  39. public void requestRepaint();
  40. /**
  41. * Repaint request event is thrown when the paintable needs to be repainted.
  42. * This is typically done when the <code>paint</code> method would return
  43. * dissimilar UIDL from the previous call of the method.
  44. */
  45. public class RepaintRequestEvent extends EventObject {
  46. /**
  47. * Serial generated by eclipse.
  48. */
  49. private static final long serialVersionUID = 3256725095530442805L;
  50. /**
  51. * Constructs a new event.
  52. *
  53. * @param source
  54. * the paintable needing repaint.
  55. */
  56. public RepaintRequestEvent(Paintable source) {
  57. super(source);
  58. }
  59. /**
  60. * Gets the paintable needing repainting.
  61. *
  62. * @return Paintable for which the <code>paint</code> method will
  63. * return dissimilar UIDL from the previous call of the method.
  64. */
  65. public Paintable getPaintable() {
  66. return (Paintable) getSource();
  67. }
  68. }
  69. /**
  70. * Listens repaint requests. The <code>repaintRequested</code> method is
  71. * called when the paintable needs to be repainted. This is typically done
  72. * when the <code>paint</code> method would return dissimilar UIDL from
  73. * the previous call of the method.
  74. */
  75. public interface RepaintRequestListener {
  76. /**
  77. * Receives repaint request events.
  78. *
  79. * @param event
  80. * the repaint request event specifying the paintable
  81. * source.
  82. */
  83. public void repaintRequested(RepaintRequestEvent event);
  84. }
  85. /**
  86. * Adds repaint request listener. In order to assure that no repaint
  87. * requests are missed, the new repaint listener should paint the paintable
  88. * right after adding itself as listener.
  89. *
  90. * @param listener
  91. * the listener to be added.
  92. */
  93. public void addListener(RepaintRequestListener listener);
  94. /**
  95. * Removes repaint request listener.
  96. *
  97. * @param listener
  98. * the listener to be removed.
  99. */
  100. public void removeListener(RepaintRequestListener listener);
  101. /**
  102. * Request sending of repaint events on any further visible changes.
  103. * Normally the paintable only send up to one repaint request for listeners
  104. * after paint as the paintable as the paintable assumes that the listeners
  105. * already know about the repaint need. This method resets the assumtion.
  106. * Paint implicitly does the assumtion reset functionality implemented by
  107. * this method.
  108. * <p>
  109. * This method is normally used only by the terminals to note paintables
  110. * about implicit repaints (painting the component without actually invoking
  111. * paint method).
  112. * </p>
  113. */
  114. public void requestRepaintRequests();
  115. }