Jplot2d...

cid019 Messages postés 237 Date d'inscription mercredi 2 juin 2004 Statut Membre Dernière intervention 11 juillet 2006 - 13 juil. 2004 à 09:02
sido722 Messages postés 6 Date d'inscription vendredi 9 juillet 2004 Statut Membre Dernière intervention 16 juillet 2004 - 13 juil. 2004 à 20:05
salut,

voila j'utilise la bibliotheque de Chapman pour tracer une courbe mais il ne me trace rien. Je comprends pas bien car j'ai repris l'exemple que j'ai trouvé et je l'ai adapté a ma facon

Dans mes tableaus en parametres j'ai regardé il y a bien des valeurs dedans.

import java.awt.*;
import javax.imageio.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import chapman.graphics.*;

//---------------------------------------------------------
// classe permettant de tracer un graphique sur une station
//---------------------------------------------------------
class graphique extends JPanel
{
private int n;
private JPlot2D jp2d;
private double[] x;
private double[] y;
private double[] y2;

public graphique(String[][] tRef, String[][] tFac)
{
setLayout(new BorderLayout());
setSize(400,400);
x = new double[tFac.length];
y = new double[tFac.length];
y2 = new double[tRef.length];
n = tFac.length;
for (int i = 0; i < tFac.length; i++)
{
x[i] = MenuPal.getFenetrePal().recodeDate(tFac[i][1]).getTime();
y[i] = new Double(tFac[i][0]).doubleValue();
System.out.println(x[i] + " " + y[i]);
}

jp2d = new JPlot2D(x,y,n);
jp2d.setPlotType(JPlot2D.MARKER_CIRCLE);
jp2d.setXLabel("Temps");
jp2d.setYLabel("Côte");

for (int i = 0; i < tRef.length; i++)
y2[i] = new Double(tRef[i][0]).doubleValue();
jp2d.addCurve(y2);

add(jp2d, BorderLayout.CENTER);
}
}

//------------------------------------------------------------
// classe permettant d'afficher les graphiques sur une station
//------------------------------------------------------------
class fenetreGraphique extends JInternalFrame implements ActionListener
{
private JButton btnImp;
private JComboBox cmbBassin;
private graphique graph;
private String[][] t1;
private String[][] t2;
private base b;
private JScrollPane scrollPane;
private JPanel temp;

public fenetreGraphique()
{
super("Graphique...", true, false ,false);
setSize(500,550);
b = MenuPal.bdd;

temp = (JPanel)this.getContentPane();
temp.setLayout(new BorderLayout());
JPanel jp = new JPanel();
jp.setLayout(new GridLayout(1,3,5,5));
cmbBassin = new JComboBox();

jp.add(new JLabel("Bassin :"));
jp.add(cmbBassin);
jp.add(new JLabel(""));
temp.add(jp, BorderLayout.NORTH);

JPanel jp2 = new JPanel();
jp2.setLayout(new FlowLayout());

BoutonAnnuler btnAnnuler = new BoutonAnnuler(this, "Fermer");
btnImp = new JButton("Imprimer");
jp2.add(btnAnnuler);
jp2.add(btnImp);

temp.add(jp2, BorderLayout.SOUTH);

String[][] tBassin = b.getBassin();
for (int i = 0; i < tBassin.length; i++)
{
cmbBassin.addItem(tBassin[i][0]);
}

cmbBassin.setSelectedIndex(-1);
cmbBassin.addActionListener(this);
}

public void actionPerformed(ActionEvent e)
{
if (e.getSource() == cmbBassin)
{
String[][] tStationBassin = b.getStationBassin((String)cmbBassin.getSelectedItem());
JPanel jp3 = new JPanel();
for (int i = 0; i < tStationBassin.length; i++)
{
t1 = b.getValCoteStation(tStationBassin[i][0]);
t2 = b.getMesureStation(tStationBassin[i][0]);

if ((t2.length > 0) && (t1.length > 0))
{
System.out.println(t1.length);
System.out.println(t2.length);
jp3.setLayout(new GridLayout(tStationBassin.length,0,5,5));
graph = new graphique(t1, t2);
temp.add(graph);
}
}
/*scrollPane = new JScrollPane(jp3,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
temp.add(scrollPane, BorderLayout.CENTER);*/
}
}
}

Serait-ce parce que les valeurs sont trop grandes?...
Merci

cid019

2 réponses

sido722 Messages postés 6 Date d'inscription vendredi 9 juillet 2004 Statut Membre Dernière intervention 16 juillet 2004
13 juil. 2004 à 20:03
ne pourrais tu pas mettre tout le programme, je vois pas la classe main, ca m'aiderais merci.
sido
0
sido722 Messages postés 6 Date d'inscription vendredi 9 juillet 2004 Statut Membre Dernière intervention 16 juillet 2004
13 juil. 2004 à 20:05
ne pourrais tu pas mettre le prog complet. merci
sido
0
Rejoignez-nous