Example usage for org.jfree.chart.renderer.xy XYItemRenderer setSeriesPaint

List of usage examples for org.jfree.chart.renderer.xy XYItemRenderer setSeriesPaint

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYItemRenderer setSeriesPaint.

Prototype

public void setSeriesPaint(int series, Paint paint);

Source Link

Document

Sets the paint used for a series and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:it.eng.spagobi.engines.chart.bo.charttypes.clusterchart.SimpleCluster.java

public JFreeChart createChart(DatasetMap datasets) {

    DefaultXYZDataset dataset = (DefaultXYZDataset) datasets.getDatasets().get("1");

    JFreeChart chart = ChartFactory.createBubbleChart(name, yLabel, xLabel, dataset, PlotOrientation.HORIZONTAL,
            legend, true, false);/*from  ww w .j ava 2s .  c o m*/

    /*Font font = new Font("Tahoma", Font.BOLD, titleDimension);
    TextTitle title = new TextTitle(name, font);
    chart.setTitle(title);*/

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    Color colorSubInvisibleTitle = Color.decode("#FFFFFF");
    StyleLabel styleSubSubTitle = new StyleLabel("Arial", 12, colorSubInvisibleTitle);
    TextTitle subsubTitle = setStyleTitle("", styleSubSubTitle);
    chart.addSubtitle(subsubTitle);

    chart.setBackgroundPaint(color);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
    //plot.setForegroundAlpha(0.50f);
    plot.setForegroundAlpha(0.65f);

    XYItemRenderer renderer = plot.getRenderer();

    //define colors
    int seriesN = dataset.getSeriesCount();
    if (colorMap != null) {
        boolean isSerieSel = true;
        for (int i = 0; i < seriesN; i++) {
            String serieName = (String) dataset.getSeriesKey(i);
            String tmpName = serieName.replaceAll(" ", "");
            tmpName = tmpName.replace('.', ' ').trim();
            if (serie_selected != null && serie_selected.size() > 0) {
                String serieSel = serie_selected.get(tmpName).toString();
                isSerieSel = (serieSel.equalsIgnoreCase("TRUE") || serieSel.equalsIgnoreCase("YES")
                        || serieSel.equalsIgnoreCase("1")) ? true : false;
                serieName = tmpName;
            }

            if (color != null && isSerieSel) {
                Color color = (Color) colorMap.get(serieName);
                renderer.setSeriesPaint(i, color);
            } else {
                Color color = new Color(Integer.decode(defaultColor).intValue());
                renderer.setSeriesPaint(i, color);
            }
        }
    }

    // increase the margins to account for the fact that the auto-range 
    // doesn't take into account the bubble size...
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    //domainAxis.setAutoRange(true);
    domainAxis.setRange(yMin, yMax);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setLabelPaint(styleXaxesLabels.getColor());
    rangeAxis
            .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor());

    //rangeAxis.setAutoRange(true);
    rangeAxis.setRange(xMin, xMax);

    TickUnits units = null;
    if (decimalXValues == false)
        units = (TickUnits) NumberAxis.createIntegerTickUnits();
    else
        units = (TickUnits) NumberAxis.createStandardTickUnits();
    rangeAxis.setStandardTickUnits(units);

    TickUnits domainUnits = null;
    if (decimalYValues == false)
        domainUnits = (TickUnits) NumberAxis.createIntegerTickUnits();
    else
        domainUnits = (TickUnits) NumberAxis.createStandardTickUnits();
    domainAxis.setStandardTickUnits(domainUnits);

    rangeAxis.setLowerMargin(1.0);
    rangeAxis.setUpperMargin(1.0);

    domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setLabelPaint(styleYaxesLabels.getColor());
    domainAxis
            .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setTickLabelPaint(styleYaxesLabels.getColor());

    domainAxis.setLowerMargin(1.0);
    domainAxis.setUpperMargin(1.0);
    //DecimalFormat format=(new DecimalFormat("0"));
    //rangeAxis.setNumberFormatOverride(format);

    if (legend == true)
        drawLegend(chart);

    return chart;
}

From source file:com.att.aro.ui.view.diagnostictab.plot.BufferOccupancyPlot.java

