/*
VisAD system for interactive analysis and visualization of numerical
data.  Copyright (C) 1996 - 2017 Bill Hibbard, Curtis Rueden, Tom
Rink, Dave Glowacki, Steve Emmerson, Tom Whittaker, Don Murray, and
Tommy Jasmin.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA
*/

package visad.collab;

/**
 * MonitorEvent is the VisAD superclass for events from
 * display monitors.

* They are sourced by DisplayMonitor objects and received by * MonitorCallback objects. */ public abstract class MonitorEvent implements java.io.Serializable { /** * This event occurs whenever a ConstantMap or * ScalarMap is added to a Display. */ public static final int MAP_ADDED = 1; /** * This event occurs whenever a ConstantMap or * ScalarMap is added to a Display. */ public static final int MAP_CHANGED = 2; /** * This event occurs whenever the ConstantMaps and * ScalarMaps are cleared from a Display. */ public static final int MAPS_CLEARED = 3; /** * This event occurs whenever a ConstantMap or * ScalarMap is removed from a Display. */ public static final int MAP_REMOVED = 4; /** * This event occurs whenever a DataReference is added to * a Display. */ public static final int REFERENCE_ADDED = 10; /** * This event occurs whenever a DataReference is removed * from a Display. */ public static final int REFERENCE_REMOVED = 11; /** * This event occurs whenever a Control attached to a * Display requests that it be initialized to the state of * a remote Control. */ public static final int CONTROL_INIT_REQUESTED = 20; /** * This event occurs whenever the state of a Control attached * to a Display is changed. */ public static final int CONTROL_CHANGED = 21; /** * This event occurs whenever a message is sent. */ public static final int MESSAGE_SENT = 22; // these two variables provide a unique number for each event private static int nextSeqNum = 0; protected int seqNum = nextSeqNum++; // the MonitorEvent type protected int type; // the originator of this MonitorEvent // (relative to the receiving DisplayMonitor) private int originator; /** * Creates a MonitorEvent * * @param type The event type. * @param originator The ID of the connection from which this event came, * relative to the receiver of the event. */ public MonitorEvent(int type, int originator) { this.type = type; this.originator = originator; } /** * Gets the type of this MonitorEvent. */ public int getType() { return type; } /** * Get the key used to uniquely identify this event. * * @return The unique key. */ public abstract String getKey(); /** * Gets the originator of this MonitorEvent. */ public int getOriginator() { return originator; } /** * Gets the sequence number of this MonitorEvent. */ public int getSequenceNumber() { return seqNum; } /** * Returns a String description of the * specified MonitorEvent type. * * @param type the MonitorEvent type. * * @return name of the specified type. */ public static String getTypeName(int type) { switch (type) { case MAP_ADDED: return "MAP_ADDED"; case MAP_REMOVED: return "MAP_REMOVED"; case MAP_CHANGED: return "MAP_CHANGED"; case MAPS_CLEARED: return "MAPS_CLEARED"; case REFERENCE_ADDED: return "REFERENCE_ADDED"; case REFERENCE_REMOVED: return "REFERENCE_REMOVED"; case CONTROL_INIT_REQUESTED: return "CONTROL_INIT_REQUESTED"; case CONTROL_CHANGED: return "CONTROL_CHANGED"; } return "Unknown MonitorEvent Type #" + type; } /** * Returns a String description of this * MonitorEvent's type. * * @return name of this event's type. */ public String getTypeName() { return getTypeName(type); } /** * Sets the originator of this MonitorEvent. * * @param id The ID of the connection from which this event came, * relative to the receiver of the event. */ public void setOriginator(int id) { originator = id; } /** * Returns an exact copy of this MonitorEvent. */ public abstract Object clone(); /** * Returns a String representation of this object. */ public String toString() { StringBuffer buf = new StringBuffer("MonitorEvent["); buf.append('#');buf.append(getSequenceNumber());buf.append(' '); buf.append(getTypeName()); if (originator == -1) { buf.append(" Lcl"); } else { buf.append(" Rmt "); buf.append(originator); } buf.append(']'); return buf.toString(); } }

Ads help maintain this website.