1 25 package org.jrobin.graph; 26 27 36 class Pdef extends Source 37 { 38 private Plottable plottable; 42 43 private int index = 0; 44 private String sourceName = null; 45 private boolean indexed = false; 46 private boolean named = false; 47 48 49 59 Pdef( String name, Plottable plottable ) 60 { 61 super(name ); 62 this.plottable = plottable; 63 } 64 65 73 Pdef( String name, Plottable plottable, int index ) 74 { 75 super(name ); 76 this.plottable = plottable; 77 this.index = index; 78 indexed = true; 79 } 80 81 89 Pdef( String name, Plottable plottable, String sourceName) 90 { 91 super(name ); 92 this.plottable = plottable; 93 this.sourceName = sourceName; 94 named = true; 95 } 96 97 98 106 void prepare( int numPoints, int aggregatePoints ) 107 { 108 values = new double[numPoints]; 110 111 this.aggregatePoints = aggregatePoints; 113 } 114 115 122 void set( int pos, long timestamp ) 123 { 124 double val = Double.NaN; 125 126 133 if ( indexed ) 134 val = plottable.getValue( timestamp - step, index ); 135 else if ( named ) 136 val = plottable.getValue( timestamp - step, sourceName ); 137 else 138 val = plottable.getValue( timestamp - step ); 139 140 super.set( pos, timestamp, val ); 141 142 values[pos] = val; 143 } 144 } 145 | Popular Tags |