⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dataaxis.java

📁 jCharts是一个100%基于Java的制图工具
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			}
			else if( segments <= 5 )
			{
				// we need 4 times this many
				yDelta = yDelta / 4.0;
			}
			else if( segments <= 10 )
			{
				yDelta = yDelta / 2.0;
			}
			// Recalc start and end to match with new delta.
			yStart = yMin - ( yMin % yDelta );
			yEnd = yMax - ( yMax % yDelta ) + yDelta;
			segments = (int) ( ( yEnd - yStart ) / yDelta );

			//axisProperties = new AxisProperties(yStart, yDelta);
			//axisProperties.setYAxisNumItems(segments);

			this.increment= yDelta;


			}
			//---else MIN is negative and MAX is positive, so add values together (minus a negative is a positive)
			else
			{
				this.minValue = this.round( axisChartDataProcessor.getMinValue(), powerOfTen );

				//---round min value down to get the start value for axis.  Compute range from this value.
				if( super.getAxisChart().getAxisProperties().getDataAxisRoundValuesToNearest() > 0 )
				{
					this.minValue -= powerOfTen;
				}
				else
				{
					this.minValue -= ( 1 / powerOfTen );
				}

				//---we want the rounded Axis min for range
				//---MIN is always negative at this point so minus a negative is a positive
				range = axisChartDataProcessor.getMaxValue() - this.minValue;

				this.increment = range / numScaleItems;
				this.roundTheIncrement( powerOfTen );

				//---axis starts at minValue, not zero!
				this.maxValue = this.minValue + ( this.increment * numScaleItems );
			}

		}
*/
	}


	/***********************************************************************************************
	 * Rounds the scale increment up by the power of ten specified in the properties.
	 *
	 * @param value the value to round
	 * @param powerOfTen the product of 10 times the rounding property.
	 * @return double the rounded result
	 ************************************************************************************************/
	private double round( double value, double powerOfTen )
	{
/*
		if( super.getAxisChart().getAxisProperties().getDataAxisRoundValuesToNearest() > 0 )
		{
			return ( Math.round( value / powerOfTen ) * powerOfTen );
		}
		else if( super.getAxisChart().getAxisProperties().getDataAxisRoundValuesToNearest() < 0 )
		{
			return ( Math.round( value * powerOfTen ) / powerOfTen );
		}
		else
		{
			return ( Math.round( value ) );
		}
*/
		return 0;
	}


	/***********************************************************************************************
	 * Rounds the scale increment up by the power of ten specified in the properties.
	 *
	 * @param powerOfTen the value of 10 times the rounding property.
	 ************************************************************************************************/
	private void roundTheIncrement( double powerOfTen )
	{
/*
		this.increment = this.round( this.increment, powerOfTen );

		//---round the increment up
		if( super.getAxisChart().getAxisProperties().getDataAxisRoundValuesToNearest() > 0 )
		{
			this.increment += powerOfTen;
		}
		else
		{
			this.increment += ( 1 / powerOfTen );
		}
*/
	}


	/**************************************************************************************************
	 * Returns the screen coordinate of the zero line.  This will not always be the same as the origin
	 *  as not all charts start at zero.
	 *
	 * @return float the screen pixel location of the zero line.
	 ***************************************************************************************************/
	public float getZeroLineCoordinate()
	{
		return this.zeroLineCoordinate;
	}


	/*************************************************************************************************
	 * Takes a value and determines the screen coordinate it should be drawn at.
	 *
	 * @param value
	 * @return float the screen pixel coordinate
	 **************************************************************************************************/
	float computeAxisCoordinate( double value )
	{
/*
		double returnValue;

		if( amHorizontal() == false )
		{
			returnValue = super.getOrigin() - ( value - this.getMinValue() ) * this.getOneUnitPixelSize();

		}
		else
		{
			returnValue = super.getOrigin() + ( value - this.getMinValue() ) * this.getOneUnitPixelSize();
		}
*/

		/* -- Debug for various settings..
		System.out.println("Pix:"+this.getOneUnitPixelSize());
		System.out.println("origin:"+super.getOrigin());
		System.out.println("Ret"+returnValue);
		*/

//		return (float) returnValue;

		return 0;
	}


	/**************************************************************************************************
	 * Returns the MAX value plotted by the axis.
	 *
	 * @return double the MAX value plotted by the axis
	 ***************************************************************************************************/
	public double getMaxValue()
	{
		return this.maxValue;
	}


	/**************************************************************************************************
	 * Returns the MIN value plotted by the axis.
	 *
	 * @return double the MIN value plotted by the axis
	 ***************************************************************************************************/
	public double getMinValue()
	{
		return this.minValue;
	}


	/**************************************************************************************************
	 * Returns the number of pixels one value unit occupies.
	 *
	 * @return double the number of pixels one value unit occupies.
	 ***************************************************************************************************/
	public double getOneUnitPixelSize()
	{
		/* -- Debug for various settings
		System.out.println("inc:"+this.increment);
		System.out.println("Scale:"+this.getScalePixelLength());
		*/
		//return ( super.getScalePixelLength() / this.increment );

		return 0;
		// return this.oneUnitPixelSize; // Old code
	}


	/*********************************************************************************************
	 * Renders the DataAxis on the passes Graphics2D object
	 *
	 * @param graphics2D
	 * @param iDataSeries
	 **********************************************************************************************/
	protected void render( Graphics2D graphics2D,
	                       IDataSeries iDataSeries )
	{
/*
		super.render( graphics2D, iDataSeries );

		Line2D.Float line2D = new Line2D.Float();

		if( amHorizontal() )
		{
			line2D = super.getAxisChart().getVerticalAxis().getAxisLine( line2D );
		}
		else
		{
			line2D = super.getAxisChart().getHorizontalAxis().getAxisLine( line2D );
		}

		float offset = super.getScalePixelLength();
		offset *= (float) -this.minValue;
		offset /= (float) this.increment;

		offset = ( amHorizontal() ) ? offset : -offset;

		float start = ( amHorizontal() ) ? line2D.x1 : line2D.y1;

		//---need this regardless if draw line or not.
		this.zeroLineCoordinate = start + offset;

		// System.out.println("Zero Line:"+zeroLineCoordinate);


		//---ZERO LINE
		if( super.getAxisChart().getAxisProperties().getShowZeroLine() &&
		   this.minValue < 0.0d &&
		   this.maxValue > 0.0d )
		{
			if( amHorizontal() )
			{
				line2D.x1 = this.zeroLineCoordinate;
				line2D.x2 = line2D.x1;
			}
			else
			{
				line2D.y1 = this.zeroLineCoordinate;
				line2D.y2 = line2D.y1;
			}

			graphics2D.setStroke( super.getAxisChart().getAxisProperties().getZeroLineStroke() );
			graphics2D.setPaint( super.getAxisChart().getAxisProperties().getZeroLinePaint() );
			graphics2D.draw( line2D );
		}
*/
	}


	/*********************************************************************************************
	 * Enables the testing routines to display the contents of this Object.
	 *
	 * @param htmlGenerator
	 **********************************************************************************************/
	public void toHTML( HTMLGenerator htmlGenerator )
	{
		super.toHTML( htmlGenerator );
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -