View Javadoc

1   /*
2    * @(#) StatisticsTransferable.java Oct 25, 2003
3    * 
4    * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
5    * Delft, the Netherlands. All rights reserved.
6    * 
7    * See for project information <a href="http://www.simulation.tudelft.nl/">
8    * www.simulation.tudelft.nl </a>.
9    * 
10   * The source code and binary code of this software is proprietary information
11   * of Delft University of Technology.
12   */
13  
14  package org.gscg.common.gui.statistics.components;
15  
16  import java.awt.datatransfer.DataFlavor;
17  import java.awt.datatransfer.Transferable;
18  
19  
20  
21  /***
22   * The ContextTransferable class transfers keys in DropNDrag Operations.
23   * <p>
24   * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
25   * Delft, the Netherlands. All rights reserved.
26   * 
27   * See for project information <a href="http://www.simulation.tudelft.nl/">
28   * www.simulation.tudelft.nl </a>.
29   * 
30   * The source code and binary code of this software is proprietary information
31   * of Delft University of Technology.
32   * 
33   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
34   *         Jacobs </a>
35   * @version $Revision: 1.1 $ $Date: 2005/06/16 12:33:54 $
36   * @since 1.0.0 <br>
37   */
38  public class StatisticsTransferable implements Transferable
39  {
40  	/*** the name under which the object can be found in the context */
41  	private String name = null;
42  
43  	/***
44  	 * constructs a new ContextTransferable
45  	 * 
46  	 * @param object the object to send
47  	 */
48  	public StatisticsTransferable(final Object object)
49  	{
50  		super();
51  		if (object.getClass() != java.lang.String.class)
52  		{
53  			this.name = ((StatisticsChartInterface) object).getChartTitle();
54  		}
55  		// else we dragged the node, ignore the action
56  	}
57  
58  	/***
59  	 * @see java.awt.datatransfer.Transferable#getTransferDataFlavors()
60  	 */
61  	public DataFlavor[] getTransferDataFlavors()
62  	{
63  		return new DataFlavor[]{DataFlavor.stringFlavor};
64  	}
65  
66  	/***
67  	 * @see java.awt.datatransfer.Transferable
68  	 *      #isDataFlavorSupported(java.awt.datatransfer.DataFlavor)
69  	 */
70  	public boolean isDataFlavorSupported(final DataFlavor flavor)
71  	{
72  		if (flavor.equals(DataFlavor.stringFlavor))
73  		{
74  			return true;
75  		}
76  		return false;
77  	}
78  
79  	/***
80  	 * @see java.awt.datatransfer.Transferable
81  	 *      #getTransferData(java.awt.datatransfer.DataFlavor)
82  	 */
83  	public Object getTransferData(final DataFlavor flavor)
84  	{
85  		if (flavor.equals(DataFlavor.stringFlavor))
86  		{
87  			return this.name;
88  		}
89  		return null;
90  	}
91  }