2 * Copyright (C) 2013 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.gallery3d.filtershow.editors;
19 import android.content.Context;
20 import android.util.Log;
21 import android.widget.FrameLayout;
23 import com.android.gallery3d.R;
24 import com.android.gallery3d.filtershow.filters.FilterRepresentation;
25 import com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation;
26 import com.android.gallery3d.filtershow.imageshow.ImageStraighten;
27 import com.android.gallery3d.filtershow.imageshow.MasterImage;
29 public class EditorStraighten extends Editor implements EditorInfo {
30 public static final String TAG = EditorStraighten.class.getSimpleName();
31 public static final int ID = R.id.editorStraighten;
32 ImageStraighten mImageStraighten;
34 public EditorStraighten() {
36 mShowParameter = SHOW_VALUE_INT;
37 mChangesGeometry = true;
41 public String calculateUserMessage(Context context, String effectName, Object parameterValue) {
42 String apply = context.getString(R.string.apply_effect);
43 apply += " " + effectName;
44 return apply.toUpperCase();
48 public void createEditor(Context context, FrameLayout frameLayout) {
49 super.createEditor(context, frameLayout);
50 if (mImageStraighten == null) {
51 mImageStraighten = new ImageStraighten(context);
53 mView = mImageShow = mImageStraighten;
54 mImageStraighten.setEditor(this);
58 public void reflectCurrentFilter() {
59 MasterImage master = MasterImage.getImage();
60 master.setCurrentFilterRepresentation(master.getPreset().getFilterWithSerializationName(
61 FilterStraightenRepresentation.SERIALIZATION_NAME));
62 super.reflectCurrentFilter();
63 FilterRepresentation rep = getLocalRepresentation();
64 if (rep == null || rep instanceof FilterStraightenRepresentation) {
66 .setFilterStraightenRepresentation((FilterStraightenRepresentation) rep);
68 Log.w(TAG, "Could not reflect current filter, not of type: "
69 + FilterStraightenRepresentation.class.getSimpleName());
71 mImageStraighten.invalidate();
75 public void finalApplyCalled() {
76 commitLocalRepresentation(mImageStraighten.getFinalRepresentation());
80 public int getTextId() {
81 return R.string.straighten;
85 public int getOverlayId() {
86 return R.drawable.filtershow_button_geometry_straighten;
90 public boolean getOverlayOnly() {
95 public boolean showsSeekBar() {
100 public boolean showsPopupIndicator() {