Example usage for org.jfree.chart.plot XYPlot setRenderer

List of usage examples for org.jfree.chart.plot XYPlot setRenderer

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setRenderer.

Prototype

public void setRenderer(XYItemRenderer renderer) 

Source Link

Document

Sets the renderer for the primary dataset and sends a change event to all registered listeners.

Usage

From source file:com.kodemore.freechart.KmSimpleLineChart.java

private JFreeChart createChart(XYDataset dataset) {
    PlotOrientation orientation = PlotOrientation.VERTICAL;

    boolean showsTooltips = false;
    boolean showsUrls = false;

    JFreeChart chart = ChartFactory.createXYLineChart(getTitle(), getAxisTitleX(), getAxisTitleY(), dataset,
            orientation, getShowsLegend(), showsTooltips, showsUrls);

    if (hasBackgroundColor())
        chart.setBackgroundPaint(getBackgroundColor());

    XYPlot plot;
    plot = chart.getXYPlot();//from www . j av  a 2 s. co m

    if (hasPlotBackgroundColor())
        plot.setBackgroundPaint(getPlotBackgroundColor());

    if (hasPlotGridLineColor()) {
        Color color = getPlotGridLineColor();
        plot.setDomainGridlinePaint(color);
        plot.setRangeGridlinePaint(color);
    }

    XYLineAndShapeRenderer renderer;
    renderer = new XYLineAndShapeRenderer();

    KmList<KmSimpleLineChartGroup> groups = getGroups();
    int n = groups.size();
    for (int i = 0; i < n; i++) {
        KmSimpleLineChartGroup group = groups.getAt(i);

        renderer.setSeriesLinesVisible(i, group.getShowsLines());
        renderer.setSeriesShapesVisible(i, group.getShowsShapes());
    }

    plot.setRenderer(renderer);

    if (getIntegerUnitsX()) {
        NumberAxis rangeAxis;
        rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    if (getIntegerUnitsY()) {
        NumberAxis rangeAxis;
        rangeAxis = (NumberAxis) plot.getDomainAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    return chart;
}

From source file:org.tolven.web.ChartAction.java

/**
 * Create Growth Chart/*  w  ww  . ja v a 2 s.  c o  m*/
 * 
 * @author Suja
 * added on 02/01/2011
 * @param type - 1: Height & 2: Weight
 * @return
 */
public JFreeChart createChart(int type) {
    long patientId = Long.parseLong(getRequestParameter("element").toString().split(":")[1].split("-")[1]);
    MenuData patMD = getMenuLocal().findMenuDataItem(patientId);
    int age = 0;
    int gender = 1;
    Date dob = null;
    if (patMD != null) {
        DateFormat df = new SimpleDateFormat("yyyy");
        dob = patMD.getDate01();
        Date cur = new Date();
        age = Integer.parseInt(df.format(cur)) - Integer.parseInt(df.format(dob));
        if (patMD.getString04().equals("Male"))
            gender = 1;
        else
            gender = 2;
    }

    // create dataset
    XYDataset dataset = createDataset(type, gender, age, dob);
    String title = "";
    if (type == 1 && age < 3)
        title = "Height birth to 36 Months Old " + (gender == 1 ? "Male" : "Female");
    else if (type == 1 && age >= 3)
        title = "Height 2-20 Year Old " + (gender == 1 ? "Male" : "Female");
    else if (type == 2 && age < 3)
        title = "Weight birth to 36 Months Old " + (gender == 1 ? "Male" : "Female");
    else if (type == 2 && age >= 3)
        title = "Weight 2-20 Year Old " + (gender == 1 ? "Male" : "Female");
    JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title
            "X-Value", // x-axis label
            "Y-Value", // y-axis label
            dataset, // data
            true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.lightGray);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    for (int i = 1; i < 10; i++) {
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesShapesVisible(i, false);
    }
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    plot.setRenderer(renderer);

    plot.setDomainAxis(new NumberAxis("Age (Months)"));
    plot.setRangeAxis(new NumberAxis((type == 1 ? "Height (Centimeters)" : "Weight (Kilograms)")));
    return chart;
}

From source file:org.gephi.statistics.plugin.DegreeDistribution.java

/**
 *
 * @return The directed version of the report.
 *//*from w  w  w.  j  a  v a 2 s .co m*/
private String getDirectedReport() {
    double inMax = 0;
    XYSeries inSeries2 = new XYSeries("Series 2");
    for (int i = 1; i < inDistribution[1].length; i++) {
        if (inDistribution[1][i] > 0) {
            inSeries2.add((Math.log(inDistribution[0][i]) / Math.log(Math.E)),
                    (Math.log(inDistribution[1][i]) / Math.log(Math.E)));
            inMax = (float) Math.max((Math.log(inDistribution[0][i]) / Math.log(Math.E)), inMax);
        }
    }
    double inA = inAlpha;
    double inB = inBeta;

    String inImageFile = "";
    String outImageFile = "";
    try {

        XYSeries inSeries1 = new XYSeries(inAlpha + " ");
        inSeries1.add(0, inA);
        inSeries1.add(inMax, inA + inB * inMax);

        XYSeriesCollection inDataset = new XYSeriesCollection();
        inDataset.addSeries(inSeries1);
        inDataset.addSeries(inSeries2);

        JFreeChart inChart = ChartFactory.createXYLineChart("In-Degree Distribution", "In-Degree", "Occurrence",
                inDataset, PlotOrientation.VERTICAL, true, false, false);
        XYPlot inPlot = (XYPlot) inChart.getPlot();
        XYLineAndShapeRenderer inRenderer = new XYLineAndShapeRenderer();
        inRenderer.setSeriesLinesVisible(0, true);
        inRenderer.setSeriesShapesVisible(0, false);
        inRenderer.setSeriesLinesVisible(1, false);
        inRenderer.setSeriesShapesVisible(1, true);
        inRenderer.setSeriesShape(1, new java.awt.geom.Ellipse2D.Double(0, 0, 1, 1));
        inPlot.setBackgroundPaint(java.awt.Color.WHITE);
        inPlot.setDomainGridlinePaint(java.awt.Color.GRAY);
        inPlot.setRangeGridlinePaint(java.awt.Color.GRAY);

        inPlot.setRenderer(inRenderer);

        final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());

        TempDir tempDir = TempDirUtils.createTempDir();
        final String fileName = "inDistribution.png";
        final File file1 = tempDir.createFile(fileName);
        inImageFile = "<IMG SRC=\"file:" + file1.getAbsolutePath() + "\" "
                + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\"></IMG>";
        ChartUtilities.saveChartAsPNG(file1, inChart, 600, 400, info);

        double outMax = 0;
        XYSeries outSeries2 = new XYSeries("Series 2");
        for (int i = 1; i < outDistribution[1].length; i++) {
            if (outDistribution[1][i] > 0) {
                outSeries2.add((Math.log(outDistribution[0][i]) / Math.log(Math.E)),
                        (Math.log(outDistribution[1][i]) / Math.log(Math.E)));
                outMax = (float) Math.max((Math.log(outDistribution[0][i]) / Math.log(Math.E)), outMax);
            }
        }
        double outA = outAlpha;
        double outB = outBeta;

        XYSeries outSeries1 = new XYSeries(outAlpha + " ");
        outSeries1.add(0, outA);
        outSeries1.add(outMax, outA + outB * outMax);

        XYSeriesCollection outDataset = new XYSeriesCollection();
        outDataset.addSeries(outSeries1);
        outDataset.addSeries(outSeries2);

        JFreeChart outchart = ChartFactory.createXYLineChart("Out-Degree Distribution", "Out-Degree",
                "Occurrence", outDataset, PlotOrientation.VERTICAL, true, false, false);
        XYPlot outPlot = (XYPlot) outchart.getPlot();
        XYLineAndShapeRenderer outRenderer = new XYLineAndShapeRenderer();
        outRenderer.setSeriesLinesVisible(0, true);
        outRenderer.setSeriesShapesVisible(0, false);
        outRenderer.setSeriesLinesVisible(1, false);
        outRenderer.setSeriesShapesVisible(1, true);
        outRenderer.setSeriesShape(1, new java.awt.geom.Ellipse2D.Double(0, 0, 1, 1));
        outPlot.setBackgroundPaint(java.awt.Color.WHITE);
        outPlot.setDomainGridlinePaint(java.awt.Color.GRAY);
        outPlot.setRangeGridlinePaint(java.awt.Color.GRAY);

        outPlot.setRenderer(outRenderer);

        final ChartRenderingInfo info2 = new ChartRenderingInfo(new StandardEntityCollection());
        final String fileName2 = "outDistribution.png";
        final File file2 = tempDir.createFile(fileName2);
        outImageFile = "<IMG SRC=\"file:" + file2.getAbsolutePath() + "\" "
                + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\"></IMG>";
        ChartUtilities.saveChartAsPNG(file2, outchart, 600, 400, info2);
    } catch (IOException e) {
        Exceptions.printStackTrace(e);
    }

    String report = "<HTML> <BODY> <h1>Degree Distribution Metric Report </h1> " + "<hr>" + "<br>"
            + "<h2> Parameters: </h2>" + "Network Interpretation:  " + (isDirected ? "directed" : "undirected")
            + "<br>" + "<br> <h2> Results: </h2>" + "In-Degree Power Law: -" + inAlpha + "\n <BR>" + inImageFile
            + "<br>Out-Degree Power Law: -" + outAlpha + "\n <BR>" + outImageFile + "</BODY> </HTML>";

    return report;
}

