elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a Git (Primera Parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Java
| | | |-+  Ayuda con Java Arduino y JFreechart
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda con Java Arduino y JFreechart  (Leído 3,878 veces)
milnac

Desconectado Desconectado

Mensajes: 4


Ver Perfil
Ayuda con Java Arduino y JFreechart
« en: 6 Diciembre 2013, 20:46 pm »

buenas tardes compañeros. segui un tutorial de visualizar la data de arduino en java en netbeans,,corregi todos los errores pero no me ejecuta nada

Les paso el codigo

Código:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package charts;

import Arduino.Arduino;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import java.awt.Window;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.Grafica;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;



/**
 *
 * @author
 */
public class Timer555 extends javax.swing.JFrame {

    Arduino Arduino = new Arduino();
    SerialPortEventListener evento;
    private JFreeChart Grafica;
//    private JFreeChart Graphic;
    
    public Timer555() {
        this.evento = new SerialPortEventListener () {
            public void serialEvent(SerialPortEvent spe){
                
            }
        };
        initComponents();
    
        try {
        Arduino.ArduinoRX("COM20", 2000, 9600, evento);
    } catch (Exception ex){
        Logger.getLogger(Window.class.getName()).log(Level.SEVERE,null, ex);
    }
    final XYSeries Serie = new XYSeries("Timer555");
    final XYSeriesCollection Coleccion = new XYSeriesCollection();
     JFreeChart Grafica;
    
        Serie.add(0,0);
             Coleccion.addSeries(Serie);
             Grafica = ChartFactory.createXYLineChart("Voltaje vs Frecuencia", "Voltaje", "Frecuencia", Coleccion,
                     PlotOrientation.VERTICAL, true, true, false);
    
    }    
              
            
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("Grafica");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(148, 148, 148)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(126, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(104, 104, 104)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(156, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
ChartPanel Panel = new ChartPanel(Grafica);
JFrame Ventana = new JFrame("JFreeChart");
Ventana.getContentPane().add(Panel);
Ventana.pack();
Ventana.setVisible(true);
Ventana.setDefaultCloseOperation(JFtame.EXIT_ON_CLOSE);
    }                                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Timer555.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Timer555.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Timer555.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Timer555.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Timer555().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                    
    private javax.swing.JButton jButton1;
    // End of variables declaration                  
}

Mi problema es en:

Código:
JFreeChart Grafica;
    
        Serie.add(0,0);
             Coleccion.addSeries(Serie);
             Grafica = ChartFactory.createXYLineChart("Voltaje vs Frecuencia", "Voltaje", "Frecuencia", Coleccion,
                     PlotOrientation.VERTICAL, true, true, false);

que queda sin ningun cambio en el compilador.

que es lo que le puede pasar??

Esperando su gran ayuda.

Gracias


« Última modificación: 6 Diciembre 2013, 20:48 pm por milnac » En línea

milnac

Desconectado Desconectado

Mensajes: 4


Ver Perfil
Re: Ayuda con Java Arduino y JFreechart
« Respuesta #1 en: 6 Diciembre 2013, 20:54 pm »

el tutorial lo saque de:

http://panamahitek.com/graficas-de-sensores-en-tiempo-real-con-arduino-java-y-jfreechart/


En línea

egyware


Desconectado Desconectado

Mensajes: 526



Ver Perfil WWW
Re: Ayuda con Java Arduino y JFreechart
« Respuesta #2 en: 6 Diciembre 2013, 20:56 pm »

No veo en ninguna parte que estés guardando los valores a la colección, así que está bien que no te muestre nada.

PS: mira.. a esto me refiero.

Código
  1. this.evento = new SerialPortEventListener () {
  2.     public void serialEvent(SerialPortEvent spe){
  3.        // ??? Deberia ir algo acá ???
  4.     }
  5. };
  6.  
« Última modificación: 6 Diciembre 2013, 20:59 pm por egyware » En línea

milnac

Desconectado Desconectado

Mensajes: 4


Ver Perfil
Re: Ayuda con Java Arduino y JFreechart
« Respuesta #3 en: 7 Diciembre 2013, 03:40 am »

Gracias egyware.

Mira, el tuto no manda nada en esa linea para poder guardar.

Dime, como haria para poder guardar esos elementos que me pide?? Y es que primera vez que trabajo en java y defrente con este proyecto.  :-(
En línea

milnac

Desconectado Desconectado

Mensajes: 4


Ver Perfil
Re: Ayuda con Java Arduino y JFreechart
« Respuesta #4 en: 7 Diciembre 2013, 03:58 am »

mencion aparte, en
Código:
 final XYSeries Serie = new XYSeries("Timer555");
    final XYSeriesCollection Coleccion = new XYSeriesCollection();
     JFreeChart Grafica;
   
        Serie.add(0,0);
             Coleccion.addSeries(Serie);
             Grafica = ChartFactory.createXYLineChart("Voltaje vs Frecuencia", "Voltaje", "Frecuencia", Coleccion,
                     PlotOrientation.VERTICAL, true, true, false);

En "Grafica", me dice que variable "Grafica" no esta usado o no se esta usando.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
JFREECHART JAVA
Java
Acid-Zord 0 2,441 Último mensaje 25 Junio 2005, 04:26 am
por Acid-Zord
Ayuda: Arduino + java
Electrónica
carepapa 1 5,002 Último mensaje 29 Noviembre 2011, 03:59 am
por carepapa
〔AYUDA 〕 Programacion en Java relacionada con Arduino
Programación General
ReaGz 7 4,646 Último mensaje 28 Octubre 2014, 05:45 am
por ReaGz
Arduino y Java
Electrónica
MrSpock 1 2,628 Último mensaje 22 Diciembre 2015, 22:46 pm
por Meta
Java en Arduino
Programación General
jitoxsup2 1 2,309 Último mensaje 30 Mayo 2016, 09:43 am
por Minusfour_cierralo_o_baneamefull
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines