Example usage for android.graphics Color argb

List of usage examples for android.graphics Color argb

Introduction

In this page you can find the example usage for android.graphics Color argb.

Prototype

@ColorInt
public static int argb(float alpha, float red, float green, float blue) 

Source Link

Document

Return a color-int from alpha, red, green, blue float components in the range \([0..1]\).

Usage

From source file:cn.wander.Utils.views.pageindicator.TabPageIndicator.java

private int getMiddleColor(int preColor, int curColor, float factor) {
    if (preColor == curColor) {
        return curColor;
    }//ww w .  j a  va  2s .co  m
    if (0f == factor) {
        return preColor;
    } else if (1f == factor) {
        return curColor;
    }
    int a = getMiddleValue(Color.alpha(preColor), Color.alpha(curColor), factor);
    int r = getMiddleValue(Color.red(preColor), Color.red(curColor), factor);
    int g = getMiddleValue(Color.green(preColor), Color.green(curColor), factor);
    int b = getMiddleValue(Color.blue(preColor), Color.blue(curColor), factor);
    return Color.argb(a, r, g, b);
}

From source file:org.florescu.android.rangeseekbar.RangeSeekBar.java

private void init(Context context, AttributeSet attrs) {
    float barHeight;
    int thumbNormal = R.drawable.seek_thumb;
    int thumbPressed = R.drawable.seek_thumb_pressed;
    int thumbDisabled = R.drawable.seek_thumb_disabled;
    int thumbShadowColor;
    int defaultShadowColor = Color.argb(75, 0, 0, 0);
    int defaultShadowYOffset = PixelUtil.dpToPx(context, 2);
    int defaultShadowXOffset = PixelUtil.dpToPx(context, 0);
    int defaultShadowBlur = PixelUtil.dpToPx(context, 2);

    offset = PixelUtil.dpToPx(context, TEXT_LATERAL_PADDING_IN_DP);
    textSeperation = PixelUtil.dpToPx(context, DEFAULT_TEXT_SEPERATION_IN_DP);
    step = DEFAULT_STEP;//w  ww .  j  ava 2  s.co  m
    snapTolerance = DEFAULT_SNAP_TOLERANCE_PERCENT / 100;
    minimumDistance = DEFAULT_MINIMUM_DISTANCE;
    increments = DEFAULT_INCREMENTS;
    incrementRanges = DEFAULT_INCREMENT_RANGES;

    if (attrs == null) {
        rangeType = DEFAULT_RANGE_TYPE;
        setRangeToDefaultValues();
        mInternalPad = PixelUtil.dpToPx(context, INITIAL_PADDING_IN_DP);
        barHeight = PixelUtil.dpToPx(context, LINE_HEIGHT_IN_DP);
        mActiveColor = ACTIVE_COLOR;
        mDefaultColor = Color.parseColor("#e5e8eb");
        mAlwaysActive = true;
        mShowTextAboveThumbs = true;
        mTextAboveThumbsColor = Color.WHITE;
        thumbShadowColor = defaultShadowColor;
        mThumbShadowXOffset = defaultShadowXOffset;
        mThumbShadowYOffset = defaultShadowYOffset;
        mThumbShadowBlur = defaultShadowBlur;
        mActivateOnDefaultValues = true;
    } else {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.RangeSeekBar, 0, 0);
        try {
            switch (a.getInt(R.styleable.RangeSeekBar_rangeType, 0)) {
            case 0:
                rangeType = RangeType.LINEAR;
                break;
            case 1:
                rangeType = RangeType.PREDEFINED;
                break;
            case 2:
                rangeType = RangeType.CUBIC;
                break;
            default:
                rangeType = RangeType.LINEAR;
            }
            setRangeValues(
                    extractNumericValueFromAttributes(a, R.styleable.RangeSeekBar_absoluteMinValue,
                            DEFAULT_MINIMUM),
                    extractNumericValueFromAttributes(a, R.styleable.RangeSeekBar_absoluteMaxValue,
                            DEFAULT_MAXIMUM));
            mShowTextAboveThumbs = a.getBoolean(R.styleable.RangeSeekBar_valuesAboveThumbs, true);
            mTextAboveThumbsColor = a.getColor(R.styleable.RangeSeekBar_textAboveThumbsColor, Color.WHITE);
            mSingleThumb = a.getBoolean(R.styleable.RangeSeekBar_singleThumb, false);
            mShowLabels = a.getBoolean(R.styleable.RangeSeekBar_showLabels, true);
            mInternalPad = PixelUtil.dpToPx(context,
                    a.getInt(R.styleable.RangeSeekBar_internalPadding, INITIAL_PADDING_IN_DP));
            barHeight = PixelUtil.dpToPx(context,
                    a.getInt(R.styleable.RangeSeekBar_barHeight, LINE_HEIGHT_IN_DP));
            mActiveColor = a.getColor(R.styleable.RangeSeekBar_activeColor, ACTIVE_COLOR);
            mDefaultColor = a.getColor(R.styleable.RangeSeekBar_defaultColor, Color.parseColor("#e5e8eb"));
            mAlwaysActive = a.getBoolean(R.styleable.RangeSeekBar_alwaysActive, true);
            customMinValueLabel = a.getString(R.styleable.RangeSeekBar_minValueLabel);
            customMaxValueLabel = a.getString(R.styleable.RangeSeekBar_maxValueLabel);

            Drawable normalDrawable = a.getDrawable(R.styleable.RangeSeekBar_thumbNormal);
            if (normalDrawable != null) {
                thumbImage = BitmapUtil.drawableToBitmap(normalDrawable);
            }
            Drawable disabledDrawable = a.getDrawable(R.styleable.RangeSeekBar_thumbDisabled);
            if (disabledDrawable != null) {
                thumbDisabledImage = BitmapUtil.drawableToBitmap(disabledDrawable);
            }
            Drawable pressedDrawable = a.getDrawable(R.styleable.RangeSeekBar_thumbPressed);
            if (pressedDrawable != null) {
                thumbPressedImage = BitmapUtil.drawableToBitmap(pressedDrawable);
            }
            mThumbShadow = a.getBoolean(R.styleable.RangeSeekBar_thumbShadow, false);
            thumbShadowColor = a.getColor(R.styleable.RangeSeekBar_thumbShadowColor, defaultShadowColor);
            mThumbShadowXOffset = a.getDimensionPixelSize(R.styleable.RangeSeekBar_thumbShadowXOffset,
                    defaultShadowXOffset);
            mThumbShadowYOffset = a.getDimensionPixelSize(R.styleable.RangeSeekBar_thumbShadowYOffset,
                    defaultShadowYOffset);
            mThumbShadowBlur = a.getDimensionPixelSize(R.styleable.RangeSeekBar_thumbShadowBlur,
                    defaultShadowBlur);

            mActivateOnDefaultValues = a.getBoolean(R.styleable.RangeSeekBar_activateOnDefaultValues, true);
        } finally {
            a.recycle();
        }
    }

    Resources resources = getResources();
    int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 18, resources.getDisplayMetrics());

    if (thumbImage == null) {
        thumbImage = Bitmap.createBitmap(px, px, Bitmap.Config.ARGB_8888);
        Drawable thumbDrawableNormal = getResources().getDrawable(thumbNormal);
        thumbDrawableNormal.setBounds(0, 0, px, px);
        thumbDrawableNormal.draw(new Canvas(thumbImage));
    }
    if (thumbPressedImage == null) {
        Drawable thumbDrawablePressed = getResources().getDrawable(thumbPressed);
        thumbDrawablePressed.setBounds(0, 0, px, px);
        thumbPressedImage = Bitmap.createBitmap(px, px, Bitmap.Config.ARGB_8888);
        thumbDrawablePressed.draw(new Canvas(thumbPressedImage));
    }
    if (thumbDisabledImage == null) {
        Drawable thumbDrawableDisabled = getResources().getDrawable(thumbDisabled);
        thumbDrawableDisabled.setBounds(0, 0, px, px);
        thumbDisabledImage = Bitmap.createBitmap(px, px, Bitmap.Config.ARGB_8888);
        thumbDrawableDisabled.draw(new Canvas(thumbDisabledImage));
    }

    mThumbHalfWidth = 0.5f * thumbImage.getWidth();
    mThumbHalfHeight = 0.5f * thumbImage.getHeight();

    setValuePrimAndNumberType();

    mTextSize = PixelUtil.spToPx(context, DEFAULT_TEXT_SIZE_IN_SP);
    mDistanceToTop = PixelUtil.dpToPx(context, DEFAULT_TEXT_DISTANCE_TO_TOP_IN_DP);
    mTextOffset = !mShowTextAboveThumbs ? 0
            : this.mTextSize + PixelUtil.dpToPx(context, DEFAULT_TEXT_DISTANCE_TO_BUTTON_IN_DP)
                    + this.mDistanceToTop;

    mRect = new RectF(padding, mTextOffset + mThumbHalfHeight - barHeight / 2, getWidth() - padding,
            mTextOffset + mThumbHalfHeight + barHeight / 2);

    // make RangeSeekBar focusable. This solves focus handling issues in case EditText widgets are being used along with the RangeSeekBar within ScrollViews.
    setFocusable(true);
    setFocusableInTouchMode(true);
    mScaledTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();

    if (mThumbShadow) {
        // We need to remove hardware acceleration in order to blur the shadow
        setLayerType(LAYER_TYPE_SOFTWARE, null);
        shadowPaint.setColor(thumbShadowColor);
        shadowPaint.setMaskFilter(new BlurMaskFilter(mThumbShadowBlur, BlurMaskFilter.Blur.NORMAL));
        mThumbShadowPath = new Path();
        mThumbShadowPath.addCircle(0, 0, mThumbHalfHeight, Path.Direction.CW);
    }
}