From source file:com.itemanalysis.jmetrik.swing.GraphPanel.java

/**
 * This method should be called after a chart dataset is updated. It
 * will iterate over all XYDatasets and provide the line color and lineStyle.
 * If it is called before a chart has a dataset, it will not have an effect.
 *
 * @param plot/*from  w w w.j a va2s  . c o  m*/
 */
public void setXYPlotRenderer(XYPlot plot) {
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    int n = plot.getSeriesCount();

    for (int i = 0; i < n; i++) {
        Stroke stroke = new BasicStroke(lineWidth, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f,
                getLineStyle(i), 0.0f);
        renderer.setSeriesStroke(i, stroke);
        renderer.setSeriesPaint(i, getPaintColor(i));
    }
    renderer.setLegendLine(new Line2D.Double(0, 5, 40, 5));
    renderer.setBaseShapesFilled(false);
    renderer.setBaseShapesVisible(showMarkers);
    renderer.setDrawSeriesLineAsPath(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRenderer(renderer);
}

From source file:org.nbheaven.sqe.codedefects.history.controlcenter.panels.SQEHistoryPanel.java

/** Creates new form SQEHistoryPanel */
public SQEHistoryPanel() {
    historyChart = org.jfree.chart.ChartFactory.createStackedXYAreaChart(null, "Snapshot", "CodeDefects",
            perProjectDataSet, PlotOrientation.VERTICAL, false, true, false);
    historyChart.setBackgroundPaint(Color.WHITE);
    historyChart.getXYPlot().setRangeGridlinePaint(Color.BLACK);
    historyChart.getXYPlot().setDomainGridlinePaint(Color.BLACK);
    historyChart.getXYPlot().setBackgroundPaint(Color.WHITE);

    XYPlot plot = historyChart.getXYPlot();
    plot.setForegroundAlpha(0.7f);//from  ww w.ja v a  2s . c o  m
    //        plot.getRenderer();

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    LogarithmicAxis rangeAxis = new LogarithmicAxis("CodeDefects");
    rangeAxis.setStrictValuesFlag(false);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    plot.setRangeAxis(rangeAxis);

    StackedXYAreaRenderer2 categoryItemRenderer = new StackedXYAreaRenderer2(); //3D();
    categoryItemRenderer.setSeriesPaint(0, Color.RED);
    categoryItemRenderer.setSeriesPaint(1, Color.ORANGE);
    categoryItemRenderer.setSeriesPaint(2, Color.YELLOW);

    plot.setRenderer(categoryItemRenderer);

    ChartPanel historyChartPanel = new ChartPanel(historyChart);
    historyChartPanel.setBorder(null);
    historyChartPanel.setPreferredSize(new Dimension(150, 200));
    historyChartPanel.setBackground(Color.WHITE);
    initComponents();

    historyView.setLayout(new BorderLayout());
    historyView.add(historyChartPanel, BorderLayout.CENTER);

    JPanel selectorPanel = new JPanel();
    selectorPanel.setOpaque(false);

    GroupLayout layout = new GroupLayout(selectorPanel);
    selectorPanel.setLayout(layout);

    // Turn on automatically adding gaps between components
    layout.setAutocreateGaps(true);

    // Turn on automatically creating gaps between components that touch
    // the edge of the container and the container.
    layout.setAutocreateContainerGaps(true);

    ParallelGroup horizontalParallelGroup = layout.createParallelGroup(GroupLayout.LEADING);
    SequentialGroup verticalSequentialGroup = layout.createSequentialGroup();

    layout.setHorizontalGroup(layout.createSequentialGroup().add(horizontalParallelGroup));

    layout.setVerticalGroup(verticalSequentialGroup);

    clearHistoryButton = new JButton();
    clearHistoryButton.setEnabled(false);
    clearHistoryButton.setIcon(ImageUtilities
            .image2Icon(ImageUtilities.loadImage("org/nbheaven/sqe/codedefects/history/resources/trash.png")));
    clearHistoryButton.setOpaque(false);
    clearHistoryButton.setFocusPainted(false);
    clearHistoryButton.setToolTipText(
            NbBundle.getBundle("org/nbheaven/sqe/codedefects/history/controlcenter/panels/Bundle")
                    .getString("HINT_clear_button"));
    horizontalParallelGroup.add(clearHistoryButton);
    verticalSequentialGroup.add(clearHistoryButton);
    clearHistoryButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (null != activeHistory) {
                activeHistory.clear();
            }
        }

    });

    Component createVerticalStrut = Box.createVerticalStrut(10);

    horizontalParallelGroup.add(createVerticalStrut);
    verticalSequentialGroup.add(createVerticalStrut);

    for (final QualityProvider provider : SQEUtilities.getProviders()) {
        final JToggleButton providerButton = new JToggleButton();
        providerButton.setIcon(provider.getIcon());
        providerButton.setOpaque(false);
        providerButton.setFocusPainted(false);
        horizontalParallelGroup.add(providerButton);
        verticalSequentialGroup.add(providerButton);
        ActionListener listener = new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                if (providerButton.isSelected()) {
                    addSelectedProvider(provider);
                } else {
                    removeSelectedProvider(provider);
                }
                updateView();
            }
        };
        providerButton.addActionListener(listener);
        addSelectedProvider(provider);
        providerButton.setSelected(true);
    }

    historyView.add(selectorPanel, BorderLayout.EAST);
}

