@@ -27,10 +27,11 @@ public class GUIMain extends JPanel {
2727 private int labelPadding = 25 ;
2828 private Color lineColor = new Color (44 , 102 , 230 , 180 );
2929 private Color pointColor = new Color (100 , 100 , 100 , 180 );
30+ //private Color pointColor = new Color(44, 102, 230, 180);
3031 private Color gridColor = new Color (200 , 200 , 200 , 200 );
3132 private static final Stroke GRAPH_STROKE = new BasicStroke (2f );
32- private int pointWidth = 4 ;
33- private int numberYDivisions = 10 ;
33+ private int pointWidth = 2 ;
34+ private int numberYDivisions = 25 ;
3435 private List <Double > scores ;
3536
3637 public GUIMain (List <Double > scores ) {
@@ -45,7 +46,7 @@ protected void paintComponent(Graphics g) {
4546
4647 double xScale = ((double ) getWidth () - (2 * padding ) - labelPadding ) / (scores .size () - 1 );
4748 double yScale = ((double ) getHeight () - 2 * padding - labelPadding ) / (getMaxScore () - getMinScore ());
48-
49+
4950 List <Point > graphPoints = new ArrayList <>();
5051 for (int i = 0 ; i < scores .size (); i ++) {
5152 int x1 = (int ) (i * xScale + padding + labelPadding );
@@ -68,7 +69,7 @@ protected void paintComponent(Graphics g) {
6869 g2 .setColor (gridColor );
6970 g2 .drawLine (padding + labelPadding + 1 + pointWidth , y0 , getWidth () - padding , y1 );
7071 g2 .setColor (Color .BLACK );
71- String yLabel = ((int ) ((getMinScore () + (getMaxScore () - getMinScore ()) * ((i * 1 .0 ) / numberYDivisions )) * 100 )) / 100.0 + "" ;
72+ String yLabel = ((int ) ((getMinScore () + (getMaxScore () - getMinScore ()) * ((i * 10 .0 ) / numberYDivisions )) * 100f )) / 100.0 + "" ;
7273 FontMetrics metrics = g2 .getFontMetrics ();
7374 int labelWidth = metrics .stringWidth (yLabel );
7475 g2 .drawString (yLabel , x0 - labelWidth - 5 , y0 + (metrics .getHeight () / 2 ) - 3 );
@@ -131,15 +132,15 @@ private double getMinScore() {
131132 for (Double score : scores ) {
132133 minScore = Math .min (minScore , score );
133134 }
134- return minScore ;
135+ return minScore - ( minScore / 50 ) ;
135136 }
136137
137138 private double getMaxScore () {
138139 double maxScore = Double .MIN_VALUE ;
139140 for (Double score : scores ) {
140141 maxScore = Math .max (maxScore , score );
141142 }
142- return maxScore ;
143+ return maxScore + ( maxScore / 50 ) ;
143144 }
144145
145146 public void setScores (List <Double > scores ) {
@@ -153,11 +154,18 @@ public List<Double> getScores() {
153154 }
154155
155156 private static void createAndShowGui () {
156- Stock S_AAPL = new Stock ("AAPL " );
157+ Stock S_AAPL = new Stock ("EDIG " );
157158 S_AAPL .retrieve ();
158- ArrayList AAPL_A = S_AAPL .request ("CLOSE" , "2015-01-01" , "2017-05-16" );
159-
160- GUIMain mainPanel = new GUIMain (AAPL_A );
159+ ArrayList P = S_AAPL .request ("ADJ_CLOSE" , "2017-05-08" , "2017-11-08" );
160+ //ArrayList AAPL_A = S_AAPL.request("CLOSE", "2012-01-01", "2017-01-01");
161+
162+ SStat EDIG_S = new SStat (S_AAPL );
163+ ArrayList AL = EDIG_S .PercentageChange ("CLOSE" , 30 , "2012-01-01" , "2017-01-01" );
164+ ArrayList AL2 = EDIG_S .ReturnVariance ("CLOSE" , 30 , "2012-01-01" , "2017-01-01" );
165+ System .out .println (AL );
166+ System .out .println (AL2 );
167+
168+ GUIMain mainPanel = new GUIMain (P );
161169 mainPanel .setPreferredSize (new Dimension (800 , 600 ));
162170 JFrame frame = new JFrame ("DrawGraph" );
163171 frame .setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE );
0 commit comments