From source file:com.master.metehan.filtereagle.AdapterRule.java

public AdapterRule(Activity context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    this.context = context;
    this.filter = prefs.getBoolean("filter", false);

    if (prefs.getBoolean("dark_theme", false))
        colorChanged = Color.argb(128, Color.red(Color.DKGRAY), Color.green(Color.DKGRAY),
                Color.blue(Color.DKGRAY));
    else/*from  w w w  . ja  va  2s . c  om*/
        colorChanged = Color.argb(128, Color.red(Color.LTGRAY), Color.green(Color.LTGRAY),
                Color.blue(Color.LTGRAY));

    TypedArray ta = context.getTheme().obtainStyledAttributes(new int[] { android.R.attr.textColorSecondary });
    try {
        colorText = ta.getColor(0, 0);
    } finally {
        ta.recycle();
    }

    TypedValue tv = new TypedValue();
    context.getTheme().resolveAttribute(R.attr.colorOn, tv, true);
    colorOn = tv.data;
    context.getTheme().resolveAttribute(R.attr.colorOff, tv, true);
    colorOff = tv.data;

    colorGrayed = ContextCompat.getColor(context, R.color.colorGrayed);

    iconSize = Util.dips2pixels(48, context);
}

From source file:io.karim.MaterialTabs.java

public MaterialTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);/*from  www. j  a  v  a2  s  .co m*/
    setWillNotDraw(false);
    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // Get system attrs (android:textSize and android:textColor).
    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    tabTextSize = a.getDimensionPixelSize(TEXT_SIZE_INDEX, tabTextSize);
    int textPrimaryColor = a.getColor(TEXT_COLOR_PRIMARY, android.R.color.white);
    tabTextColorUnselected = a.getColor(TEXT_COLOR_INDEX, textPrimaryColor);

    underlineColor = textPrimaryColor;
    indicatorColor = textPrimaryColor;
    int padding = a.getDimensionPixelSize(PADDING_INDEX, 0);
    paddingLeft = padding > 0 ? padding : a.getDimensionPixelSize(PADDING_LEFT_INDEX, 0);
    paddingRight = padding > 0 ? padding : a.getDimensionPixelSize(PADDING_RIGHT_INDEX, 0);
    a.recycle();

    a = context.obtainStyledAttributes(attrs, R.styleable.MaterialTabs);

    // Get custom attrs of MaterialTabs.
    indicatorColor = a.getColor(R.styleable.MaterialTabs_mtIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.MaterialTabs_mtUnderlineColor, underlineColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.MaterialTabs_mtIndicatorHeight, indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.MaterialTabs_mtUnderlineHeight, underlineHeight);
    tabPadding = a.getDimensionPixelSize(R.styleable.MaterialTabs_mtTabPaddingLeftRight, tabPadding);
    sameWeightTabs = a.getBoolean(R.styleable.MaterialTabs_mtSameWeightTabs, sameWeightTabs);
    textAllCaps = a.getBoolean(R.styleable.MaterialTabs_mtTextAllCaps, textAllCaps);
    isPaddingMiddle = a.getBoolean(R.styleable.MaterialTabs_mtPaddingMiddle, isPaddingMiddle);
    tabTypefaceUnselectedStyle = a.getInt(R.styleable.MaterialTabs_mtTextUnselectedStyle, Typeface.BOLD);
    tabTypefaceSelectedStyle = a.getInt(R.styleable.MaterialTabs_mtTextSelectedStyle, Typeface.BOLD);
    tabTextColorSelected = a.getColor(R.styleable.MaterialTabs_mtTextColorSelected, textPrimaryColor);

    // Get custom attrs of MaterialRippleLayout.
    rippleColor = a.getColor(R.styleable.MaterialTabs_mtMrlRippleColor, MaterialRippleLayout.DEFAULT_COLOR);
    // Making default ripple highlight color the same as rippleColor but with 1/4 the alpha.
    rippleHighlightColor = Color.argb((int) (Color.alpha(rippleColor) * 0.25), Color.red(rippleColor),
            Color.green(rippleColor), Color.blue(rippleColor));
    rippleHighlightColor = a.getColor(R.styleable.MaterialTabs_mtMrlRippleHighlightColor, rippleHighlightColor);
    rippleDiameterDp = a.getDimension(R.styleable.MaterialTabs_mtMrlRippleDiameter,
            MaterialRippleLayout.DEFAULT_DIAMETER_DP);
    rippleOverlay = a.getBoolean(R.styleable.MaterialTabs_mtMrlRippleOverlay,
            MaterialRippleLayout.DEFAULT_RIPPLE_OVERLAY);
    rippleDuration = a.getInt(R.styleable.MaterialTabs_mtMrlRippleDuration,
            MaterialRippleLayout.DEFAULT_DURATION);
    rippleAlphaFloat = a.getFloat(R.styleable.MaterialTabs_mtMrlRippleAlpha,
            MaterialRippleLayout.DEFAULT_ALPHA);
    rippleDelayClick = a.getBoolean(R.styleable.MaterialTabs_mtMrlRippleDelayClick,
            MaterialRippleLayout.DEFAULT_DELAY_CLICK);
    rippleFadeDuration = a.getInteger(R.styleable.MaterialTabs_mtMrlRippleFadeDuration,
            MaterialRippleLayout.DEFAULT_FADE_DURATION);
    ripplePersistent = a.getBoolean(R.styleable.MaterialTabs_mtMrlRipplePersistent,
            MaterialRippleLayout.DEFAULT_PERSISTENT);
    rippleInAdapter = a.getBoolean(R.styleable.MaterialTabs_mtMrlRippleInAdapter,
            MaterialRippleLayout.DEFAULT_SEARCH_ADAPTER);
    rippleRoundedCornersDp = a.getDimension(R.styleable.MaterialTabs_mtMrlRippleRoundedCorners,
            MaterialRippleLayout.DEFAULT_ROUNDED_CORNERS_DP);

    a.recycle();

    setMarginBottomTabContainer();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.homechart.app.commont.matertab.MaterialTabs.java

