001: /*
002: * uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004,
003: * Refractions Research Inc. This library is free software; you can redistribute it and/or modify it
004: * under the terms of the GNU Lesser General Public License as published by the Free Software
005: * Foundation; version 2.1 of the License. This library is distributed in the hope that it will be
006: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
007: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
008: */
009: package net.refractions.udig.project.internal.render;
010:
011: import org.eclipse.emf.common.notify.Notification;
012: import org.eclipse.emf.common.notify.impl.AdapterImpl;
013:
014: /**
015: * An Adapter for RenderExecutors that allow other objects to listen to state changes that occur in
016: * the RenderExecutor.
017: * <p>
018: * See the example for how to use an this class as a listener.
019: * </p>
020: * <p>
021: * Responsibilities:
022: * <ul>
023: * <li>Listener for RenderExecutor state events</li>
024: * <li>Call renderDone, renderStarting, or renderUpdate when an event occurs that can be mapped to
025: * one of the methods.</li>
026: * </ul>
027: * </p>
028: * <p>
029: * Example Use:
030: *
031: * <pre><code>
032: * renderExecutor.eAdapters().add(new RenderListenerAdapter(){
033: * protected void renderStarting() {
034: * //Enter starting behaviour
035: * }
036: *
037: * protected void renderUpdate() {
038: * //Enter update behaviour
039: * }
040: *
041: * protected void renderDone() {
042: * //Enter done behaviour
043: * }
044: * });
045: * </code></pre>
046: *
047: * </p>
048: *
049: * @author jeichar
050: * @since 0.3
051: */
052: public class RenderListenerAdapter extends AdapterImpl {
053: /**
054: * @see org.eclipse.emf.common.notify.impl.AdapterImpl#isAdapterForType(java.lang.Object)
055: */
056: public boolean isAdapterForType(Object type) {
057: return RenderListenerAdapter.class == type;
058: }
059:
060: /**
061: * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
062: */
063: public void notifyChanged(Notification msg) {
064: if (msg.getFeatureID(Renderer.class) == RenderPackage.RENDERER__STATE) {
065: switch (msg.getNewIntValue()) {
066: case Renderer.STARTING:
067: renderStarting();
068: break;
069: case Renderer.RENDERING: {
070: renderUpdate();
071: break;
072: }
073: case Renderer.DONE: {
074: renderDone();
075: break;
076: }
077: case Renderer.DISPOSED: {
078: renderDisposed(msg);
079: break;
080: }
081: case Renderer.RENDER_REQUEST: {
082: renderRequest();
083: break;
084: }
085: }
086: }
087: }
088:
089: /**
090: * Subclasses may implement if they are interested in being notified when a renderer needs to be
091: * rerendered
092: */
093: protected void renderRequest() {
094: // do nothing
095: }
096:
097: /**
098: * Subclasses may implement if they are interested in being notified when a renderer has been
099: * disposed
100: *
101: * @param msg
102: */
103: protected void renderDisposed(Notification msg) {
104: // do nothing
105: }
106:
107: /**
108: * Subclasses may implement if they are interested in receiving renderStarting events
109: */
110: protected void renderStarting() {
111: // do nothing
112: }
113:
114: /**
115: * Subclasses may implement if they are interested in receiving renderUpdate events
116: */
117: protected void renderUpdate() {
118: // do nothing
119: }
120:
121: /**
122: * Subclasses may implement if they are interested in receiving renderDone events
123: */
124: protected void renderDone() {
125: // do nothing
126: }
127: }
|