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.controller;
19 import android.graphics.Color;
21 import java.util.Arrays;
23 public class ParameterColor implements Parameter {
24 public static String sParameterType = "ParameterColor";
25 protected Control mControl;
26 protected FilterView mEditor;
27 float[] mHSVO = new float[4];
28 String mParameterName;
32 Color.RED & 0x80FFFFFF,
33 Color.GREEN & 0x80FFFFFF,
34 Color.BLUE & 0x80FFFFFF,
35 Color.BLACK & 0x80FFFFFF,
36 Color.WHITE & 0x80FFFFFF
39 public ParameterColor(int id, int defaultColor) {
41 Color.colorToHSV(defaultColor, mHSVO);
42 mHSVO[3] = ((defaultColor >> 24) & 0xFF) / (float) 255;
46 public String getParameterType() {
47 return sParameterType;
50 public void setColor(float[] hsvo) {
52 mValue = Color.HSVToColor((int) (hsvo[3] * 255), mHSVO);
55 public float[] getColor() {
59 public void copyFrom(Parameter src) {
60 if (!(src instanceof ParameterColor)) {
61 throw new IllegalArgumentException(src.getClass().getName());
63 ParameterColor p = (ParameterColor) src;
66 System.arraycopy(p.mHSVO, 0, mHSVO, 0, 4);
70 public String getParameterName() {
71 return mParameterName;
75 public String getValueString() {
76 return "(" + Integer.toHexString(mValue) + ")";
80 public void setController(Control control) {
84 public int getValue() {
88 public void setValue(int value) {
90 Color.colorToHSV(mValue, mHSVO);
91 mHSVO[3] = ((mValue >> 24) & 0xFF) / (float) 255;
95 public String toString() {
96 return getValueString();
100 public void setFilterView(FilterView editor) {
104 public void copyPalletFrom(ParameterColor parameterColor) {
105 System.arraycopy(parameterColor.mBasColors,0,mBasColors,0,mBasColors.length);
108 public void setColorpalette(int[] palette) {
109 mBasColors = Arrays.copyOf(palette, palette.length);
112 public int[] getColorPalette() {