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);
}
}
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);
}
}
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;
}
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;
}
}
}
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;
}
}
}
Aggregations