Search in sources :

Example 51 with ChartPanel

use of org.jfree.chart.ChartPanel in project Course_Generator by patrovite.

the class JPanelAnalysisSpeedSlope method initComponents.

private void initComponents() {
    setLayout(new java.awt.BorderLayout());
    // -- Left - Toolbar
    Create_Toolbar();
    add(toolBar, java.awt.BorderLayout.WEST);
    // -- Bottom - Info
    jPanelSpeedSlopeInfo = new javax.swing.JPanel();
    jPanelSpeedSlopeInfo.setOpaque(true);
    jPanelSpeedSlopeInfo.setBackground(Color.WHITE);
    jPanelSpeedSlopeInfo.setLayout(new GridBagLayout());
    add(jPanelSpeedSlopeInfo, java.awt.BorderLayout.SOUTH);
    // -- Speed/Slope
    // -- Speed
    lbSpeedSlopeInfoSpeed = new javax.swing.JLabel();
    lbSpeedSlopeInfoSpeed.setOpaque(true);
    lbSpeedSlopeInfoSpeed.setBackground(Color.WHITE);
    lbSpeedSlopeInfoSpeed.setText(" " + bundle.getString("JPanelAnalysisSpeedSlope.lbSpeedSlopeInfoSpeed.text") + "=0km/h ");
    lbSpeedSlopeInfoSpeed.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelSpeedSlopeInfo, lbSpeedSlopeInfoSpeed, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // -- Slope
    lbSpeedSlopeInfoSlope = new javax.swing.JLabel();
    lbSpeedSlopeInfoSlope.setOpaque(true);
    lbSpeedSlopeInfoSlope.setBackground(Color.WHITE);
    lbSpeedSlopeInfoSlope.setText(" " + bundle.getString("JPanelAnalysisSpeedSlope.lbSpeedSlopeInfoSlope.text") + "=0.0% ");
    lbSpeedSlopeInfoSlope.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelSpeedSlopeInfo, lbSpeedSlopeInfoSlope, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL);
    // -- Chart Speed/Dist & Time/Dist
    ChartPanelSpeedSlope = new ChartPanel(chart, true, /* Properties */
    true, /* save */
    true, /* print */
    false, /* zoom */
    true);
    ChartPanelSpeedSlope.setDomainZoomable(false);
    ChartPanelSpeedSlope.setRangeZoomable(false);
    CrosshairOverlay crosshairOverlay = new CrosshairOverlay();
    xCrosshair = new Crosshair(Double.NaN, Color.RED, new BasicStroke(0f));
    xCrosshair.setLabelBackgroundPaint(Color.WHITE);
    // yCrosshair = new Crosshair(Double.NaN, Color.RED, new
    // BasicStroke(0f));
    // yCrosshair.setLabelBackgroundPaint(Color.WHITE);
    crosshairOverlay.addDomainCrosshair(xCrosshair);
    // crosshairOverlay.addRangeCrosshair(yCrosshair);
    ChartPanelSpeedSlope.addOverlay(crosshairOverlay);
    ChartPanelSpeedSlope.setBackground(new java.awt.Color(255, 0, 51));
    ChartPanelSpeedSlope.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            ChartEntity chartentity = event.getEntity();
            if (chartentity instanceof XYItemEntity) {
                XYItemEntity e = (XYItemEntity) chartentity;
                XYDataset d = e.getDataset();
                int s = e.getSeriesIndex();
                int i = e.getItem();
                double x = d.getXValue(s, i);
                double y = d.getYValue(s, i);
                xCrosshair.setValue(x);
                // yCrosshair.setValue(y);
                RefreshInfo(i);
            // //Refresh the position on the data grid
            // TableMain.setRowSelectionInterval(i, i);
            // Rectangle rect = TableMain.getCellRect(i, 0, true);
            // TableMain.scrollRectToVisible(rect);
            // //Refresh the marker position on the map
            // RefreshCurrentPosMarker(Track.data.get(i).getLatitude(),
            // Track.data.get(i).getLongitude());
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
        }
    });
    add(ChartPanelSpeedSlope, java.awt.BorderLayout.CENTER);
}
Also used : BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) ChartPanel(org.jfree.chart.ChartPanel) GridBagLayout(java.awt.GridBagLayout) Crosshair(org.jfree.chart.plot.Crosshair) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) ChartMouseListener(org.jfree.chart.ChartMouseListener) XYItemEntity(org.jfree.chart.entity.XYItemEntity) JLabel(javax.swing.JLabel) CrosshairOverlay(org.jfree.chart.panel.CrosshairOverlay) XYDataset(org.jfree.data.xy.XYDataset) ChartEntity(org.jfree.chart.entity.ChartEntity) JPanel(javax.swing.JPanel)

