Android Open Source - SpunkyCharts Opening View






From Project

Back to project page SpunkyCharts.

License

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.

Java Source Code

package com.jogden.spunkycharts;
/* /*from  w  ww  .  j  ava2  s  .c  o 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 android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.jogden.spunkycharts.InitActivity.InitButtonClicks;

/** Our opening design: a little heavy handed but gives us the 
 * ability to quickly tweak until we know what we want to keep */
public class OpeningView extends RelativeLayout 
{    
    @SuppressWarnings("serial")
    public static class DimensionsNotAvailableException 
        extends RuntimeException
    {}
    private OpeningView _this = this;
    private static Paint brush1 = 
        new Paint(Paint.ANTI_ALIAS_FLAG); // logo text
    private static Paint brush2 = 
        new Paint(Paint.ANTI_ALIAS_FLAG);  // main oval 
    private static int color1 = Color.BLUE;
    private static int color2 = Color.WHITE;
    static{
        brush1.setTextSize(40);
        brush1.setTextScaleX(1.75f);
        brush1.setTextSkewX(-.10f);
        brush1.setColor(color1);
        brush1.setStyle(Style.STROKE);
        brush1.setStrokeWidth(6);
        brush2.setColor(color1);    
    }    
    public OpeningView(Context context) 
        {
            super(context);     
            this.addView(
                new IntroDraw(this.getContext()),
                new ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT
                    )
                );
        }
    public class IntroDraw extends View 
    {
        private int _height = 0;
        private int _width = 0;
        private RectF oval1 = new RectF();
        private Path oval1Path1 = new Path();
        private WhiteCircleButton wcbStart =
            new WhiteCircleButton(
                this.getContext(), "START",true
                );
        private WhiteCircleButton wcbSttng =
            new WhiteCircleButton(
                this.getContext(), "SETTINGS",true
                );
        private WhiteCircleButton wcbAbout =
            new WhiteCircleButton(
                this.getContext(), "ABOUT",false
                );        
        private RelativeLayout.LayoutParams wcbStartLp = 
            new RelativeLayout.LayoutParams(0,0);
        private RelativeLayout.LayoutParams wcbSttngLp = 
                new RelativeLayout.LayoutParams(0,0);
        private RelativeLayout.LayoutParams wcbAboutLp = 
                new RelativeLayout.LayoutParams(0,0);
        private int START_ID = 99990;
        private int STTNG_ID = 99991;
        private int ABOUT_ID = 99992;
        public IntroDraw(Context context) 
            {
                super(context);  
            }
        public IntroDraw(Context context, AttributeSet attrs)
            {
                super(context,attrs);
            }
        public IntroDraw(
            Context context, AttributeSet attrs, int style
            ){
                super(context,attrs,style);
            }
        {            
            wcbStart.setId(START_ID);
            wcbSttng.setId(STTNG_ID);
            wcbAbout.setId(ABOUT_ID);
            wcbStart.setOnClickListener(
                new InitButtonClicks.Start()
                );
            wcbSttng.setOnClickListener(
                new InitButtonClicks.Settings()
                );
            wcbAbout.setOnClickListener(
                new InitButtonClicks.About()
                );        
            wcbStartLp.setMargins(2, 2, 2, 2);
            wcbSttngLp.setMargins(2,2,2,2);
            wcbAboutLp.setMargins(2,2,2,2);
            wcbStartLp.addRule(
                ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE
                );
            wcbStartLp.addRule(
                ALIGN_PARENT_RIGHT, RelativeLayout.TRUE
                );        
            wcbSttngLp.addRule(
                ALIGN_PARENT_RIGHT,RelativeLayout.TRUE
                );
            wcbSttngLp.addRule(ABOVE,START_ID);
            wcbAboutLp.addRule(
                ALIGN_PARENT_LEFT, RelativeLayout.TRUE
                );
            wcbAboutLp.addRule(
                ALIGN_PARENT_TOP, RelativeLayout.TRUE
                );    
        }        
        @Override
        protected void onMeasure(int wSpec, int hSpec )
        {
            super.onMeasure(wSpec, hSpec);
            this._width = MeasureSpec.getSize(wSpec);
            this._height = MeasureSpec.getSize(hSpec);
        }    
        
        @Override
        protected void onDraw(Canvas canvas)
        {
            super.onDraw(canvas);
            if(this._width == 0 || this._height == 0)
            {
                if((this._width = getMeasuredWidth()) == 0 || 
                    (this._height = getMeasuredHeight()) == 0)
                        throw new DimensionsNotAvailableException();
            }    
            int dimen = Math.min(
                (int)(this._width * .40),(int)( this._height * .40)
                );        
            oval1.left =     (int)(this._width*.05);
            oval1.top = (int)(this._height * .05);
            oval1.right = (int)(this._width*2);
            oval1.bottom = (int)(this._height*2);
            canvas.drawOval(oval1, brush2);
            oval1Path1.addArc(oval1,180, 90);    
            canvas.drawTextOnPath(
                "SPUNKY CHARTS",     oval1Path1, 250, -2, brush1
                );                
            wcbStartLp.width = wcbStartLp.height = dimen;
            wcbSttngLp.width = 
                wcbSttngLp.height = (int)(dimen * .75);
            wcbAboutLp.width = 
                wcbAboutLp.height = (int)(dimen * .75);        
            wcbAboutLp.leftMargin = 
                wcbAboutLp.topMargin = (int)(dimen * -.30);        
            wcbStart.setTextSize(dimen*.075f);
            wcbSttng.setTextSize(dimen*.075f);
            wcbAbout.setTextSize(dimen*.075f);
            if(_this.findViewById(START_ID) == null)            
                _this.addView(wcbStart,wcbStartLp);
            if( _this.findViewById(STTNG_ID) == null)
                _this.addView(wcbSttng,wcbSttngLp);
            if( _this.findViewById(ABOUT_ID) == null)
                _this.addView(wcbAbout,wcbAboutLp);        
        }
        
        public class WhiteCircleButton extends TextView
        {
            private int _width = 0;
            private int _height = 0;
            private Paint brush3 = 
                new Paint(Paint.ANTI_ALIAS_FLAG); // circles
            private  Paint brush4 = 
                new Paint(Paint.ANTI_ALIAS_FLAG); //circle text
            RectF innerOval1 = new RectF();        
            String text;
            boolean stndrd;
            public WhiteCircleButton(
                Context context, String text, boolean stndrd
                ){
                    super(context);                        
                    this.text = text;
                    this.setTag(text);    
                    brush3.setColor(color2);    
                    brush3.setTextScaleX(1.50f);                    
                    brush3.setStrokeWidth( brush3.getTextSize() / 10 );
                    brush3.setTextSize(20);
                    brush4.setColor(color1);
                    brush4.setTextScaleX(1.5f);                    
                    brush4.setStrokeWidth( brush3.getTextSize() / 10 );
                    brush4.setTextSize(20);
                    if( this.stndrd = stndrd){                                                    
                        brush4.setStyle(Style.STROKE);                    
                        brush4.setTextAlign(Align.LEFT);
                        brush3.setStyle(Style.FILL);
                    } else     {                    
                        brush3.setStyle(Style.STROKE);                    
                        brush3.setTextAlign(Align.RIGHT);
                        brush4.setStyle(Style.FILL);
                    }
                }
            @Override
            public void setTextSize(float size)
            {
                brush3.setTextSize(size);
                brush4.setTextSize(size);
                brush3.setStrokeWidth(size / 10 );
                brush4.setStrokeWidth( size / 10 );
            }            
            @Override
            protected void onMeasure(int wSpec, int hSpec )
            {
                super.onMeasure(wSpec, hSpec);
                _width = MeasureSpec.getSize(wSpec);
                _height = MeasureSpec.getSize(hSpec);
            }
            @Override
            protected void onDraw(Canvas canvas)
            {
                super.onDraw(canvas);
                if(_width == 0 || _height == 0){
                    if((_width = getMeasuredWidth()) == 0 || 
                        (_height = getMeasuredHeight()) == 0)
                            throw new DimensionsNotAvailableException();
                }
            //    float lAdj = .10f;
            //    float ovrLap = .50f;
                innerOval1.left = innerOval1.top = 0;
                innerOval1.right = _width;
                innerOval1.bottom = _height;            
                canvas.drawOval(innerOval1, stndrd ? brush3 : brush4);    
                canvas.drawText(
                    text, 
                //stndrd ? (_width*lAdj*ovrLap) : (_width*(1-(lAdj*ovrLap))),
                    stndrd ? 0 : _width,
                    stndrd ? _height/2 : _height*2/3, 
                    stndrd ? brush4 : brush3
                    );                        
                /*
                canvas.drawLine(
                    stndrd ? 0 : _width*(1-lAdj), 
                    stndrd ? _height/2f : _height*2/3, 
                    stndrd ? _width*lAdj : _width, 
                    stndrd ?_height/2f : _height*2/3, 
                    stndrd ? brush4 : brush3 
                    ); */
            
            }
        }
    }
}




