Example usage for org.jfree.chart.renderer.xy XYStepAreaRenderer setDataBoundsIncludesVisibleSeriesOnly

List of usage examples for org.jfree.chart.renderer.xy XYStepAreaRenderer setDataBoundsIncludesVisibleSeriesOnly

Introduction

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

Prototype

public void setDataBoundsIncludesVisibleSeriesOnly(boolean visibleOnly) 

Source Link

Document

Sets the flag that controls whether or not the data bounds reported by this renderer will exclude non-visible series and sends a RendererChangeEvent to all registered listeners.

Usage

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;//from ww  w  .  java2  s  . com
        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:com.intel.stl.ui.common.view.ComponentFactory.java

public static JFreeChart createStepAreaChart(XYDataset dataset, XYItemLabelGenerator labelGenerator) {
    if (dataset == null) {
        throw new IllegalArgumentException("No dataset.");
    }//from  w  w w.j  a v a 2  s  . c o m

    JFreeChart jfreechart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL,
            false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(UIConstants.INTEL_BACKGROUND_GRAY);
    // xyplot.setOutlinePaint(null);
    XYStepAreaRenderer xysteparearenderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA) {

        @Override
        public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea,
                PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis,
                XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) {
            setShapesVisible(item == dataset.getItemCount(series) - 1);
            super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item,
                    crosshairState, pass);
        }

    };
    xysteparearenderer.setDataBoundsIncludesVisibleSeriesOnly(false);
    xysteparearenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    xysteparearenderer.setDefaultEntityRadius(6);
    xysteparearenderer.setShapesFilled(true);
    xyplot.setRenderer(xysteparearenderer);

    if (labelGenerator != null) {
        xysteparearenderer.setBaseItemLabelGenerator(labelGenerator);
    }
    xysteparearenderer.setSeriesPaint(0, UIConstants.INTEL_GREEN);
    xyplot.setOutlinePaint(UIConstants.INTEL_DARK_GRAY);
    xyplot.setDomainGridlinePaint(UIConstants.INTEL_DARK_GRAY);
    xyplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY);

    xyplot.getDomainAxis().setVisible(false);

    NumberAxis axis = (NumberAxis) xyplot.getRangeAxis();
    axis.setRangeType(RangeType.POSITIVE);
    axis.setAxisLineVisible(false);

    return jfreechart;
}

From source file:cnu.eslab.fileTest.NewJFrame.java

public void StackedXYAreaRenderer(ArrayList<Integer> arCpuArrayList, ArrayList<Integer> arWifiArrayList,
        ArrayList<Integer> arLedArrayList, ArrayList<Integer> arGpsArrayList,
        ArrayList<Integer> arAudioArrayList, ArrayList<Integer> arThreeGArrayList) {

    boolean flagGPS, flagAUDIO;
    flagGPS = mGPSCheckBox.isSelected();
    flagAUDIO = mAudioCheckBox.isSelected();

    XYSeries xyseriesCPU = new XYSeries("CPU");
    XYSeries xyseriesWIFI = new XYSeries("WIFI");
    XYSeries xyseriesThreeG = new XYSeries("3G");
    XYSeries xyseriesLED = new XYSeries("LED");
    XYSeries xyseriesGPS = new XYSeries("GPS");
    XYSeries xyseriesAUDIO = new XYSeries("AUDIO");

    for (int i = 0; i < arCpuArrayList.size(); i++) {
        //Power Tutor Bug 
        if (arCpuArrayList.get(i) > 450) {
            arCpuArrayList.set(i, 450);/*  w ww. j ava 2 s .  c  om*/
        }
        /*
         * stack ? (Top -> bottom)
         * AUDIO / GPS / LED / ThreeG / WIFI / CPU
         */
        xyseriesCPU.add(i, arCpuArrayList.get(i));
        xyseriesWIFI.add(i, arWifiArrayList.get(i) + arCpuArrayList.get(i));
        xyseriesThreeG.add(i, arThreeGArrayList.get(i) + arWifiArrayList.get(i) + arCpuArrayList.get(i));
        xyseriesLED.add(i, arLedArrayList.get(i) + arThreeGArrayList.get(i) + arWifiArrayList.get(i)
                + arCpuArrayList.get(i));

        if (flagGPS == true && flagAUDIO == true) {
            xyseriesGPS.add(i, arGpsArrayList.get(i) + arLedArrayList.get(i) + arThreeGArrayList.get(i)
                    + arWifiArrayList.get(i) + arCpuArrayList.get(i));

            xyseriesAUDIO.add(i, arAudioArrayList.get(i) + arGpsArrayList.get(i) + arLedArrayList.get(i)
                    + arThreeGArrayList.get(i) + arWifiArrayList.get(i) + arCpuArrayList.get(i));

        } else if (flagGPS == true && flagAUDIO == false) {
            xyseriesGPS.add(i, arGpsArrayList.get(i) + arLedArrayList.get(i) + arThreeGArrayList.get(i)
                    + arWifiArrayList.get(i) + arCpuArrayList.get(i));

            xyseriesAUDIO.add(i, 0); // AUDIO ?  .
        } else if (flagGPS == false && flagAUDIO == true) {
            xyseriesGPS.add(i, 0); //GPS ?  .
            xyseriesAUDIO.add(i, arAudioArrayList.get(i) + arLedArrayList.get(i) + arThreeGArrayList.get(i)
                    + arWifiArrayList.get(i) + arCpuArrayList.get(i));
        } else {
            xyseriesGPS.add(i, 0); //GPS ?  .
            xyseriesAUDIO.add(i, 0); // AUDIO ?  .
        }
    }

    XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    xyseriescollection.addSeries(xyseriesCPU);
    xyseriescollection.addSeries(xyseriesWIFI);
    xyseriescollection.addSeries(xyseriesThreeG);
    xyseriescollection.addSeries(xyseriesLED);
    xyseriescollection.addSeries(xyseriesGPS);
    xyseriescollection.addSeries(xyseriesAUDIO);

    JFreeChart jfreechart = ChartFactory.createXYLineChart("", "Time(sec)", "Power(mW)", xyseriescollection,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainPannable(true);
    xyplot.setBackgroundPaint(new Color(255, 255, 255));//?  . 

    XYStepAreaRenderer xysteparearenderer = new XYStepAreaRenderer(2);
    //?? ? . ?? 
    /*xysteparearenderer.setSeriesPaint(0, new Color(0,0,0));
    xysteparearenderer.setSeriesPaint(1, new Color(30,30,30));
    xysteparearenderer.setSeriesPaint(2, new Color(60,60,60));
    xysteparearenderer.setSeriesPaint(3, new Color(90,90,90));
    xysteparearenderer.setSeriesPaint(4, new Color(120,120,120));
    xysteparearenderer.setSeriesPaint(5, new Color(150,150,150));*/

    xysteparearenderer.setDataBoundsIncludesVisibleSeriesOnly(false);
    xysteparearenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    xysteparearenderer.setDefaultEntityRadius(6);
    xyplot.setRenderer(xysteparearenderer);

    ChartPanel chartPanel = new ChartPanel(jfreechart);

    JFrame f = new JFrame("StackedXYAreaRenderer");
    f.setSize(600, 600);
    f.getContentPane().add(chartPanel);

    // f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}