@@ -16,8 +16,8 @@ public class Barras extends JPanel {
16
16
private final static int WIN_WIDTH = 1024 ;
17
17
private final static int WIN_HEIGHT = 1024 ;
18
18
private static int NUM_BARS = 32 ;
19
- private static int BAR_WIDTH = getWinWidth () / getNUM_BARS () ;
20
- private static int BAR_HEIGHT = getWinHeight () / getNUM_BARS () ;
19
+ static int BAR_WIDTH = WIN_WIDTH / NUM_BARS ;
20
+ static int BAR_HEIGHT = WIN_HEIGHT / NUM_BARS ;
21
21
private boolean marcarSepacaion = false ;
22
22
23
23
/**
@@ -32,8 +32,8 @@ public Barras() {
32
32
* Constructor de iniciar el array con numeros ordenados.
33
33
*/
34
34
public void barras () {
35
- Sorts .n = new int [getNUM_BARS () ];
36
- for (int i = 0 ; i < getNUM_BARS () ; i ++) {
35
+ Sorts .n = new int [NUM_BARS ];
36
+ for (int i = 0 ; i < NUM_BARS ; i ++) {
37
37
Sorts .n [i ] = i ;
38
38
}
39
39
}
@@ -45,8 +45,8 @@ public void barras() {
45
45
*/
46
46
public void shuffleArray () {
47
47
Random rng = new Random ();
48
- for (int i = 0 ; i < getNUM_BARS () ; i ++) {
49
- int swapWidthIndex = rng .nextInt (getNUM_BARS () - 1 );
48
+ for (int i = 0 ; i < NUM_BARS ; i ++) {
49
+ int swapWidthIndex = rng .nextInt (NUM_BARS - 1 );
50
50
int temp = Sorts .n [i ];
51
51
Sorts .n [i ] = Sorts .n [swapWidthIndex ];
52
52
Sorts .n [swapWidthIndex ] = temp ;
@@ -55,6 +55,8 @@ public void shuffleArray() {
55
55
}
56
56
}
57
57
58
+ public static int mismo ;
59
+
58
60
/**
59
61
* Pinta los componentes.
60
62
*
@@ -64,41 +66,45 @@ public void shuffleArray() {
64
66
public void paintComponent (Graphics g ) {
65
67
Graphics2D graphics = (Graphics2D ) g ;
66
68
super .paintComponent (graphics );
67
- graphics . setColor ( Color . WHITE );
69
+
68
70
int opcionGrafico = Main .getComboboxtiposgraficos ().getSelectedIndex ();
69
71
70
- for (int i = 0 ; i < getNUM_BARS (); i ++) {
72
+ for (int i = 0 ; i < NUM_BARS ; i ++) {
73
+ graphics .setColor (Color .WHITE );
74
+ // if (i == mismo) {
75
+ // graphics.setColor(Color.RED);
76
+ // }
71
77
comunes (i , graphics , opcionGrafico );
72
78
}
73
79
}
74
80
75
81
private void comunes (int i , Graphics2D graphics , int opcionGrafico ) {
76
82
int height = 0 , xBegin = 0 , yBegin = 0 ;
77
- height = (Sorts .n [i ] * getBAR_HEIGHT ()) + getBAR_HEIGHT () ;
78
- xBegin = i + (getBAR_WIDTH () - 1 ) * i ;
83
+ height = (Sorts .n [i ] * BAR_HEIGHT ) + BAR_HEIGHT ;
84
+ xBegin = i + (BAR_WIDTH - 1 ) * i ;
79
85
// --------------------------------------------------------------------------------------------
80
86
81
87
// SELECCION ENTRE EL ESTILO GRAFICO DE "ESCALERAS" Y "PIRAMIDE HORIZONTAL"
82
88
if (opcionGrafico == 1 ) { // GRAFICOS "Piramide horizontal"
83
89
// Al dividir entre 2 de divide el espacio entre las barras y los lados de la
84
90
// ventana.
85
- yBegin = (( getWinHeight () - height ) / 2 ) ;
91
+ yBegin = (WIN_HEIGHT - height ) / 2 ;
86
92
} else if (opcionGrafico != 1 ) { // GRAFICOS "Escalera"
87
- yBegin = (( getWinHeight () - height )) ;
93
+ yBegin = WIN_HEIGHT - height ;
88
94
}
89
95
// --------------------------------------------------------------------------------------------
90
96
91
97
// SELECCION ENTRE LOS DISTINTOS TIPOS DE ESTILOS GRAFICOS
92
98
if (opcionGrafico == 0 || opcionGrafico == 1 ) { // GRAFICOS "Escalera" Y "Piramide horizontal"
93
99
if (marcarSepacaion ) { // EFECTO GRAFICO CON EL CONTORNO BARRAS
94
- graphics .fill3DRect (xBegin , yBegin , getBAR_WIDTH () , height , true );
100
+ graphics .fill3DRect (xBegin , yBegin , BAR_WIDTH , height , true );
95
101
} else if (!marcarSepacaion ) { // EFECTO GRAFICO SIN EL CONTORNO BARRAS
96
- graphics .fillRect (xBegin , yBegin , getBAR_HEIGHT () , height );
102
+ graphics .fillRect (xBegin , yBegin , BAR_HEIGHT , height );
97
103
}
98
104
} else if (opcionGrafico == 2 ) { // GRAFICOS "Cuadrado"
99
- graphics .fillRect (xBegin , yBegin , getBAR_HEIGHT (), getBAR_HEIGHT () );
105
+ graphics .fillRect (xBegin , yBegin , BAR_HEIGHT , BAR_HEIGHT );
100
106
} else if (opcionGrafico == 3 ) { // GRAFICOS "Punto"
101
- graphics .fillOval (xBegin , yBegin , getBAR_HEIGHT (), getBAR_HEIGHT () );
107
+ graphics .fillOval (xBegin , yBegin , BAR_HEIGHT , BAR_HEIGHT );
102
108
}
103
109
}
104
110
@@ -109,7 +115,7 @@ private void comunes(int i, Graphics2D graphics, int opcionGrafico) {
109
115
*/
110
116
@ Override
111
117
public Dimension getPreferredSize () {
112
- return new Dimension (getWinWidth (), getWinHeight () );
118
+ return new Dimension (WIN_WIDTH , WIN_HEIGHT );
113
119
}
114
120
115
121
public static int getWinWidth () {
@@ -128,25 +134,25 @@ public static void setNUM_BARS(int nUM_BARS) {
128
134
NUM_BARS = nUM_BARS ;
129
135
}
130
136
131
- public static int getBAR_WIDTH () {
132
- return BAR_WIDTH ;
133
- }
137
+ // public static int getBAR_WIDTH() {
138
+ // return BAR_WIDTH;
139
+ // }
134
140
135
141
public static void setBAR_WIDTH (int bAR_WIDTH ) {
136
142
BAR_WIDTH = bAR_WIDTH ;
137
143
}
138
144
139
- public static int getBAR_HEIGHT () {
140
- return BAR_HEIGHT ;
141
- }
145
+ // public static int getBAR_HEIGHT() {
146
+ // return BAR_HEIGHT;
147
+ // }
142
148
143
149
public static void setBAR_HEIGHT (int bAR_HEIGHT ) {
144
150
BAR_HEIGHT = bAR_HEIGHT ;
145
151
}
146
152
147
- public boolean isMarcarSepacaion () {
148
- return marcarSepacaion ;
149
- }
153
+ // public boolean isMarcarSepacaion() {
154
+ // return marcarSepacaion;
155
+ // }
150
156
151
157
public void setMarcarSepacaion (boolean marcarSepacaion ) {
152
158
this .marcarSepacaion = marcarSepacaion ;
0 commit comments