use of com.aviary.android.feather.library.graphics.drawable.TextDrawable in project mobile-android by photo.
the class TextPanel method onAddNewText.
/**
* Add a new editable text on the screen.
*/
private void onAddNewText() {
final ImageViewDrawableOverlay image = (ImageViewDrawableOverlay) mImageView;
if (image.getHighlightCount() > 0)
onApplyCurrent(image.getHighlightViewAt(0));
final TextDrawable text = new TextDrawable("", defaultTextSize);
text.setTextColor(mColor);
text.setTextHint(getContext().getBaseContext().getString(R.string.enter_text_here));
final DrawableHighlightView hv = new DrawableHighlightView(mImageView, text);
final Matrix mImageMatrix = mImageView.getImageViewMatrix();
final int width = mImageView.getWidth();
final int height = mImageView.getHeight();
final int imageSize = Math.max(width, height);
// width/height of the sticker
int cropWidth = text.getIntrinsicWidth();
int cropHeight = text.getIntrinsicHeight();
final int cropSize = Math.max(cropWidth, cropHeight);
if (cropSize > imageSize) {
cropWidth = width / 2;
cropHeight = height / 2;
}
final int x = (width - cropWidth) / 2;
final int y = (height - cropHeight) / 2;
final Matrix matrix = new Matrix(mImageMatrix);
matrix.invert(matrix);
final float[] pts = new float[] { x, y, x + cropWidth, y + cropHeight };
MatrixUtils.mapPoints(matrix, pts);
final RectF cropRect = new RectF(pts[0], pts[1], pts[2], pts[3]);
final Rect imageRect = new Rect(0, 0, width, height);
hv.setRotateAndScale(true);
hv.showDelete(false);
hv.setup(mImageMatrix, imageRect, cropRect, false);
hv.drawOutlineFill(true);
hv.drawOutlineStroke(true);
hv.setPadding(textPadding);
hv.setMinSize(minTextSize);
hv.setOutlineEllipse(mHighlightEllipse);
hv.setOutlineFillColor(mHighlightFillColorStateList);
hv.setOutlineStrokeColor(mHighlightStrokeColorStateList);
Paint stroke = hv.getOutlineStrokePaint();
stroke.setStrokeWidth(mHighlightStrokeWidth);
image.addHighlightView(hv);
// image.setSelectedHighlightView( hv );
onClick(hv);
}
Aggregations