@Override
public void populate(XYPlot plot, AROTraceData analysis) {

    if (analysis != null) {

        bufferFillDataCollection.removeAllSeries();
        seriesBufferFill = new XYSeries("Buffer Fill");
        seriesDataSets = new TreeMap<>();

        seriesDataSets = bufferOccupancyCalculatorImpl.populateBufferOccupancyDataSet(
                analysis.getAnalyzerResult().getVideoUsage(), chunkPlayTimeList);
        bufferSizeList.clear();//from w w  w  . ja v  a 2s  .  c  o  m

        double xCoordinate, yCoordinate;
        String ptCoordinate[] = new String[2]; // to hold x & y values
        if (!seriesDataSets.isEmpty()) {

            for (int key : seriesDataSets.keySet()) {
                ptCoordinate = seriesDataSets.get(key).trim().split(",");
                xCoordinate = Double.parseDouble(ptCoordinate[0]);
                yCoordinate = Double.parseDouble(ptCoordinate[1]);
                yCoordinate = yCoordinate / 1024; //Converting Buffer size measurement unit to KB
                bufferSizeList.add(yCoordinate);
                seriesBufferFill.add(xCoordinate, yCoordinate);
            }
        }
        Collections.sort(bufferSizeList);
        BufferOccupancyBPResult bufferOccupancyResult = bufferOccupancyCalculatorImpl
                .setMaxBuffer(bufferSizeList.get(bufferSizeList.size() - 1));
        bufferOccupancyResult.setBufferByteDataSet(bufferSizeList);
        analysis.getAnalyzerResult().setBufferOccupancyResult(bufferOccupancyResult);
        // populate collection
        bufferFillDataCollection.addSeries(seriesBufferFill);

        XYItemRenderer renderer = new StandardXYItemRenderer();
        renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {

                // Tooltip value
                Number timestamp = dataset.getX(series, item);
                Number bufferSize = dataset.getY(series, item);
                StringBuffer tooltipValue = new StringBuffer();
                tooltipValue.append(String.format("%.2f", bufferSize) + "," + String.format("%.2f", timestamp));

                String[] value = tooltipValue.toString().split(",");
                return (MessageFormat.format(BUFFEROCCUPANCY_TOOLTIP, value[0], value[1]));
                //return "BufferSize: " + String.format("%.2f", bufferSize) + "KB \n Timestamp: " + String.format("%.2f", timestamp)+"S";
            }

        });
        renderer.setSeriesStroke(0, new BasicStroke(2.0f));
        renderer.setSeriesPaint(0, Color.blue);
        renderer.setSeriesShape(0, shape);

        plot.setRenderer(renderer);

    }
    plot.setDataset(bufferFillDataCollection);
}

From source file:windows.sensorWindow.java

/**
 * updates the width of the template plot
 * /*  w ww  .jav a 2  s .c  o  m*/
 * @param UID
 */
public static void updateTmplPlotWidth(String UID, int index) {
    Brick tmpBrick = Brick.getBrick(connectionData.BrickList, UID);
    if (index == 0) {
        if (rendererMap3.containsKey(UID)) {
            XYItemRenderer rendererTmp = rendererMap3.get(UID);
            int width = computeTmplPlotWidth(tmpBrick.tmpl1Width);
            BasicStroke stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);// ,
            // 10.0f,
            // dash,
            // 0.0f);
            rendererTmp.setSeriesPaint(0, Color.GREEN);
            // renderer3.setSeriesStroke( 0, new BasicStroke( 1 ) );
            rendererTmp.setSeriesStroke(0, stroke);
            rendererMap3.put(UID, rendererTmp);
            // tmplPlot1Width.put(UID,
            // computeTmplPlotWidth(tmpBrick.tmpl1Width));
        }
    }
    if (index == 1) {
        if (rendererMap4.containsKey(UID)) {
            // TODO
        }
    }
}

From source file:org.esa.beam.timeseries.ui.graph.TimeSeriesGraphModel.java

@Override
public void addTimeSeries(List<TimeSeries> timeSeriesList, TimeSeriesType type) {
    final int timeSeriesCount;
    final int collectionOffset;
    if (TimeSeriesType.INSITU.equals(type)) {
        timeSeriesCount = displayAxisMapping.getInsituCount();
        collectionOffset = INSITU_COLLECTION_INDEX_OFFSET;
    } else {//from   www  .j  a v a  2 s  .  c o  m
        timeSeriesCount = displayAxisMapping.getRasterCount();
        if (TimeSeriesType.CURSOR.equals(type)) {
            collectionOffset = CURSOR_COLLECTION_INDEX_OFFSET;
        } else {
            collectionOffset = PIN_COLLECTION_INDEX_OFFSET;
        }
    }
    final String[] aliasNames = getAliasNames();

    for (int aliasIdx = 0; aliasIdx < aliasNames.length; aliasIdx++) {
        final int targetCollectionIndex = collectionOffset + aliasIdx * 3;
        final TimeSeriesCollection targetTimeSeriesCollection = (TimeSeriesCollection) timeSeriesPlot
                .getDataset(targetCollectionIndex);
        if (targetTimeSeriesCollection != null) {
            targetTimeSeriesCollection.removeAllSeries();
        }
    }
    if (timeSeriesCount == 0) {
        return;
    }
    final int numPositions = timeSeriesList.size() / timeSeriesCount;
    int timeSeriesIndexOffset = 0;
    for (int posIdx = 0; posIdx < numPositions; posIdx++) {
        final Shape posShape = getShapeForPosition(type, posIdx);
        for (int aliasIdx = 0; aliasIdx < aliasNames.length; aliasIdx++) {
            final int targetCollectionIndex = collectionOffset + aliasIdx * 3;
            final TimeSeriesCollection targetTimeSeriesCollection = (TimeSeriesCollection) timeSeriesPlot
                    .getDataset(targetCollectionIndex);
            if (targetTimeSeriesCollection == null) {
                continue;
            }
            final XYItemRenderer renderer = timeSeriesPlot.getRenderer(targetCollectionIndex);
            final int dataSourceCount = getDataSourceCount(type, aliasNames[aliasIdx]);
            for (int ignoredIndex = 0; ignoredIndex < dataSourceCount; ignoredIndex++) {
                final TimeSeries currentTimeSeries = timeSeriesList.get(timeSeriesIndexOffset);
                targetTimeSeriesCollection.addSeries(currentTimeSeries);
                final int timeSeriesTargetIdx = targetTimeSeriesCollection.getSeriesCount() - 1;
                renderer.setSeriesShape(timeSeriesTargetIdx, posShape);
                renderer.setSeriesPaint(timeSeriesTargetIdx,
                        renderer.getSeriesPaint(timeSeriesTargetIdx % dataSourceCount));
                renderer.setSeriesVisibleInLegend(timeSeriesTargetIdx, !currentTimeSeries.isEmpty());
                timeSeriesIndexOffset++;
            }
            final ValueAxis axisForDataset = timeSeriesPlot.getDomainAxisForDataset(targetCollectionIndex);
            axisForDataset.configure();
        }
    }
    updateAnnotation(getCurrentView().getRaster());
}