From source file:ispd.gui.auxiliar.Graficos.java

public void criarProcessamentoTempoUser(List<Tarefa> tarefas, RedeDeFilas rdf) {
    ArrayList<tempo_uso_usuario> lista = new ArrayList<tempo_uso_usuario>();
    int numberUsers = rdf.getUsuarios().size();
    Map<String, Integer> users = new HashMap<String, Integer>();
    XYSeries tmp_series[] = new XYSeries[numberUsers];
    XYSeries tmp_series1[] = new XYSeries[numberUsers];
    Double utilizacaoUser[] = new Double[numberUsers];
    Double utilizacaoUser1[] = new Double[numberUsers];
    XYSeriesCollection dadosGrafico = new XYSeriesCollection();
    XYSeriesCollection dadosGrafico1 = new XYSeriesCollection();
    for (int i = 0; i < numberUsers; i++) {
        users.put(rdf.getUsuarios().get(i), i);
        utilizacaoUser[i] = 0.0;//www.  j a  v  a  2 s .co  m
        tmp_series[i] = new XYSeries(rdf.getUsuarios().get(i));
        utilizacaoUser1[i] = 0.0;
        tmp_series1[i] = new XYSeries(rdf.getUsuarios().get(i));
    }
    if (!tarefas.isEmpty()) {
        //Insere cada tarefa como dois pontos na lista
        for (Tarefa task : tarefas) {
            CS_Processamento local = (CS_Processamento) task.getLocalProcessamento();
            if (local != null) {

                for (int i = 0; i < task.getTempoInicial().size(); i++) {
                    Double uso = (task.getHistoricoProcessamento().get(i).getPoderComputacional()
                            / poderComputacionalTotal) * 100;
                    tempo_uso_usuario provisorio1 = new tempo_uso_usuario(task.getTempoInicial().get(i), true,
                            uso, users.get(task.getProprietario()));
                    lista.add(provisorio1);
                    tempo_uso_usuario provisorio2 = new tempo_uso_usuario(task.getTempoFinal().get(i), false,
                            uso, users.get(task.getProprietario()));
                    lista.add(provisorio2);
                }
            }
        }
        //Ordena lista
        Collections.sort(lista);
    }
    for (int i = 0; i < lista.size(); i++) {
        tempo_uso_usuario temp = (tempo_uso_usuario) lista.get(i);
        int usuario = temp.get_user();
        //Altera os valores do usuario atual e todos acima dele
        for (int j = usuario; j < numberUsers; j++) {
            //Salva valores anteriores
            tmp_series[j].add(temp.get_tempo(), utilizacaoUser[j]);
            if (temp.get_tipo()) {
                utilizacaoUser[j] += temp.get_uso_no();
            } else {
                utilizacaoUser[j] -= temp.get_uso_no();
            }
            //Novo valor
            tmp_series[j].add(temp.get_tempo(), utilizacaoUser[j]);
        }
        //Grafico1
        tmp_series1[usuario].add(temp.get_tempo(), utilizacaoUser1[usuario]);
        if (temp.get_tipo()) {
            utilizacaoUser1[usuario] += temp.get_uso_no();
        } else {
            utilizacaoUser1[usuario] -= temp.get_uso_no();
        }
        tmp_series1[usuario].add(temp.get_tempo(), utilizacaoUser1[usuario]);
    }
    for (int i = 0; i < numberUsers; i++) {
        dadosGrafico.addSeries(tmp_series[i]);
        dadosGrafico1.addSeries(tmp_series1[i]);
    }
    JFreeChart user1 = ChartFactory.createXYAreaChart("Use of total computing power through time" + "\nUsers", //Titulo
            "Time (seconds)", // Eixo X
            "Rate of total use of resources  (%)", //Eixo Y
            dadosGrafico1, // Dados para o grafico
            PlotOrientation.VERTICAL, //Orientacao do grafico
            true, true, false); // exibir: legendas, tooltips, url

    JFreeChart user2 = ChartFactory.createXYLineChart("Use of total resources  through time" + "\nUsers", //Titulo
            "Time (seconds)", // Eixo X
            "Rate of total use of resources  (%)", //Eixo Y
            dadosGrafico, // Dados para o grafico
            PlotOrientation.VERTICAL, //Orientacao do grafico
            true, true, false); // exibir: legendas, tooltips, url
    XYPlot xyplot = (XYPlot) user2.getPlot();
    xyplot.setDomainPannable(true);
    XYStepAreaRenderer xysteparearenderer = new XYStepAreaRenderer(2);
    xysteparearenderer.setDataBoundsIncludesVisibleSeriesOnly(false);
    xysteparearenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    xysteparearenderer.setDefaultEntityRadius(6);
    xyplot.setRenderer(xysteparearenderer);

    UserThroughTimeChart1 = new ChartPanel(user1);
    UserThroughTimeChart1.setPreferredSize(new Dimension(600, 300));
    UserThroughTimeChart2 = new ChartPanel(user2);
    UserThroughTimeChart2.setPreferredSize(new Dimension(600, 300));
}

