/** * The y position of the x axis. * @return the y position. */ public double getxAxisPosition() { return this.xAxisConfig.getLocation()[1]; }
@Override public Double calculateUnitsAt( final Double position ) { return position / (this.axisLength/(this.config.getMaxValue()-this.config.getMinValue())); }
/** * Default constructor */ public AxesRenderer2D() { this.xAxisConfig.setOrientation( new double[] { 0 } ); this.yAxisConfig.setOrientation( new double[] { this.xAxisConfig.getOrientation()[0]-Math.PI/2d } ); }
final AxisConfig<Float[]> conf = new AxisConfig<Float[]>(); conf.setLocation( new double[]{ 20, 200 } ); conf.setOrientation( new double[] {0/(360/(2*Math.PI))} ); conf.setMaxValue( 10 ); conf.setMinValue( 5 ); conf.getRenderingConfig().setMajorTickSpacing( 1 ); conf.getRenderingConfig().setMinorTickSpacing( 0.5d ); conf.getRenderingConfig().setColour( RGBColour.WHITE ); conf.getRenderingConfig().setMajorTickColour( RGBColour.WHITE ); conf.getRenderingConfig().setMinorTickColour( RGBColour.WHITE ); conf.getRenderingConfig().setMinorGridColour( RGBColour.GRAY ); conf.getRenderingConfig().setMajorGridColour( RGBColour.GRAY ); conf.getRenderingConfig().setDrawMajorGrid( true ); conf.getRenderingConfig().setDrawMinorGrid( true );
/** * @param xAxisColour the xAxisColour to set */ public void setxAxisColour( final Q xAxisColour ) { this.xAxisConfig.getRenderingConfig().setColour( xAxisColour ); }
@Override public void precalc() { // Create an axis line between the min and max value this.axisLine = new Line2d( (float)this.config.getMinValue(), 0, (float)this.config.getMaxValue(), 0 ); // Transform to (0,0) in data units this.transform = TransformUtilities.translateMatrix( -this.config.getMinValue(), 0 ); // Scale to pixels this.currentScale = this.axisLength / (this.config.getMaxValue() - this.config.getMinValue()); this.transform = TransformUtilities.scaleMatrix( (float)this.currentScale, 1 ) .times(this.transform); // Rotate to the preferred orientation this.transform = TransformUtilities.rotationMatrix( this.config.getOrientation()[0] ) .times(this.transform); // Translate to the preferred position this.transform = TransformUtilities.translateMatrix( this.config.getLocation()[0], this.config.getLocation()[1] ) .times( this.transform ); // Transform the axis this.axisLine = this.axisLine.transform( this.transform ); }
@Override public void drawAxis( final AxisConfig<float[]> config ) { final GL2 gl = this.glad.getGL().getGL2(); gl.glPushMatrix(); this.orient( gl ); final float zero = 0.001f; gl.glBegin( GL.GL_LINE_STRIP ); { gl.glLineWidth( (float)config.getRenderingConfig().getThickness() ); gl.glColor3f( config.getRenderingConfig().getColour()[0], config.getRenderingConfig().getColour()[1], config.getRenderingConfig().getColour()[2] ); final float n1 = this.calculatePosition( config.getMinValue() ).floatValue(); final float n2 = this.calculatePosition( config.getMaxValue() ).floatValue(); // We draw in the x axis, so the orientation has to be set appropriately gl.glVertex3f( n1, zero, zero ); gl.glVertex3f( n2, zero, zero ); } gl.glEnd(); gl.glPopMatrix(); }
/** * */ public AxesRenderer3D() { this.xAxisRenderer.setGridDirection( -1 ); this.yAxisRenderer.getConfig().setOrientation( new double[] { 90, 0, 0, 1, 180, 1, 0, 0 } ); this.zAxisRenderer.getConfig().setOrientation( new double[] { 90, 0, 1, 0 } ); this.yAxisRenderer.getConfig().getRenderingConfig().setNameOrientation( new double[] { 90, 0, 0, 1 } ); this.yAxisRenderer.getConfig().getRenderingConfig().setNameDirection( -1 ); this.zAxisRenderer.getConfig().getRenderingConfig().setNameOrientation( new double[] { 90, 0, 1, 0, -90, 1, 0, 0 } ); this.zAxisRenderer.getConfig().getRenderingConfig().setNameDirection( -1 ); this.xAxisRenderer.getConfig().setName( "x-axis" ); this.yAxisRenderer.getConfig().setName( "y-axis" ); this.zAxisRenderer.getConfig().setName( "z-axis" ); this.setAxisThickness( 4 ); this.setDrawMajorGrid( false ); this.setDrawMinorGrid( false ); }
final double[] xLoc = this.xAxisConfig.getLocation(); xLoc[0] = this.axisPaddingLeft; xLoc[1] = this.getxAxisPosition(); -this.xAxisConfig.getMinValue(), 0 ).times( this.dataTransformMatrix ); this.dataTransformMatrix = TransformUtilities.scaleMatrix( this.xAxisRenderer.getCurrentScale(), -this.yAxisRenderer.getCurrentScale() ) .times( this.dataTransformMatrix ); this.dataTransformMatrix = TransformUtilities.rotationMatrix( this.xAxisConfig.getOrientation()[0] ).times( this.dataTransformMatrix ); this.dataTransformMatrix = TransformUtilities.translateMatrix( xLoc[0], xLoc[1] ) .times( this.dataTransformMatrix ); final double[] yLoc = this.yAxisConfig.getLocation(); final Point2d dd = this.calculatePosition( 0, this.yAxisConfig.getMinValue() ); yLoc[0] = dd.getX(); yLoc[1] = dd.getY();
/** * @param minYValue the minYValue to set */ public void setMinYValue( final double minYValue ) { this.yAxisConfig.setMinValue( this.yAxisRenderer.nearestLowerMajorTick( minYValue ) ); }
/** * Set the maximum x value * @param d The new maximum */ public void setMaxXValue( final double d ) { this.xAxisRenderer.getConfig().setMaxValue( d ); }
final double[] o = this.config.getRenderingConfig().getNameOrientation(); if( o != null ) final float scale = 0.003f; final Rectangle2D nameBounds = this.textRenderer.getBounds( config.getName() ); this.textRenderer.draw3D( config.getName(), (float)(1-nameBounds.getWidth()*scale), (float)(-nameBounds.getHeight()*scale) *config.getRenderingConfig().getNameDirection(), 0.1f, scale );
/** * Returns the maximum value of the y axis * @return The y axis maximum value */ public double getMaxYValue() { return this.yAxisConfig.getMaxValue(); }
/** * @param xAxisPosition the xAxisPosition to set */ public void setxAxisPosition( final double xAxisPosition ) { this.xAxisConfig.setLocation( new double[] { this.axisPaddingLeft, xAxisPosition } ); }
private void orient( final GL2 gl ) { if( this.config.getOrientation()[0] != 0 ) { gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW ); final double[] o = this.config.getOrientation(); for( int i = 0; i < o.length; i+=4 ) gl.glRotated( o[i], o[i+1], o[i+2], o[i+3] ); } }
/** * Get the minimum value in use. * * @return The minimum value */ public double getMinValue() { return axesRenderer2D.getyAxisConfig().getMinValue(); }
/** * @param yAxisThickness the yAxisThickness to set */ public void setyAxisThickness( final int yAxisThickness ) { this.yAxisConfig.getRenderingConfig().setThickness( yAxisThickness ); }
final AxisRenderingConfig<Q> rc = this.config.getRenderingConfig(); double min = this.config.getMinValue(); double max = this.config.getMaxValue();
/** * Set the Minimum y value * @param d The new Minimum */ public void setMinYValue( final double d ) { this.yAxisRenderer.getConfig().setMinValue( d ); }
/** * @param maxXValue the maxXValue to set */ public void setMaxXValue( final double maxXValue ) { this.xAxisConfig.setMaxValue( this.xAxisRenderer.nearestHigherMajorTick( maxXValue ) ); }