Example usage for org.jfree.chart ChartPanel setPopupMenu

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

Introduction

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

Prototype

public void setPopupMenu(JPopupMenu popup) 

Source Link

Document

Sets the popup menu for the panel.

Usage

From source file:org.jfree.chart.demo.ScatterPlotDemo1.java

public static JPanel createDemoPanel() {
    JFreeChart jfreechart = createChart(new SampleXYDataset2());
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setVerticalAxisTrace(true);
    chartpanel.setHorizontalAxisTrace(true);
    chartpanel.setPopupMenu(null);
    chartpanel.setDomainZoomable(true);// www . j a va 2  s.  c  o  m
    chartpanel.setRangeZoomable(true);
    return chartpanel;
}

From source file:de.rbs90.fwdisp.settingsgui.gui.tabs.statistics.OtherCityStats.java

public OtherCityStats() {
    setName("Region");

    setLayout(new BorderLayout());

    DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("HOT", 110);
    data.setValue("Oberlungwitz", 60);
    data.setValue("Limbach", 80);
    data.setValue("Glauchau", 90);
    data.setValue("Meerane", 100);
    data.setValue("Lichtenstein", 90);

    JFreeChart chart = ChartFactory.createPieChart3D("Einsatztypen", data, false, false, false);

    chart.setBackgroundPaint(getBackground());

    ChartPanel panel = new ChartPanel(chart);

    panel.setPopupMenu(null);
    add(panel, BorderLayout.CENTER);
}

From source file:de.rbs90.fwdisp.settingsgui.gui.tabs.statistics.TimeStatisticsPanel.java

public TimeStatisticsPanel() {
    setName("Uhrzeit");

    setLayout(new BorderLayout());

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    int alarmCount[] = new int[24];

    try {//from   w  w w  .j ava 2  s .  co m
        ResultSet resultSet = Starter.getDatabase().getStatement().executeQuery(
                "SELECT STARTTIME_HOUR, COUNT(*) AS COUNT FROM ALARMHISTORY GROUP BY STARTTIME_HOUR");

        while (resultSet.next()) {
            alarmCount[resultSet.getInt("STARTTIME_HOUR")] = resultSet.getInt("COUNT");
        }

    } catch (SQLException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < 24; i++) {
        dataset.addValue(alarmCount[i], "", "" + i);
    }

    JFreeChart chart = ChartFactory.createBarChart3D("Zeitbersicht", "Uhrzeit", "Einstze", dataset,
            PlotOrientation.VERTICAL, false, false, false);

    chart.setBackgroundPaint(getBackground());

    ChartPanel panel = new ChartPanel(chart);
    panel.setPopupMenu(null);
    add(panel, BorderLayout.CENTER);
}

From source file:de.rbs90.fwdisp.settingsgui.gui.tabs.statistics.MonthlyStatisticPanel.java

public MonthlyStatisticPanel() {
    setName("Monat");
    setLayout(new BorderLayout());

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    int alarmCount[] = new int[12];

    try {//  w  w  w . j  a v a  2  s.  c  om
        ResultSet resultSet = Starter.getDatabase().getStatement().executeQuery(
                "SELECT STARTDATE_MONTH, COUNT(*) AS COUNT FROM ALARMHISTORY GROUP BY STARTDATE_MONTH");

        while (resultSet.next()) {
            alarmCount[resultSet.getInt("STARTDATE_MONTH") - 1] = resultSet.getInt("COUNT");
        }

    } catch (SQLException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < 12; i++) {
        dataset.addValue(alarmCount[i], "", "" + (i + 1));
    }

    JFreeChart chart = ChartFactory.createBarChart3D("Monatsbersicht", "Monat", "Einstze", dataset,
            PlotOrientation.VERTICAL, false, false, false);

    chart.setBackgroundPaint(getBackground());
    ChartPanel panel = new ChartPanel(chart);
    panel.setPopupMenu(null);

    add(panel, BorderLayout.CENTER);
}

