/* ************************************************************************* IT Mill Toolkit Development of Browser User Interfaces Made Easy Copyright (C) 2000-2006 IT Mill Ltd ************************************************************************* This product is distributed under commercial license that can be found from the product package on license.pdf. Use of this product might require purchasing a commercial license from IT Mill Ltd. For guidelines on usage, see licensing-guidelines.html ************************************************************************* For more information, contact: IT Mill Ltd phone: +358 2 4802 7180 Ruukinkatu 2-4 fax: +358 2 4802 7181 20540, Turku email: info@itmill.com Finland company www: www.itmill.com Primary source for information and releases: www.itmill.com ********************************************************************** */ package com.itmill.toolkit.terminal; import java.util.EventObject; /** * Interface implemented by all classes that can be painted. Classes * implementing this interface know how to output themselves to a UIDL stream * and that way describing to the terminal how it should be displayed in the UI. * * @author IT Mill Ltd. * @version * @VERSION@ * @since 3.0 */ public interface Paintable extends java.util.EventListener { /** *

* Paints the paintable into a UIDL stream. This method creates the UIDL * sequence describing it and outputs it to the given UIDL stream. *

* *

* It is called when the contents of the component should be painted in * response to the component first being shown or having been altered so * that its visual representation is changed. *

* * @param target * the target UIDL stream where the component should paint * itself to. * @throws PaintException * if the paint operation failed. */ public void paint(PaintTarget target) throws PaintException; /** * Requests that the paintable should be repainted as soon as possible. */ public void requestRepaint(); /** * Repaint request event is thrown when the paintable needs to be repainted. * This is typically done when the paint method would return * dissimilar UIDL from the previous call of the method. */ public class RepaintRequestEvent extends EventObject { /** * Serial generated by eclipse. */ private static final long serialVersionUID = 3256725095530442805L; /** * Constructs a new event. * * @param source * the paintable needing repaint. */ public RepaintRequestEvent(Paintable source) { super(source); } /** * Gets the paintable needing repainting. * * @return Paintable for which the paint method will * return dissimilar UIDL from the previous call of the method. */ public Paintable getPaintable() { return (Paintable) getSource(); } } /** * Listens repaint requests. The repaintRequested method is * called when the paintable needs to be repainted. This is typically done * when the paint method would return dissimilar UIDL from * the previous call of the method. */ public interface RepaintRequestListener { /** * Receives repaint request events. * * @param event * the repaint request event specifying the paintable * source. */ public void repaintRequested(RepaintRequestEvent event); } /** * Adds repaint request listener. In order to assure that no repaint * requests are missed, the new repaint listener should paint the paintable * right after adding itself as listener. * * @param listener * the listener to be added. */ public void addListener(RepaintRequestListener listener); /** * Removes repaint request listener. * * @param listener * the listener to be removed. */ public void removeListener(RepaintRequestListener listener); /** * Request sending of repaint events on any further visible changes. * Normally the paintable only send up to one repaint request for listeners * after paint as the paintable as the paintable assumes that the listeners * already know about the repaint need. This method resets the assumtion. * Paint implicitly does the assumtion reset functionality implemented by * this method. *

* This method is normally used only by the terminals to note paintables * about implicit repaints (painting the component without actually invoking * paint method). *

*/ public void requestRepaintRequests(); }