use of com.aviary.android.feather.library.graphics.drawable.MemeTextDrawable in project mobile-android by photo.
the class MemePanel method onLayoutChanged.
@Override
public void onLayoutChanged(boolean changed, int left, int top, int right, int bottom) {
if (changed) {
final Matrix mImageMatrix = mImageView.getImageViewMatrix();
float[] matrixValues = getMatrixValues(mImageMatrix);
final float w = mBitmap.getWidth();
final float h = mBitmap.getHeight();
final float scale = matrixValues[Matrix.MSCALE_X];
if (topHv != null) {
MemeTextDrawable text = (MemeTextDrawable) topHv.getContent();
text.setContentSize(w * scale, h * scale);
}
if (bottomHv != null) {
MemeTextDrawable text = (MemeTextDrawable) bottomHv.getContent();
text.setContentSize(w * scale, h * scale);
}
}
}
use of com.aviary.android.feather.library.graphics.drawable.MemeTextDrawable in project mobile-android by photo.
the class MemePanel method clearEditView.
private void clearEditView(DrawableHighlightView hv) {
final MemeTextDrawable text = (MemeTextDrawable) hv.getContent();
text.setText("");
text.invalidateSelf();
hv.forceUpdate();
}
use of com.aviary.android.feather.library.graphics.drawable.MemeTextDrawable in project mobile-android by photo.
the class MemePanel method onAddBottomText.
/**
* Create and place the bottom editable text.
*/
private void onAddBottomText() {
final Matrix mImageMatrix = mImageView.getImageViewMatrix();
final int width = (int) (mBitmap.getWidth());
final int height = (int) (mBitmap.getHeight());
final MemeTextDrawable text = new MemeTextDrawable("", (float) mBitmap.getHeight() / 7.0f, mTypeface);
text.setTextColor(Color.WHITE);
text.setTextStrokeColor(Color.BLACK);
text.setContentSize(width, height);
bottomHv = new DrawableHighlightView(mImageView, text);
bottomHv.setAlignModeV(DrawableHighlightView.AlignModeV.Bottom);
final int cropHeight = text.getIntrinsicHeight();
final int x = 0;
final int y = 0;
final Matrix matrix = new Matrix(mImageMatrix);
matrix.invert(matrix);
final float[] pts = new float[] { x, y + height - cropHeight - (height / 30), x + width, y + height - (height / 30) };
MatrixUtils.mapPoints(matrix, pts);
final RectF cropRect = new RectF(pts[0], pts[1], pts[2], pts[3]);
addEditable(bottomHv, mImageMatrix, cropRect);
}
use of com.aviary.android.feather.library.graphics.drawable.MemeTextDrawable in project mobile-android by photo.
the class MemePanel method flattenText.
/**
* Flatten text.
*
* @param hv
* the hv
*/
private void flattenText(final DrawableHighlightView hv, final MemeFilter filter) {
if (hv != null) {
hv.setHidden(true);
final Matrix mImageMatrix = mImageView.getImageViewMatrix();
float[] matrixValues = getMatrixValues(mImageMatrix);
mLogger.log("image scaled: " + matrixValues[Matrix.MSCALE_X]);
// TODO: check this modification
final int width = (int) (mBitmap.getWidth());
final int height = (int) (mBitmap.getHeight());
final RectF cropRect = hv.getCropRectF();
final Rect rect = new Rect((int) cropRect.left, (int) cropRect.top, (int) cropRect.right, (int) cropRect.bottom);
final MemeTextDrawable editable = (MemeTextDrawable) hv.getContent();
final int saveCount = mCanvas.save(Canvas.MATRIX_SAVE_FLAG);
// force end edit and hide the blinking cursor
editable.endEdit();
editable.invalidateSelf();
editable.setContentSize(width, height);
editable.setBounds(rect.left, rect.top, rect.right, rect.bottom);
editable.draw(mCanvas);
if (topHv == hv) {
filter.setTopText((String) editable.getText(), (double) editable.getTextSize() / mBitmap.getWidth());
filter.setTopOffset((cropRect.left + (double) editable.getXoff()) / mBitmap.getWidth(), (cropRect.top + (double) editable.getYoff()) / mBitmap.getHeight());
// action.setValue( "toptext", (String) editable.getText() );
// action.setValue( "topsize", (double)editable.getTextSize()/mBitmap.getWidth() );
// action.setValue( "topxoff", (cropRect.left + (double)editable.getXoff())/mBitmap.getWidth() );
// action.setValue( "topyoff", (cropRect.top + (double)editable.getYoff())/mBitmap.getHeight() );
} else {
filter.setBottomText((String) editable.getText(), (double) editable.getTextSize() / mBitmap.getWidth());
filter.setBottomOffset((cropRect.left + (double) editable.getXoff()) / mBitmap.getWidth(), (cropRect.top + (double) editable.getYoff()) / mBitmap.getHeight());
// action.setValue( "bottomtext", (String) editable.getText() );
// action.setValue( "bottomsize", (double)editable.getTextSize()/mBitmap.getWidth() );
// action.setValue( "bottomxoff", (cropRect.left + (double)editable.getXoff())/mBitmap.getWidth() );
// action.setValue( "bottomyoff", (cropRect.top + (double)editable.getYoff())/mBitmap.getHeight() );
}
filter.setTextScale(matrixValues[Matrix.MSCALE_X]);
// action.setValue( "scale", matrixValues[Matrix.MSCALE_X] );
// action.setValue( "textsize", editable.getTextSize() );
mCanvas.restoreToCount(saveCount);
mImageView.invalidate();
}
onPreviewChanged(mPreview, false);
}
use of com.aviary.android.feather.library.graphics.drawable.MemeTextDrawable in project mobile-android by photo.
the class MemePanel method onAddTopText.
/**
* Creates and places the top editable text
*/
private void onAddTopText() {
final Matrix mImageMatrix = mImageView.getImageViewMatrix();
final int width = (int) (mBitmap.getWidth());
final int height = (int) (mBitmap.getHeight());
final MemeTextDrawable text = new MemeTextDrawable("", (float) mBitmap.getHeight() / 7.f, mTypeface);
text.setTextColor(Color.WHITE);
text.setTextStrokeColor(Color.BLACK);
text.setContentSize(width, height);
topHv = new DrawableHighlightView(mImageView, text);
topHv.setAlignModeV(DrawableHighlightView.AlignModeV.Top);
final int cropHeight = text.getIntrinsicHeight();
final int x = 0;
final int y = 0;
final Matrix matrix = new Matrix(mImageMatrix);
matrix.invert(matrix);
final float[] pts = new float[] { x, y, x + width, y + cropHeight };
MatrixUtils.mapPoints(matrix, pts);
final RectF cropRect = new RectF(pts[0], pts[1], pts[2], pts[3]);
addEditable(topHv, mImageMatrix, cropRect);
}
Aggregations