Example usage for org.jfree.chart ChartPanel setMouseWheelEnabled

List of usage examples for org.jfree.chart ChartPanel setMouseWheelEnabled

Introduction

In this page you can find the example usage for org.jfree.chart ChartPanel setMouseWheelEnabled.

Prototype

public void setMouseWheelEnabled(boolean flag) 

Source Link

Document

Enables or disables mouse wheel support for the panel.

Usage

From source file:main.GUI.java

private void createHistogram() {
    IntervalXYDataset dataset = carlo.getDataset();
    JFreeChart chart = ChartFactory.createHistogram("Histogram", "Pocet dni", "Vskyt", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel myChart = new ChartPanel(chart);
    myChart.setMouseWheelEnabled(true);
    panelHistogram.setLayout(new java.awt.BorderLayout());
    panelHistogram.add(myChart, BorderLayout.CENTER);
    panelHistogram.validate();/*  w ww  . java  2 s.c  om*/
}

From source file:vista.ReporteConversionLeads.java

public void iniciarGraficos(PieDataset datasetCantidades, PieDataset datasetConversion) {
    double porcConversion = 0;
    this.cantClientesLeadActuales.setText(Integer.toString(datasetCantidades.getValue(0).intValue()));
    this.cantClientesHabActuales.setText(Integer.toString(datasetCantidades.getValue(1).intValue()));
    double base = datasetConversion.getValue(0).floatValue() + datasetConversion.getValue(1).floatValue();
    if (base > 0) {
        porcConversion = (datasetConversion.getValue(1).floatValue() * 100) / base;
    }/*  w  w w.  ja  va  2 s  .co m*/

    NumberFormat nf = new DecimalFormat("##.##");
    this.cantLeadsaHabituales.setText(nf.format(porcConversion) + "%");

    JFreeChart chartCa = ChartFactory.createPieChart("Clientes y Leads", // chart title 
            datasetCantidades, // data    
            true, // include legend   
            true, false);

    JFreeChart chartCo = ChartFactory.createPieChart("Conversion Leads a Habituales", // chart title 
            datasetConversion, // data    
            true, // include legend   
            true, false);

    ChartPanel chartCantidades = new ChartPanel(chartCa);
    ChartPanel chartConversion = new ChartPanel(chartCo);
    chartCantidades.setSize(new Dimension(600, 400));
    chartCantidades.setMouseWheelEnabled(true);
    chartConversion.setSize(new Dimension(600, 400));
    chartConversion.setMouseWheelEnabled(true);

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout
            .setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup().addGap(0, 0, 0)
                            .addComponent(chartCantidades).addContainerGap(0, Short.MAX_VALUE)));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup().addGap(0, 0, 0).addComponent(chartCantidades)
                    .addContainerGap(0, Short.MAX_VALUE)));

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout
            .setHorizontalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup().addGap(0, 0, 0)
                            .addComponent(chartConversion).addContainerGap(0, Short.MAX_VALUE)));
    jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup().addGap(0, 0, 0).addComponent(chartConversion)
                    .addContainerGap(0, Short.MAX_VALUE)));

}

From source file:GUI.Starts.java