From source file:lu.lippmann.cdb.datasetview.tabs.ScatterPlotTabView.java

private static ChartPanel buildChartPanel(final Instances dataSet, final int xidx, final int yidx,
        final int coloridx, final boolean asSerie) {
    final XYSeriesCollection data = new XYSeriesCollection();
    final Map<Integer, List<Instance>> filteredInstances = new HashMap<Integer, List<Instance>>();
    final int classIndex = dataSet.classIndex();
    if (classIndex < 0) {
        final XYSeries series = new XYSeries("Serie", false);
        for (int i = 0; i < dataSet.numInstances(); i++) {
            series.add(dataSet.instance(i).value(xidx), dataSet.instance(i).value(yidx));

        }/*from w  w  w .  ja  v  a  2 s  . co  m*/
        data.addSeries(series);
    } else {
        final Set<String> pvs = WekaDataStatsUtil.getPresentValuesForNominalAttribute(dataSet, classIndex);
        int p = 0;
        for (final String pv : pvs) {
            final XYSeries series = new XYSeries(pv, false);
            for (int i = 0; i < dataSet.numInstances(); i++) {
                if (dataSet.instance(i).stringValue(classIndex).equals(pv)) {
                    if (!filteredInstances.containsKey(p)) {
                        filteredInstances.put(p, new ArrayList<Instance>());
                    }
                    filteredInstances.get(p).add(dataSet.instance(i));

                    series.add(dataSet.instance(i).value(xidx), dataSet.instance(i).value(yidx));
                }
            }
            data.addSeries(series);

            p++;
        }

    }

    final JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot", // chart title
            dataSet.attribute(xidx).name(), // x axis label
            dataSet.attribute(yidx).name(), // y axis label
            data, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    final XYPlot xyPlot = (XYPlot) chart.getPlot();
    final XYToolTipGenerator gen = new XYToolTipGenerator() {
        @Override
        public String generateToolTip(final XYDataset dataset, final int series, final int item) {
            if (classIndex < 0) {
                return InstanceFormatter.htmlFormat(dataSet.instance(item), true);
            } else {
                return InstanceFormatter.htmlFormat(filteredInstances.get(series).get(item), true);
            }
        }
    };

    int nbSeries;
    if (classIndex < 0) {
        nbSeries = 1;
    } else {
        nbSeries = filteredInstances.keySet().size();
    }

    final XYItemRenderer renderer = new XYLineAndShapeRenderer(asSerie, true) {
        /** */
        private static final long serialVersionUID = 1L;

        @Override
        public Paint getItemPaint(final int row, final int col) {
            //System.out.println(row+" "+col);
            if (classIndex < 0) {
                final double v = dataSet.instance(col).value(coloridx);
                final double[] minmax = WekaDataStatsUtil.getMinMaxForAttributeAsArrayOfDoubles(dataSet,
                        coloridx);

                final double rated = (v - minmax[0]) / (minmax[1] - minmax[0]);
                System.out.println("rated -> " + rated + " min=" + minmax[0] + "max=" + minmax[1]);
                final int colorIdx = (int) Math.round((ColorHelper.YlGnBu_9_COLORS.length - 1) * rated);

                //System.out.println(minmax[0]+" "+minmax[1]+" "+v+" "+rated+" "+colorIdx);
                return ColorHelper.YlGnBu_9_COLORS[colorIdx];
            } else
                return super.getItemPaint(row, col);
        }
    };
    xyPlot.setRenderer(renderer);

    for (int i = 0; i < nbSeries; i++) {
        renderer.setSeriesToolTipGenerator(i, gen);
    }

    return new ChartPanel(chart);
}

