Example usage for org.jfree.data.time TimeSeries setDomainDescription

List of usage examples for org.jfree.data.time TimeSeries setDomainDescription

Introduction

In this page you can find the example usage for org.jfree.data.time TimeSeries setDomainDescription.

Prototype

public void setDomainDescription(String description) 

Source Link

Document

Sets the domain description and sends a PropertyChangeEvent (with the property name Domain) to all registered property change listeners.

Usage

From source file:de.citec.csra.allocation.vis.MovingChart.java

public void updateDataPoints(String id, String label, String resource, long start, long end, State state,
        Priority prio, boolean token) {
    synchronized (this.dataset) {
        TimeSeries series = this.dataset.getSeries(id);
        if (series == null) {
            series = new TimeSeries(id);
            this.dataset.addSeries(series);
        }/*ww  w . j  av a 2  s .  co  m*/

        series.setDomainDescription(label);
        int stroke = -1;
        Color c = null;

        boolean randomcolor = false;
        if (!randomcolor) {
            switch (prio) {
            case EMERGENCY:
                c = Color.RED;
                break;
            case URGENT:
                c = Color.ORANGE;
                break;
            case HIGH:
                c = Color.YELLOW;
                break;
            case NORMAL:
                c = Color.GREEN;
                break;
            case LOW:
                c = Color.BLUE;
                break;
            case NO:
                c = Color.BLACK;
                break;
            }
        }

        switch (state) {
        case REQUESTED:
            stroke = 1;
            break;
        case SCHEDULED:
            stroke = 3;
            break;
        case ALLOCATED:
            stroke = 9;
            break;
        case RELEASED:
            stroke = 1;
            break;
        case REJECTED:
        case CANCELLED:
        case ABORTED:
            c = Color.GRAY;
            stroke = 1;
            break;
        }

        XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) this.chart.getXYPlot()
                .getRendererForDataset(dataset);

        int number = -1;
        for (int i = 0; i < this.dataset.getSeries().size(); i++) {
            TimeSeries t = this.dataset.getSeries(i);
            if (t.getKey().equals(id)) {
                number = i;
            }
        }
        if (number > 0) {
            if (stroke > 0) {
                if (token) {
                    r.setSeriesStroke(number,
                            new BasicStroke(stroke, CAP_BUTT, JOIN_BEVEL, 1, new float[] { 1.5f, .5f }, .5f));
                } else {
                    r.setSeriesStroke(number, new BasicStroke(stroke, CAP_BUTT, JOIN_BEVEL, 1));
                }
            }
            if (c != null) {
                r.setSeriesPaint(number, c);
            }
        }

        long channel;
        String key = resource; //prio
        if (values.containsKey(key)) {
            channel = values.get(key);
        } else {
            channel = events++;
            values.put(key, channel);
        }

        if (!series.isEmpty()) {
            series.clear();
        }
        series.addOrUpdate(new Millisecond(new Date(start)), channel);
        series.addOrUpdate(new Millisecond(new Date(end)), channel);
    }
}