private void initGraphs() {
    XYDataset datasets = createDataset();

    JFreeChart chart = ChartFactory.createXYLineChart("", "Periods", "Price", datasets,
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel cp = new ChartPanel(chart);

    cp.setMouseWheelEnabled(true);
    cp.setSize(jPanel1.getWidth(), jPanel1.getHeight());
    cp.setVisible(true);/*  w  w  w .  j  a va  2 s.  c  o  m*/
    jPanel1.add(cp);
    jPanel1.validate();
}

From source file:moller.javapeg.program.gui.frames.ImageRepositoryStatisticsViewer.java

private ChartPanel createChart(CategoryDataset bardataset, String label) {
    String title = getLang().get("imagestatisticsviewer.chart.title.prefix");
    String valueAxisLabel = getLang().get("imagestatisticsviewer.chart.valueAxisLabel");

    JFreeChart barChart = ChartFactory.createBarChart(title + " " + label, label, valueAxisLabel, bardataset);

    ChartPanel chartPanel = new ChartPanel(barChart);
    chartPanel.setName(label);//from  w  ww.j a  va  2s. c om
    chartPanel.setMouseWheelEnabled(true);

    final CategoryPlot plot = barChart.getCategoryPlot();
    plot.setBackgroundPaint(new Color(204, 204, 204));

    BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
    barRenderer.setBarPainter(new StandardBarPainter());
    barRenderer.setSeriesPaint(0, new Color(102, 153, 204));
    barRenderer.setDrawBarOutline(true);
    barRenderer.setSeriesOutlinePaint(0, Color.BLACK);

    return chartPanel;
}

From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PortHeatMapPlotPanel.java

/**
 * Creates a panel for heat map (make it zoomable)
 *
 * @return A panel.//  ww  w .  java2s  .  c o  m
 */
public JPanel createHeatPanel(OMS_Collection history, ArrayList<IB_Vertex> includedNodes,
        EnumSet<IB_Depth> includedDepths) {
    // this will return quickly, it uses a swing worker to
    // develop the dataset, which can take considerable time
    // so a dummy chart is returned, to be fixed later
    createHeatChart(new XYSeriesCollection(), history, includedNodes, includedDepths);
    heatChart.addChangeListener(this);
    ChartPanel panel = new ChartPanel(heatChart);
    panel.setFillZoomRectangle(true);
    panel.setMouseWheelEnabled(true);
    return panel;
}

From source file:DashboardInterface.LaunchGraph.java

/**
 * Creates a panel for the demo (used by SuperDemo.java).
 *
 * @return A panel.// w  ww  . j  a v a  2 s  . c o  m
 */
public JPanel createDemoPanel() {
    JFreeChart chart = createChart(null);
    ChartPanel panel = new ChartPanel(chart);
    panel.setFillZoomRectangle(false);
    panel.setMouseWheelEnabled(false);
    panel.setAutoscrolls(false);
    panel.setDomainZoomable(false);
    panel.setFocusable(false);
    return panel;
}

From source file:Trabalho.HistogramaHSB.java

public ChartPanel criaHistograma() throws IOException {

    //pega a imagem
    BufferedImage img = pegaImagem();
    //w pega a largura da imagem - h pega a altura da imagem
    int w = img.getWidth();
    int h = img.getHeight();
    //d calcula o tamanho da imagem
    int d = (w * h);
    //red, green e blue iro receber os tons de cor antigo da imagem - u vai receber o RGB da cor 
    int red, green, blue, u;
    //retorna rgb no mtodo
    float[] hsb;//from w  w  w .ja  v  a 2  s . c om
    int[] vetH = new int[256];
    int[] vetS = new int[256];
    int[] vetB = new int[256];
    float hue, sat, bri;
    //cAux e oldColor pegam os tons originais da imagem - newColor pega os tons aps o clculo
    Color oldColor;
    Color newColor;

    //for responsvel por substituir os tons antigos pelos novos; percorrem a imagem por largura e altura
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            u = img.getRGB(i, j); //u vai receber o RGB da posio i, j
            oldColor = new Color(u); //oldColor  instanciado e recebe o valor de u
            //cada cor recebe o valor do tom original
            red = oldColor.getRed();
            green = oldColor.getGreen();
            blue = oldColor.getBlue();
            hsb = Color.RGBtoHSB(red, green, blue, null);
            hue = hsb[0];
            sat = hsb[1];
            bri = hsb[2];
            //                System.out.println("RGB [" + red + "," + green + "," + blue + "] converted to HSB [" + hue + "," + sat + "," + bri + "]");

            //                hue = hue * 360;
            //                int convH = Integer.valueOf(new Float(hue).intValue());
            //                vetH[convH]++;
            //
            //                sat = sat * 100;
            //                int convS = Integer.valueOf(new Float(sat).intValue());
            //                vetS[convS]++;
            //
            //                bri = bri * 100;
            //                int convB = Integer.valueOf(new Float(bri).intValue());
            //                vetB[convB]++;

            newColor = new Color(hue, sat, bri);
            //seta o RGB da imagem nas posies i, j pegando os valores da newColor
            img.setRGB(i, j, newColor.getRGB());
        }
    }

    File ouptut = new File("D:\\ProjetosNetBeans\\PDI\\src\\imagens\\5.jpeg");
    ImageIO.write(img, "png", ouptut);

    dataset = new HistogramDataset();
    //pega o RGB

    r = raster.getSamples(0, 0, w, h, 0, r);
    dataset.addSeries("Red", r, 360);
    r = raster.getSamples(0, 0, w, h, 1, r);
    dataset.addSeries("Green", r, 101);
    r = raster.getSamples(0, 0, w, h, 2, r);
    dataset.addSeries("Blue", r, 101);

    JFreeChart chart = ChartFactory.createHistogram("Histograma", "Pixels", "Y", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    //Plota as cores
    XYPlot plot = (XYPlot) chart.getPlot();
    renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setBarPainter(new StandardXYBarPainter());
    //vermelho, verde, azul
    Paint[] paintArray = { new Color(0x80ff0000, true), new Color(0x8000ff00, true),
            new Color(0x800000ff, true) };
    //desenhando o grfico
    plot.setDrawingSupplier(
            new DefaultDrawingSupplier(paintArray, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);
    return panel;
}

From source file:lu.lippmann.cdb.lab.mds.UniversalMDS.java

public JXPanel buildMDSViewFromDataSet(Instances ds, MDSTypeEnum type) throws Exception {

    final XYSeriesCollection dataset = new XYSeriesCollection();

    final JFreeChart chart = ChartFactory.createScatterPlot("", // title 
            "X", "Y", // axis labels 
            dataset, // dataset 
            PlotOrientation.VERTICAL, true, // legend? yes 
            true, // tooltips? yes 
            false // URLs? no 
    );/*from w w w. j  ava 2 s .  c  o m*/

    final XYPlot xyPlot = (XYPlot) chart.getPlot();

    chart.setTitle(type.name() + " MDS");

    Attribute clsAttribute = null;
    int nbClass = 1;
    if (ds.classIndex() != -1) {
        clsAttribute = ds.classAttribute();
        nbClass = clsAttribute.numValues();
    }

    final List<XYSeries> lseries = new ArrayList<XYSeries>();
    if (nbClass <= 1) {
        lseries.add(new XYSeries("Serie #1", false));
    } else {
        for (int i = 0; i < nbClass; i++) {
            lseries.add(new XYSeries(clsAttribute.value(i), false));
        }
    }
    dataset.removeAllSeries();

    /**
     * Initialize filtered series
     */
    final List<Instances> filteredInstances = new ArrayList<Instances>();
    for (int i = 0; i < lseries.size(); i++) {
        filteredInstances.add(new Instances(ds, 0));
    }

    for (int i = 0; i < ds.numInstances(); i++) {
        final Instance oInst = ds.instance(i);
        int indexOfSerie = 0;
        if (oInst.classIndex() != -1) {
            indexOfSerie = (int) oInst.value(oInst.classAttribute());
        }
        lseries.get(indexOfSerie).add(coordinates[i][0], coordinates[i][1]);
        filteredInstances.get(indexOfSerie).add(oInst);
    }

    final List<Paint> colors = new ArrayList<Paint>();

    for (final XYSeries series : lseries) {
        dataset.addSeries(series);
    }

    final XYToolTipGenerator gen = new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            return InstanceFormatter.htmlFormat(filteredInstances.get(series).instance(item), true);
        }
    };

    final Shape shape = new Ellipse2D.Float(0f, 0f, 5f, 5f);

    ((XYLineAndShapeRenderer) xyPlot.getRenderer()).setUseOutlinePaint(true);

    for (int p = 0; p < nbClass; p++) {
        xyPlot.getRenderer().setSeriesToolTipGenerator(p, gen);
        ((XYLineAndShapeRenderer) xyPlot.getRenderer()).setLegendShape(p, shape);
        xyPlot.getRenderer().setSeriesOutlinePaint(p, Color.BLACK);
    }

    for (int ii = 0; ii < nbClass; ii++) {
        colors.add(xyPlot.getRenderer().getItemPaint(ii, 0));
    }

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPreferredSize(new Dimension(1200, 900));
    chartPanel.setBorder(new TitledBorder("MDS Projection"));
    chartPanel.setBackground(Color.WHITE);

    final JXPanel allPanel = new JXPanel();
    allPanel.setLayout(new BorderLayout());
    allPanel.add(chartPanel, BorderLayout.CENTER);

    return allPanel;
}

