All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mxgraph.util.mxEventObject Maven / Gradle / Ivy

Go to download

JGraphX Swing Component - Java Graph Visualization Library This is a binary & source redistribution of the original, unmodified JGraphX library originating from: "https://github.com/jgraph/jgraphx/archive/v3.4.1.3.zip". The purpose of this redistribution is to make the library available to other Maven projects.

There is a newer version: 3.4.1.3
Show newest version
/**
 * $Id: mxEventObject.java,v 1.4 2009/12/01 15:21:30 gaudenz Exp $
 * Copyright (c) 2007, Gaudenz Alder
 */
package com.mxgraph.util;

import java.util.Hashtable;
import java.util.Map;

/**
 * Base class for objects that dispatch named events.
 */
public class mxEventObject
{

	/**
	 * Holds the name of the event.
	 */
	protected String name;
	
	/**
	 * Holds the properties of the event.
	 */
	protected Map properties;
	
	/**
	 * Holds the consumed state of the event. Default is false.
	 */
	protected boolean consumed = false;

	/**
	 * Constructs a new event for the given name.
	 */
	public mxEventObject(String name)
	{
		this(name, (Object[]) null);
	}

	/**
	 * Constructs a new event for the given name and properties. The optional
	 * properties are specified using a sequence of keys and values, eg.
	 * new mxEventObject("eventName", key1, val1, .., keyN, valN))
	 */
	public mxEventObject(String name, Object... args)
	{
		this.name = name;
		properties = new Hashtable();
		
		if (args != null)
		{
			for (int i = 0; i < args.length; i += 2)
			{
				if (args[i + 1] != null)
				{
					properties.put(String.valueOf(args[i]), args[i + 1]);
				}
			}
		}
	}

	/**
	 * Returns the name of the event.
	 */
	public String getName()
	{
		return name;
	}
	
	/**
	 * 
	 */
	public Map getProperties()
	{
		return properties;
	}

	/**
	 * 
	 */
	public Object getProperty(String key)
	{
		return properties.get(key);
	}

	/**
	 * Returns true if the event has been consumed.
	 */
	public boolean isConsumed()
	{
		return consumed;
	}

	/**
	 * Consumes the event.
	 */
	public void consume()
	{
		consumed = true;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy