Example usage for org.jfree.data.category DefaultCategoryDataset clear

List of usage examples for org.jfree.data.category DefaultCategoryDataset clear

Introduction

In this page you can find the example usage for org.jfree.data.category DefaultCategoryDataset clear.

Prototype

public void clear() 

Source Link

Document

Clears all data from the dataset and sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:control.JGeraGraficos.java

public void PrintGraficoSegundoExemplo() {
    String valorJava = getValorArquivoTxt("c:\\AppsPrjFinal\\ESTOUROJVMJAVA.txt");
    String valorJavaThRead = getValorArquivoTxt("c:\\AppsPrjFinal\\ESTOUROJVMJAVATHREAD.txt");
    String valorJOCL = getValorArquivoTxt("c:\\AppsPrjFinal\\ESTOUROJVMJOCL.txt");
    if (valorJava.isEmpty()) {
        JOptionPane.showMessageDialog(new JPanel(), "Processo Java No Executado", "Executar Processo",
                JOptionPane.INFORMATION_MESSAGE);
    } else if (valorJavaThRead.isEmpty()) {
        JOptionPane.showMessageDialog(new JPanel(), "Processo Java ThRead No Executado", "Executar Processo",
                JOptionPane.INFORMATION_MESSAGE);
    } else if (valorJOCL.isEmpty()) {
        JOptionPane.showMessageDialog(new JPanel(), "Processo JOCL No Executado", "Executar Processo",
                JOptionPane.INFORMATION_MESSAGE);
    } else {//from w  ww .j ava2 s . com
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        dataset.clear();
        dataset.addValue(Float.parseFloat(valorJava), "Java", "Java");
        dataset.addValue(Float.parseFloat(valorJavaThRead), "Java ThRead", "Java ThRead");
        dataset.addValue(Float.parseFloat(valorJOCL), "JOCL", "JOCL");
        JFreeChart chart = ChartFactory.createBarChart("Grafio de Performance", null, "Tempo(ms)", dataset,
                PlotOrientation.VERTICAL, true, true, true);
        ChartFrame frame = new ChartFrame("Grafio de Performance", chart);

        frame.setBounds(300, 78, 800, 620);
        frame.setVisible(true);
    }
}

From source file:control.JGeraGraficos.java

public ChartPanel GetGraficoParcial(ArrayList<DadosEstatisticos> listaParcial, String Titulo) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    int i = 0;//from  ww w .ja  va 2s . c  o  m
    dataset.clear();
    for (DadosEstatisticos dados : listaParcial) {
        i++;
        if (listaParcial.indexOf(dados) < 2) {
            dataset.setValue(dados.getTempoGasto(), "C" + i + " - " + dados.getDescricao(), "C" + i);
        } else {
            dataset.setValue(dados.getTempoGasto(), "C" + i + " - " + dados.getDimensoes(), "C" + i);
        }
    }

    JFreeChart chart = ChartFactory.createBarChart(Titulo, null, "Tempo(ms)", dataset,
            PlotOrientation.HORIZONTAL, true, true, true);

    ChartPanel CP = new ChartPanel(chart);
    CP.setBounds(5, 15, 180, 470);

    return CP;
}

From source file:org.jfree.data.category.SlidingCategoryDatasetTest.java

/**
 * Some checks for the getRowCount() method.
 *//*w w w  .  ja v a 2s .com*/
@Test
public void testGetRowCount() {
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, 10, 5);
    assertEquals(0, dataset.getRowCount());
    underlying.addValue(1.0, "R1", "C1");
    assertEquals(1, dataset.getRowCount());

    underlying.clear();
    assertEquals(0, dataset.getRowCount());
}

From source file:de.fub.maps.project.detector.model.inference.ui.InferenceResultPanel.java

public void updateView(InferenceDataProcessHandler.ClassificationResult classificationResult) {
    DefaultCategoryDataset relDataset = getClassificationBarChart().getRelDataset();
    DefaultCategoryDataset absDataset = getClassificationBarChart().getAbsDataset();
    relDataset.clear();
    absDataset.clear();/*from   w ww. j  a  v a  2s  .com*/
    dataItemList.clear();
    Map<String, List<Instance>> resultMap = classificationResult.getResultMap();
    if (!resultMap.isEmpty()) {
        double sum = 0;

        for (Entry<String, List<Instance>> entry : resultMap.entrySet()) {
            sum += entry.getValue().size();
        }
        CategoryPlot plot = getClassificationBarChart().getPlot();
        CategoryItemRenderer relRenderer = plot.getRenderer(0);
        CategoryItemRenderer absRenderer = plot.getRenderer(1);
        ArrayList<String> arrayList = new ArrayList<String>(resultMap.keySet());
        Collections.sort(arrayList);

        for (String transportMode : arrayList) {
            double abs = resultMap.get(transportMode).size();
            double rel = abs / sum * 100;
            absDataset.addValue(null, "Instances (rel.)", transportMode);
            absDataset.addValue(abs, "Instances (abs.)", transportMode);
            relDataset.addValue(rel, "Instances (rel.)", transportMode);
            relDataset.addValue(null, "Instances (abs.)", transportMode);
            dataItemList.add(new DataItem(transportMode, rel, abs));
        }
        final LegendItemCollection result = new LegendItemCollection();
        result.add(relRenderer.getLegendItem(0, 0));
        result.add(absRenderer.getLegendItem(1, 1));

        double classified = (sum / classificationResult.getInstanceToTrackSegmentMap().size() * 100);
        double notClassified = ((classificationResult.getInstanceToTrackSegmentMap().size() - sum)
                / classificationResult.getInstanceToTrackSegmentMap().size() * 100);
        getClassifiedInstances().setText(MessageFormat.format("{0, number, 000.00} %", classified));
        getNotClassifiedInstances().setText(MessageFormat.format("{0, number, 000.00} %", notClassified));

        repaint();
    }
}