From source file:org.glotaran.core.datadisplayers.common.ImageSVDPanel.java

private void updateSVDPlots() {
    XYSeriesCollection lSVCollection = new XYSeriesCollection();
    XYSeries seria;/*  ww  w  . ja  v a2  s .  c  o m*/
    for (int j = 0; j < (Integer) jSnumSV.getValue(); j++) {
        seria = new XYSeries("LSV" + j + 1);
        for (int i = 0; i < timeSteps; i++) {
            seria.add(timeAxe[i], svdResult[0].getAsDouble((long) i, j));
        }
        lSVCollection.addSeries(seria);
    }
    leftSVChart.getXYPlot().setDataset(lSVCollection);

    double[] tempRsingVec = null;
    double minVal = 0;
    double maxVal = 0;

    if (jPRightSingVectors.getComponentCount() < (Integer) jSnumSV.getValue()) {
        double tempValue;
        for (int i = jPRightSingVectors.getComponentCount(); i < (Integer) jSnumSV.getValue(); i++) {
            tempRsingVec = new double[imageWitdth * imageHeight];
            for (int j = 0; j < imageWitdth * imageHeight; j++) {
                tempValue = svdResult[2].getAsDouble(j, i);
                tempRsingVec[j] = tempValue;
                minVal = minVal > tempValue ? tempValue : minVal;
                maxVal = maxVal < tempValue ? tempValue : maxVal;
            }
            IntensImageDataset rSingVec = new IntensImageDataset(imageWitdth, imageHeight, tempRsingVec);
            PaintScale ps = new RedGreenPaintScale(minVal, maxVal);
            JFreeChart rSingVect = CommonDataDispTools.createScatChart(
                    ImageUtilities.createColorCodedImage(rSingVec, ps), ps, imageWitdth, imageHeight);
            //            rSingVect.setTitle("R Singular vector " + String.valueOf(j + 1));
            //rSingVect.getTitle().setFont(new Font(tracechart.getTitle().getFont().getFontName(), Font.PLAIN, 12));
            ChartPanel rSingVectPanel = new ChartPanel(rSingVect);
            rSingVectPanel.setFillZoomRectangle(true);
            rSingVectPanel.setMouseWheelEnabled(true);
            jPRightSingVectors.add(rSingVectPanel);
        }

    } else {
        for (int i = jPRightSingVectors.getComponentCount() - 1; i >= (Integer) jSnumSV.getValue(); i--) {
            jPRightSingVectors.remove(i);
            jPRightSingVectors.repaint();
        }
    }
    jPRightSingVectors.validate();
}