From source file:net.nikr.eve.jeveasset.gui.tabs.tracker.TrackerTab.java

private void updateRender(int index, Color color) {
    XYItemRenderer renderer = jNextChart.getXYPlot().getRenderer();
    renderer.setSeriesPaint(index, color);
    renderer.setSeriesStroke(index, new BasicStroke(1));
}

From source file:com.att.aro.main.GraphPanel.java

/**
 * Sets rendering color for all different network type data series. 
 * @param renderer Renderer for the data series
 * @param dataSeries Data series/* www.jav  a 2  s  . c  o m*/
 */
static void setRenderingColorForDataSeries(XYItemRenderer renderer,
        final XYIntervalSeriesCollection dataSeries) {
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.none), Color.WHITE);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.LTE), Color.RED);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.WIFI), Color.BLUE);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.UMTS), Color.PINK);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.ETHERNET), Color.BLACK);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSDPA), Color.YELLOW);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSPA), Color.ORANGE);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSPAP), Color.MAGENTA);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.HSUPA), Color.CYAN);
    renderer.setSeriesPaint(dataSeries.indexOf(NetworkType.GPRS), Color.GRAY);
}

From source file:edu.unibonn.kmeans.mapreduce.plotting.TimeSeriesPlotter_KMeans.java

/**
  * Creates a chart./*  w w  w  . j av  a  2 s  . c  o  m*/
  * 
  * @param dataset  a dataset.
 * @param clusters 
  * 
  * @return A chart.
  */
//    private JFreeChart createChart(final XYDataset dataset, ArrayList<Cluster_DBScan> clusters) {
//
//        final JFreeChart chart = ChartFactory.createTimeSeriesChart(
//            "Sensors",
//            "Time", "Erlang",
//            dataset,
//            false, //t
//            true, //t
//            false //f
//        );
//
//        ChartUtilities.applyCurrentTheme(chart);
//        
//        //chart.setBackgroundPaint(Color.white);
//
////        final StandardLegend sl = (StandardLegend) chart.getLegend();
////        sl.setDisplaySeriesShapes(true);
//
//        final XYPlot plot = chart.getXYPlot();
//        plot.setBackgroundPaint(Color.WHITE);
//        plot.setDomainGridlinePaint(Color.white);
//        plot.setRangeGridlinePaint(Color.white);
////        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
//        plot.setDomainCrosshairVisible(true);
//        plot.setRangeCrosshairVisible(true);
//        
//        final XYItemRenderer renderer = plot.getRenderer();
//        
//        if (renderer instanceof StandardXYItemRenderer) 
//        {
//            final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
//            //rr.setPlotShapes(true);
//            rr.setShapesFilled(true);
//            rr.setItemLabelsVisible(true);
//        }
//
//        int temp_count = 0;
//        
//        //for (int i = 0; i < clusters.size(); i++)
//        for (int i = 0; (i < 11) && (i < clusters.size()); i++)
//      {
//         Cluster_DBScan current_cluster = clusters.get(i);   
//         ArrayList<Day_24d> member_time_series = current_cluster.getMembership();
//         
//         for (int j = 0; j < member_time_series.size(); j++)
//         {
//            renderer.setSeriesPaint(j+temp_count, getColor(i));
//         }
//         temp_count = temp_count + member_time_series.size();
//      }
//        
//        final DateAxis axis = (DateAxis) plot.getDomainAxis();    
//        axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));
//        
//        final ValueAxis axis_y = plot.getRangeAxis();
//        axis_y.setRange(0, 100);
//        
//        return chart;
//
//    }