Example 52 with ChartPanel

use of org.jfree.chart.ChartPanel in project Course_Generator by patrovite.

the class JPanelAnalysisTimeDist method initComponents.

private void initComponents() {
    setLayout(new java.awt.BorderLayout());
    // -- Bottom - Info
    jPanelTimeDistInfo = new javax.swing.JPanel();
    jPanelTimeDistInfo.setOpaque(true);
    jPanelTimeDistInfo.setBackground(Color.WHITE);
    jPanelTimeDistInfo.setLayout(new GridBagLayout());
    add(jPanelTimeDistInfo, java.awt.BorderLayout.SOUTH);
    // -- Distance/Elevation/Time/Hour/Slope
    lbTimeDistInfoDistance = new javax.swing.JLabel();
    lbTimeDistInfoDistance.setOpaque(true);
    lbTimeDistInfoDistance.setBackground(Color.WHITE);
    lbTimeDistInfoDistance.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistInfoDistance.text") + "=0.000km ");
    lbTimeDistInfoDistance.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelTimeDistInfo, lbTimeDistInfoDistance, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // -- Elevation
    lbTimeDistInfoElevation = new javax.swing.JLabel();
    lbTimeDistInfoElevation.setOpaque(true);
    lbTimeDistInfoElevation.setBackground(Color.WHITE);
    lbTimeDistInfoElevation.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistInfoElevation.text") + "=0m ");
    lbTimeDistInfoElevation.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelTimeDistInfo, lbTimeDistInfoElevation, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // -- Time
    lbTimeDistInfoTime = new javax.swing.JLabel();
    lbTimeDistInfoTime.setOpaque(true);
    lbTimeDistInfoTime.setBackground(Color.WHITE);
    lbTimeDistInfoTime.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistInfoTime.text") + "=00:00:00 ");
    lbTimeDistInfoTime.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelTimeDistInfo, lbTimeDistInfoTime, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // -- Hour
    lbTimeDistInfoHour = new javax.swing.JLabel();
    lbTimeDistInfoHour.setOpaque(true);
    lbTimeDistInfoHour.setBackground(Color.WHITE);
    lbTimeDistInfoHour.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistInfoHour.text") + "=00:00:00 ");
    lbTimeDistInfoHour.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelTimeDistInfo, lbTimeDistInfoHour, 3, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH);
    // -- Slope
    lbTimeDistSlope = new javax.swing.JLabel();
    lbTimeDistSlope.setOpaque(true);
    lbTimeDistSlope.setBackground(Color.WHITE);
    lbTimeDistSlope.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistSlope.text") + "=0.0% ");
    lbTimeDistSlope.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelTimeDistInfo, lbTimeDistSlope, 4, 0, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL);
    // -- Chart Time/Dist
    ChartPanelTimeDist = new ChartPanel(chart, true, /*Properties*/
    true, /*save*/
    true, /*print*/
    false, /*zoom*/
    true);
    ChartPanelTimeDist.setDomainZoomable(false);
    ChartPanelTimeDist.setRangeZoomable(false);
    CrosshairOverlay crosshairOverlay = new CrosshairOverlay();
    xCrosshair = new Crosshair(Double.NaN, Color.RED, new BasicStroke(0f));
    xCrosshair.setLabelBackgroundPaint(Color.WHITE);
    crosshairOverlay.addDomainCrosshair(xCrosshair);
    ChartPanelTimeDist.addOverlay(crosshairOverlay);
    ChartPanelTimeDist.setBackground(new java.awt.Color(255, 0, 51));
    ChartPanelTimeDist.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            ChartEntity chartentity = event.getEntity();
            if (chartentity instanceof XYItemEntity) {
                XYItemEntity e = (XYItemEntity) chartentity;
                XYDataset d = e.getDataset();
                int s = e.getSeriesIndex();
                int i = e.getItem();
                double x = d.getXValue(s, i);
                double y = d.getYValue(s, i);
                xCrosshair.setValue(x);
                RefreshInfo(i);
            // Refresh the position on the data grid
            // TableMain.setRowSelectionInterval(i, i);
            // Rectangle rect = TableMain.getCellRect(i, 0, true);
            // TableMain.scrollRectToVisible(rect);
            // Refresh the marker position on the map
            // RefreshCurrentPosMarker(Track.data.get(i).getLatitude(),
            // Track.data.get(i).getLongitude());
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
        }
    });
    add(ChartPanelTimeDist, java.awt.BorderLayout.CENTER);
}
Also used : BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) ChartPanel(org.jfree.chart.ChartPanel) GridBagLayout(java.awt.GridBagLayout) Crosshair(org.jfree.chart.plot.Crosshair) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) ChartMouseListener(org.jfree.chart.ChartMouseListener) XYItemEntity(org.jfree.chart.entity.XYItemEntity) JLabel(javax.swing.JLabel) CrosshairOverlay(org.jfree.chart.panel.CrosshairOverlay) XYDataset(org.jfree.data.xy.XYDataset) ChartEntity(org.jfree.chart.entity.ChartEntity) JPanel(javax.swing.JPanel)

