use of android.graphics.PaintFlagsDrawFilter in project c-geo by just-radovan.
the class cgMapMyOverlay method drawInternal.
private void drawInternal(Canvas canvas, MapProjectionImpl projection) {
if (coordinates == null || location == null)
return;
MapFactory mapFactory = settings.getMapFactory();
if (accuracyCircle == null) {
accuracyCircle = new Paint();
accuracyCircle.setAntiAlias(true);
accuracyCircle.setStrokeWidth(1.0f);
}
if (historyLine == null) {
historyLine = new Paint();
historyLine.setAntiAlias(true);
historyLine.setStrokeWidth(3.0f);
historyLine.setColor(0xFFFFFFFF);
}
if (historyLineShadow == null) {
historyLineShadow = new Paint();
historyLineShadow.setAntiAlias(true);
historyLineShadow.setStrokeWidth(7.0f);
historyLineShadow.setColor(0x66000000);
}
if (setfil == null)
setfil = new PaintFlagsDrawFilter(0, Paint.FILTER_BITMAP_FLAG);
if (remfil == null)
remfil = new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG, 0);
canvas.setDrawFilter(setfil);
double latitude = coordinates.getLatitude();
double longitude = coordinates.getLongitude();
float accuracy = coordinates.getAccuracy();
float[] result = new float[1];
Location.distanceBetween(latitude, longitude, latitude, longitude + 1, result);
float longitudeLineDistance = result[0];
GeoPointImpl leftGeo = mapFactory.getGeoPointBase((int) (latitude * 1e6), (int) ((longitude - accuracy / longitudeLineDistance) * 1e6));
projection.toPixels(leftGeo, left);
projection.toPixels(location, center);
int radius = center.x - left.x;
accuracyCircle.setColor(0x66000000);
accuracyCircle.setStyle(Style.STROKE);
canvas.drawCircle(center.x, center.y, radius, accuracyCircle);
accuracyCircle.setColor(0x08000000);
accuracyCircle.setStyle(Style.FILL);
canvas.drawCircle(center.x, center.y, radius, accuracyCircle);
if (coordinates.getAccuracy() < 50f && ((historyRecent != null && cgBase.getDistance(historyRecent.getLatitude(), historyRecent.getLongitude(), coordinates.getLatitude(), coordinates.getLongitude()) > 0.005) || historyRecent == null)) {
if (historyRecent != null)
history.add(historyRecent);
historyRecent = coordinates;
int toRemove = history.size() - 700;
if (toRemove > 0) {
for (int cnt = 0; cnt < toRemove; cnt++) {
history.remove(cnt);
}
}
}
if (settings.maptrail == 1) {
int size = history.size();
if (size > 1) {
int alpha = 0;
int alphaCnt = size - 201;
if (alphaCnt < 1)
alphaCnt = 1;
for (int cnt = 1; cnt < size; cnt++) {
Location prev = history.get(cnt - 1);
Location now = history.get(cnt);
if (prev != null && now != null) {
projection.toPixels(mapFactory.getGeoPointBase((int) (prev.getLatitude() * 1e6), (int) (prev.getLongitude() * 1e6)), historyPointP);
projection.toPixels(mapFactory.getGeoPointBase((int) (now.getLatitude() * 1e6), (int) (now.getLongitude() * 1e6)), historyPointN);
if ((alphaCnt - cnt) > 0)
alpha = Math.round(255 / (alphaCnt - cnt));
else
alpha = 255;
historyLineShadow.setAlpha(alpha);
historyLine.setAlpha(alpha);
canvas.drawLine(historyPointP.x, historyPointP.y, historyPointN.x, historyPointN.y, historyLineShadow);
canvas.drawLine(historyPointP.x, historyPointP.y, historyPointN.x, historyPointN.y, historyLine);
}
}
}
if (size > 0) {
Location prev = history.get(size - 1);
Location now = coordinates;
if (prev != null && now != null) {
projection.toPixels(mapFactory.getGeoPointBase((int) (prev.getLatitude() * 1e6), (int) (prev.getLongitude() * 1e6)), historyPointP);
projection.toPixels(mapFactory.getGeoPointBase((int) (now.getLatitude() * 1e6), (int) (now.getLongitude() * 1e6)), historyPointN);
historyLineShadow.setAlpha(255);
historyLine.setAlpha(255);
canvas.drawLine(historyPointP.x, historyPointP.y, historyPointN.x, historyPointN.y, historyLineShadow);
canvas.drawLine(historyPointP.x, historyPointP.y, historyPointN.x, historyPointN.y, historyLine);
}
}
}
if (arrow == null) {
arrow = BitmapFactory.decodeResource(settings.getContext().getResources(), R.drawable.my_location_chevron);
widthArrow = arrow.getWidth();
heightArrow = arrow.getHeight();
}
int marginLeft;
int marginTop;
marginLeft = center.x - (widthArrow / 2);
marginTop = center.y - (heightArrow / 2);
canvas.rotate(new Float(heading), center.x, center.y);
canvas.drawBitmap(arrow, marginLeft, marginTop, null);
canvas.rotate(-(new Float(heading)), center.x, center.y);
canvas.setDrawFilter(remfil);
//super.draw(canvas, mapView, shadow);
}
use of android.graphics.PaintFlagsDrawFilter in project c-geo by just-radovan.
the class cgCompassMini method onAttachedToWindow.
@Override
public void onAttachedToWindow() {
compassArrow = BitmapFactory.decodeResource(context.getResources(), arrowSkin);
setfil = new PaintFlagsDrawFilter(0, Paint.FILTER_BITMAP_FLAG);
remfil = new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG, 0);
}
use of android.graphics.PaintFlagsDrawFilter in project mobile-android by photo.
the class Wheel method init.
/**
* Inits the.
*
* @param context
* the context
* @param attrs
* the attrs
* @param defStyle
* the def style
*/
private void init(Context context, AttributeSet attrs, int defStyle) {
if (android.os.Build.VERSION.SDK_INT > 8) {
try {
mFlingRunnable = (IFlingRunnable) ReflectionUtils.newInstance("com.aviary.android.feather.widget.Fling9Runnable", new Class<?>[] { FlingRunnableView.class, int.class }, this, mAnimationDuration);
} catch (ReflectionException e) {
mFlingRunnable = new Fling8Runnable(this, mAnimationDuration);
}
} else {
mFlingRunnable = new Fling8Runnable(this, mAnimationDuration);
}
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Wheel, defStyle, 0);
mTicksCount = a.getInteger(R.styleable.Wheel_ticks, 18);
mWheelSizeFactor = a.getInteger(R.styleable.Wheel_numRotations, 2);
a.recycle();
mFast = new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG, 0);
mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
mGestureDetector = new GestureDetector(context, this);
mGestureDetector.setIsLongpressEnabled(false);
setFocusable(true);
setFocusableInTouchMode(true);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
TypedValue.complexToDimensionPixelSize(25, metrics);
try {
mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
} catch (Exception e) {
Log.e(LOG_TAG, e.toString());
}
if (mVibrator != null) {
setVibrationEnabled(true);
}
setBackgroundDrawable(new LinearGradientDrawable(Orientation.LEFT_RIGHT, mBgColors, mBgPositions));
}
use of android.graphics.PaintFlagsDrawFilter in project android_frameworks_base by ResurrectionRemix.
the class ColorArrayAdapter method createColorImage.
private ImageView createColorImage(int position) {
ImageView imageView = new ImageView(getContext());
final int width = getContext().getResources().getDimensionPixelSize(R.dimen.crop_buttons);
final int contentWidth = getContext().getResources().getDimensionPixelSize(R.dimen.crop_buttons_inlet);
final int color = colors[position];
final Canvas canvas = new Canvas();
canvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.ANTI_ALIAS_FLAG, Paint.FILTER_BITMAP_FLAG));
final Bitmap bmp = Bitmap.createBitmap(contentWidth, contentWidth, Bitmap.Config.ARGB_8888);
canvas.setBitmap(bmp);
final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.FILL);
paint.setColor(color);
canvas.drawRect(0, 0, contentWidth, contentWidth, paint);
imageView.setImageDrawable(new BitmapDrawable(getContext().getResources(), bmp));
AbsListView.LayoutParams params = new AbsListView.LayoutParams(width, width);
imageView.setLayoutParams(params);
imageView.setScaleType(ScaleType.CENTER);
return imageView;
}
use of android.graphics.PaintFlagsDrawFilter in project android_frameworks_base by ResurrectionRemix.
the class ScreenshotEditor method createColorImage.
private BitmapDrawable createColorImage(int color) {
final int width = getResources().getDimensionPixelSize(R.dimen.crop_buttons_inlet);
final Canvas canvas = new Canvas();
canvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.ANTI_ALIAS_FLAG, Paint.FILTER_BITMAP_FLAG));
final Bitmap bmp = Bitmap.createBitmap(width, width, Bitmap.Config.ARGB_8888);
canvas.setBitmap(bmp);
// inside
final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.FILL);
paint.setColor(color);
canvas.drawRect(0, 0, width, width, paint);
// border
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(2);
paint.setColor(Color.BLACK);
canvas.drawRect(0, 0, width, width, paint);
return new BitmapDrawable(getResources(), bmp);
}
Aggregations