/** * Set the time scalar of this timeline. The units are milliseconds per * pixel. * * @param ts The new time scalar */ public void setTimeScalar( final double ts ) { this.timeScalar = ts; this.axesRenderer2D.setMaxXValue( this.timeScalar * (this.visImage.getWidth()-this.sidebarWidth) ); this.updateVis(); }
/** * Set up the min/max of the axes based on the data. */ protected void validateData() { if( this.autoScaleAxes && this.data.size() > 0 ) { double minX = Double.MAX_VALUE; double maxX = -Double.MAX_VALUE; double minY = Double.MAX_VALUE; double maxY = -Double.MAX_VALUE; for( final LocatedObject<O> o : this.data) { minX = Math.min( minX, o.x ); maxX = Math.max( maxX, o.x ); minY = Math.min( minY, o.y ); maxY = Math.max( maxY, o.y ); } this.axesRenderer2D.setMaxXValue( maxX ); this.axesRenderer2D.setMinXValue( minX ); this.axesRenderer2D.setMaxYValue( maxY ); this.axesRenderer2D.setMinYValue( minY ); this.axesRenderer2D.precalc(); // System.out.println( "XYPlotVis.validateData(): max x: "+maxX+ // ", min x: "+minX+", max y: "+maxY+", min y: "+minY ); } }
/** * Set the data to a double array * * @param data * The data */ public void setData(final double[] data) { super.data.clear(); if (this.useFixedBarWidth) for (int i = 0; i < data.length; i++) super.data.add(new LocatedObject<Bar>(i, data[i], new Bar(data[i], i, i + this.barWidth, RGBColour.RED))); else for (int i = 0; i < data.length; i++) super.data.add(new LocatedObject<Bar>(i, data[i], new Bar(data[i], i, i + this.barWidth, RGBColour.RED))); super.validateData(); this.axesRenderer2D.setMaxXValue(data.length); // Force the axis to be zero if the axis always visible flag is set if (axisAlwaysVisible) if (getMinValue() > 0) setMinValue(0); else if (getMaxValue() < 0) setMaxValue(0); super.updateVis(); }
/** * Main method to demonstrate the vis. * @param args command-line args (not used) */ public static void main( final String[] args ) { final DotPlotVisualisation dpv = new DotPlotVisualisation( 1000, 600 ); dpv.axesRenderer2D.setMaxXValue( 1 ); dpv.axesRenderer2D.setMinXValue( -1 ); dpv.axesRenderer2D.setMaxYValue( 1 ); dpv.axesRenderer2D.setMinYValue( -1 ); dpv.axesRenderer2D.setxMajorTickSpacing( 0.2 ); dpv.axesRenderer2D.setxMinorTickSpacing( 0.1 ); dpv.axesRenderer2D.setyMajorTickSpacing( 0.2 ); dpv.axesRenderer2D.setyMinorTickSpacing( 0.1 ); dpv.axesRenderer2D.setxAxisPosition( 300 ); dpv.setAutoScaleAxes( false ); dpv.setColourMapRange( 0, 0.2 ); for( int i = 0; i < 10; i++ ) dpv.addPoint( (Math.random()-0.5)*2, (Math.random()-0.5)*2, i/50d ); dpv.updateVis(); dpv.showWindow( "Dot plot" ); } }
super.axesRenderer2D.setMaxXValue(xmax); super.axesRenderer2D.setMinYValue(ymin); super.axesRenderer2D.setMaxYValue(ymax);
ar.setMaxXValue( 1 ); ar.setMinYValue( -5 ); ar.setMaxYValue( 1 );