From source file:se.technipelago.weather.chart.Generator.java

private JFreeChart createLineChart(final String title, final String valueLabel, final XYDataset dataset) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, null, valueLabel, dataset, false, false,
            false);/*from  w  w  w .  ja va2s.  co m*/

    if (dataset.getItemCount(0) < 30) {
        final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        final XYPlot plot = (XYPlot) chart.getPlot();
        plot.setRenderer(renderer);
    }
    return chart;
}

From source file:GroupProject.OriginalChartUI.java

/**
 * The method to draw line chart/*from   w w w  .  jav a  2  s . c  o m*/
 * @param lineChartData the data used in the line chart
 * @param XTitle the measurement of X axis
 * @param YTitle the measurement of Y axis
 */
public void drawLineChart(Map<String, Float> lineChartData, String XTitle, String YTitle) {
    String title = XTitle + " VS " + YTitle;
    System.out.print("drawLineChart");

    ArrayList<String> keyArrayList = new ArrayList<>();
    ArrayList<Float> valueArrayList = new ArrayList<>();
    Set set = lineChartData.keySet();
    int i = 1;
    XYSeries series1 = new XYSeries("");

    for (Map.Entry<String, Float> data : lineChartData.entrySet()) {
        String key = data.getKey();
        Float value = data.getValue();
        keyArrayList.add(key);
        valueArrayList.add(value);
        series1.add(Integer.valueOf(key), value);
    }
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);
    JFreeChart chart = ChartFactory.createXYLineChart(title, XTitle, YTitle, dataset, PlotOrientation.VERTICAL,
            true, true, false);
    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.BLUE);

    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

    plot.setRangeGridlinePaint(Color.GRAY);
    plot.setBackgroundPaint(Color.white);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartDisplayPanel.removeAll();
    chartDisplayPanel.add(chartPanel, BorderLayout.CENTER);
    chartDisplayPanel.validate();
}