Java - Ayuda Diagrama de intervalos con jfreechart

 
Vista:
sin imagen de perfil

Ayuda Diagrama de intervalos con jfreechart

Publicado por Andros (1 intervención) el 26/05/2015 00:00:51
Buenas tardes,

Por favor espero me puedan ayudar, nesecito realizar una grafica y lo mejor que he encontrado es jfreechart. El codigo que tengo me devuelve dos arreglos cada uno con diferentes valores los cuales me servirian como un intervalo, tengo el siguiente codigo pero al realizar la grafica me muestra unicamente el ultimo valor y no me genera los intervalos. La imagen del formulario se encuentra en el ultimo vinculo.

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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
public class planificador extends javax.swing.JFrame {
 
    JFreeChart Grafica;
    DefaultIntervalCategoryDataset ddatos = null;
 
 
 
    public planificador() {
 
        initComponents();
 
        txtoriginales.setVisible(true);
        txtordenados.setVisible(true);
        etnprocesos.setVisible(true);
        nprocesos.setVisible(true);
        etRafaga.setVisible(true);
        etordenados.setVisible(true);
        txtesta.setVisible(true);
        etpromedioespera.setVisible(true);
        promedioespera.setVisible(true);
        etiquetapromedioida.setVisible(true);
        promedioida.setVisible(true);
        b3.setVisible(true);
 
    }
    int co[];
    int p[];
    int co1[];
    int p1[];
    int vuelta[];
    int Rafaga[];
    int procesos_originales1[];
    int tamaño;
    int tamaño1;
    int c = 0;
    int temp = 0;
    int total = 0;
    float tiempo_espera, tiempo_ida;
 
    int av=0, ae=0;
 
    public void Prioridad(){
        tamaño=Integer.parseInt(nprocesos.getText());
        tamaño1=Integer.parseInt(nprocesos.getText());
 
        int p[] = new int[tamaño];
        int co[] = new int[tamaño];
        int p1[] = new int[tamaño];
        int co1[] = new int[tamaño];
        int es[] = new int[tamaño];
        int vuelta[] = new int[tamaño];
        int Rafaga[] = new int[tamaño];
        int procesos_originales1[] = new int[tamaño];
 
        for (int i = 0; i < tamaño; i++)
            Rafaga[i] = co[i] = p[i] = Integer.parseInt(JOptionPane.showInputDialog("Ingrese la prioridad del proceso por favor"));
 
        for (int i = 0; i < tamaño - 1; i++) {
            for (int j = i + 1; j < tamaño; j++) {
                if (p[i] > p[j]) {
                    temp = p[i];
                    p[i] = p[j];
                    p[j] = temp;
                }
            }
        }
 
        for (int i = 0; i < p.length; i++) {
                       txtoriginales.append("\nP[" + (i + 1) + "] : " + p[i] + "\t");
        }
 
        for (int i = 0; i < tamaño - 1; i++) {
            for (int j = i + 1; j < tamaño; j++) {
                if (co[i] > co[j]) {
                    temp = co[i];
                    co[i] = co[j];
                    co[j] = temp;
                }
            }
        }
 
 
        for (int a = 0; a < tamaño; a++) {
            procesos_originales1[a] = co1[a] = p1[a] = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el tiempo de ejecucion del proceso"
                  +" "+ (a + 1) ));
        }
 
        vuelta[0] = 0;
 
        for (int i = 1; i < tamaño; i++) {
            vuelta[i] = vuelta[i - 1] + co1[i - 1];
            total = total + vuelta[i]+ co1[i];
        }
 
        for (int i = 0; i < p1.length; i++) {
            es[i] = vuelta[i]+co1[i];
            tiempo_espera += vuelta[i];
            tiempo_ida += es[i];
        }
 
        for (int a = 0; a < p1.length; a++) {
            txtordenados.append("\nP[" + (a + 1) + "] : " + procesos_originales1[a] + "\t");
        }
 
        txtesta.append("\nProceso\tTamaño\tEspera\tRespuesta");
 
        for (int i = 0; i < p1.length; i++) {
            txtesta.append("\np[" + (i + 1) + "] \t   " + co1[i] + "\t   " +vuelta[i]+ "\t" + es[i]);
 
            final double[][] t = {{vuelta[i],}};
            final double[][] x = {{es[i],}};
            ddatos = new DefaultIntervalCategoryDataset(t, x);
            Grafica = ChartFactory.createBarChart("Diagrama de Gantt", null, null, ddatos, PlotOrientation.HORIZONTAL, true, true, false);
 
            av = vuelta[i];
            ae = es[i];
 
        }
 
        promedioespera.setText(""+(tiempo_espera / tamaño));
        promedioida.setText("" + (tiempo_ida / tamaño));
    }
 
 
private void b3ActionPerformed(java.awt.event.ActionEvent evt) {
Prioridad();
   }
 
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        ChartPanel Panel = new ChartPanel(Grafica);
        JFrame Ventana = new JFrame("GANTT");
        Ventana.getContentPane().add(Panel);
        Ventana.pack();
        Ventana.setVisible(true);
        Ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

Sin-titulo
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder