OSDN Git Service

99e1edf9a2b6c6cbef7d346ea8465462f1fb9c83
[android-x86/packages-apps-Gallery2.git] / src / com / android / gallery3d / filtershow / filters / FilterColorBorderRepresentation.java
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         setFilterType(FilterRepresentation.TYPE_BORDER);
33         setTextId(R.string.borders);
34         setEditorId(ImageOnlyEditor.ID);
35         setShowParameterValue(false);
36     }
37
38     public String toString() {
39         return "FilterBorder: " + getName();
40     }
41
42     @Override
43     public FilterRepresentation clone() throws CloneNotSupportedException {
44         setFilterClass(ImageFilterParametricBorder.class);
45         FilterColorBorderRepresentation representation = (FilterColorBorderRepresentation) super.clone();
46         representation.setName(getName());
47         representation.setColor(getColor());
48         representation.setBorderSize(getBorderSize());
49         representation.setBorderRadius(getBorderRadius());
50         return representation;
51     }
52
53     public void useParametersFrom(FilterRepresentation a) {
54         if (a instanceof FilterColorBorderRepresentation) {
55             FilterColorBorderRepresentation representation = (FilterColorBorderRepresentation) a;
56             setName(representation.getName());
57             setColor(representation.getColor());
58             setBorderSize(representation.getBorderSize());
59             setBorderRadius(representation.getBorderRadius());
60         }
61     }
62
63     @Override
64     public boolean equals(FilterRepresentation representation) {
65         if (!super.equals(representation)) {
66             return false;
67         }
68         if (representation instanceof FilterColorBorderRepresentation) {
69             FilterColorBorderRepresentation border = (FilterColorBorderRepresentation) representation;
70             if (border.mColor == mColor
71                     && border.mBorderSize == mBorderSize
72                     && border.mBorderRadius == mBorderRadius) {
73                 return true;
74             }
75         }
76         return false;
77     }
78
79     public boolean allowsMultipleInstances() {
80         return true;
81     }
82
83     @Override
84     public int getTextId() {
85         return R.string.borders;
86     }
87
88     public int getColor() {
89         return mColor;
90     }
91
92     public void setColor(int color) {
93         mColor = color;
94     }
95
96     public int getBorderSize() {
97         return mBorderSize;
98     }
99
100     public void setBorderSize(int borderSize) {
101         mBorderSize = borderSize;
102     }
103
104     public int getBorderRadius() {
105         return mBorderRadius;
106     }
107
108     public void setBorderRadius(int borderRadius) {
109         mBorderRadius = borderRadius;
110     }
111 }