Home | History | Annotate | Download | only in filters
      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.filters;
     18 
     19 import com.android.gallery3d.R;
     20 import com.android.gallery3d.filtershow.editors.ImageOnlyEditor;
     21 
     22 public class FilterImageBorderRepresentation extends FilterRepresentation {
     23     private int mDrawableResource = 0;
     24 
     25     public FilterImageBorderRepresentation(int drawableResource) {
     26         super("ImageBorder");
     27         mDrawableResource = drawableResource;
     28         setFilterClass(ImageFilterBorder.class);
     29         setPriority(FilterRepresentation.TYPE_BORDER);
     30         setTextId(R.string.borders);
     31         setEditorId(ImageOnlyEditor.ID);
     32         setShowEditingControls(false);
     33         setShowParameterValue(false);
     34         setShowUtilityPanel(false);
     35     }
     36 
     37     public String toString() {
     38         return "FilterBorder: " + getName();
     39     }
     40 
     41     @Override
     42     public FilterRepresentation clone() throws CloneNotSupportedException {
     43         FilterImageBorderRepresentation representation = (FilterImageBorderRepresentation) super.clone();
     44         representation.setName(getName());
     45         representation.setDrawableResource(getDrawableResource());
     46         return representation;
     47     }
     48 
     49     public void useParametersFrom(FilterRepresentation a) {
     50         if (a instanceof FilterImageBorderRepresentation) {
     51             FilterImageBorderRepresentation representation = (FilterImageBorderRepresentation) a;
     52             setName(representation.getName());
     53             setDrawableResource(representation.getDrawableResource());
     54         }
     55     }
     56 
     57     @Override
     58     public boolean equals(FilterRepresentation representation) {
     59         if (!super.equals(representation)) {
     60             return false;
     61         }
     62         if (representation instanceof FilterImageBorderRepresentation) {
     63             FilterImageBorderRepresentation border = (FilterImageBorderRepresentation) representation;
     64             if (border.mDrawableResource == mDrawableResource) {
     65                 return true;
     66             }
     67         }
     68         return false;
     69     }
     70 
     71     @Override
     72     public int getTextId() {
     73         return R.string.none;
     74     }
     75 
     76     public boolean allowsMultipleInstances() {
     77         return true;
     78     }
     79 
     80     public int getDrawableResource() {
     81         return mDrawableResource;
     82     }
     83 
     84     public void setDrawableResource(int drawableResource) {
     85         mDrawableResource = drawableResource;
     86     }
     87 }
     88