001/* ===========================================================
002 * Orson Charts : a 3D chart library for the Java(tm) platform
003 * ===========================================================
004 * 
005 * (C)opyright 2013-2022, by David Gilbert.  All rights reserved.
006 * 
007 * https://github.com/jfree/orson-charts
008 * 
009 * This program is free software: you can redistribute it and/or modify
010 * it under the terms of the GNU General Public License as published by
011 * the Free Software Foundation, either version 3 of the License, or
012 * (at your option) any later version.
013 *
014 * This program is distributed in the hope that it will be useful,
015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017 * GNU General Public License for more details.
018 *
019 * You should have received a copy of the GNU General Public License
020 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
021 * 
022 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 
023 * Other names may be trademarks of their respective owners.]
024 * 
025 * If you do not wish to be bound by the terms of the GPL, an alternative
026 * commercial license can be purchased.  For details, please see visit the
027 * Orson Charts home page:
028 * 
029 * http://www.object-refinery.com/orsoncharts/index.html
030 * 
031 */
032
033package org.jfree.chart3d.legend;
034
035import java.awt.Shape;
036import java.util.HashMap;
037import java.util.Map;
038import java.awt.Color;
039import org.jfree.chart3d.internal.Args;
040
041/**
042 * A standard implementation of the {@link LegendItemInfo} interface.
043 */
044public class StandardLegendItemInfo implements LegendItemInfo {
045
046    /** The series key. */
047    private Comparable<?> seriesKey;
048    
049    /** The series label. */
050    private String label;
051    
052    /** A description of the item. */
053    private String description;
054    
055    /** The color to represent this legend item. */
056    private Color color;
057    
058    /** The shape to represent this legend item. */
059    private Shape shape;
060    
061    /** Storage for other properties. */
062    private Map<Comparable<?>, Object> properties;
063    
064    /**
065     * Creates a new instance.
066     * 
067     * @param seriesKey  the series key ({@code null} not permitted).
068     * @param label  the label ({@code null} not permitted).
069     * @param color  the color ({@code null} not permitted).
070     */
071    public StandardLegendItemInfo(Comparable<?> seriesKey, String label, 
072            Color color) {
073        this(seriesKey, label, null, color, null);
074    }
075    
076    /**
077     * Creates a new instance with the specified attributes.
078     * 
079     * @param seriesKey  the series key ({@code null} not permitted).
080     * @param label  the label ({@code null} not permitted).
081     * @param description  the description ({@code null} permitted).
082     * @param color  the color ({@code null} not permitted).
083     * @param shape the shape ({@code null} permitted).
084     */
085    public StandardLegendItemInfo(Comparable<?> seriesKey, String label, 
086            String description, Color color, Shape shape) {
087        Args.nullNotPermitted(seriesKey, "seriesKey");
088        Args.nullNotPermitted(label, "label");
089        Args.nullNotPermitted(color, "color");
090        this.seriesKey = seriesKey;  
091        this.label = label;
092        this.description = description;
093        this.color = color;
094        this.shape = shape;
095        this.properties = new HashMap<>();
096    }
097    
098    /**
099     * Returns the series key.
100     * 
101     * @return The series key (never {@code null}). 
102     */
103    @Override
104    public Comparable<?> getSeriesKey() {
105        return this.seriesKey;
106    }
107
108    /**
109     * Returns the label for the legend item.
110     * 
111     * @return The label (never {@code null}). 
112     */
113    @Override
114    public String getLabel() {
115        return this.label;
116    }
117
118    /**
119     * Returns the description for the legend item.
120     * 
121     * @return The description (possibly {@code null}). 
122     */
123    @Override
124    public String getDescription() {
125        return this.description;
126    }
127
128    /**
129     * Returns the shape for the legend item.
130     * 
131     * @return The shape (possibly {@code null}). 
132     */
133    @Override
134    public Shape getShape() {
135        return this.shape;
136    }
137
138    /**
139     * Returns the color for the legend item.
140     * 
141     * @return The color (never {@code null}). 
142     */
143    @Override
144    public Color getColor() {
145        return this.color;    
146    }
147
148    /**
149     * Returns the properties for the legend item.
150     * 
151     * @return The properties for the legend item. 
152     */
153    @Override
154    public Map<Comparable<?>, Object> getProperties() {
155        return this.properties;
156    }
157    
158}