1 7 package org.ejtools.graph; 8 9 10 17 public class Range 18 { 19 20 protected double max = 0.0f; 21 22 protected double min = 0.0f; 23 24 public final static int X_AXIS = 0; 25 26 public final static int Y_AXIS = 1; 27 28 29 35 public Range(double min, double max) 36 { 37 this.min = (double) min; 38 this.max = (double) max; 39 } 40 41 42 48 public Range compose(Range range) 49 { 50 double nmin = Math.min(this.min, range.min); 51 double nmax = Math.max(this.max, range.max); 52 53 return new Range(nmin, nmax); 54 } 55 56 57 62 public double getMax() 63 { 64 return this.max; 65 } 66 67 68 73 public double getMin() 74 { 75 return this.min; 76 } 77 78 79 84 public synchronized void put(double value) 85 { 86 this.min = Math.min(this.min, value); 87 this.max = Math.max(this.max, value); 88 } 89 90 91 96 public void setMax(double max) 97 { 98 this.max = max; 99 } 100 101 102 107 public void setMin(double min) 108 { 109 this.min = min; 110 } 111 112 113 118 public String toString() 119 { 120 return "[" + getMin() + " to " + getMax() + "]"; 121 } 122 } 123 | Popular Tags |