144a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford/* 244a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * Copyright (C) 2012 The Android Open Source Project 344a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * 444a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * Licensed under the Apache License, Version 2.0 (the "License"); 544a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * you may not use this file except in compliance with the License. 644a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * You may obtain a copy of the License at 744a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * 844a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * http://www.apache.org/licenses/LICENSE-2.0 944a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * 1044a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * Unless required by applicable law or agreed to in writing, software 1144a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * distributed under the License is distributed on an "AS IS" BASIS, 1244a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1344a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * See the License for the specific language governing permissions and 1444a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford * limitations under the License. 1544a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford */ 1644a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford 1744a499a64158cd5a12f8e44655f82b68c33bf3b2John Hofordpackage com.android.gallery3d.filtershow.filters; 1844a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford 196900cad45d240c9a54b92991538b6a33652e766cnicolasroardimport com.android.gallery3d.R; 206900cad45d240c9a54b92991538b6a33652e766cnicolasroardimport com.android.gallery3d.filtershow.editors.EditorTinyPlanet; 2144a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford 2244a499a64158cd5a12f8e44655f82b68c33bf3b2John Hofordpublic class FilterTinyPlanetRepresentation extends FilterBasicRepresentation { 23afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford private static final String SERIALIZATION_NAME = "TINYPLANET"; 2444a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford private static final String LOGTAG = "FilterTinyPlanetRepresentation"; 25afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford private static final String SERIAL_ANGLE = "Angle"; 2644a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford private float mAngle = 0; 2744a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford 2844a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford public FilterTinyPlanetRepresentation() { 2944a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford super("TinyPlanet", 0, 50, 100); 30afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford setSerializationName(SERIALIZATION_NAME); 3144a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford setShowParameterValue(true); 326900cad45d240c9a54b92991538b6a33652e766cnicolasroard setFilterClass(ImageFilterTinyPlanet.class); 333cb106ddd7ad0f8494ac9c7a33660831c1694295Ruben Brunk setFilterType(FilterRepresentation.TYPE_TINYPLANET); 346900cad45d240c9a54b92991538b6a33652e766cnicolasroard setTextId(R.string.tinyplanet); 356900cad45d240c9a54b92991538b6a33652e766cnicolasroard setEditorId(EditorTinyPlanet.ID); 3691d26f6c3b183862eeffc1856e2d758e800d13f4John Hoford setMinimum(1); 37e19cb8725655869092a73bed24a66395dd89013cJohn Hoford setSupportsPartialRendering(false); 3844a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford } 3944a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford 4044a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford @Override 413f0034140c165b86fbaf5c0369f39431548308e9John Hoford public FilterRepresentation copy() { 423f0034140c165b86fbaf5c0369f39431548308e9John Hoford FilterTinyPlanetRepresentation representation = new FilterTinyPlanetRepresentation(); 433f0034140c165b86fbaf5c0369f39431548308e9John Hoford copyAllParameters(representation); 4444a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford return representation; 4544a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford } 4644a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford 4791d26f6c3b183862eeffc1856e2d758e800d13f4John Hoford @Override 483f0034140c165b86fbaf5c0369f39431548308e9John Hoford protected void copyAllParameters(FilterRepresentation representation) { 493f0034140c165b86fbaf5c0369f39431548308e9John Hoford super.copyAllParameters(representation); 503f0034140c165b86fbaf5c0369f39431548308e9John Hoford representation.useParametersFrom(this); 513f0034140c165b86fbaf5c0369f39431548308e9John Hoford } 523f0034140c165b86fbaf5c0369f39431548308e9John Hoford 533f0034140c165b86fbaf5c0369f39431548308e9John Hoford @Override 5491d26f6c3b183862eeffc1856e2d758e800d13f4John Hoford public void useParametersFrom(FilterRepresentation a) { 5591d26f6c3b183862eeffc1856e2d758e800d13f4John Hoford FilterTinyPlanetRepresentation representation = (FilterTinyPlanetRepresentation) a; 5691d26f6c3b183862eeffc1856e2d758e800d13f4John Hoford super.useParametersFrom(a); 5791d26f6c3b183862eeffc1856e2d758e800d13f4John Hoford mAngle = representation.mAngle; 5891d26f6c3b183862eeffc1856e2d758e800d13f4John Hoford setZoom(representation.getZoom()); 5991d26f6c3b183862eeffc1856e2d758e800d13f4John Hoford } 6091d26f6c3b183862eeffc1856e2d758e800d13f4John Hoford 6144a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford public void setAngle(float angle) { 6244a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford mAngle = angle; 6344a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford } 6444a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford 6544a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford public float getAngle() { 6644a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford return mAngle; 6744a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford } 6844a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford 6944a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford public int getZoom() { 7044a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford return getValue(); 7144a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford } 7244a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford 7344a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford public void setZoom(int zoom) { 7444a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford setValue(zoom); 7544a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford } 766900cad45d240c9a54b92991538b6a33652e766cnicolasroard 776900cad45d240c9a54b92991538b6a33652e766cnicolasroard public boolean isNil() { 786900cad45d240c9a54b92991538b6a33652e766cnicolasroard // TinyPlanet always has an effect 796900cad45d240c9a54b92991538b6a33652e766cnicolasroard return false; 806900cad45d240c9a54b92991538b6a33652e766cnicolasroard } 81afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford 82e19cb8725655869092a73bed24a66395dd89013cJohn Hoford public boolean equals(FilterRepresentation representation) { 83e19cb8725655869092a73bed24a66395dd89013cJohn Hoford if (!super.equals(representation)) { 84e19cb8725655869092a73bed24a66395dd89013cJohn Hoford return false; 85e19cb8725655869092a73bed24a66395dd89013cJohn Hoford } 86e19cb8725655869092a73bed24a66395dd89013cJohn Hoford if (mAngle == ((FilterTinyPlanetRepresentation) representation).mAngle) { 87e19cb8725655869092a73bed24a66395dd89013cJohn Hoford return true; 88e19cb8725655869092a73bed24a66395dd89013cJohn Hoford } 89e19cb8725655869092a73bed24a66395dd89013cJohn Hoford return false; 90e19cb8725655869092a73bed24a66395dd89013cJohn Hoford } 91e19cb8725655869092a73bed24a66395dd89013cJohn Hoford 92afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford @Override 93afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford public String[][] serializeRepresentation() { 94afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford String[][] ret = { 95afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford {SERIAL_NAME , getName() }, 96afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford {SERIAL_VALUE , Integer.toString(getValue())}, 97afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford {SERIAL_ANGLE , Float.toString(mAngle)}}; 98afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford return ret; 99afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford } 100afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford 101afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford @Override 102afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford public void deSerializeRepresentation(String[][] rep) { 103afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford super.deSerializeRepresentation(rep); 104afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford for (int i = 0; i < rep.length; i++) { 105afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford if (SERIAL_VALUE.equals(rep[i][0])) { 106afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford setValue(Integer.parseInt(rep[i][1])); 107afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford } else if (SERIAL_ANGLE.equals(rep[i][0])) { 108afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford setAngle(Float.parseFloat(rep[i][1])); 109afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford } 110afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford } 111afa8ed9d46e760d4b0c0331cfcb4bb49ef6ba280John Hoford } 11244a499a64158cd5a12f8e44655f82b68c33bf3b2John Hoford} 113