use of com.android.gallery3d.filtershow.filters.FilterRotateRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method showRepresentation.
public void showRepresentation(FilterRepresentation representation) {
if (representation == null) {
return;
}
Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
if (currentPanel instanceof MainPanel && ((MainPanel) currentPanel).hasEditorPanel()) {
if (representation.equals(MasterImage.getImage().getCurrentFilterRepresentation())) {
return;
}
// cancel previous filter.
cancelCurrentFilter();
showDefaultImageView();
removeSeekBarPanel();
}
if (representation instanceof FilterRotateRepresentation) {
FilterRotateRepresentation r = (FilterRotateRepresentation) representation;
r.rotateCW();
}
if (representation instanceof FilterMirrorRepresentation) {
FilterMirrorRepresentation r = (FilterMirrorRepresentation) representation;
r.cycle();
}
if (representation.isBooleanFilter()) {
ImagePreset preset = MasterImage.getImage().getPreset();
if (preset.getRepresentation(representation) != null) {
// remove
ImagePreset copy = new ImagePreset(preset);
copy.removeFilter(representation);
FilterRepresentation filterRepresentation = representation.copy();
MasterImage.getImage().setPreset(copy, filterRepresentation, true);
MasterImage.getImage().setCurrentFilterRepresentation(null);
setActionBar();
showActionBar(true);
return;
}
}
if (representation.getFilterType() == FilterRepresentation.TYPE_DUALCAM) {
DisplayMetrics dm = getResources().getDisplayMetrics();
float[] mTmpPoint = new float[2];
mTmpPoint[0] = dm.widthPixels / 2;
mTmpPoint[1] = dm.heightPixels / 2;
Matrix m = MasterImage.getImage().getScreenToImageMatrix(true);
m.mapPoints(mTmpPoint);
if (representation instanceof FilterDualCamBasicRepresentation) {
((FilterDualCamBasicRepresentation) representation).setPoint((int) mTmpPoint[0], (int) mTmpPoint[1]);
}
if (representation instanceof FilterDualCamFusionRepresentation) {
((FilterDualCamFusionRepresentation) representation).setPoint((int) mTmpPoint[0], (int) mTmpPoint[1]);
}
}
if (representation.getFilterType() == FilterRepresentation.TYPE_WATERMARK) {
if (MasterImage.getImage().getCurrentFilterRepresentation() != null && representation.getSerializationName().equals(MasterImage.getImage().getCurrentFilterRepresentation().getSerializationName())) {
return;
}
showWaterMark(representation);
}
if (TrueScannerActs.SERIALIZATION_NAME.equals(representation.getSerializationName())) {
Bitmap b = MasterImage.getImage().getOriginalBitmapHighres();
int w = b.getWidth();
int h = b.getHeight();
if (w < h) {
w = h;
h = b.getWidth();
}
if (w <= TrueScannerActs.MIN_WIDTH || h <= TrueScannerActs.MIN_HEIGHT) {
Toast.makeText(this, getString(R.string.image_size_too_small), Toast.LENGTH_SHORT).show();
return;
}
}
useFilterRepresentation(representation);
loadEditorPanel(representation);
}
use of com.android.gallery3d.filtershow.filters.FilterRotateRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method useFilterRepresentation.
public void useFilterRepresentation(FilterRepresentation filterRepresentation) {
if (filterRepresentation == null) {
return;
}
if (!(filterRepresentation instanceof FilterRotateRepresentation) && !(filterRepresentation instanceof FilterMirrorRepresentation) && MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) {
return;
}
if (filterRepresentation.getFilterType() == FilterWatermarkRepresentation.TYPE_WATERMARK_CATEGORY) {
return;
}
boolean addToHistory = filterRepresentation.getFilterType() != FilterWatermarkRepresentation.TYPE_WATERMARK;
if (filterRepresentation instanceof FilterUserPresetRepresentation || filterRepresentation instanceof FilterRotateRepresentation || filterRepresentation instanceof FilterMirrorRepresentation) {
MasterImage.getImage().onNewLook(filterRepresentation);
}
ImagePreset oldPreset = MasterImage.getImage().getPreset();
ImagePreset copy = new ImagePreset(oldPreset);
FilterRepresentation representation = copy.getRepresentation(filterRepresentation);
if (representation == null) {
filterRepresentation = filterRepresentation.copy();
copy.addFilter(filterRepresentation);
} else {
if (filterRepresentation.allowsSingleInstanceOnly()) {
// null.
if (!representation.equals(filterRepresentation)) {
// Only do this if the filter isn't the same
// (state panel clicks can lead us here)
copy.removeFilter(representation);
copy.addFilter(filterRepresentation);
}
}
}
MasterImage.getImage().setPreset(copy, filterRepresentation, addToHistory);
MasterImage.getImage().setCurrentFilterRepresentation(filterRepresentation);
}
use of com.android.gallery3d.filtershow.filters.FilterRotateRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class FilterShowActivity method resetHistory.
void resetHistory() {
if (mMasterImage == null) {
return;
}
HistoryManager adapter = mMasterImage.getHistory();
adapter.reset();
HistoryItem historyItem = adapter.getItem(0);
ImagePreset original = null;
original = new ImagePreset();
FilterRepresentation rep = null;
if (historyItem != null) {
rep = historyItem.getFilterRepresentation();
}
mMasterImage.setPreset(original, rep, true);
mMasterImage.setFusionUnderlay(null);
mMasterImage.resetTranslation();
mMasterImage.setScaleFactor(1);
mMasterImage.setCurrentFilterRepresentation(null);
ArrayList<FilterRepresentation> frList = FiltersManager.getManager().getTools();
for (FilterRepresentation fr : frList) {
if (fr instanceof FilterRotateRepresentation) {
((FilterRotateRepresentation) fr).resetRotation();
}
}
showDefaultImageView();
showSaveButtonIfNeed();
invalidateViews();
}
use of com.android.gallery3d.filtershow.filters.FilterRotateRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class ImagePreset method equals.
public boolean equals(ImagePreset preset) {
if (preset == null) {
return false;
}
if (preset.mFilters.size() != mFilters.size()) {
return false;
}
if (mDoApplyGeometry != preset.mDoApplyGeometry) {
return false;
}
if (mDoApplyFilters != preset.mDoApplyFilters) {
if (mFilters.size() > 0 || preset.mFilters.size() > 0) {
return false;
}
}
for (int i = 0; i < preset.mFilters.size(); i++) {
FilterRepresentation a = preset.mFilters.elementAt(i);
FilterRepresentation b = mFilters.elementAt(i);
boolean isGeometry = false;
if (a instanceof FilterRotateRepresentation || a instanceof FilterMirrorRepresentation || a instanceof FilterCropRepresentation || a instanceof FilterStraightenRepresentation) {
isGeometry = true;
}
boolean evaluate = true;
if (!isGeometry && mDoApplyGeometry && !mDoApplyFilters) {
evaluate = false;
} else if (isGeometry && !mDoApplyGeometry && mDoApplyFilters) {
evaluate = false;
}
if (evaluate && !a.equals(b)) {
return false;
}
}
return true;
}
use of com.android.gallery3d.filtershow.filters.FilterRotateRepresentation in project android_packages_apps_Gallery2 by LineageOS.
the class EditorRotate method reflectCurrentFilter.
@Override
public void reflectCurrentFilter() {
MasterImage master = MasterImage.getImage();
master.setCurrentFilterRepresentation(master.getPreset().getFilterWithSerializationName(FilterRotateRepresentation.SERIALIZATION_NAME));
super.reflectCurrentFilter();
FilterRepresentation rep = getLocalRepresentation();
if (rep == null || rep instanceof FilterRotateRepresentation) {
mImageRotate.setFilterRotateRepresentation((FilterRotateRepresentation) rep);
} else {
Log.w(TAG, "Could not reflect current filter, not of type: " + FilterRotateRepresentation.class.getSimpleName());
}
mImageRotate.invalidate();
}
Aggregations