Back to project page subsampling-scale-image-view.
The source code is released under:
Apache License
If you think the Android project subsampling-scale-image-view listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* Copyright 2014 David Morrissey//from www.ja v a2s .c om Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.davemorrissey.labs.subscaleview.sample.extension.views; import android.content.Context; import android.graphics.*; import android.graphics.Paint.Cap; import android.graphics.Paint.Style; import android.util.AttributeSet; import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; public class CircleView extends SubsamplingScaleImageView { private int strokeWidth; public CircleView(Context context) { this(context, null); } public CircleView(Context context, AttributeSet attr) { super(context, attr); initialise(); } private void initialise() { float density = getResources().getDisplayMetrics().densityDpi; strokeWidth = (int)(density/60f); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // Don't draw pin before image is ready so it doesn't move around during setup. if (!isImageReady()) { return; } PointF sCenter = new PointF(getSWidth()/2, getSHeight()/2); PointF vCenter = sourceToViewCoord(sCenter); float radius = (getScale() * getSWidth()) * 0.25f; Paint paint = new Paint(); paint.setAntiAlias(true); paint.setStyle(Style.STROKE); paint.setStrokeCap(Cap.ROUND); paint.setStrokeWidth(strokeWidth * 2); paint.setColor(Color.BLACK); canvas.drawCircle(vCenter.x, vCenter.y, radius, paint); paint.setStrokeWidth(strokeWidth); paint.setColor(Color.argb(255, 51, 181, 229)); canvas.drawCircle(vCenter.x, vCenter.y, radius, paint); } }