Search in sources :

Example 46 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project sensorreadout by onyxbits.

the class BarChart method drawBar.

/**
   * Draws a bar.
   * 
   * @param canvas the canvas
   * @param xMin the X axis minimum
   * @param yMin the Y axis minimum
   * @param xMax the X axis maximum
   * @param yMax the Y axis maximum
   * @param scale the scale index
   * @param seriesIndex the current series index
   * @param paint the paint
   */
private void drawBar(Canvas canvas, float xMin, float yMin, float xMax, float yMax, int scale, int seriesIndex, Paint paint) {
    // Fix negative bars issue in Android 4.2
    float temp;
    if (xMin > xMax) {
        temp = xMin;
        xMin = xMax;
        xMax = temp;
    }
    if (yMin > yMax) {
        temp = yMin;
        yMin = yMax;
        yMax = temp;
    }
    SimpleSeriesRenderer renderer = mRenderer.getSeriesRendererAt(seriesIndex);
    if (renderer.isGradientEnabled()) {
        float minY = (float) toScreenPoint(new double[] { 0, renderer.getGradientStopValue() }, scale)[1];
        float maxY = (float) toScreenPoint(new double[] { 0, renderer.getGradientStartValue() }, scale)[1];
        float gradientMinY = Math.max(minY, Math.min(yMin, yMax));
        float gradientMaxY = Math.min(maxY, Math.max(yMin, yMax));
        int gradientMinColor = renderer.getGradientStopColor();
        int gradientMaxColor = renderer.getGradientStartColor();
        int gradientStartColor = gradientMaxColor;
        int gradientStopColor = gradientMinColor;
        if (yMin < minY) {
            paint.setColor(gradientMinColor);
            canvas.drawRect(Math.round(xMin), Math.round(yMin), Math.round(xMax), Math.round(gradientMinY), paint);
        } else {
            gradientStopColor = getGradientPartialColor(gradientMinColor, gradientMaxColor, (maxY - gradientMinY) / (maxY - minY));
        }
        if (yMax > maxY) {
            paint.setColor(gradientMaxColor);
            canvas.drawRect(Math.round(xMin), Math.round(gradientMaxY), Math.round(xMax), Math.round(yMax), paint);
        } else {
            gradientStartColor = getGradientPartialColor(gradientMaxColor, gradientMinColor, (gradientMaxY - minY) / (maxY - minY));
        }
        GradientDrawable gradient = new GradientDrawable(Orientation.BOTTOM_TOP, new int[] { gradientStartColor, gradientStopColor });
        gradient.setBounds(Math.round(xMin), Math.round(gradientMinY), Math.round(xMax), Math.round(gradientMaxY));
        gradient.draw(canvas);
    } else {
        if (Math.abs(yMin - yMax) < 1) {
            if (yMin < yMax) {
                yMax = yMin + 1;
            } else {
                yMax = yMin - 1;
            }
        }
        canvas.drawRect(Math.round(xMin), Math.round(yMin), Math.round(xMax), Math.round(yMax), paint);
    }
}
Also used : SimpleSeriesRenderer(org.achartengine.renderer.SimpleSeriesRenderer) Paint(android.graphics.Paint) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 47 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project ETSMobile-Android2 by ApplETS.

the class TodayWidgetConfigureActivity method setUpOpacitySeekBar.

private void setUpOpacitySeekBar() {
    int mOpacitySeekBarColor = ContextCompat.getColor(this, R.color.ets_red_fonce);
    mOpacitySeekBar = (SeekBar) findViewById(R.id.opacity_seekbar);
    mOpacitySeekBar.setOnSeekBarChangeListener(mOpacityListener);
    mOpacitySeekBar.getProgressDrawable().setColorFilter(mOpacitySeekBarColor, PorterDuff.Mode.SRC_IN);
    if (android.os.Build.VERSION.SDK_INT < 16) {
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setShape(GradientDrawable.OVAL);
        gradientDrawable.setSize(50, 50);
        gradientDrawable.setColor(mOpacitySeekBarColor);
        mOpacitySeekBar.setThumb(gradientDrawable);
    } else {
        mOpacitySeekBar.getThumb().setColorFilter(mOpacitySeekBarColor, PorterDuff.Mode.SRC_IN);
    }
}
Also used : Paint(android.graphics.Paint) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 48 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project loading-dots by EyalBira.

the class LoadingDots method createDotView.

private View createDotView(Context context) {
    ImageView dot = new ImageView(context);
    dot.setImageResource(R.drawable.loading_dots_dot);
    ((GradientDrawable) dot.getDrawable()).setColor(mDotsColor);
    return dot;
}
Also used : ImageView(android.widget.ImageView) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 49 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project AStickyHeader by DWorkS.

the class PinnedSectionListView method initShadow.

// -- pinned section drawing methods
public void initShadow(boolean visible) {
    if (visible) {
        if (mShadowDrawable == null) {
            mShadowDrawable = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { Color.parseColor("#ffa0a0a0"), Color.parseColor("#50a0a0a0"), Color.parseColor("#00a0a0a0") });
            mShadowHeight = (int) (8 * getResources().getDisplayMetrics().density);
        }
    } else {
        if (mShadowDrawable != null) {
            mShadowDrawable = null;
            mShadowHeight = 0;
        }
    }
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 50 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project AStickyHeader by DWorkS.

the class PinnedSectionGridView method initShadow.

// -- pinned section drawing methods
public void initShadow(boolean visible) {
    if (visible) {
        if (mShadowDrawable == null) {
            mShadowDrawable = new GradientDrawable(Orientation.TOP_BOTTOM, new int[] { Color.parseColor("#ffa0a0a0"), Color.parseColor("#50a0a0a0"), Color.parseColor("#00a0a0a0") });
            mShadowHeight = (int) (8 * getResources().getDisplayMetrics().density);
        }
    } else {
        if (mShadowDrawable != null) {
            mShadowDrawable = null;
            mShadowHeight = 0;
        }
    }
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable)

Aggregations

GradientDrawable (android.graphics.drawable.GradientDrawable)169 Paint (android.graphics.Paint)19 Drawable (android.graphics.drawable.Drawable)19 StateListDrawable (android.graphics.drawable.StateListDrawable)19 View (android.view.View)19 SuppressLint (android.annotation.SuppressLint)18 TextView (android.widget.TextView)18 LayerDrawable (android.graphics.drawable.LayerDrawable)16 ImageView (android.widget.ImageView)14 LinearLayout (android.widget.LinearLayout)12 TypedArray (android.content.res.TypedArray)8 FrameLayout (android.widget.FrameLayout)6 TimeAnimator (android.animation.TimeAnimator)5 Typeface (android.graphics.Typeface)5 LayoutInflater (android.view.LayoutInflater)5 ViewGroup (android.view.ViewGroup)5 Attributes (com.cengalabs.flatui.Attributes)5 Resources (android.content.res.Resources)4 TextPaint (android.text.TextPaint)4 Button (android.widget.Button)4