View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.trinidad.event;
20  
21  import javax.faces.component.UIComponent;
22  import javax.faces.event.FacesEvent;
23  import javax.faces.event.FacesListener;
24  
25  /**
26   * The Event generated when a Collection is to be sorted.
27   */
28  public final class ChartDrillDownEvent extends FacesEvent
29  {
30    public ChartDrillDownEvent(
31      UIComponent source, 
32      int[] seriesIndices, 
33      int[] yValueIndices, 
34      double[] yValues, 
35      double[] xValues)
36    {
37      super(source);
38      _seriesIndices = (seriesIndices == null) ? null : seriesIndices.clone();
39      _yValueIndices = (yValueIndices == null) ? null : yValueIndices.clone();
40      _yValues = (yValues == null) ? null : yValues.clone();
41      _xValues = (xValues == null) ? null : xValues.clone();
42    }
43  
44  
45    @Override
46    public boolean isAppropriateListener(FacesListener listener)
47    {
48      return (listener instanceof ChartDrillDownListener);
49    }
50  
51    @Override
52    public void processListener(FacesListener listener)
53    {
54      ((ChartDrillDownListener) listener).processChartDrillDown(this);
55    }
56    
57    /**
58     * returns an array of series indices where the user clicked.
59     * In most cases only index 0 is applicable. Currently multiple indices
60     * are applicable only to areaChart and radarArea chart types.
61     * 
62     * @return the array of series indices as an int array
63     */
64    public int[] getSeriesIndices()
65    {
66      if (_seriesIndices == null)
67        return null;
68  
69      return _seriesIndices.clone();
70    }
71  
72    /**
73     * returns an array of yvalue indices where the user clicked.
74     * In most cases only index 0 is applicable. Currently multiple indices
75     * are applicable only to areaChart and radarArea chart types.
76     * This parameter might be null for charts where the interpolated value is
77     * computed(for e.g. area, line etc.)
78     * 
79     * @return the array of yvalue indices as an int array
80     */
81    public int[] getYValueIndices()
82    {
83      if (_yValueIndices == null)
84        return null;
85  
86      return _yValueIndices.clone();
87    }
88  
89    /**
90     * returns an array of yvalues where the user clicked.
91     * The values in this event might be different from the
92     * data set used for displaying the chart since it might represent
93     * interpolated values (for e.g. area, line etc.)
94     * 
95     * @return the array of yvalues as a float array
96     */
97    public double[] getYValues()
98    {
99      if (_yValues == null)
100       return null;
101 
102     return _yValues.clone();
103   }
104 
105   /**
106    * returns an array of xvalues where the user clicked. This is currently 
107    * only applicable to XYLine and scatterPlot
108    * The values in this event might be different from the
109    * data set used for displaying the chart since it might represent
110    * interpolated values (XYLine)
111    * 
112    * @return the array of xvalues as a float array
113    */
114   public double[] getXValues()
115   {
116     if (_xValues == null)
117       return null;
118     return _xValues.clone();
119   }
120   
121   private final int[] _seriesIndices;
122   private final int[] _yValueIndices; 
123   private final double[] _yValues; 
124   private final double[] _xValues;
125   private static final long serialVersionUID = 1L;
126 }