Home | History | Annotate | Download | only in editors
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      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
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     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.
     15  */
     16 
     17 package com.android.gallery3d.filtershow.editors;
     18 
     19 import android.content.Context;
     20 
     21 import com.android.gallery3d.R;
     22 import com.android.gallery3d.filtershow.controller.Control;
     23 import com.android.gallery3d.filtershow.controller.FilterView;
     24 import com.android.gallery3d.filtershow.controller.Parameter;
     25 import com.android.gallery3d.filtershow.controller.ParameterInteger;
     26 import com.android.gallery3d.filtershow.filters.FilterBasicRepresentation;
     27 import com.android.gallery3d.filtershow.filters.FilterRepresentation;
     28 
     29 
     30 /**
     31  * The basic editor that all the one parameter filters
     32  */
     33 public class BasicEditor extends ParametricEditor implements ParameterInteger {
     34     public static int ID = R.id.basicEditor;
     35     private final String LOGTAG = "BasicEditor";
     36 
     37     public BasicEditor() {
     38         super(ID, R.layout.filtershow_default_editor, R.id.basicEditor);
     39     }
     40 
     41     protected BasicEditor(int id) {
     42         super(id, R.layout.filtershow_default_editor, R.id.basicEditor);
     43     }
     44 
     45     protected BasicEditor(int id, int layoutID, int viewID) {
     46         super(id, layoutID, viewID);
     47     }
     48 
     49     @Override
     50     public void reflectCurrentFilter() {
     51         super.reflectCurrentFilter();
     52         if (getLocalRepresentation() != null && getLocalRepresentation() instanceof FilterBasicRepresentation) {
     53             FilterBasicRepresentation interval = (FilterBasicRepresentation) getLocalRepresentation();
     54             updateText();
     55         }
     56     }
     57 
     58     private FilterBasicRepresentation getBasicRepresentation() {
     59         FilterRepresentation tmpRep = getLocalRepresentation();
     60         if (tmpRep != null && tmpRep instanceof FilterBasicRepresentation) {
     61             return (FilterBasicRepresentation) tmpRep;
     62 
     63         }
     64         return null;
     65     }
     66 
     67     @Override
     68     public int getMaximum() {
     69         FilterBasicRepresentation rep = getBasicRepresentation();
     70         if (rep == null) {
     71             return 0;
     72         }
     73         return rep.getMaximum();
     74     }
     75 
     76     @Override
     77     public int getMinimum() {
     78         FilterBasicRepresentation rep = getBasicRepresentation();
     79         if (rep == null) {
     80             return 0;
     81         }
     82         return rep.getMinimum();
     83     }
     84 
     85     @Override
     86     public int getDefaultValue() {
     87         return 0;
     88     }
     89 
     90     @Override
     91     public int getValue() {
     92         FilterBasicRepresentation rep = getBasicRepresentation();
     93         if (rep == null) {
     94             return 0;
     95         }
     96         return rep.getValue();
     97     }
     98 
     99     @Override
    100     public String getValueString() {
    101         return null;
    102     }
    103 
    104     @Override
    105     public void setValue(int value) {
    106         FilterBasicRepresentation rep = getBasicRepresentation();
    107         if (rep == null) {
    108             return;
    109         }
    110         rep.setValue(value);
    111         commitLocalRepresentation();
    112     }
    113 
    114     @Override
    115     public String getParameterName() {
    116         FilterBasicRepresentation rep = getBasicRepresentation();
    117         return mContext.getString(rep.getTextId());
    118     }
    119 
    120     @Override
    121     public String getParameterType() {
    122         return sParameterType;
    123     }
    124 
    125     @Override
    126     public void setController(Control c) {
    127     }
    128 
    129     @Override
    130     public void setFilterView(FilterView editor) {
    131 
    132     }
    133 
    134     @Override
    135     public void copyFrom(Parameter src) {
    136 
    137     }
    138 }
    139