View Javadoc

1   /*
2    * Copyright (c) 2006 Stiftung Deutsches Elektronen-Synchroton,
3    * Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
4    *
5    * THIS SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "../AS IS" BASIS.
6    * WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
7    * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR PARTICULAR PURPOSE AND
8    * NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
9    * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
10   * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
11   * THE USE OR OTHER DEALINGS IN THE SOFTWARE. SHOULD THE SOFTWARE PROVE DEFECTIVE
12   * IN ANY RESPECT, THE USER ASSUMES THE COST OF ANY NECESSARY SERVICING, REPAIR OR
13   * CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
14   * NO USE OF ANY SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
15   * DESY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
16   * OR MODIFICATIONS.
17   * THE FULL LICENSE SPECIFYING FOR THE SOFTWARE THE REDISTRIBUTION, MODIFICATION,
18   * USAGE AND OTHER RIGHTS AND OBLIGATIONS IS INCLUDED WITH THE DISTRIBUTION OF THIS
19   * PROJECT IN THE FILE LICENSE.HTML. IF THE LICENSE IS NOT INCLUDED YOU MAY FIND A COPY
20   * AT HTTP://WWW.DESY.DE/LEGAL/LICENSE.HTM
21   */
22  
23  package de.desy.acop.displayers.selector;
24  
25  import java.awt.Component;
26  
27  import de.desy.acop.chart.AcopDisplayMode;
28  import de.desy.acop.chart.AcopDrawStyleEnum;
29  import de.desy.acop.chart.AcopFFTEnum;
30  import de.desy.acop.displayers.tools.AcopDisplayerParameters;
31  import de.desy.acop.displayers.tools.AcopGraphParameters;
32  import de.desy.acop.transport.ConnectionParameters;
33  
34  /**
35   * <code>AcopGraphParametersDialog</code> enables generation of 
36   * <code>AcopGraphParameters</code>. It uses the <code>GraphCustomizerPanel</code>
37   * to customize the parameters.
38   * 
39   * @author Jaka Bobnar, Cosylab
40   * @see AcopGraphParameters
41   * @see GraphCustomizerPanel
42   */
43  public class AcopGraphParametersDialog extends AcopDisplayerParametersDialog<AcopGraphParameters>{
44  
45  	private static final long serialVersionUID = 4031445693248397678L;
46  	private GraphCustomizerPanel graphCustomizerPanel;
47  	
48  	/**
49  	 * Constructs a new AcopGraphParametersDialog.
50  	 * 
51  	 * @param comp the parent of the dialog
52  	 */
53  	public AcopGraphParametersDialog(Component comp) {
54  		super(comp);
55  	}
56  
57  	/*
58  	 * (non-Javadoc)
59  	 * @see de.desy.acop.displayers.selector.AcopDisplayerParametersDialog#generateParameters()
60  	 */
61  	@Override
62  	protected AcopGraphParameters generateParameters() {
63  	    return  new AcopGraphParameters(
64  		getDisplayerParameters(),
65  		getGraphCustomizerPanel().getColor(),
66  		getGraphCustomizerPanel().getGraphFFT(),
67  		getGraphCustomizerPanel().getGraphStyle(),
68  		getGraphCustomizerPanel().getGraphMode(),
69  		getGraphCustomizerPanel().getGraphWidth(),
70  		getGraphCustomizerPanel().isTrend(),
71  		getGraphCustomizerPanel().getTrendLength(),
72  		getConverterPanel().getConverter());
73  	}
74  
75  	/*
76  	 * (non-Javadoc)
77  	 * @see de.desy.acop.displayers.selector.AcopDisplayerParametersDialog#getCustomizerPanel()
78  	 */
79  	@Override
80  	protected MultipleDisplayerAbstractSettingsPanel<AcopGraphParameters> getCustomizerPanel() {
81  		return getGraphCustomizerPanel();
82  	}
83  	
84  	private GraphCustomizerPanel getGraphCustomizerPanel()
85  	{
86  		if (graphCustomizerPanel == null) {
87  			graphCustomizerPanel = new GraphCustomizerPanel();
88  			graphCustomizerPanel.setParameters(null);
89  		}
90  		return graphCustomizerPanel;
91  	}
92  	
93  	
94  	/*
95  	 * (non-Javadoc)
96  	 * @see de.desy.acop.displayers.selector.AcopDisplayerParametersDialog#showChartDialog(java.awt.Component, de.desy.acop.displayers.tools.AcopDisplayerParameters)
97  	 */
98  	@Override
99  	public AcopGraphParameters showDialog(Component component, AcopDisplayerParameters adp) {
100 		this.getGraphCustomizerPanel().setColor(null);
101 		this.getGraphCustomizerPanel().setGraphFFT(AcopFFTEnum.NoFFT.ordinal());
102 		this.getGraphCustomizerPanel().setGraphWidth(1);
103 		this.getGraphCustomizerPanel().setDrawStyle(AcopDrawStyleEnum.PS_SOLID.ordinal());
104 		if (SelectorUtilities.isChannel(adp.getConnectionParameters())) {
105 			getGraphCustomizerPanel().setGraphMode(AcopDisplayMode.SimpleHistogram.ordinal());
106 		} else {
107 			getGraphCustomizerPanel().setGraphMode(AcopDisplayMode.PolyLine.ordinal());
108 		}
109 		return super.showDialog(component, adp);
110 	}
111 	
112 	/*
113 	 * (non-Javadoc)
114 	 * @see de.desy.acop.displayers.selector.AcopDisplayerParametersDialog#showChartDialog(java.awt.Component, de.desy.acop.transport.ConnectionParameters)
115 	 */
116 	@Override
117 	public AcopGraphParameters showDialog(Component component, ConnectionParameters cp) {
118 		this.getGraphCustomizerPanel().setColor(null);
119 		this.getGraphCustomizerPanel().setGraphFFT(AcopFFTEnum.NoFFT.ordinal());
120 		this.getGraphCustomizerPanel().setGraphWidth(1);
121 		this.getGraphCustomizerPanel().setDrawStyle(AcopDrawStyleEnum.PS_SOLID.ordinal());
122 		if (SelectorUtilities.isChannel(cp)) {
123 			getGraphCustomizerPanel().setGraphMode(AcopDisplayMode.SimpleHistogram.ordinal());
124 		} else {
125 			getGraphCustomizerPanel().setGraphMode(AcopDisplayMode.PolyLine.ordinal());
126 		}
127 		return super.showDialog(component, cp);
128 	}
129 
130 }