View Javadoc
1   /*
2    * Tethys: GUI Utilities
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package io.github.tonywasher.joceanus.tethys.api.chart;
18  
19  import io.github.tonywasher.joceanus.oceanus.decimal.OceanusMoney;
20  import io.github.tonywasher.joceanus.oceanus.event.OceanusEventRegistrar.OceanusEventProvider;
21  import io.github.tonywasher.joceanus.tethys.api.base.TethysUIComponent;
22  import io.github.tonywasher.joceanus.tethys.api.base.TethysUIEvent;
23  
24  import java.util.Iterator;
25  
26  /**
27   * Pie Chart.
28   */
29  public interface TethysUIPieChart
30          extends OceanusEventProvider<TethysUIEvent>, TethysUIComponent {
31      /**
32       * Update PieChart with data.
33       *
34       * @param pData the data
35       */
36      void updatePieChart(TethysUIPieChartData pData);
37  
38      /**
39       * PieChart Data.
40       */
41      interface TethysUIPieChartData {
42          /**
43           * Obtain the title.
44           *
45           * @return the title.
46           */
47          String getTitle();
48  
49          /**
50           * Add a section.
51           *
52           * @param pName  the name
53           * @param pValue the value
54           */
55          default void addSection(final String pName,
56                                  final OceanusMoney pValue) {
57              addSection(pName, pValue, pName);
58          }
59  
60          /**
61           * Add a section.
62           *
63           * @param pName   the name
64           * @param pValue  the value
65           * @param pSource the source
66           */
67          void addSection(String pName,
68                          OceanusMoney pValue,
69                          Object pSource);
70  
71          /**
72           * Obtain the pieChart sections.
73           *
74           * @return the iterator
75           */
76          Iterator<TethysUIPieChartSection> sectionIterator();
77      }
78  
79      /**
80       * The Section definition.
81       */
82      interface TethysUIPieChartSection {
83          /**
84           * Obtain the name.
85           *
86           * @return the name.
87           */
88          String getName();
89  
90          /**
91           * Obtain the value.
92           *
93           * @return the value.
94           */
95          OceanusMoney getValue();
96  
97          /**
98           * Obtain the source.
99           *
100          * @return the source.
101          */
102         Object getSource();
103     }
104 }