View Javadoc

1   /*
2    * Copyright (c) 2003-2008 by Cosylab d. d.
3    *
4    * This file is part of CosyBeans.
5    *
6    * CosyBeans is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10   *
11   * CosyBeans is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU General Public License
17   * along with CosyBeans.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  
20  package com.cosylab.gui.util;
21  
22  import java.awt.datatransfer.DataFlavor;
23  
24  import javax.swing.JComponent;
25  
26  import com.cosylab.gui.displayers.Displayer;
27  import com.cosylab.gui.displayers.DisplayerParameters;
28  import com.cosylab.gui.displayers.DoubleDisplayer;
29  
30  /**
31   * <code>DefaultDisplayerParametersTransferHandler</code> is a default
32   * extension of {@link AbstractDisplayerParametersTransferHandler} which can handle
33   * DisplayerParameters. 
34   * 
35   * @author tkusterle
36   *
37   */
38  public class DefaultDisplayerParametersTransferHandler extends AbstractDisplayerParametersTransferHandler {
39  	
40  	private static final long serialVersionUID = -4223198013311762602L;
41  
42  	protected Displayer displayer;
43  
44  	public DefaultDisplayerParametersTransferHandler(Displayer comp, boolean reciveEnabled, boolean exportEnabled) {
45  		super((JComponent)comp,reciveEnabled, exportEnabled);
46  		displayer= (Displayer)comp;
47  	}
48  	
49  	public DefaultDisplayerParametersTransferHandler(Displayer comp, boolean reciveEnabled, boolean exportEnabled, DataFlavor[] f, boolean resetFlavors) {
50  		super((JComponent)comp, reciveEnabled, exportEnabled, f, resetFlavors);
51  		displayer= (Displayer)comp;
52  	}
53  
54  	/*
55  	 * (non-Javadoc)
56  	 * @see com.cosylab.gui.util.AbstractDisplayerParametersTransferHandler#exportDisplayerParameters()
57  	 */
58  	protected DisplayerParameters exportDisplayerParameters() {
59   		if (displayer instanceof DoubleDisplayer) {
60  			return new DisplayerParameters(displayer.getTitle(),(DoubleDisplayer)displayer);
61  		} 
62   		return new DisplayerParameters(displayer.getTitle());
63  	}
64  
65  	/**
66  	 * Returns the displayer.
67  	 * @return Returns the displayer.
68  	 */
69  	public Displayer getDisplayer() {
70  		return displayer;
71  	}	
72  }