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 public class PositionMetrics implements Comparable<PositionMetrics> { 20 21 private XPositionMetric xPositionMetric; 22 private YPositionMetric yPositionMetric; 23 private AnchorPosition anchor; 24 private float layerDepth; 25 26 public PositionMetrics(float x, XLayoutStyle xLayoutStyle, float y, YLayoutStyle yLayoutStyle, AnchorPosition anchor) { 27 setXPositionMetric(new XPositionMetric(x, xLayoutStyle)); 28 setYPositionMetric(new YPositionMetric(y, yLayoutStyle)); 29 setAnchor(anchor); 30 31 } 32 33 public YPositionMetric getYPositionMetric() { 34 return yPositionMetric; 35 } 36 37 public void setYPositionMetric(YPositionMetric yPositionMetric) { 38 this.yPositionMetric = yPositionMetric; 39 } 40 41 public AnchorPosition getAnchor() { 42 return anchor; 43 } 44 45 public void setAnchor(AnchorPosition anchor) { 46 this.anchor = anchor; 47 } 48 49 @Override 50 public int compareTo(PositionMetrics o) { 51 if(this.layerDepth < o.layerDepth) { 52 return -1; 53 } else if(this.layerDepth == o.layerDepth) { 54 return 0; 55 } else { 56 return 1; 57 } 58 } 59 60 public XPositionMetric getXPositionMetric() { 61 return xPositionMetric; 62 } 63 64 public void setXPositionMetric(XPositionMetric xPositionMetric) { 65 this.xPositionMetric = xPositionMetric; 66 } 67 } 68