Example 53 with ChartPanel

use of org.jfree.chart.ChartPanel in project Course_Generator by patrovite.

the class JPanelProfil method initComponents.

private void initComponents() {
    setPreferredSize(new java.awt.Dimension(677, 150));
    setLayout(new java.awt.BorderLayout());
    // -- Profil tool bar
    // ---------------------------------------------------
    Create_Profil_Toolbar();
    add(ToolBarProfil, java.awt.BorderLayout.WEST);
    // -- Profil chart
    // ------------------------------------------------------
    ChartPanelProfil = new ChartPanel(chartProfil);
    CrosshairOverlay crosshairOverlay = new CrosshairOverlay();
    xCrosshair = new Crosshair(Double.NaN, Color.RED, new BasicStroke(0f));
    // xCrosshair.setLabelVisible(true);
    xCrosshair.setLabelBackgroundPaint(Color.WHITE);
    yCrosshair = new Crosshair(Double.NaN, Color.RED, new BasicStroke(0f));
    // yCrosshair.setLabelVisible(true);
    yCrosshair.setLabelBackgroundPaint(Color.WHITE);
    crosshairOverlay.addDomainCrosshair(xCrosshair);
    crosshairOverlay.addRangeCrosshair(yCrosshair);
    ChartPanelProfil.addOverlay(crosshairOverlay);
    ChartPanelProfil.setBackground(new java.awt.Color(255, 0, 51));
    ChartPanelProfil.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            ChartEntity chartentity = event.getEntity();
            if (chartentity instanceof XYItemEntity) {
                XYItemEntity e = (XYItemEntity) chartentity;
                XYDataset d = e.getDataset();
                int s = e.getSeriesIndex();
                int i = e.getItem();
                double x = d.getXValue(s, i);
                double y = d.getYValue(s, i);
                xCrosshair.setValue(x);
                yCrosshair.setValue(y);
                RefreshProfilInfo(i);
                notifyProfilSelection();
                index = i;
            // //Refresh the position on the data grid
            // TableMain.setRowSelectionInterval(i, i);
            // Rectangle rect = TableMain.getCellRect(i, 0, true);
            // TableMain.scrollRectToVisible(rect);
            // //Refresh the marker position on the map
            // RefreshCurrentPosMarker(Track.data.get(i).getLatitude(), Track.data.get(i).getLongitude());
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
        }
    });
    add(ChartPanelProfil, java.awt.BorderLayout.CENTER);
    // -- Profil info bar
    // ---------------------------------------------------
    jPanelProfilInfo = new javax.swing.JPanel();
    jPanelProfilInfo.setLayout(new GridBagLayout());
    add(jPanelProfilInfo, java.awt.BorderLayout.SOUTH);
    // -- Line 0
    // -- Distance
    // ----------------------------------------------------------
    lbProfilDistance = new javax.swing.JLabel();
    lbProfilDistance.setOpaque(true);
    lbProfilDistance.setBackground(Color.WHITE);
    lbProfilDistance.setText(" " + bundle.getString("frmMain.lbProfilDistance.text") + "=0.000km ");
    lbProfilDistance.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilDistance, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH);
    // -- Time
    // --------------------------------------------------------------
    lbProfilTime = new javax.swing.JLabel();
    lbProfilTime.setOpaque(true);
    lbProfilTime.setBackground(Color.WHITE);
    lbProfilTime.setText(" " + bundle.getString("frmMain.lbProfilTime.text") + "=00:00:00 ");
    lbProfilTime.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilTime, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH);
    // -- Slope
    // -------------------------------------------------------------
    lbProfilSlope = new javax.swing.JLabel();
    lbProfilSlope.setOpaque(true);
    lbProfilSlope.setBackground(Color.WHITE);
    lbProfilSlope.setText(" " + bundle.getString("frmMain.lbProfilSlope.text") + "=0.0% ");
    lbProfilSlope.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilSlope, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH);
    // -- Name
    // --------------------------------------------------------------
    lbProfilName = new javax.swing.JLabel();
    lbProfilName.setOpaque(true);
    lbProfilName.setBackground(Color.WHITE);
    lbProfilName.setText(" " + bundle.getString("frmMain.lbProfilName.text") + "= ");
    lbProfilName.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilName, 3, 0, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH);
    // -- Line 1
    // -- Elevation
    // ---------------------------------------------------------
    lbProfilElevation = new javax.swing.JLabel();
    lbProfilElevation.setOpaque(true);
    lbProfilElevation.setBackground(Color.WHITE);
    lbProfilElevation.setText(" " + bundle.getString("frmMain.lbProfilElevation.text") + "=0m ");
    lbProfilElevation.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilElevation, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH);
    // -- Hour
    // --------------------------------------------------------------
    lbProfilHour = new javax.swing.JLabel();
    lbProfilHour.setOpaque(true);
    lbProfilHour.setBackground(Color.WHITE);
    lbProfilHour.setText(" " + bundle.getString("frmMain.lbProfilHour.text") + "=00:00:00 ");
    lbProfilHour.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilHour, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH);
    // -- Speed
    // -------------------------------------------------------------
    lbProfilSpeed = new javax.swing.JLabel();
    lbProfilSpeed.setOpaque(true);
    lbProfilSpeed.setBackground(Color.WHITE);
    lbProfilSpeed.setText(" " + bundle.getString("frmMain.lbProfilSpeed.text") + "=0.0km/h ");
    lbProfilSpeed.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilSpeed, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH);
    // -- Comment
    // -----------------------------------------------------------
    lbProfilComment = new javax.swing.JLabel();
    lbProfilComment.setOpaque(true);
    lbProfilComment.setBackground(Color.WHITE);
    lbProfilComment.setText(" " + bundle.getString("frmMain.lbProfilComment.text") + "= ");
    lbProfilComment.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(jPanelProfilInfo, lbProfilComment, 3, 1, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH);
