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 FilterColorBorderRepresentation extends FilterRepresentation { 23 private int mColor; 24 private int mBorderSize; 25 private int mBorderRadius; 26 27 public FilterColorBorderRepresentation(int color, int size, int radius) { 28 super("ColorBorder"); 29 mColor = color; 30 mBorderSize = size; 31 mBorderRadius = radius; 32 setFilterClass(ImageFilterParametricBorder.class); 33 setPriority(FilterRepresentation.TYPE_BORDER); 34 setTextId(R.string.borders); 35 setEditorId(ImageOnlyEditor.ID); 36 setShowEditingControls(false); 37 setShowParameterValue(false); 38 setShowUtilityPanel(false); 39 } 40 41 public String toString() { 42 return "FilterBorder: " + getName(); 43 } 44 45 @Override 46 public FilterRepresentation clone() throws CloneNotSupportedException { 47 FilterColorBorderRepresentation representation = (FilterColorBorderRepresentation) super.clone(); 48 representation.setName(getName()); 49 representation.setColor(getColor()); 50 representation.setBorderSize(getBorderSize()); 51 representation.setBorderRadius(getBorderRadius()); 52 return representation; 53 } 54 55 public void useParametersFrom(FilterRepresentation a) { 56 if (a instanceof FilterColorBorderRepresentation) { 57 FilterColorBorderRepresentation representation = (FilterColorBorderRepresentation) a; 58 setName(representation.getName()); 59 setColor(representation.getColor()); 60 setBorderSize(representation.getBorderSize()); 61 setBorderRadius(representation.getBorderRadius()); 62 } 63 } 64 65 @Override 66 public boolean equals(FilterRepresentation representation) { 67 if (!super.equals(representation)) { 68 return false; 69 } 70 if (representation instanceof FilterColorBorderRepresentation) { 71 FilterColorBorderRepresentation border = (FilterColorBorderRepresentation) representation; 72 if (border.mColor == mColor 73 && border.mBorderSize == mBorderSize 74 && border.mBorderRadius == mBorderRadius) { 75 return true; 76 } 77 } 78 return false; 79 } 80 81 public boolean allowsMultipleInstances() { 82 return true; 83 } 84 85 @Override 86 public int getTextId() { 87 return R.string.borders; 88 } 89 90 public int getColor() { 91 return mColor; 92 } 93 94 public void setColor(int color) { 95 mColor = color; 96 } 97 98 public int getBorderSize() { 99 return mBorderSize; 100 } 101 102 public void setBorderSize(int borderSize) { 103 mBorderSize = borderSize; 104 } 105 106 public int getBorderRadius() { 107 return mBorderRadius; 108 } 109 110 public void setBorderRadius(int borderRadius) { 111 mBorderRadius = borderRadius; 112 } 113 } 114