public MaterialTabs(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setFillViewport(true);//  ww w.  ja  v a 2 s .  c o  m
    setWillNotDraw(false);
    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // Get system attrs (android:textSize and android:textColor).
    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    tabTextSize = a.getDimensionPixelSize(TEXT_COLOR_INDEX, tabTextSize);
    int textPrimaryColor = a.getColor(TEXT_COLOR_PRIMARY, 0);
    tabTextColorUnselected = a.getColor(TEXT_COLOR_INDEX, textPrimaryColor);

    underlineColor = textPrimaryColor;
    indicatorColor = textPrimaryColor;
    int padding = a.getDimensionPixelSize(PADDING_INDEX, 0);
    paddingLeft = padding > 0 ? padding : a.getDimensionPixelSize(PADDING_LEFT_INDEX, 0);
    paddingRight = padding > 0 ? padding : a.getDimensionPixelSize(PADDING_RIGHT_INDEX, 0);
    a.recycle();

    a = context.obtainStyledAttributes(attrs, R.styleable.MaterialTabs);

    // Get custom attrs of MaterialTabs.
    indicatorColor = a.getColor(R.styleable.MaterialTabs_mtIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.MaterialTabs_mtUnderlineColor, underlineColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.MaterialTabs_mtIndicatorHeight, indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.MaterialTabs_mtUnderlineHeight, underlineHeight);
    tabPadding = a.getDimensionPixelSize(R.styleable.MaterialTabs_mtTabPaddingLeftRight, tabPadding);
    sameWeightTabs = a.getBoolean(R.styleable.MaterialTabs_mtSameWeightTabs, sameWeightTabs);
    textAllCaps = a.getBoolean(R.styleable.MaterialTabs_mtTextAllCaps, textAllCaps);
    isPaddingMiddle = a.getBoolean(R.styleable.MaterialTabs_mtPaddingMiddle, isPaddingMiddle);
    tabTypefaceUnselectedStyle = a.getInt(R.styleable.MaterialTabs_mtTextUnselectedStyle, Typeface.BOLD);
    tabTypefaceSelectedStyle = a.getInt(R.styleable.MaterialTabs_mtTextSelectedStyle, Typeface.BOLD);
    tabTextColorSelected = a.getColor(R.styleable.MaterialTabs_mtTextColorSelected, textPrimaryColor);

    // Get custom attrs of MaterialRippleLayout.
    rippleColor = a.getColor(R.styleable.MaterialTabs_mtMrlRippleColor, MaterialRippleLayout.DEFAULT_COLOR);
    // Making default ripple highlight color the same as rippleColor but with 1/4 the alpha.
    rippleHighlightColor = Color.argb((int) (Color.alpha(rippleColor) * 0.25), Color.red(rippleColor),
            Color.green(rippleColor), Color.blue(rippleColor));
    rippleHighlightColor = a.getColor(R.styleable.MaterialTabs_mtMrlRippleHighlightColor, rippleHighlightColor);
    rippleDiameterDp = a.getDimension(R.styleable.MaterialTabs_mtMrlRippleDiameter,
            MaterialRippleLayout.DEFAULT_DIAMETER_DP);
    rippleOverlay = a.getBoolean(R.styleable.MaterialTabs_mtMrlRippleOverlay,
            MaterialRippleLayout.DEFAULT_RIPPLE_OVERLAY);
    rippleDuration = a.getInt(R.styleable.MaterialTabs_mtMrlRippleDuration,
            MaterialRippleLayout.DEFAULT_DURATION);
    rippleAlphaFloat = a.getFloat(R.styleable.MaterialTabs_mtMrlRippleAlpha,
            MaterialRippleLayout.DEFAULT_ALPHA);
    rippleDelayClick = a.getBoolean(R.styleable.MaterialTabs_mtMrlRippleDelayClick,
            MaterialRippleLayout.DEFAULT_DELAY_CLICK);
    rippleFadeDuration = a.getInteger(R.styleable.MaterialTabs_mtMrlRippleFadeDuration,
            MaterialRippleLayout.DEFAULT_FADE_DURATION);
    ripplePersistent = a.getBoolean(R.styleable.MaterialTabs_mtMrlRipplePersistent,
            MaterialRippleLayout.DEFAULT_PERSISTENT);
    rippleInAdapter = a.getBoolean(R.styleable.MaterialTabs_mtMrlRippleInAdapter,
            MaterialRippleLayout.DEFAULT_SEARCH_ADAPTER);
    rippleRoundedCornersDp = a.getDimension(R.styleable.MaterialTabs_mtMrlRippleRoundedCorners,
            MaterialRippleLayout.DEFAULT_ROUNDED_CORNERS_DP);

    a.recycle();

    setMarginBottomTabContainer();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:net.networksaremadeofstring.rhybudd.ZenossWidgetGraph.java

private Bitmap RenderBarGraph(int CritCount, int ErrCount, int WarnCount) {

    //Log.i("Counts", Integer.toString(CritCount) + " / " + Integer.toString(ErrCount) + " / " + Integer.toString(WarnCount));
    Bitmap emptyBmap = Bitmap.createBitmap(290, 150, Config.ARGB_8888);

    int width = emptyBmap.getWidth();
    int height = emptyBmap.getHeight();
    Bitmap charty = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(charty);
    //final int color = 0xff0B0B61; 
    final Paint paint = new Paint();

    paint.setStyle(Paint.Style.FILL);
    paint.setColor(Color.WHITE);//from   w  w  w  . j  a  va  2 s  .  c o  m

    //y
    canvas.drawLine(25, 0, 25, 289, paint);
    //x
    canvas.drawLine(25, 149, 289, 149, paint);

    paint.setAntiAlias(true);
    int Max = 0;

    if (CritCount > ErrCount && CritCount > WarnCount)
        Max = CritCount;
    else if (ErrCount > CritCount && ErrCount > WarnCount)
        Max = ErrCount;
    else if (WarnCount > CritCount && WarnCount > ErrCount)
        Max = WarnCount;
    else
        Max = CritCount;

    if (Max > 0)
        canvas.drawText(Integer.toString(Max), 0, 10, paint);

    if (Max > 1)
        canvas.drawText(Integer.toString(Max / 2), 0, 75, paint);

    canvas.drawText("0", 0, 148, paint);

    double divisor = 148 / (double) Max;

    paint.setAlpha(128);

    Rect rect = new Rect(32, (int) (148 - (divisor * CritCount)), 64, 148);
    paint.setColor(Color.argb(200, 208, 0, 0)); //red

    if (CritCount > 0)
        canvas.drawRect(new RectF(rect), paint);

    rect = new Rect(128, (int) (148 - (divisor * ErrCount)), 160, 148);
    paint.setColor(Color.argb(200, 255, 102, 0));//orange

    if (ErrCount > 0)
        canvas.drawRect(new RectF(rect), paint);

    rect = new Rect(224, (int) (148 - (divisor * WarnCount)), 256, 148);
    paint.setColor(Color.argb(200, 255, 224, 57)); //yellow
    if (WarnCount > 0)
        canvas.drawRect(new RectF(rect), paint);

    //Return
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    charty.compress(CompressFormat.PNG, 50, out);

    return BitmapFactory.decodeByteArray(out.toByteArray(), 0, out.size());
}

From source file:org.deviceconnect.android.deviceplugin.hitoe.fragment.HitoeProfileECGFragment.java

/**
 * Build ECG Chart renderer./*from  www  .  ja  va2 s.  co  m*/
 * @return ecg chart renderer
 */
private XYMultipleSeriesRenderer buildRenderer() {

    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();

    for (int i = 0; i < DATA_COUNT; i++) {
        XYSeriesRenderer r = new XYSeriesRenderer();
        r.setColor(COLORS[i]);
        r.setLineWidth(4f);
        r.setPointStyle(PointStyle.CIRCLE);
        r.setFillPoints(true);
        r.setPointStrokeWidth(1f);
        renderer.addSeriesRenderer(r);
    }

    renderer.setPointSize(1f);
    renderer.setChartTitle("");
    renderer.setChartTitleTextSize(CHART_TITLE_SIZE);

    renderer.setXTitle("? [ms]");
    renderer.setYTitle("                [v]");

    renderer.setLabelsTextSize(LABELS_SIZE);
    renderer.setLabelsColor(TITLE_COLOR);
    renderer.setXLabelsAlign(Paint.Align.LEFT);
    renderer.setYLabelsAlign(Paint.Align.RIGHT);

    renderer.setXLabelsColor(XLABEL_COLOR);
    renderer.setYLabelsColor(0, YLABEL_COLOR);

    renderer.setAxisTitleTextSize(AXIS_TITLE_SIZE);
    renderer.setAxesColor(AXIS_COLOR);
    renderer.setXAxisMin(mMinX);
    renderer.setXAxisMax(mMaxX);
    renderer.setYAxisMin(-3.0);
    renderer.setYAxisMax(3.0);

    renderer.setShowGridX(true);
    renderer.setShowGridY(true);
    renderer.setGridColor(GRID_COLOR);

    renderer.setApplyBackgroundColor(true);
    renderer.setBackgroundColor(Color.BLACK);

    renderer.setMargins(new int[] { 16, 48, 16, 8 });
    renderer.setMarginsColor(Color.argb(0, 255, 255, 255));
    renderer.setPanEnabled(false, false);
    renderer.setShowLegend(true);
    renderer.setLegendTextSize(15);
    renderer.setFitLegend(false);

    renderer.setZoomButtonsVisible(false);
    renderer.setZoomEnabled(false, false);

    return renderer;
}

From source file:com.wanderingcan.floatingactionmenu.FloatingActionMenu.java

private void initBackgroundDimAnimation() {
    final int maxAlpha = Color.alpha(mBackgroundColor);
    final int red = Color.red(mBackgroundColor);
    final int green = Color.green(mBackgroundColor);
    final int blue = Color.blue(mBackgroundColor);

    mShowBackgroundAnimator = ValueAnimator.ofInt(0, maxAlpha);
    mShowBackgroundAnimator.setDuration(mAnimationDuration);
    mShowBackgroundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//  ww w. j  av a  2s .  c om
        public void onAnimationUpdate(ValueAnimator animation) {
            Integer alpha = (Integer) animation.getAnimatedValue();
            setBackgroundColor(Color.argb(alpha, red, green, blue));
        }
    });

    mHideBackgroundAnimator = ValueAnimator.ofInt(maxAlpha, 0);
    mHideBackgroundAnimator.setDuration(mAnimationDuration);
    mHideBackgroundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Integer alpha = (Integer) animation.getAnimatedValue();
            setBackgroundColor(Color.argb(alpha, red, green, blue));
        }
    });
}

