Back to project page SpunkyCharts.
The source code is released under:
GNU General Public License
If you think the Android project SpunkyCharts listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.jogden.spunkycharts.traditionalchart; /* /*from www . ja va 2 s .co m*/ Copyright (C) 2014 Jonathon Ogden < jeog.dev@gmail.com > This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses. */ import com.jogden.spunkycharts.ApplicationPreferences; import com.jogden.spunkycharts.BaseChartFragmentA; import com.jogden.spunkycharts.MainApplication; import com.jogden.spunkycharts.R; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.util.AttributeSet; import android.view.View; /** View that goes just above the X time axis of traditional * charts to provide the minor axis marks*/ class InnerXAxis extends View { static private int minorMark = ApplicationPreferences.getAxisMarkLength(); private int _segWidth = ApplicationPreferences.getSegmentWidth(); private int _height = 0; private int _width = 0; public InnerXAxis(Context context) { super(context); } public InnerXAxis(Context context, AttributeSet attrs) { super(context,attrs); TypedArray ta = context.obtainStyledAttributes( attrs, R.styleable.CustomSpunky ); _segWidth = (int)ta.getDimension( R.styleable.CustomSpunky_seg_width, ApplicationPreferences.getSegmentWidth() ); ta.recycle(); } public InnerXAxis(Context context, AttributeSet attrs, int steez) { super(context,attrs,steez); TypedArray ta = context.obtainStyledAttributes( attrs, R.styleable.CustomSpunky, steez, 0 ); _segWidth = (int)ta.getDimension( R.styleable.CustomSpunky_seg_width, ApplicationPreferences.getSegmentWidth() ); ta.recycle(); } public void setSegmentWidth(int w) { if( w > 0){ _segWidth = w; try{ this.invalidate(); }catch(Exception e ){ this.postInvalidate(); } } } public int getSegmentWidth() { return _segWidth; } static public void setMinorMark(int mark) { minorMark = mark; } @Override protected void onMeasure(int wMSpec, int hMSpec) { super.onMeasure(wMSpec,hMSpec); _height = MeasureSpec.getSize(hMSpec); _width = MeasureSpec.getSize(wMSpec); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if(TraditionalChartFragment.minorMarkFlag){ float pos = this.getPaddingRight() + ((float)_segWidth / 2); if( _segWidth > 0) while( pos < _width ){ canvas.drawLine( (float)_width- pos, _height, (float)_width-pos, _height - minorMark, TraditionalChartFragment.axisMarkBrush ); pos += _segWidth; } } } }