Salut à tous,
Je viens vous demander votre aide car j'aimerais s'avoir comment je pourrais dessiner un graphique dynamiquement. J'utilise la librairie JenSoftAPI.
Pour le moment je suis arriver à afficher mon graphique et à le rendre dynamique c'est a dire qu'il récupère bien les données reçu par mes capteurs. Mon problème est j'aimerais que cela ce fasse sur une base de temps (secondes, minute, heures) et que ma courbe grandisse en fonction de cela mais je n'arrive pas à la faire grandir plus d'une minute.

Code qui gère le dynamisme.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 
 public void run() {
        while (boucle) {
            try {
                // acceder au listener
                if (starter != null) {
                    Listener listener = starter.getListener();
 
                    // incrementer le compteur des x
                    listeX.add((double) cpt);
                    cpt++;
                    // stocker les y
                    listeCadence.add(Math.floor(listener.getCadence()));
 
                    //compteur axe des x
                    tabX = new double[listeX.size()];
                    int i = 0;
                    for (double d : listeX) {
                        tabX[i] = d;
                        i++;
                    }
 
                    //Cadence
                    tabYCadence = new double[listeCadence.size()];
                    int j = 0;
                    for (double c : listeCadence) {
                        tabYCadence[j] = c;
                        j++;
                    }
                    // acceder au graphique de l'ihm
                    amlxf = this.ihm.getAreaMultipleLineXFunction();
                    // parametrer l'axe des X et des Y
                    amlxf.setMaxY(200);
 
                    // calcul des axes x
                    if (cpt <= 60) {
                        amlxf.genererGraphique();
                        amlxf.setMaxX(axeSeconde);
                        amlxf.setxValues1(tabX);
                        amlxf.setyValues1(tabYCadence);
                        cptMinute++;
                    }
                    if (cptMinute == 60 && cpt <=60){                   
                        amlxf.genererGraphique();
                        amlxf.setMaxX(axeMinute);
                        amlxf.setxValues1(tabX);
                        amlxf.setyValues1(tabYCadence);
                    }
 
                    this.ihm.getjPanel1().repaint();
 
 
                }
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                Logger.getLogger(AfficheurCadence.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
 
    }
 
    public Starter getStarter() {
        return starter;
    }
 
    public void setStarter(Starter starter) {
        this.starter = starter;
    }
}

Code du graphique
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
 
@JenSoftView(background = DarkViewBackground.class, description = "Area with multiple lines based on line x function")
public class AreaMultipleLineXFunction extends View2D {
 
    // source functions
    //Cadence
    double[] xValues1 = {0};
    double[] yValues1 = {0};
    int i;
 
    int maxX=6;
    int maxY=100;
 
    public AreaMultipleLineXFunction() {
        super(50);
    }
 
    public void genererGraphique() {
        UserSourceFunction source1 = new UserSourceFunction.LineSource(xValues1, yValues1);
//x1, X2 y1, y2
        Window2D window = new Window2D.Linear(0, maxX, 0, maxY);
        registerWindow2D(window);
        window.setThemeColor(RosePalette.LEMONPEEL);
 
// device outline plug-in
        window.registerPlugin(new OutlinePlugin());
 
        Font font = new Font("lucida console", Font.PLAIN, 10);
 
// create modeled axis plug-in in south part
        AxisMetricsPlugin.ModeledMetrics southMetrics = new AxisMetricsPlugin.ModeledMetrics.S();
        window.registerPlugin(southMetrics);
        southMetrics.setMetricsFont(font);
        southMetrics.registerMetricsModels(MetricsModelRangeCollections.NanoGiga);
 
// create modeled axis plug-in in west part
        AxisMetricsPlugin.ModeledMetrics westMetrics = new AxisMetricsPlugin.ModeledMetrics.W();
        window.registerPlugin(westMetrics);
        westMetrics.setMetricsFont(font);
        westMetrics.registerMetricsModels(MetricsModelRangeCollections.NanoGiga);
 
// area functions plug-in
        AreaFunction areaPlugin = new FunctionPlugin.AreaFunction();
        window.registerPlugin(areaPlugin);
 
 
        Area area1 = new Area(source1);
        area1.setThemeColor(PetalPalette.GRAY);
        area1.setAreaDraw(new AreaDefaultDraw(Color.WHITE, new BasicStroke(1.5f), Color.WHITE, new BasicStroke(1.5f)));
        area1.setAreaFill(new AreaGradientFill());
        area1.setAreaBase(-3);
        areaPlugin.addFunction(area1);
 
 
// legend
        Legend legend = new Legend("Areas functions");
        legend.setLegendFill(new LegendGradientFill(Color.WHITE, JennyPalette.JENNY8));
        legend.setFont(InputFonts.getFont(InputFonts.NEUROPOL, 10));
        legend.setConstraints(new LegendConstraints(LegendPosition.East, 0.3f, LegendAlignment.Rigth));
        LegendPlugin legendPlugin = new LegendPlugin(legend);
        window.registerPlugin(legendPlugin);
 
// stripe
        MultiplierStripe stripePlugin = new StripePlugin.MultiplierStripe.H(0, 2.5);
        StripePalette bp = new StripePalette();
        bp.addPaint(new Color(255, 255, 255, 20));
        bp.addPaint(ColorPalette.alpha(FilPalette.GREEN4, 20));
        stripePlugin.setStripePalette(bp);
        window.registerPlugin(stripePlugin);
 
// grid
        MultiplierGrid gridLayout = new GridPlugin.MultiplierGrid(0, 2.5, GridOrientation.Horizontal);
        gridLayout.setGridColor(new Color(255, 255, 255, 60));
        window.registerPlugin(gridLayout);
 
        MultiplierGrid gridLayout2 = new GridPlugin.MultiplierGrid(0, 2.5, GridOrientation.Vertical);
        gridLayout2.setGridColor(new Color(255, 255, 255, 60));
        window.registerPlugin(gridLayout2);
 
// translate
        TranslatePlugin translatePlugin = new TranslatePlugin();
        translatePlugin.registerContext(new TranslateDefaultDeviceContext());
        window.registerPlugin(translatePlugin);
    }
 
    public double[] getxValues1() {
        return xValues1;
    }
 
    public void setxValues1(double[] xValues1) {
        this.xValues1 = xValues1;
    }
 
    public double[] getyValues1() {
        return yValues1;
    }
 
    public void setyValues1(double[] yValues1) {
        this.yValues1 = yValues1;
    }
 
    public int getMaxX() {
        return maxX;
    }
 
    public void setMaxX(int maxX) {
        this.maxX = maxX;
    }
 
    public int getMaxY() {
        return maxY;
    }
 
    public void setMaxY(int maxY) {
        this.maxY = maxY;
    }
}
Je vous remercie d'avance de l'aide que vous pouvez m'apporter
Cordialement
Christophe