From source file:org.glotaran.core.datadisplayers.common.ImageSVDPanel.java

public void createSVDPlots() {

    int maxSpinnerNumberModel = Math.min(MAX_NUMBER_SINGULAR_VALUES, (int) svdResult[1].getRowCount());
    jTFtotalNumSV//from w  w  w. j av  a2  s  .c  om
            .setText("Max " + maxSpinnerNumberModel + " of  " + String.valueOf(svdResult[1].getRowCount()));
    jSnumSV.setModel(new SpinnerNumberModel((int) 1, (int) 0, maxSpinnerNumberModel, (int) 1));

    //creare collection with first 2 LSV
    XYSeriesCollection lSVCollection = new XYSeriesCollection();
    XYSeries seria;
    seria = new XYSeries("LSV1");
    for (int i = 0; i < timeSteps; i++) {
        seria.add(timeAxe[i], svdResult[0].getAsDouble((long) i, 0));
    }
    lSVCollection.addSeries(seria);

    //creare chart for 2 LSV
    leftSVChart = ChartFactory.createXYLineChart("Left singular vectors", "Time (~s)", null, lSVCollection,
            PlotOrientation.VERTICAL, false, false, false);
    //leftSVChart.getTitle().setFont(new Font(leftSVChart.getTitle().getFont().getFontName(), Font.PLAIN, 12));
    leftSVChart.setBackgroundPaint(JFreeChart.DEFAULT_BACKGROUND_PAINT);
    GraphPanel chpan = new GraphPanel(leftSVChart);
    jPLeftSingVectors.removeAll();
    jPLeftSingVectors.add(chpan);

    //creare collection with first RSV
    double[] tempRsingVec = null;
    double minVal = 0;
    double maxVal = 0;

    //            seria = new XYSeries("RSV" + (j + 1));
    tempRsingVec = new double[imageWitdth * imageHeight];
    double tempValue;
    for (int i = 0; i < imageWitdth * imageHeight; i++) {
        tempValue = svdResult[2].getAsDouble(i, 0);
        tempRsingVec[i] = tempValue;
        minVal = minVal > tempValue ? tempValue : minVal;
        maxVal = maxVal < tempValue ? tempValue : maxVal;
    }

    IntensImageDataset rSingVec = new IntensImageDataset(imageWitdth, imageHeight, tempRsingVec);
    PaintScale ps = new RedGreenPaintScale(minVal, maxVal);
    JFreeChart rSingVect = CommonDataDispTools
            .createScatChart(ImageUtilities.createColorCodedImage(rSingVec, ps), ps, imageWitdth, imageHeight);
    //            rSingVect.setTitle("R Singular vector " + String.valueOf(j + 1));
    //rSingVect.getTitle().setFont(new Font(tracechart.getTitle().getFont().getFontName(), Font.PLAIN, 12));
    ChartPanel rSingVectPanel = new ChartPanel(rSingVect);
    rSingVectPanel.setFillZoomRectangle(true);
    rSingVectPanel.setMouseWheelEnabled(true);

    jPRightSingVectors.removeAll();
    jPRightSingVectors.add(rSingVectPanel);

    //creare collection with singular values
    XYSeriesCollection sVCollection = new XYSeriesCollection();
    seria = new XYSeries("SV");
    for (int i = 0; i < maxSpinnerNumberModel; i++) {
        seria.add(i + 1, svdResult[1].getAsDouble((long) i, (long) i));
    }
    sVCollection.addSeries(seria);

    //create chart for singular values
    JFreeChart tracechart = ChartFactory.createXYLineChart("Screeplot", "Singular Value index (n)", null,
            sVCollection, PlotOrientation.VERTICAL, false, false, false);
    LogAxis logAxe = new LogAxis("Log(SVn)");
    final NumberAxis domainAxis = (NumberAxis) tracechart.getXYPlot().getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    tracechart.getXYPlot().setRangeAxis(logAxe);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) tracechart.getXYPlot().getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.white);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));

    //tracechart.getTitle().setFont(new Font(tracechart.getTitle().getFont().getFontName(), Font.PLAIN, 12));
    tracechart.setBackgroundPaint(JFreeChart.DEFAULT_BACKGROUND_PAINT);

    chpan = new GraphPanel(tracechart);
    //add chart with 2 RSV to JPannel
    jPSingValues.removeAll();
    jPSingValues.add(chpan);
}