From source file:org.protocoderrunner.apprunner.api.PUI.java

@ProtocoderScript
@APIMethod(description = "Changes the title bar color", example = "")
@APIParam(params = { "r", "g", "b", "a" })
public void setToolbarBgColor(int r, int g, int b, int alpha) {
    if (noActionBarAllowed) {
        return;//from w  w  w.ja  v a 2 s .  c o  m
    }
    int c = Color.argb(alpha, r, g, b);
    appRunnerActivity.get().setActionBar(c, null);
}

From source file:galilei.kelimekavanozu.activity.ThemeChooserActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Accelerometer check
    PackageManager manager = getPackageManager();
    hasAccelerometer = manager.hasSystemFeature(PackageManager.FEATURE_SENSOR_ACCELEROMETER);

    setContentView(R.layout.activity_theme_chooser);
    SugarContext.init(this);
    arkaplan500 = (ImageView) findViewById(R.id.arkaplan500);
    kavanoz = (ImageView) findViewById(R.id.cannonball_logo);
    recyclerView = (RecyclerView) findViewById(R.id.main_list);

    final Animation shake = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.shake);

    fab = (FloatingActionButton) findViewById(R.id.fab);

    StaggeredGridLayoutManager gridLayoutManager = new StaggeredGridLayoutManager(2,
            StaggeredGridLayoutManager.VERTICAL);
    gridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);

    recyclerView.setLayoutManager(gridLayoutManager);
    initialCount = Note.count(Note.class);
    if (savedInstanceState != null)
        modifyPos = savedInstanceState.getInt("modify");

    if (initialCount >= 0) {

        notes = Note.listAll(Note.class);

        adapter = new KelimelerAdapter(ThemeChooserActivity.this, notes);
        recyclerView.setAdapter(adapter);

    }//  w  w w. ja  va 2  s.  c  om

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {

        Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_add_24dp);
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(drawable, Color.WHITE);
        DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN);

        fab.setImageDrawable(drawable);

    }

    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //                Crashlytics.log("Yeni Kelime: butona basld");
            //                Answers.getInstance().logCustom(new CustomEvent("Ekle butonuna basld"));
            Intent i = new Intent(ThemeChooserActivity.this, AddNoteActivity.class);
            startActivity(i);

        }
    });
    if (isNetworkConnected()) {
        new arkaplan().execute();
    }
    // Handling swipe to delete

    setUpViews();
    ItemTouchHelper.SimpleCallback simpleCallback = new ItemTouchHelper.SimpleCallback(0,
            ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
                RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            //Remove swiped item from list and notify the RecyclerView

            final int position = viewHolder.getAdapterPosition();
            final Note note = notes.get(viewHolder.getAdapterPosition());
            notes.remove(viewHolder.getAdapterPosition());
            adapter.notifyItemRemoved(position);

            note.delete();
            initialCount -= 1;

            Snackbar.make(fab, "Kelime silindi", Snackbar.LENGTH_SHORT)
                    .setAction("GER AL", new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {

                            note.save();
                            notes.add(position, note);
                            adapter.notifyItemInserted(position);
                            initialCount += 1;

                        }
                    }).show();
        }

    };

    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleCallback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
    adapter.SetOnItemClickListener(new KelimelerAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {

            Log.d("Main", "click");

            Intent i = new Intent(ThemeChooserActivity.this, AddNoteActivity.class);
            i.putExtra("isEditing", true);
            i.putExtra("note_title", notes.get(position).title);
            i.putExtra("note", notes.get(position).note);
            i.putExtra("note_time", notes.get(position).time);

            modifyPos = position;

            startActivity(i);
        }
    });
    if (hasAccelerometer) {
        kavanoz.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // View element to be shaken
                // Perform animation
                if (notclick) {
                    kavanoz.startAnimation(shake);
                    shakemode = true;
                    notclick = false;
                    Snackbar.make(fab, "Rastgele kelimelerden birini grmek iin telefonunuzu sallayn.",
                            Snackbar.LENGTH_LONG).show();
                    kavanoz.setColorFilter(Color.argb(100, 255, 140, 0));
                } else {
                    shakemode = false;
                    notclick = true;
                    kavanoz.setColorFilter(getResources().getColor(R.color.green));

                }
            }
        });
        // ShakeDetector initialization
        mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
        mShakeDetector = new ShakeDetector();

        mShakeDetector.setOnShakeListener(new ShakeDetector.OnShakeListener() {

            @Override
            public void onShake(int count) {
                if (shakemode) {
                    /*
                     * The following method, "handleShakeEvent(count):" is a stub //
                    * method you would use to setup whatever you want done once the
                    * device has been shook.
                    */
                    // View element to be shaken
                    // Perform animation
                    Crashlytics.log("Shake event : triggered");
                    Answers.getInstance().logCustom(new CustomEvent("Shake event : tetiklendi"));
                    kavanoz.startAnimation(shake);
                    new rastgeletweet().execute();
                }
            }
        });
    }
}