private JFreeChart createChart(final XYDataset dataset, final XYDataset dataset_centroids,
        ArrayList<Cluster_KMeans> clusters) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Sensors", "Time", "Erlang", dataset, false, //t
            true, //t
            false //f
    );

    ChartUtilities.applyCurrentTheme(chart);

    //chart.setBackgroundPaint(Color.white);

    //        final StandardLegend sl = (StandardLegend) chart.getLegend();
    //        sl.setDisplaySeriesShapes(true);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final XYItemRenderer renderer = plot.getRenderer();

    if (renderer instanceof StandardXYItemRenderer) {
        final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
        //rr.setPlotShapes(true);
        rr.setShapesFilled(true);
        rr.setItemLabelsVisible(true);
    }

    int temp_count = 0;

    //for (int i = 0; i < clusters.size(); i++)
    for (int i = 0; (i < 11) && (i < clusters.size()); i++) {
        Cluster_KMeans current_cluster = clusters.get(i);
        ArrayList<Day_24d> member_time_series = current_cluster.getMembership();

        for (int j = 0; j < member_time_series.size(); j++) {
            renderer.setSeriesPaint(j + temp_count, getColor(i));
        }
        temp_count = temp_count + member_time_series.size();
    }

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("HH:mm"));

    //final ValueAxis axis_y = plot.getRangeAxis();
    //axis_y.setRange(0, 20);

    plot.setDataset(1, dataset_centroids);
    plot.setRenderer(1, new StandardXYItemRenderer());

    for (int i = 0; (i < clusters.size()); i++) {
        //plot.getRenderer(1).setSeriesPaint(i, getColor(i));
        plot.getRenderer(1).setSeriesPaint(i, Color.BLACK);
        plot.getRenderer(1).setSeriesStroke(i, new BasicStroke(3.0f, BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f));
    }

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    return chart;
}

From source file:com.chart.SwingChart.java

/**
 * /*from  www  .  java2s  . c o  m*/
 * @param axis Axis name to wich the new series belongs
 * @param cs Series Coinfiguration
 */
@Override
public final void addSeries(String axis, SimpleSeriesConfiguration cs) {
    for (int i = 0; i < axes.size(); i++) {
        if (axes.get(i).getName().equals(axis)) {
            String strColor;
            javafx.scene.paint.Color color;
            int indice = seriesList.size();
            if (cs.getColor() == null) {
                color = getColor(indice);
            } else {
                color = cs.getColor();
            }
            strColor = color.toString();

            XYSeriesCollection dataset = datasetList.get(i);
            Series series = new Series(cs.getName(), "color: " + strColor + ";width: "
                    + String.valueOf(cs.getLineWidth()) + ";shape: " + cs.getShapeName() + ";", i,
                    dataset.getSeriesCount());
            dataset.addSeries(series);

            XYItemRenderer renderer = plot.getRenderer(i);
            renderer.setSeriesPaint(dataset.getSeriesCount() - 1, scene2awtColor(color));

            SeriesShape simb = new SeriesShape(cs.getShapeName(),
                    javafx.scene.paint.Color.web(strColor.replace("#", "0x")));

            if (cs.getLineWidth() > 0) {
                ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(dataset.getSeriesCount() - 1, true);
                renderer.setSeriesStroke(dataset.getSeriesCount() - 1, new BasicStroke(cs.getLineWidth()));
            } else {
                ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(dataset.getSeriesCount() - 1, false);
            }

            if (cs.getShapeName().equals("null")) {
                renderer.setSeriesShape(dataset.getSeriesCount() - 1, null);
                ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(dataset.getSeriesCount() - 1, false);
            } else {
                renderer.setSeriesShape(dataset.getSeriesCount() - 1, simb.getShapeAWT());
                ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(dataset.getSeriesCount() - 1, true);
                if (cs.getShapeName().contains("empty")) {
                    ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(dataset.getSeriesCount() - 1,
                            false);
                } else {
                    ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(dataset.getSeriesCount() - 1,
                            true);
                }
            }

            if (i == 0) {
                plot.setRenderer(renderer);
            } else {
                plot.setRenderer(i, renderer);
            }

            seriesList.add(series);

            final LegendAxis le = getLegendAxis(axis);
            final Label label = new Label(cs.toString());
            Platform.runLater(() -> {
                label.setStyle("fondo: " + strChartBackgroundColor
                        + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: "
                        + String.valueOf(fontSize) + "px");
            });

            label.setOnMouseClicked((MouseEvent t) -> {
                if (t.getClickCount() == 2) {
                    for (int i1 = 0; i1 < seriesList.size(); i1++) {
                        if (seriesList.get(i1).getKey().toString().equals(label.getText())) {
                            editSeries(seriesList.get(i1));
                            break;
                        }
                    }
                }
            });
            label.setOnMouseExited((MouseEvent t) -> {
                label.setStyle(
                        label.getStyle().replace("-fx-background-color: blue", "-fx-background-color: fondo"));
            });
            label.setOnMouseEntered((MouseEvent t) -> {
                label.setStyle(
                        label.getStyle().replace("-fx-background-color: fondo", "-fx-background-color: blue"));
                for (Node le1 : legendFrame.getChildren()) {
                    if (le1 instanceof LegendAxis) {
                        le1.setStyle("-fx-background-color:" + strBackgroundColor);
                        ((LegendAxis) le1).selected = false;
                    }
                }
            });
            label.setStyle("fondo: " + strChartBackgroundColor
                    + ";-fx-text-fill: white;-fx-background-color: fondo;-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: "
                    + String.valueOf(fontSize) + "px");

            le.getChildren().add(label);
            label.setGraphic(simb.getShapeGraphic());

            break;
        }
    }
}