From source file:de.rbs90.fwdisp.settingsgui.gui.tabs.statistics.YearStatisticPanel.java

public YearStatisticPanel() {
    setName("Jahr");
    setLayout(new BorderLayout());

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    HashMap<Integer, Integer> alarmCount = new HashMap<>();

    try {//from  w  w  w  . j av a  2 s  .  c  om
        ResultSet resultSet = Starter.getDatabase().getStatement().executeQuery(
                "SELECT STARTDATE_YEAR, COUNT(*) AS COUNT FROM ALARMHISTORY GROUP BY STARTDATE_YEAR"
                        + " ORDER BY STARTDATE_YEAR ASC");

        while (resultSet.next()) {
            alarmCount.put(resultSet.getInt("STARTDATE_YEAR"), resultSet.getInt("COUNT"));
        }

    } catch (SQLException e) {
        e.printStackTrace();
    }

    Set<Integer> years = alarmCount.keySet();

    for (Integer year : years) {
        Integer count = alarmCount.get(year);
        dataset.addValue(count, count, year);
    }

    JFreeChart chart = ChartFactory.createBarChart3D("Jahresbersicht", "Jahr", "Einstze", dataset,
            PlotOrientation.VERTICAL, false, false, false);

    chart.setBackgroundPaint(getBackground());
    ChartPanel panel = new ChartPanel(chart);
    panel.setPopupMenu(null);

    add(panel, BorderLayout.CENTER);
}

From source file:de.rbs90.fwdisp.settingsgui.gui.tabs.statistics.TypeStatisticsPanel.java

public TypeStatisticsPanel() {
    setName("EinsatzTyp");

    setLayout(new BorderLayout());

    DefaultPieDataset dataset = new DefaultPieDataset();

    HashMap<String, Integer> alarmCount = new HashMap<>();

    try {// w  w w.  j  a  v a2 s.com
        ResultSet resultSet = Starter.getDatabase().getStatement()
                .executeQuery("SELECT TYPE, COUNT(*) AS COUNT FROM ALARMHISTORY GROUP BY TYPE");

        while (resultSet.next()) {
            String type = resultSet.getString("TYPE");
            if (type.isEmpty())
                type = "unbekannt";

            int count = resultSet.getInt("COUNT");
            type += " (" + count + ")";

            alarmCount.put(type, count);
        }

    } catch (SQLException e) {
        e.printStackTrace();
    }

    for (String key : alarmCount.keySet()) {
        dataset.setValue(key, alarmCount.get(key));
    }

    JFreeChart chart = ChartFactory.createPieChart3D("Einsatztypen", dataset, false, false, false);

    chart.setBackgroundPaint(getBackground());

    ChartPanel panel = new ChartPanel(chart);

    panel.setPopupMenu(null);
    panel.setBackground(getBackground());

    add(panel, BorderLayout.CENTER);

}

From source file:de.rbs90.fwdisp.settingsgui.gui.tabs.statistics.WeekDayStatisticsPanel.java

public WeekDayStatisticsPanel() {
    setName("Wochentag");

    setLayout(new BorderLayout());

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    String weekDays[] = { "Mo", "Die", "Mi", "Do", "Fr", "Sa", "So" };
    int alarmCount[] = new int[7];

    try {//from  w ww. j  a va2  s .co m
        ResultSet resultSet = Starter.getDatabase().getStatement().executeQuery(
                "SELECT STARTDATE_WEEKDAY, COUNT(*) AS COUNT FROM ALARMHISTORY GROUP BY STARTDATE_WEEKDAY");

        while (resultSet.next()) {
            alarmCount[resultSet.getInt("STARTDATE_WEEKDAY") - 1] = resultSet.getInt("COUNT");
        }

    } catch (SQLException e) {
        e.printStackTrace();
    }

    for (int i = 0; i < 7; i++) {
        String dayName;
        int dayNumber;

        if (i != 6) {
            dayNumber = i + 1;
            dayName = weekDays[i];
        } else {
            dayName = weekDays[6]; //Sunday
            dayNumber = 0;
        }

        dataset.addValue(alarmCount[dayNumber], "", dayName);
    }

    JFreeChart chart = ChartFactory.createBarChart3D("Wochentagsbersicht", "Wochentag", "Einstze", dataset,
            PlotOrientation.VERTICAL, false, false, false);

    chart.setBackgroundPaint(getBackground());

    ChartPanel panel = new ChartPanel(chart);
    panel.setPopupMenu(null);
    add(panel, BorderLayout.CENTER);
}