// -- Distance / Time / Slope / Name
// -- Elevation / Hour / Speed / Comment
}
Also used : BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) ChartPanel(org.jfree.chart.ChartPanel) GridBagLayout(java.awt.GridBagLayout) Crosshair(org.jfree.chart.plot.Crosshair) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) ChartMouseListener(org.jfree.chart.ChartMouseListener) XYItemEntity(org.jfree.chart.entity.XYItemEntity) JLabel(javax.swing.JLabel) CrosshairOverlay(org.jfree.chart.panel.CrosshairOverlay) XYDataset(org.jfree.data.xy.XYDataset) ChartEntity(org.jfree.chart.entity.ChartEntity) JPanel(javax.swing.JPanel)

Example 54 with ChartPanel

use of org.jfree.chart.ChartPanel in project Course_Generator by patrovite.

the class frmEditCurve method initComponents.

/**
 * This method is called to initialize the form.
 */
private void initComponents() {
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(bundle.getString("frmEditCurve.title"));
    setPreferredSize(new Dimension(1200, 600));
    setAlwaysOnTop(true);
    setResizable(false);
    setType(java.awt.Window.Type.UTILITY);
    addWindowListener(new java.awt.event.WindowAdapter() {

        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });
    // -- Layout
    // ------------------------------------------------------------
    Container paneGlobal = getContentPane();
    paneGlobal.setLayout(new GridBagLayout());
    // -- Curves list
    ListCurves = new javax.swing.JList<>();
    model = new ParamListModel();
    ListCurves.setModel(model);
    ListCurves.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    ListCurves.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            SelectCurve();
        }
    });
    jScrollPaneCurves = new javax.swing.JScrollPane();
    jScrollPaneCurves.setViewportView(ListCurves);
    Utils.addComponent(paneGlobal, jScrollPaneCurves, 0, 0, 1, 4, 0.5, 1, 10, 10, 0, 0, GridBagConstraints.PAGE_START, GridBagConstraints.BOTH);
    // -- Curve management toolbar
    CreateCurvesToolbar();
    Utils.addComponent(paneGlobal, ToolBarAction, 1, 0, 1, 4, 0, 0, 10, 0, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    lbSelectedCurve = new javax.swing.JLabel();
    lbSelectedCurve.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    lbSelectedCurve.setText("Selected");
    lbSelectedCurve.setHorizontalAlignment(JLabel.LEFT);
    Utils.addComponent(paneGlobal, lbSelectedCurve, 2, 0, GridBagConstraints.REMAINDER, 1, 1, 0, 10, 0, 5, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // -- Curve name
    lbName = new javax.swing.JLabel();
    lbName.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    lbName.setText(" " + bundle.getString("frmEditCurve.lbName.text") + " ");
    Utils.addComponent(paneGlobal, lbName, 2, 1, 1, 1, 0, 0, 0, 0, 5, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    lbNameVal = new javax.swing.JLabel();
    lbNameVal.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(paneGlobal, lbNameVal, 3, 1, GridBagConstraints.REMAINDER, 1, 1, 0, 0, 5, 5, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    // -- Curve comment
    lbComment = new javax.swing.JLabel();
    lbComment.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    lbComment.setText(" " + bundle.getString("frmEditCurve.lbComment.text") + " ");
    Utils.addComponent(paneGlobal, lbComment, 2, 2, 1, 1, 0, 0, 0, 0, 5, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    tfComment = new JTextField();
    tfComment.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    Utils.addComponent(paneGlobal, tfComment, 3, 2, GridBagConstraints.REMAINDER, 1, 1, 0, 0, 5, 5, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.HORIZONTAL);
    // -- Point list
    TablePoints = new javax.swing.JTable();
    // new ParamPointsModel(param));
    TablePoints.setModel(tablemodel);
    TablePoints.getTableHeader().setReorderingAllowed(false);
    TablePoints.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
        // TableMainMouseClicked(evt);
        // TODO
        }
    });
    TablePoints.addKeyListener(new java.awt.event.KeyAdapter() {

        public void keyReleased(java.awt.event.KeyEvent evt) {
        // TableMainKeyReleased(evt);
        // TODO
        }
    });
    TablePoints.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent event) {
            btEditLine.setEnabled(TablePoints.getSelectedRow() > 0);
        }
    });
    jScrollPanePoint = new javax.swing.JScrollPane();
    jScrollPanePoint.setViewportView(TablePoints);
    Utils.addComponent(paneGlobal, jScrollPanePoint, 2, 3, 2, 1, 0.5, 0, 0, 0, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    // -- Edit toolbar
    CreateEditToolbar();
    Utils.addComponent(paneGlobal, ToolBarEdit, 4, 3, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    jPanelProfilChart = new ChartPanel(chart);
    Utils.addComponent(paneGlobal, jPanelProfilChart, 5, 3, 1, 1, 1, 0, 0, 0, 0, 10, GridBagConstraints.BASELINE_LEADING, GridBagConstraints.BOTH);
    CrosshairOverlay crosshairOverlay = new CrosshairOverlay();
    xCrosshair = new Crosshair(Double.NaN, Color.DARK_GRAY, new BasicStroke(0f));
    xCrosshair.setLabelVisible(true);
    xCrosshair.setLabelBackgroundPaint(Color.WHITE);
    yCrosshair = new Crosshair(Double.NaN, Color.DARK_GRAY, new BasicStroke(0f));
    yCrosshair.setLabelVisible(true);
    yCrosshair.setLabelBackgroundPaint(Color.WHITE);
    crosshairOverlay.addDomainCrosshair(xCrosshair);
    crosshairOverlay.addRangeCrosshair(yCrosshair);
    jPanelProfilChart.addOverlay(crosshairOverlay);
    jPanelProfilChart.setBackground(new java.awt.Color(255, 0, 51));
    jPanelProfilChart.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            ChartEntity chartentity = event.getEntity();
            if (chartentity instanceof XYItemEntity) {
                XYItemEntity e = (XYItemEntity) chartentity;
                XYDataset d = e.getDataset();
                int s = e.getSeriesIndex();
                int i = e.getItem();
                double x = d.getXValue(s, i);
                double y = d.getYValue(s, i);
                xCrosshair.setValue(x);
                yCrosshair.setValue(y);
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
        }
    });
    // == Bottom button
    // ===========================================================
    btOk = new javax.swing.JButton();
    btOk.setText(bundle.getString("Global.btOk.text"));
    btOk.setIcon(new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/valid.png")));
    btOk.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            RequestToClose();
        }
    });
    Utils.addComponent(paneGlobal, btOk, 0, 5, GridBagConstraints.REMAINDER, 1, 0, 0, 10, 0, 10, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE);
    // --
    pack();
    // -- Refresh the curve list
    RefreshCurveList();
    // -- Center the windows
    setLocationRelativeTo(null);
}
Also used : BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) ChartPanel(org.jfree.chart.ChartPanel) GridBagLayout(java.awt.GridBagLayout) Crosshair(org.jfree.chart.plot.Crosshair) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JTextField(javax.swing.JTextField) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) XYItemEntity(org.jfree.chart.entity.XYItemEntity) Container(java.awt.Container) CrosshairOverlay(org.jfree.chart.panel.CrosshairOverlay) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) WindowEvent(java.awt.event.WindowEvent) ListSelectionListener(javax.swing.event.ListSelectionListener) ChartMouseListener(org.jfree.chart.ChartMouseListener) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) JTable(javax.swing.JTable) XYDataset(org.jfree.data.xy.XYDataset) ChartEntity(org.jfree.chart.entity.ChartEntity)