From source file:windows.sensorWindow.java

/**
 * creates all relevant data and adds it into the corresponding maps
 * //from w ww  .  j  a  va  2  s. co m
 * @param UID
 *            UID of the plotting sensor
 */
@SuppressWarnings("deprecation")
public static void addPlot(Brick newBrick) {
    // create series
    TimeSeries newSeries = new TimeSeries("" + 0, Millisecond.class);
    TimeSeries newSeries2 = new TimeSeries("" + 0, Millisecond.class);
    TimeSeries newSeries3 = new TimeSeries("" + 0, Millisecond.class);
    TimeSeries newSeries4 = new TimeSeries("" + 0, Millisecond.class);
    TimeSeries newSeries5 = new TimeSeries("" + 0, Millisecond.class);
    TimeSeries newSeries6 = new TimeSeries("" + 0, Millisecond.class);

    Measurement m1 = new Measurement(maxValues, maxCycles, newBrick.uid, 0);
    valuesMap.put(newBrick.uid, m1);
    if (newBrick.checked3 == true) {
        Measurement m2 = new Measurement(maxValues, maxCycles, newBrick.uid, 1);
        values2Map.put(newBrick.uid, m2);
    }

    // create entry in state map
    plot1StateMap.put(newBrick.uid, 0);
    plot2StateMap.put(newBrick.uid, 0);

    // create index map entry
    tmplindex.put(newBrick.uid, 0);

    // create avrgCtrlEnabled maps
    if (newBrick.controlAverage == true)
        avrgCtrl1Enabled.put(newBrick.uid, true);
    else
        avrgCtrl1Enabled.put(newBrick.uid, false);
    if (newBrick.controlAverage2 == true)
        avrgCtrl2Enabled.put(newBrick.uid, true);
    else
        avrgCtrl2Enabled.put(newBrick.uid, false);

    // create series map entry
    seriesMap.put(newBrick.uid, newSeries);
    seriesMap2.put(newBrick.uid, newSeries2);
    seriesMap3.put(newBrick.uid, newSeries3);
    seriesMap4.put(newBrick.uid, newSeries4);
    seriesMap5.put(newBrick.uid, newSeries3);
    seriesMap6.put(newBrick.uid, newSeries4);

    // create collection map entry
    seriesCollectionMap.put(newBrick.uid, new TimeSeriesCollection(newSeries));
    seriesCollectionMap2.put(newBrick.uid, new TimeSeriesCollection(newSeries2));
    tmplCollection1_1.put(newBrick.uid, new TimeSeriesCollection(newSeries3));
    tmplCollection1_2.put(newBrick.uid, new TimeSeriesCollection(newSeries4));
    tmplCollection2_1.put(newBrick.uid, new TimeSeriesCollection(newSeries5));
    tmplCollection2_2.put(newBrick.uid, new TimeSeriesCollection(newSeries6));

    // create plot map entry, special case for current/voltage brick, since
    // it has 2 parallel measurements and therefore 2 graphs must be treated
    XYPlot tmpSubPlot;
    tmpSubPlot = new XYPlot(seriesCollectionMap.get(newBrick.uid), null, null, new StandardXYItemRenderer());

    // create the 1st graph
    if (newBrick.checked2 == true) {
        // create plot map entry
        NumberAxis rangeAxis = new NumberAxis(
                String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)));
        rangeAxis.setAutoRangeIncludesZero(true);
        tmpSubPlot.setRangeAxis(0, rangeAxis);
        rangeAxis.setLabelPaint(Color.BLUE);
        rangeAxis.setVisible(newBrick.checked2);
        tmpSubPlot.setDataset(0, seriesCollectionMap.get(newBrick.uid));

        // set dot - shape
        // Shape cross = ShapeUtilities.createDiagonalCross(3, 1);

        // create and store renderer
        XYItemRenderer renderer1 = new XYLineAndShapeRenderer();
        renderer1 = tmpSubPlot.getRenderer();
        renderer1.setSeriesPaint(0, Color.BLUE);
        renderer1.setSeriesStroke(0, new BasicStroke(3));
        // line = dashes:
        // float dash[] = {5.0f};
        // renderer1.setSeriesStroke( 0, new
        // BasicStroke(3,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,
        // 10.0f, dash, 0.0f));
        // renderer1.setSeriesShape(0, cross);
        tmpSubPlot.setRenderer(0, renderer1);

        // set colors
        tmpSubPlot.setBackgroundPaint(Color.white);
        tmpSubPlot.setDomainGridlinePaint(Color.lightGray);
        tmpSubPlot.setRangeGridlinePaint(Color.lightGray);
        // tmpSubPlot.setRenderer(renderer2);

        // set font
        rangeAxis.setLabelFont(customFonts.get("axisLabelFont"));
        rangeAxis.setTickLabelFont(customFonts.get("axisValueFont"));

        // create template graph
        // if (newBrick.ctrlTmpl[0] == true)
        // {
        tmpSubPlot.setDataset(2, tmplCollection1_1.get(newBrick.uid));

        XYItemRenderer renderer3 = new XYLineAndShapeRenderer();
        int width = computeTmplPlotWidth(newBrick.tmpl1Width);
        BasicStroke stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);// , 10.0f, dash, 0.0f);
        renderer3.setSeriesPaint(0, Color.GREEN);
        // renderer3.setSeriesStroke( 0, new BasicStroke( 1 ) );
        renderer3.setSeriesStroke(0, stroke);
        renderer3.setSeriesVisible(0, newBrick.ctrlTmpl[0]);
        rendererMap3.put(newBrick.uid, renderer3);
        tmpSubPlot.setRenderer(2, rendererMap3.get(newBrick.uid));
        // }

        // put everything to the maps
        rendererMap.put(newBrick.uid, renderer1);
        plotMap.put(newBrick.uid, tmpSubPlot);
        axisMap.put(newBrick.uid, rangeAxis);
    }

    // create the 2nd graph
    if (newBrick.checked3 == true) {
        // set second axis for voltage/ampere brick
        NumberAxis secondaryAxis = new NumberAxis(
                String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)));
        secondaryAxis.setAutoRangeIncludesZero(true);
        tmpSubPlot.setRangeAxis(1, secondaryAxis);
        secondaryAxis.setLabelPaint(Color.RED);
        secondaryAxis.setVisible(newBrick.checked3);
        tmpSubPlot.setDataset(1, seriesCollectionMap2.get(newBrick.uid));
        tmpSubPlot.mapDatasetToRangeAxis(1, 1);

        // set font
        secondaryAxis.setLabelFont(customFonts.get("axisLabelFont"));
        secondaryAxis.setTickLabelFont(customFonts.get("axisValueFont"));

        // create and store renderer
        XYItemRenderer renderer2 = new StandardXYItemRenderer();
        // renderer2 = tmpSubPlot.getRenderer();
        renderer2.setSeriesPaint(1, Color.RED);
        renderer2.setSeriesStroke(0, new BasicStroke(3));
        tmpSubPlot.setRenderer(1, renderer2);

        // set colors
        tmpSubPlot.setBackgroundPaint(Color.white);
        tmpSubPlot.setDomainGridlinePaint(Color.lightGray);
        tmpSubPlot.setRangeGridlinePaint(Color.lightGray);

        // ----------------------------------------------------------------------------------
        // create min1 critical map value
        ValueMarker vm5 = new ValueMarker(newBrick.tresholdMin2);
        markerMapMin2Critical.put(newBrick.uid, vm5);
        // set critical line
        markerMapMin2Critical.get(newBrick.uid).setPaint(Color.red);
        markerMapMin2Critical.get(newBrick.uid).setLabel(
                String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " critical min");
        markerMapMin2Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        markerMapMin2Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        tmpSubPlot.addRangeMarker(1, markerMapMin2Critical.get(newBrick.uid), Layer.BACKGROUND);

        // create min1 warning map value
        ValueMarker vm6 = new ValueMarker(
                newBrick.tresholdMin2 + newBrick.tresholdMin2 * warningPercentage / 100);
        markerMapMin2Warning.put(newBrick.uid, vm6);
        // set warning line
        markerMapMin2Warning.get(newBrick.uid).setPaint(Color.orange);
        markerMapMin2Warning.get(newBrick.uid).setLabel(
                String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " warning min");
        markerMapMin2Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        markerMapMin2Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        // tmpSubPlot.addRangeMarker(markerMapMin2Warning.get(newBrick.uid));
        tmpSubPlot.addRangeMarker(1, markerMapMin2Warning.get(newBrick.uid), Layer.BACKGROUND);

        // create max1 critical map value
        ValueMarker vm7 = new ValueMarker(newBrick.tresholdMax2);
        markerMapMax2Critical.put(newBrick.uid, vm7);
        // set critical line
        markerMapMax2Critical.get(newBrick.uid).setPaint(Color.red);
        markerMapMax2Critical.get(newBrick.uid).setLabel(
                String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " critical max");
        markerMapMax2Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        markerMapMax2Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        tmpSubPlot.addRangeMarker(1, markerMapMax2Critical.get(newBrick.uid), Layer.BACKGROUND);

        // create max1 warning map value
        ValueMarker vm8 = new ValueMarker(
                newBrick.tresholdMax2 + newBrick.tresholdMax2 * warningPercentage / 100);
        markerMapMax2Warning.put(newBrick.uid, vm8);
        // set warning line
        markerMapMax2Warning.get(newBrick.uid).setPaint(Color.orange);
        markerMapMax2Warning.get(newBrick.uid).setLabel(
                String.valueOf(constants.brick2ndUnitMap.get(newBrick.deviceIdentifier)) + " warning max");
        markerMapMax2Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        markerMapMax2Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        tmpSubPlot.addRangeMarker(1, markerMapMax2Warning.get(newBrick.uid), Layer.BACKGROUND);

        // create and add min, max and average markers
        // create maxima marker
        ValueMarker vmMax = new ValueMarker(0);
        vmMax.setPaint(Color.orange);
        vmMax.setLabel("max");
        vmMax.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        vmMax.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        // create minima marker
        ValueMarker vmMin = new ValueMarker(0);
        vmMin.setPaint(Color.orange);
        vmMin.setLabel("min");
        vmMin.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        vmMin.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        // create average marker
        ValueMarker vmAvg = new ValueMarker(0);
        vmAvg.setPaint(Color.red);
        vmAvg.setLabel("average");
        vmAvg.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        vmAvg.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        // add to maps
        marker2Maxima.put(newBrick.uid, vmMax);
        marker2Minima.put(newBrick.uid, vmMin);
        marker2Average.put(newBrick.uid, vmAvg);
        // add to plot
        tmpSubPlot.addRangeMarker(1, vmMax, Layer.BACKGROUND);
        tmpSubPlot.addRangeMarker(1, vmMin, Layer.BACKGROUND);
        tmpSubPlot.addRangeMarker(1, vmAvg, Layer.BACKGROUND);

        // create and add avrgCntrMarkers
        // create upper marker
        ValueMarker avrgCtrl2high = new ValueMarker(newBrick.getAvg2high());
        avrgCtrl2high.setPaint(Color.orange);
        avrgCtrl2high.setLabel("avrg high");
        avrgCtrl2high.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        avrgCtrl2high.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        // create lower marker
        ValueMarker avrgCtrl2low = new ValueMarker(newBrick.getAvg2low());
        avrgCtrl2low.setPaint(Color.orange);
        avrgCtrl2low.setLabel("avrg low");
        avrgCtrl2low.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
        avrgCtrl2low.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        // add both markers
        avrg2High.put(newBrick.uid, avrgCtrl2high);
        avrg2Low.put(newBrick.uid, avrgCtrl2low);
        // add both to plot
        if (newBrick.controlAverage2) {
            tmpSubPlot.addRangeMarker(1, avrgCtrl2high, Layer.BACKGROUND);
            tmpSubPlot.addRangeMarker(1, avrgCtrl2low, Layer.BACKGROUND);
        }
        // ----------------------------------------------------------------------------------

        // put everything to the map
        rendererMap2.put(newBrick.uid, renderer2);
        plotMap.put(newBrick.uid, tmpSubPlot);
        axisMap2.put(newBrick.uid, secondaryAxis);
    }

    // 1st graph
    // markers--------------------------------------------------------------------------------------------------
    // create min1 critical map value
    ValueMarker vm1 = new ValueMarker(newBrick.tresholdMin1);
    markerMapMin1Critical.put(newBrick.uid, vm1);
    // set critical line
    markerMapMin1Critical.get(newBrick.uid).setPaint(Color.red);
    // / .setLabel("critical");
    // markerMapMin1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.BOTTOM);
    markerMapMin1Critical.get(newBrick.uid)
            .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " critical min");
    markerMapMin1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT);
    markerMapMin1Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT);
    plotMap.get(newBrick.uid).addRangeMarker(markerMapMin1Critical.get(newBrick.uid));

    // create min1 warning map value
    ValueMarker vm2 = new ValueMarker(newBrick.tresholdMin1 + newBrick.tresholdMin1 * warningPercentage / 100);
    markerMapMin1Warning.put(newBrick.uid, vm2);
    // set warning line
    markerMapMin1Warning.get(newBrick.uid).setPaint(Color.orange);
    // marker2Map.get(newBrick.uid).setPaint(Color.);
    // / marker2Map.get(newBrick.uid).setLabel("warning");
    markerMapMin1Warning.get(newBrick.uid)
            .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " warning min");
    markerMapMin1Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT);
    markerMapMin1Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT);
    plotMap.get(newBrick.uid).addRangeMarker(markerMapMin1Warning.get(newBrick.uid));

    // create max1 critical map value
    ValueMarker vm3 = new ValueMarker(newBrick.tresholdMax1);
    markerMapMax1Critical.put(newBrick.uid, vm3);
    // set critical line
    markerMapMax1Critical.get(newBrick.uid).setPaint(Color.red);
    // / .setLabel("critical");
    // markerMapMax1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.BOTTOM);
    markerMapMax1Critical.get(newBrick.uid)
            .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " critical max");
    markerMapMax1Critical.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT);
    markerMapMax1Critical.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT);
    plotMap.get(newBrick.uid).addRangeMarker(markerMapMax1Critical.get(newBrick.uid));

    // create max1 warning map value
    ValueMarker vm4 = new ValueMarker(newBrick.tresholdMax1 + newBrick.tresholdMax1 * warningPercentage / 100);
    markerMapMax1Warning.put(newBrick.uid, vm4);
    // set warning line
    markerMapMax1Warning.get(newBrick.uid).setPaint(Color.orange);
    markerMapMax1Warning.get(newBrick.uid)
            .setLabel(String.valueOf(constants.brickUnitMap.get(newBrick.deviceIdentifier)) + " warning max");
    markerMapMax1Warning.get(newBrick.uid).setLabelAnchor(RectangleAnchor.TOP_LEFT);
    markerMapMax1Warning.get(newBrick.uid).setLabelTextAnchor(TextAnchor.TOP_LEFT);
    plotMap.get(newBrick.uid).addRangeMarker(markerMapMax1Warning.get(newBrick.uid));

    // create and add min, max and average markers
    // create maxima marker
    ValueMarker vmMax = new ValueMarker(0);
    vmMax.setPaint(Color.cyan);
    vmMax.setLabel("max");
    vmMax.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    vmMax.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    // create minima marker
    ValueMarker vmMin = new ValueMarker(0);
    vmMin.setPaint(Color.cyan);
    vmMin.setLabel("min");
    vmMin.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    vmMin.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    // create average marker
    ValueMarker vmAvg = new ValueMarker(0);
    vmAvg.setPaint(Color.blue);
    vmAvg.setLabel("average");
    vmAvg.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    vmAvg.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    // add to maps
    markerMaxima.put(newBrick.uid, vmMax);
    markerMinima.put(newBrick.uid, vmMin);
    markerAverage.put(newBrick.uid, vmAvg);
    // add to plot
    plotMap.get(newBrick.uid).addRangeMarker(vmMax);
    plotMap.get(newBrick.uid).addRangeMarker(vmMin);
    plotMap.get(newBrick.uid).addRangeMarker(vmAvg);

    // create and add avrgCntrMarkers
    // create upper marker
    ValueMarker avrgCtrl1high = new ValueMarker(newBrick.getAvg1high());
    avrgCtrl1high.setPaint(Color.orange);
    avrgCtrl1high.setLabel("avrg high");
    avrgCtrl1high.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    avrgCtrl1high.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    // create lower marker
    ValueMarker avrgCtrl1low = new ValueMarker(newBrick.getAvg1low());
    avrgCtrl1low.setPaint(Color.orange);
    avrgCtrl1low.setLabel("avrg low");
    avrgCtrl1low.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    avrgCtrl1low.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    // add both markers
    avrg1High.put(newBrick.uid, avrgCtrl1high);
    avrg1Low.put(newBrick.uid, avrgCtrl1low);
    // add both to plot
    if (newBrick.controlAverage) {
        plotMap.get(newBrick.uid).addRangeMarker(avrgCtrl1high);
        plotMap.get(newBrick.uid).addRangeMarker(avrgCtrl1low);
    }
    // -----------------------------------------------------------------------------------------------------

    // set title
    NumberAxis axisForTitleOnly = new NumberAxis(
            data.constants.brickIdMap.get(newBrick.deviceIdentifier) + " (" + newBrick.uid + ")");
    axisForTitleOnly.setLabelFont(customFonts.get("titleFont"));
    axisForTitleOnly.setTickLabelsVisible(false);
    axisForTitleOnly.setTickMarksVisible(false);
    axisForTitleOnly.setMinorTickMarksVisible(false);
    axisForTitleOnly.setAxisLineVisible(false);
    plotMap.get(newBrick.uid).setDomainAxis(1, axisForTitleOnly);

    // add subplot to the main plot
    plot.add(plotMap.get(newBrick.uid));
}

