View Javadoc
1   /*
2    * Copyright (c) 2011-2024 PrimeFaces Extensions
3    *
4    *  Permission is hereby granted, free of charge, to any person obtaining a copy
5    *  of this software and associated documentation files (the "Software"), to deal
6    *  in the Software without restriction, including without limitation the rights
7    *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    *  copies of the Software, and to permit persons to whom the Software is
9    *  furnished to do so, subject to the following conditions:
10   *
11   *  The above copyright notice and this permission notice shall be included in
12   *  all copies or substantial portions of the Software.
13   *
14   *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20   *  THE SOFTWARE.
21   */
22  package org.primefaces.extensions.component.legend;
23  
24  import java.util.Map;
25  
26  import javax.faces.application.ResourceDependency;
27  import javax.faces.component.UIComponentBase;
28  
29  import org.primefaces.component.api.Widget;
30  
31  /**
32   * <code>Legend</code> component.
33   *
34   * @author Melloware mellowaredev@gmail.com
35   * @since 7.1
36   */
37  @ResourceDependency(library = "primefaces", name = "components.css")
38  @ResourceDependency(library = "primefaces", name = "jquery/jquery.js")
39  @ResourceDependency(library = "primefaces", name = "jquery/jquery-plugins.js")
40  @ResourceDependency(library = "primefaces", name = "core.js")
41  @ResourceDependency(library = "primefaces-extensions", name = "legend/legend.css")
42  @ResourceDependency(library = "primefaces-extensions", name = "legend/legend.js")
43  public class Legend extends UIComponentBase implements Widget {
44  
45      public static final String COMPONENT_TYPE = "org.primefaces.extensions.component.Legend";
46      public static final String COMPONENT_FAMILY = "org.primefaces.extensions.component";
47      public static final String STYLE_CLASS_VERTICAL = "ui-legend-vertical ";
48      public static final String STYLE_CLASS_HORIZONTAL = "ui-legend-horizontal ";
49      public static final String SCALE_STYLE = "ui-legend-scale";
50      public static final String LABELS_STYLE = "ui-legend-labels";
51      public static final String TITLE_STYLE = "ui-legend-title";
52      public static final String FOOTER_STYLE = "ui-legend-footer";
53  
54      private static final String DEFAULT_RENDERER = "org.primefaces.extensions.component.LegendRenderer";
55  
56      @SuppressWarnings("java:S115")
57      protected enum PropertyKeys {
58  
59          // @formatter:off
60          widgetVar,
61          style,
62          styleClass,
63          title,
64          footer,
65          values,
66          layout
67          // @formatter:on
68      }
69  
70      /**
71       * Default constructor
72       */
73      public Legend() {
74          setRendererType(DEFAULT_RENDERER);
75      }
76  
77      /**
78       * {@inheritDoc}
79       */
80      @Override
81      public String getFamily() {
82          return COMPONENT_FAMILY;
83      }
84  
85      public String getLayout() {
86          return (String) getStateHelper().eval(PropertyKeys.layout, "vertical");
87      }
88  
89      public void setLayout(final String layout) {
90          getStateHelper().put(PropertyKeys.layout, layout);
91      }
92  
93      public String getTitle() {
94          return (String) getStateHelper().eval(PropertyKeys.title, null);
95      }
96  
97      public void setTitle(final String title) {
98          getStateHelper().put(PropertyKeys.title, title);
99      }
100 
101     public String getFooter() {
102         return (String) getStateHelper().eval(PropertyKeys.footer, null);
103     }
104 
105     public void setFooter(final String footer) {
106         getStateHelper().put(PropertyKeys.footer, footer);
107     }
108 
109     public String getStyle() {
110         return (String) getStateHelper().eval(PropertyKeys.style, null);
111     }
112 
113     public void setStyle(final String _style) {
114         getStateHelper().put(PropertyKeys.style, _style);
115     }
116 
117     public String getStyleClass() {
118         return (String) getStateHelper().eval(PropertyKeys.styleClass, null);
119     }
120 
121     public void setStyleClass(final String _styleClass) {
122         getStateHelper().put(PropertyKeys.styleClass, _styleClass);
123     }
124 
125     public Map<String, String> getValues() {
126         return (Map<String, String>) getStateHelper().eval(PropertyKeys.values, null);
127     }
128 
129     public void setValues(final Map<String, String> map) {
130         getStateHelper().put(PropertyKeys.values, map);
131     }
132 
133 }