Example 55 with ChartPanel

use of org.jfree.chart.ChartPanel in project Energieverbrauchssimulator by duschdas2.

the class Diagramm method erzeuge2.

public static void erzeuge2(String s) throws IOException {
    JFreeChart xylineChart = ChartFactory.createXYLineChart("Simulierter Haushalt", "Zeit in Minuten", "Verbrauch in Watt", erstelleDataset(s), PlotOrientation.VERTICAL, true, true, false);
    XYPlot plot = xylineChart.getXYPlot();
    plot.setBackgroundPaint(Color.black);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    // Erstellt das Frame zum abbilden des Graphen
    ChartFrame frame = new ChartFrame("Diagramm", xylineChart);
    frame.pack();
    frame.setVisible(true);
}
Also used : ChartFrame(org.jfree.chart.ChartFrame) ChartPanel(org.jfree.chart.ChartPanel) XYPlot(org.jfree.chart.plot.XYPlot) JFreeChart(org.jfree.chart.JFreeChart)

Aggregations

ChartPanel (org.jfree.chart.ChartPanel)66 JFreeChart (org.jfree.chart.JFreeChart)42 XYPlot (org.jfree.chart.plot.XYPlot)19 Color (java.awt.Color)16 Dimension (java.awt.Dimension)16 NumberAxis (org.jfree.chart.axis.NumberAxis)16 JPanel (javax.swing.JPanel)15 XYSeries (org.jfree.data.xy.XYSeries)14 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)14 XYDataset (org.jfree.data.xy.XYDataset)12 BasicStroke (java.awt.BasicStroke)11 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)11 DecimalFormat (java.text.DecimalFormat)7 JButton (javax.swing.JButton)7 JLabel (javax.swing.JLabel)7 StandardXYToolTipGenerator (org.jfree.chart.labels.StandardXYToolTipGenerator)7 DefaultFormBuilder (com.jgoodies.forms.builder.DefaultFormBuilder)6 FormLayout (com.jgoodies.forms.layout.FormLayout)6 Font (java.awt.Font)6 GridBagLayout (java.awt.GridBagLayout)6