From source file:org.moeaframework.analysis.plot.Plot.java

/**
 * Modifies the paint (e.g,. color) of each series in the last dataset.
 * If the dataset contains more series than the number of arguments, the
 * arguments are reused as needed.//  w ww.j  av  a  2  s  . c o  m
 * 
 * @param paint one or more paint instances
 * @return a reference to this {@code Plot} instance
 */
public Plot withPaint(Paint... paint) {
    if (chart.getPlot() instanceof XYPlot) {
        XYPlot plot = chart.getXYPlot();
        XYDataset dataset = plot.getDataset(currentDataset);
        XYItemRenderer renderer = plot.getRenderer(currentDataset);

        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            Paint p = paint[i % paint.length];

            paintHelper.set(dataset.getSeriesKey(i), p);
            renderer.setSeriesPaint(i, p);

            if (renderer instanceof XYLineAndShapeRenderer) {
                ((XYLineAndShapeRenderer) renderer).setSeriesFillPaint(i, p);
            }
        }
    } else if (chart.getPlot() instanceof CategoryPlot) {
        CategoryPlot plot = chart.getCategoryPlot();
        CategoryDataset dataset = plot.getDataset();
        CategoryItemRenderer renderer = plot.getRenderer();

        for (int i = 0; i < dataset.getRowCount(); i++) {
            Paint p = paint[i % paint.length];

            paintHelper.set(dataset.getRowKey(i), p);
            renderer.setSeriesPaint(i, p);
        }
    }

    return this;
}