From source file:cgpanalyser.gui.EvoInfoChart.java

/**
 * Creates a new demo.//from  ww  w .j a  va  2 s .c om
 *
 * @param title the frame title.
 */
public EvoInfoChart(final String title, long[] gateFuncsCounts, GateFuctionsAll gateFuncsAll) {
    super(title);
    final CategoryDataset dataset = createDataset(gateFuncsCounts, gateFuncsAll);
    final JFreeChart chart = createChart(dataset, gateFuncsCounts, gateFuncsAll);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(700, 400));
    chartPanel.setPopupMenu(null);
    chartPanel.setRangeZoomable(false);
    chartPanel.setDomainZoomable(false);
    setContentPane(chartPanel);
    pack();
    RefineryUtilities.centerFrameOnScreen(this);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setVisible(true);
}

From source file:gui.TraitViewerDialog.java

@SuppressWarnings("rawtypes")
private ChartPanel getChart(int selectedRow) {

    ArrayList<Float> data = new ArrayList<Float>();
    for (float[] row : tFile.getRows()) {
        if (row[selectedRow + 1] != (float) -99.0) {
            data.add(row[selectedRow + 1]);
        }//w w w  .ja va  2 s  . c  om
    }
    BoxAndWhiskerItem a = BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(data);
    java.util.List l = new ArrayList(0);

    a = new BoxAndWhiskerItem(a.getMean(), a.getMedian(), a.getQ1(), a.getQ3(), a.getMinRegularValue(),
            a.getMaxRegularValue(), a.getMinRegularValue(), a.getMaxRegularValue(), l);
    traitstats.setText(showBoxAndWhiskerItem(a));

    DefaultBoxAndWhiskerCategoryDataset ds2 = new DefaultBoxAndWhiskerCategoryDataset();

    ds2.add(a, (Comparable) 1, (Comparable) 1);
    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, null, null, ds2, false);

    chart.removeLegend();

    // XYPlot plot = chart.getXYPlot();
    CategoryPlot plot = chart.getCategoryPlot();
    plot.getDomainAxis().setVisible(false);
    BoxAndWhiskerRenderer b = (BoxAndWhiskerRenderer) plot.getRenderer();
    // b.setFillBox(false);
    b.setSeriesPaint(0, new Color(236, 55, 169));
    b.setSeriesOutlinePaint(1, new Color(131, 79, 112));
    b.setBaseOutlineStroke(new BasicStroke(1.0f));
    // b.get
    b.setWhiskerWidth(0.8);
    b.setBaseOutlinePaint(new Color(84, 144, 201));
    b.setDefaultEntityRadius(2);
    b.setMaximumBarWidth(0.18);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPopupMenu(null);
    return chartPanel;
}

From source file:org.knime.knip.core.ui.imgviewer.panels.HistogramBC.java

/**
 *
 * @param b/*from  w  ww . j a  v a  2s .  c o  m*/
 * @return
 */
private ChartPanel makeChartPanel(final HistogramBundle b) {
    final JFreeChart chart = getChart(null, b);
    final ChartPanel panel = new ChartPanel(chart);
    panel.setPopupMenu(null);
    panel.setDomainZoomable(false);
    panel.setRangeZoomable(false);
    final int xSize = b.getPreferredSizeX() / 2;
    final int ySize = b.getPreferredSizeY() / 2;
    panel.setPreferredSize(new java.awt.Dimension(xSize, ySize));
    panel.setMinimumSize(new java.awt.Dimension(xSize, ySize));
    return panel;
}