Java Source Code List

com.jogden.spunkycharts.ApplicationPreferences.java
com.jogden.spunkycharts.BaseChartFragmentA.java
com.jogden.spunkycharts.ChartPanelSurfaceView.java
com.jogden.spunkycharts.DockingPanelActivity.java
com.jogden.spunkycharts.GlobalChartPreferences.java
com.jogden.spunkycharts.InitActivity.java
com.jogden.spunkycharts.MainApplication.java
com.jogden.spunkycharts.OpeningView.java
com.jogden.spunkycharts.animations.BaseAnimationA.java
com.jogden.spunkycharts.animations.BaseEntExAnimationA.java
com.jogden.spunkycharts.animations.BaseSelectAnimationA.java
com.jogden.spunkycharts.animations.HorizontalBulgeAnimation.java
com.jogden.spunkycharts.animations.HorizontalShakeAnimation.java
com.jogden.spunkycharts.animations.VerticalBulgeAnimation.java
com.jogden.spunkycharts.animations.VerticalShakeAnimation.java
com.jogden.spunkycharts.animations.WiggleAnimation.java
com.jogden.spunkycharts.data.DataClientLocalDebug.java
com.jogden.spunkycharts.data.DataContentService.java
com.jogden.spunkycharts.misc.BorderOverlay.java
com.jogden.spunkycharts.misc.ColorPaletteDialog.java
com.jogden.spunkycharts.misc.HideHorizontalLeftOverflowWrapper.java
com.jogden.spunkycharts.misc.OHLC.java
com.jogden.spunkycharts.misc.Pair.java
com.jogden.spunkycharts.misc.TextInput.java
com.jogden.spunkycharts.misc.Triple.java
com.jogden.spunkycharts.pricebyvolumechart.PriceByVolumeChartFragmentAdapter.java
com.jogden.spunkycharts.pricebyvolumechart.PriceByVolumeChartFragment.java
com.jogden.spunkycharts.pricebyvolumechart.PriceByVolumeChartPanel.java
com.jogden.spunkycharts.pricebyvolumechart.PriceByVolumeChartPreferences.java
com.jogden.spunkycharts.pricebyvolumechart.draw.DrawSemanticsA.java
com.jogden.spunkycharts.pricebyvolumechart.draw.DrawSemantics_SILO.java
com.jogden.spunkycharts.traditionalchart.InnerXAxis.java
com.jogden.spunkycharts.traditionalchart.TraditionalChartFragmentAdapter.java
com.jogden.spunkycharts.traditionalchart.TraditionalChartFragment.java
com.jogden.spunkycharts.traditionalchart.TraditionalChartPanel.java
com.jogden.spunkycharts.traditionalchart.TraditionalChartPreferences.java
com.jogden.spunkycharts.traditionalchart.XAxisTimeLabel.java
com.jogden.spunkycharts.traditionalchart.YAxisPriceLabel.java
com.jogden.spunkycharts.traditionalchart.draw.DrawSemanticsA_C.java
com.jogden.spunkycharts.traditionalchart.draw.DrawSemanticsA.java
com.jogden.spunkycharts.traditionalchart.draw.DrawSemantics_CANDLE.java
com.jogden.spunkycharts.traditionalchart.draw.DrawSemantics_LINE.java
com.jogden.spunkycharts.traditionalchart.draw.DrawSemantics_OC.java
com.jogden.spunkycharts.traditionalchart.draw.DrawSemantics_OHLC.java
com.jogden.spunkycharts.traditionalchart.draw.DrawSemantics_POINT.java
com.jogden.spunkycharts.traditionalchart.draw.DrawSemantics_SILO.java