private void yAxis ( Graphics g ) { // y-axis g . setColor ( Color . BLACK ) ; g . drawLine ( X_OFFSET_LEFT , calcY ( 0 ) , X_OFFSET_LEFT , Y_OFFSET_TOP ) ; // center horizontal line g . setColor ( new Color ( 220 , 220 , 220 ) ) ; g . drawLine ( X_OFFSET_LEFT , height / 2 + Y_OFFSET_TOP , getWidth ( ) , height / 2 + Y_OFFSET_TOP ) ; g . setColor ( Color . BLACK ) ; // y-achsis markers + labels DecimalFormat d = new DecimalFormat ( "0.00" ) ; double numLabels = Math . min ( Math . pow ( 2 , y_resolution ) , 32 ) ; /* * technically, this is numLabels-1, but as we're iterating 0 <= i <= * numLabels, we need the extra label. Also don't draw more than 32 * labels. */ for ( int i = 0 ; i <= numLabels ; i ++ ) { double fraction = i / numLabels ; double value = fraction * upper_y_value ; g . drawString ( d . format ( value ) , 1 , ( int ) ( ( 1 - fraction ) * height ) + Y_OFFSET_TOP + 5 ) ; g . drawLine ( X_OFFSET_LEFT - 5 , ( int ) ( ( 1 - fraction ) * height ) + Y_OFFSET_TOP , X_OFFSET_LEFT , ( int ) ( ( 1 - fraction ) * height ) + Y_OFFSET_TOP ) ; } }
Draws the y axis containing og the axis line the horizontal helping line and the labels .