From source file:keel.Algorithms.UnsupervisedLearning.AssociationRules.Visualization.keelassotiationrulesbarchart.ResultsProccessor.java

public void writeToFile(String outName)
        throws FileNotFoundException, UnsupportedEncodingException, IOException {
    calcMeans();/*from w w w.  j  a va  2 s .c  o m*/
    calcAvgRulesBySeed();

    // Create JFreeChart Dataset
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    HashMap<String, Double> measuresFirst = algorithmMeasures.entrySet().iterator().next().getValue();
    for (Map.Entry<String, Double> measure : measuresFirst.entrySet()) {
        String measureName = measure.getKey();
        //Double measureValue = measure.getValue();
        dataset.clear();

        for (Map.Entry<String, HashMap<String, Double>> entry : algorithmMeasures.entrySet()) {
            String alg = entry.getKey();
            Double measureValue = entry.getValue().get(measureName);

            // Parse algorithm name to show it correctly
            String aName = alg.substring(0, alg.length() - 1);
            int startAlgName = aName.lastIndexOf("/");
            aName = aName.substring(startAlgName + 1);

            dataset.addValue(measureValue, aName, measureName);

            ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
            JFreeChart barChart = ChartFactory.createBarChart("Assotiation Rules Measures", measureName,
                    measureName, dataset, PlotOrientation.VERTICAL, true, true, false);
            StandardChartTheme.createLegacyTheme().apply(barChart);

            CategoryItemRenderer renderer = barChart.getCategoryPlot().getRenderer();

            // Black and White
            int numItems = algorithmMeasures.size();
            for (int i = 0; i < numItems; i++) {
                Color color = Color.DARK_GRAY;
                if (i % 2 == 1) {
                    color = Color.LIGHT_GRAY;
                }
                renderer.setSeriesPaint(i, color);
                renderer.setSeriesOutlinePaint(i, Color.BLACK);
            }

            int width = 640 * 2; /* Width of the image */
            int height = 480 * 2; /* Height of the image */

            // JPEG
            File BarChart = new File(outName + "_" + measureName + "_barchart.jpg");
            ChartUtilities.saveChartAsJPEG(BarChart, barChart, width, height);

            // SVG
            SVGGraphics2D g2 = new SVGGraphics2D(width, height);
            Rectangle r = new Rectangle(0, 0, width, height);
            barChart.draw(g2, r);
            File BarChartSVG = new File(outName + "_" + measureName + "_barchart.svg");
            SVGUtils.writeToSVG(BarChartSVG, g2.getSVGElement());
        }
    }
    /*
    for (Map.Entry<String, HashMap<String, Double>> entry : algorithmMeasures.entrySet())
    {
    String alg = entry.getKey();
    HashMap<String, Double> measures = entry.getValue();
            
    for (Map.Entry<String, Double> entry1 : measures.entrySet())
    {
        String measureName = entry1.getKey();
        Double measureValue = entry1.getValue();
                
        dataset.addValue(measureValue, alg, measureName);
    }
    }
        */

}

From source file:org.jfree.data.category.SlidingCategoryDatasetTest.java

/**
 * Some checks for the getColumnCount() method.
 *//*w  ww  .  ja va  2s .c  o m*/
@Test
public void testGetColumnCount() {
    DefaultCategoryDataset underlying = new DefaultCategoryDataset();
    SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, 10, 2);
    assertEquals(0, dataset.getColumnCount());
    underlying.addValue(1.0, "R1", "C1");
    assertEquals(0, dataset.getColumnCount());
    underlying.addValue(1.0, "R1", "C2");
    assertEquals(0, dataset.getColumnCount());
    dataset.setFirstCategoryIndex(0);
    assertEquals(2, dataset.getColumnCount());
    underlying.addValue(1.0, "R1", "C3");
    assertEquals(2, dataset.getColumnCount());
    dataset.setFirstCategoryIndex(2);
    assertEquals(1, dataset.getColumnCount());
    underlying.clear();
    assertEquals(0, dataset.getColumnCount());
}