/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sample.scatterplot.jaxb;

import java.util.Map;
import java.util.TreeMap;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import sample.scatterplot.persistence.PlotSample;
import sample.scatterplot.persistence.PlotType;

/**
 *
 * Class for JAXB to represent any data to be plotted in the browser. The plot
 * data are the following information:
 *
 * <ul>
 * <li>type: The PlotType name of the plot data.</li>
 * <li>start: Timestamp for start time of the data.</li>
 * <li>end: Timestamp for the end tyme of the data.</li>
 * <li>description: The PlotType description.</li>
 * <li>legend: The PlotType legend.</li>
 * </ul>
 *
 * @author ricky
 * @see PlotType
 * @see PlotSample
 */
@XmlRootElement(name = "plot-data")
public class PlotData {

    private String type = null;
    private String start = null;
    private String end = null;
    private String description = null;
    private String legend = null;
    private Map<String,Float> data = null;
    
    public PlotData() {
        this.type = "Unknown";
        this.data = new TreeMap<String,Float>();
    }

    public PlotData(String magnitude) {
        this.type = magnitude;
        this.data = new TreeMap<String,Float>();
    }

    @XmlElement(name = "type")
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @XmlElement(name="data")
    // trick from: http://java.net/jira/browse/JERSEY-551
    @XmlJavaTypeAdapter(JsonMapAdapter.class)
    public Map<String,Float> getData() {
        return data;
    }

    public void setData(Map<String,Float> data) {
        this.data = new TreeMap(data);
    }

    @XmlElement(name="end")
    public String getEnd() {
        return end;
    }

    public void setEnd(String end) {
        this.end = end;
    }

    @XmlElement(name="start")
    public String getStart() {
        return start;
    }

    public void setStart(String start) {
        this.start = start;
    }

    @XmlElement(name="description")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getLegend() {
        return legend;
    }

    @XmlElement(name="legend")
    public void setLegend(String legend) {
        this.legend = legend;
    }

}

