Home | History | Annotate | Download | only in ui
      1 /*
      2  * Copyright 2012 AndroidPlot.com
      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.androidplot.ui;
     18 
     19 
     20 
     21 abstract class LayoutMetric<LayoutType extends Enum> {
     22 
     23     private LayoutType layoutType;
     24 
     25     //private LayoutType layoutType;
     26     private float value;
     27     //private float lastRow;
     28 
     29     public LayoutMetric(float value, LayoutType layoutType) {
     30         validatePair(value, layoutType);
     31         set(value, layoutType);
     32         //setLayoutType(layoutType);
     33         //setValue(value);
     34         //setLayoutType(layoutType);
     35     }
     36 
     37     /**
     38      * Verifies that the values passed in are valid for the layout algorithm being used.
     39      * @param value
     40      * @param layoutType
     41      */
     42     protected abstract void validatePair(float value, LayoutType layoutType);
     43 
     44     public void set(float value, LayoutType layoutType) {
     45         validatePair(value, layoutType);
     46         this.value = value;
     47         this.layoutType = layoutType;
     48     }
     49 
     50     public float getValue() {
     51         return value;
     52     }
     53 
     54     public void setValue(float value) {
     55         validatePair(value, layoutType);
     56         this.value = value;
     57     }
     58 
     59     public abstract float getPixelValue(float size);
     60 
     61     public LayoutType getLayoutType() {
     62         return layoutType;
     63     }
     64 
     65     public void setLayoutType(LayoutType layoutType) {
     66         validatePair(value, layoutType);
     67         this.layoutType = layoutType;
     68     }
     69 }
     70