You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(95) |
Sep
(42) |
Oct
(2) |
Nov
(7) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
|
Feb
(34) |
Mar
|
Apr
|
May
(64) |
Jun
(113) |
Jul
(60) |
Aug
(9) |
Sep
(6) |
Oct
(20) |
Nov
(11) |
Dec
|
From: Gann B. <ga...@us...> - 2004-11-19 01:35:46
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11034/src/java/org/krysalis/jcharts/axisChart Modified Files: AxisChart.java Log Message: Added ability to have a custom NumberFormat for the y axis. Sometimes percent or dollar signs just is not enough... Index: AxisChart.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/AxisChart.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** AxisChart.java 5 Nov 2004 01:49:20 -0000 1.14 --- AxisChart.java 19 Nov 2004 01:35:35 -0000 1.15 *************** *** 189,198 **** //TODO what if they do not want to display axis labels? //todo we still need to know how to size the axis ! NumericTagGroup numericTagGroup = new NumericTagGroup( dataAxisProperties.getScaleChartFont(), ! fontRenderContext, ! dataAxisProperties.useDollarSigns(), ! dataAxisProperties.usePercentSigns(), ! dataAxisProperties.useCommas(), ! dataAxisProperties.getRoundToNearest() ); numericTagGroup.createAxisScaleLabels( axis.getScaleCalculator() ); --- 189,211 ---- //TODO what if they do not want to display axis labels? //todo we still need to know how to size the axis ! NumericTagGroup numericTagGroup = null; ! if (dataAxisProperties.getCustomFormatter() != null) ! { ! numericTagGroup = new NumericTagGroup(dataAxisProperties.getScaleChartFont(), ! fontRenderContext, ! dataAxisProperties.getCustomFormatter()); ! } ! else ! { ! numericTagGroup = new NumericTagGroup( dataAxisProperties.getScaleChartFont(), ! fontRenderContext, ! dataAxisProperties.useDollarSigns(), ! dataAxisProperties.usePercentSigns(), ! dataAxisProperties.useCommas(), ! dataAxisProperties.getRoundToNearest() ); ! } ! ! ! numericTagGroup.createAxisScaleLabels( axis.getScaleCalculator() ); |
From: Gann B. <ga...@us...> - 2004-11-19 01:35:46
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/chartText In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11034/src/java/org/krysalis/jcharts/chartText Modified Files: NumericTagGroup.java Log Message: Added ability to have a custom NumberFormat for the y axis. Sometimes percent or dollar signs just is not enough... Index: NumericTagGroup.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/chartText/NumericTagGroup.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NumericTagGroup.java 17 May 2003 16:58:32 -0000 1.1 --- NumericTagGroup.java 19 Nov 2004 01:35:35 -0000 1.2 *************** *** 74,77 **** --- 74,85 ---- } + public NumericTagGroup( ChartFont chartFont, + FontRenderContext fontRenderContext, + NumberFormat format ) + { + super( chartFont, fontRenderContext); + this.numberFormat = format; + } + /********************************************************************************************* |
From: Gann B. <ga...@us...> - 2004-11-19 01:35:46
|
Update of /cvsroot/jcharts/krysalis-jcharts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11034 Modified Files: status.xml Log Message: Added ability to have a custom NumberFormat for the y axis. Sometimes percent or dollar signs just is not enough... Index: status.xml =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/status.xml,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** status.xml 16 Nov 2004 06:39:34 -0000 1.25 --- status.xml 19 Nov 2004 01:35:34 -0000 1.26 *************** *** 75,78 **** --- 75,81 ---- Added ability to align rotated X-labels at the top rather than the bottom with <code>AxisTypeProperties.setRotatedLabelAlignTop(true)</code>. This also causes the tops to "point" directly to the matching points on the X axis rather than be centered below them. </action> + <action dev="Gann Bierner" type="add" context="code"> + Added api to set a custom number formatter for <code>DataAxisProperties</code> + </action> </release> |
From: Gann B. <ga...@us...> - 2004-11-19 01:35:45
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/properties In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11034/src/java/org/krysalis/jcharts/properties Modified Files: DataAxisProperties.java Log Message: Added ability to have a custom NumberFormat for the y axis. Sometimes percent or dollar signs just is not enough... Index: DataAxisProperties.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/properties/DataAxisProperties.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DataAxisProperties.java 17 May 2003 17:00:34 -0000 1.1 --- DataAxisProperties.java 19 Nov 2004 01:35:35 -0000 1.2 *************** *** 48,51 **** --- 48,52 ---- import java.lang.reflect.Field; + import java.text.NumberFormat; *************** *** 70,73 **** --- 71,75 ---- private boolean usePercentSigns = false; + private NumberFormat customFormatter = null; //---holds data relevant to values displayed on the axis. may be null *************** *** 106,109 **** --- 108,122 ---- + public NumberFormat getCustomFormatter() + { + return customFormatter; + } + + + public void setCustomFormatter( NumberFormat formatter ) + { + this.customFormatter = formatter; + } + public int getRoundToNearest() { *************** *** 116,120 **** this.roundToNearest = roundToNearest; } ! public boolean showZeroLine() --- 129,133 ---- this.roundToNearest = roundToNearest; } ! public boolean showZeroLine() |
From: Gann B. <ga...@us...> - 2004-11-19 01:34:44
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/imageMap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10813/src/java/org/krysalis/jcharts/imageMap Modified Files: CircleMapArea.java ImageMapArea.java Log Message: Opened up the API some because not everyone is going to access this through jsp. Index: CircleMapArea.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/imageMap/CircleMapArea.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CircleMapArea.java 17 May 2003 16:59:18 -0000 1.1 --- CircleMapArea.java 19 Nov 2004 01:34:31 -0000 1.2 *************** *** 118,122 **** ! protected void getCoordinates( StringBuffer html ) { html.append( this.x[ 0 ] + "," + this.y[ 0 ] + "," + this.radius ); --- 118,122 ---- ! public void getCoordinates( StringBuffer html ) { html.append( this.x[ 0 ] + "," + this.y[ 0 ] + "," + this.radius ); Index: ImageMapArea.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/imageMap/ImageMapArea.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ImageMapArea.java 17 May 2003 16:59:18 -0000 1.1 --- ImageMapArea.java 19 Nov 2004 01:34:31 -0000 1.2 *************** *** 108,112 **** * @return AreaShape ***********************************************************************************/ ! abstract AreaShape getAreaShape(); --- 108,112 ---- * @return AreaShape ***********************************************************************************/ ! public abstract AreaShape getAreaShape(); *************** *** 187,191 **** * @param html pass a reference to the StringBuffer so I can minimize Object creation ****************************************************************************************/ ! protected void getCoordinates( StringBuffer html ) { for( int i=0; i < this.x.length; i++ ) --- 187,191 ---- * @param html pass a reference to the StringBuffer so I can minimize Object creation ****************************************************************************************/ ! public void getCoordinates( StringBuffer html ) { for( int i=0; i < this.x.length; i++ ) |
From: Gann B. <ga...@us...> - 2004-11-16 07:02:43
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/documentation/content/xdocs/userGuide/axisCharts/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12415/src/documentation/content/xdocs/userGuide/axisCharts/common Modified Files: axisLabels.xml Log Message: Added ability to align rotated X-labels at the top rather the bottom. This also causes the tops to point directly to the matching points on the X axis rather than be centered below them. Finally, just like with purely vertical labels, we only need consider the text height rather than width to figure out how many to show in this case. Index: axisLabels.xml =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/documentation/content/xdocs/userGuide/axisCharts/common/axisLabels.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** axisLabels.xml 14 Jun 2004 03:35:16 -0000 1.2 --- axisLabels.xml 16 Nov 2004 07:02:25 -0000 1.3 *************** *** 46,49 **** --- 46,52 ---- AxisProperties axisProperties= new AxisProperties( false ); axisProperties.getXAxisProperties().setLabelRotationAngle(30); + // The line below causes the labels to be aligned at the top rather than bottom + // and to point to the matching position on the X-axis rather than centered below. + // axisProperties.getXAxisProperties().setRotatedLabelAlignTop(true); </source> <figure src="images/userGuide/axisCharts/rotatedXAxisLabels.png" alt="X Axis Label Rotation"/> |
From: Gann B. <ga...@us...> - 2004-11-16 06:39:44
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/axis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8971/src/java/org/krysalis/jcharts/axisChart/axis Modified Files: XAxis.java Log Message: Added ability to align rotated X-labels at the top rather the bottom. This also causes the tops to point directly to the matching points on the X axis rather than be centered below them. Finally, just like with purely vertical labels, we only need consider the text height rather than width to figure out how many to show in this case. Index: XAxis.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/axis/XAxis.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** XAxis.java 13 Aug 2004 01:46:23 -0000 1.6 --- XAxis.java 16 Nov 2004 06:39:34 -0000 1.7 *************** *** 316,323 **** if ( axisTypeProperties.getLabelRotationAngle() != 0 ) { ! stringY += super.getAxisLabelsGroup().getWidestLabel() ! * (float)Math.abs(Math.sin(Math.toRadians(axisTypeProperties.getLabelRotationAngle()))); // Find the vertical drop of the tallest text label ! stringY += super.getAxisLabelsGroup().getTallestLabel() ! * (float)Math.abs(Math.cos(Math.toRadians(axisTypeProperties.getLabelRotationAngle()))); graphics2D.setFont( axisTypeProperties.getScaleChartFont().getFont() ); } --- 316,327 ---- if ( axisTypeProperties.getLabelRotationAngle() != 0 ) { ! if (! axisTypeProperties.getRotatedLabelAlignTop()) { ! ! stringY += super.getAxisLabelsGroup().getWidestLabel() ! * (float)Math.abs(Math.sin(Math.toRadians(axisTypeProperties.getLabelRotationAngle()))); // Find the vertical drop of the tallest text label ! stringY += super.getAxisLabelsGroup().getTallestLabel() ! * (float)Math.abs(Math.cos(Math.toRadians(axisTypeProperties.getLabelRotationAngle()))); ! ! } graphics2D.setFont( axisTypeProperties.getScaleChartFont().getFont() ); } *************** *** 387,393 **** { // x1 is the 1/2 the horizontal width of the rotated label ! float x1 = (super.getAxisLabelsGroup().getTextTag( i ).getWidth() / 2) * (float)Math.abs(Math.cos(Math.toRadians(axisTypeProperties.getLabelRotationAngle()))); ! //---we can not only look at the last label as there could be a filter and labels near the last might go off the edge of the screen. ! if( stringX + x1 < super.getAxisChart().getImageWidth() ) { //---get the original transform so we can reset it. --- 391,402 ---- { // x1 is the 1/2 the horizontal width of the rotated label ! float x1 = axisTypeProperties.getRotatedLabelAlignTop() ? ! (super.getAxisLabelsGroup().getTextTag( i ).getWidth()) * (float)Math.abs(Math.cos(Math.toRadians(axisTypeProperties.getLabelRotationAngle()))) : ! (super.getAxisLabelsGroup().getTextTag( i ).getWidth() / 2) * (float)Math.abs(Math.cos(Math.toRadians(axisTypeProperties.getLabelRotationAngle()))); ! ! //---we can not only look at the last label as there could be a filter and labels near the last might go off the edge of the screen. ! // Gann: only need to add x1 if it's not the full text width. ! float extraWidth = axisTypeProperties.getRotatedLabelAlignTop() ? 0 : x1; ! if( stringX + extraWidth < super.getAxisChart().getImageWidth() ) { //---get the original transform so we can reset it. *************** *** 397,402 **** // calculate the X coord to center the top of the label text to the axis tick as opposed to the bottom // x2 takes this into account ! float x2 = super.getAxisLabelsGroup().getTextTag( i ).getFontDescent() * (float)Math.abs(Math.sin(Math.toRadians(axisTypeProperties.getLabelRotationAngle()))); ! graphics2D.translate(stringX - x1 + x2, stringY); // rotate entire context graphics2D.rotate(Math.toRadians(-axisTypeProperties.getLabelRotationAngle())); --- 406,418 ---- // calculate the X coord to center the top of the label text to the axis tick as opposed to the bottom // x2 takes this into account ! float x2 = super.getAxisLabelsGroup().getTextTag( i ).getFontDescent() * (float)Math.abs(Math.sin(Math.toRadians(axisTypeProperties.getLabelRotationAngle()))); ! if (axisTypeProperties.getRotatedLabelAlignTop()) { ! float y = super.getAxisLabelsGroup().getTextTag( i ).getWidth() * (float)Math.abs(Math.sin(Math.toRadians(axisTypeProperties.getLabelRotationAngle()))); ! graphics2D.translate(stringX - x1 + x2, stringY + y); ! ! } else { ! graphics2D.translate(stringX - x1 + x2, stringY); ! } ! // rotate entire context graphics2D.rotate(Math.toRadians(-axisTypeProperties.getLabelRotationAngle())); *************** *** 486,490 **** AxisTypeProperties axisTypeProperties = super.getAxisChart().getAxisProperties().getXAxisProperties(); ! if( super.getAxisChart().getAxisProperties().xAxisLabelsAreVertical() ) { widestLabelSize = super.getAxisLabelsGroup().getTallestLabel(); --- 502,518 ---- AxisTypeProperties axisTypeProperties = super.getAxisChart().getAxisProperties().getXAxisProperties(); ! if ( axisTypeProperties.getLabelRotationAngle() != 0) { ! // if we are aligning our rotated labels at the top rather and therefore they are ! // "pointing" at the proper point on the axis axis (rather than being centered below ! // it, then these are effectively just like vertical labels. If they are centered, ! // then it's best to separate them by the full bounding box of the labels. ! if ( axisTypeProperties.getRotatedLabelAlignTop() ) { ! widestLabelSize = super.getAxisLabelsGroup().getTallestLabel(); ! } else { ! widestLabelSize = (super.getAxisLabelsGroup().getWidestLabel()) * (float)Math.abs(Math.cos(Math.toRadians(axisTypeProperties.getLabelRotationAngle()))); ! ! } ! } ! else if( super.getAxisChart().getAxisProperties().xAxisLabelsAreVertical() ) { widestLabelSize = super.getAxisLabelsGroup().getTallestLabel(); |
From: Gann B. <ga...@us...> - 2004-11-16 06:39:44
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/properties In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8971/src/java/org/krysalis/jcharts/properties Modified Files: AxisTypeProperties.java Log Message: Added ability to align rotated X-labels at the top rather the bottom. This also causes the tops to point directly to the matching points on the X axis rather than be centered below them. Finally, just like with purely vertical labels, we only need consider the text height rather than width to figure out how many to show in this case. Index: AxisTypeProperties.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/properties/AxisTypeProperties.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AxisTypeProperties.java 1 Jul 2004 01:47:53 -0000 1.4 --- AxisTypeProperties.java 16 Nov 2004 06:39:34 -0000 1.5 *************** *** 91,94 **** --- 91,95 ---- private boolean showAxis = true; private int labelRotationAngle = 0; + private boolean rotatedLabelAlignTop = false; *************** *** 293,296 **** --- 294,306 ---- } + public boolean getRotatedLabelAlignTop( ) + { + return this.rotatedLabelAlignTop; + } + + public void setRotatedLabelAlignTop( boolean rotatedLabelAlignTop ) + { + this.rotatedLabelAlignTop = rotatedLabelAlignTop; + } public int getLabelRotationAngle() |
From: Gann B. <ga...@us...> - 2004-11-16 06:39:43
|
Update of /cvsroot/jcharts/krysalis-jcharts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8971 Modified Files: status.xml Log Message: Added ability to align rotated X-labels at the top rather the bottom. This also causes the tops to point directly to the matching points on the X axis rather than be centered below them. Finally, just like with purely vertical labels, we only need consider the text height rather than width to figure out how many to show in this case. Index: status.xml =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/status.xml,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** status.xml 5 Nov 2004 01:49:20 -0000 1.24 --- status.xml 16 Nov 2004 06:39:34 -0000 1.25 *************** *** 72,75 **** --- 72,78 ---- Fixed exception in <code>AxisChart</code> when there are no RightYAxisProperties. This was breaking the "Horizontal Bar with Image Map" demo. </action> + <action dev="Gann Bierner" type="add" context="code"> + Added ability to align rotated X-labels at the top rather than the bottom with <code>AxisTypeProperties.setRotatedLabelAlignTop(true)</code>. This also causes the tops to "point" directly to the matching points on the X axis rather than be centered below them. + </action> </release> |
From: Gann B. <ga...@us...> - 2004-11-05 01:49:30
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9685/src/java/org/krysalis/jcharts/axisChart Modified Files: AxisChart.java Log Message: Fixed NPE in overlayChartsAutomatically when there is no rightYAxisProperties. Index: AxisChart.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/AxisChart.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AxisChart.java 18 Oct 2004 03:04:14 -0000 1.13 --- AxisChart.java 5 Nov 2004 01:49:20 -0000 1.14 *************** *** 597,601 **** StackedAreaChart.render( this, ( IAxisChartDataSet ) iAxisPlotDataSet ); } ! if ( this.axisProperties.getRightYAxisProperties().getShowAxis() ) { iAxisPlotDataSet = this.iAxisDataSeries.getIAxisPlotDataSet( ChartType.AREA_STACKED_RHS ); if( iAxisPlotDataSet != null ) --- 597,602 ---- StackedAreaChart.render( this, ( IAxisChartDataSet ) iAxisPlotDataSet ); } ! if ( this.axisProperties.getRightYAxisProperties() != null && ! this.axisProperties.getRightYAxisProperties().getShowAxis() ) { iAxisPlotDataSet = this.iAxisDataSeries.getIAxisPlotDataSet( ChartType.AREA_STACKED_RHS ); if( iAxisPlotDataSet != null ) |
From: Gann B. <ga...@us...> - 2004-11-05 01:49:29
|
Update of /cvsroot/jcharts/krysalis-jcharts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9685 Modified Files: status.xml Log Message: Fixed NPE in overlayChartsAutomatically when there is no rightYAxisProperties. Index: status.xml =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/status.xml,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** status.xml 18 Oct 2004 03:04:13 -0000 1.23 --- status.xml 5 Nov 2004 01:49:20 -0000 1.24 *************** *** 69,72 **** --- 69,75 ---- Added constructor to <code>ValueLabelRenderer</code> to use a custom number formatter. </action> + <action dev="Gann Bierner" type="fix" context="code"> + Fixed exception in <code>AxisChart</code> when there are no RightYAxisProperties. This was breaking the "Horizontal Bar with Image Map" demo. + </action> </release> |
From: Nathaniel G. A. <nat...@us...> - 2004-10-28 21:03:11
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29471/src/java/org/krysalis/jcharts/axisChart Modified Files: RegressionChart.java Log Message: Index: RegressionChart.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/RegressionChart.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RegressionChart.java 27 Oct 2004 20:44:13 -0000 1.3 --- RegressionChart.java 28 Oct 2004 21:02:59 -0000 1.4 *************** *** 48,53 **** /************************************************************************************** * ! * @author Nathan Feger * @version $Id$ ************************************************************************************/ --- 48,54 ---- /************************************************************************************** + * Regression Chart * ! * @author Nathan Feger, Nathaniel Auvil * @version $Id$ ************************************************************************************/ *************** *** 64,72 **** double Sxx, Sxy, Syy; double a, b; //regression coefficients ! ArrayList v = new ArrayList(); //vector of points ! ArrayList residuals = new ArrayList(); //vector of residuals ! private double figureY( YAxis yAxis, double num ) { --- 65,78 ---- double Sxx, Sxy, Syy; double a, b; //regression coefficients ! ArrayList v = new ArrayList(); ! ArrayList residuals = new ArrayList(); + /************************************************************************************** + * + * @param yAxis + * @param num + * @return + *************************************************************************************/ private double figureY( YAxis yAxis, double num ) { *************** *** 91,95 **** //---cache the computed values ! float[][] yAxisCoordinates = new float[iAxisChartDataSet.getNumberOfDataSets()][iAxisChartDataSet.getNumberOfDataItems()]; //---need this for image map calculation --- 97,101 ---- //---cache the computed values ! float[][] yAxisCoordinates = new float[ iAxisChartDataSet.getNumberOfDataSets() ][ iAxisChartDataSet.getNumberOfDataItems() ]; //---need this for image map calculation *************** *** 102,111 **** for( int i = 0; i < yAxisCoordinates.length; i++ ) { if( iAxisChartDataSet.getValue( i, j ) != Double.NaN ) { ! yAxisCoordinates[i][j] = axisChart.getYAxis().computeAxisCoordinate( axisChart.getYAxis().getOrigin(), iAxisChartDataSet.getValue( i, j ), axisChart.getYAxis().getScaleCalculator().getMinValue() ); ! addLoc( new Loc( j, iAxisChartDataSet.getValue( i, j ) ) ); --- 108,118 ---- for( int i = 0; i < yAxisCoordinates.length; i++ ) { + //TODO how does this affect things? Need to test Double.NaN if( iAxisChartDataSet.getValue( i, j ) != Double.NaN ) { ! /* yAxisCoordinates[i][j] = axisChart.getYAxis().computeAxisCoordinate( axisChart.getYAxis().getOrigin(), iAxisChartDataSet.getValue( i, j ), axisChart.getYAxis().getScaleCalculator().getMinValue() ); ! */ addLoc( new Loc( j, iAxisChartDataSet.getValue( i, j ) ) ); *************** *** 124,131 **** axisChart.getImageMap().addImageMapArea( new CircleMapArea( xMapCoordinate, ! yAxisCoordinates[i][j], ! iAxisChartDataSet.getValue( i, j ), ! label, ! iAxisChartDataSet.getLegendLabel( i ) ) ); } } --- 131,138 ---- axisChart.getImageMap().addImageMapArea( new CircleMapArea( xMapCoordinate, ! yAxisCoordinates[i][j], ! iAxisChartDataSet.getValue( i, j ), ! label, ! iAxisChartDataSet.getLegendLabel( i ) ) ); } } *************** *** 139,187 **** } - // AffineTransform originalTransform = null; - // double[] cornerXOffset = null; - // double[] cornerYOffset = null; - //---check if there are any points to display if( lineChartProperties.getShapes() != null ) { - //---when centering the shapes on the points, need x and y offset to do this - // cornerXOffset = new double[iAxisChartDataSet.getNumberOfDataSets()]; - // cornerYOffset = new double[iAxisChartDataSet.getNumberOfDataSets()]; - - //---get the original transform so can reset it. - // originalTransform = g2d.getTransform(); - - // Rectangle2D rectangle; - //LOOP for( int i = 0; i < iAxisChartDataSet.getNumberOfDataSets(); i++ ) { ! // if( lineChartProperties.getShapes()[i] != null ) ! { ! // rectangle = lineChartProperties.getShapes()[i].getBounds2D(); ! // cornerXOffset[i] = rectangle.getWidth() / 2; ! // cornerYOffset[i] = rectangle.getHeight() / 2; ! ! ArrayList v = regress(); ! // round to 5 places ! double yoffset = (Math.round( 1.0E5 * a )) * 1.0E-5; ! double slope = (Math.round( 1.0E5 * b )) * 1.0E-5; ! g2d.setPaint( iAxisChartDataSet.getPaint( i ) ); ! //g2d.fill( lineChartProperties.getShapes()[ i ] ); ! g2d.setStroke( lineChartProperties.getLineStrokes()[i] ); ! Line2D.Double line = new Line2D.Double( axisChart.getXAxis().getTickStart(), ! figureY( axisChart.getYAxis(), (yoffset + slope * 0) ), ! axisChart.getXAxis().getTickStart() ! + axisChart.getXAxis().getScalePixelWidth() * (v.size()-2), ! figureY( axisChart.getYAxis(), (yoffset + slope * v.size()) ) ); ! //g2d.fill( line ); ! g2d.draw( line ); ! // g2d.setTransform( originalTransform ); ! } } } --- 146,170 ---- } //---check if there are any points to display if( lineChartProperties.getShapes() != null ) { //LOOP for( int i = 0; i < iAxisChartDataSet.getNumberOfDataSets(); i++ ) { ! ArrayList v = regress(); ! // round to 5 places ! double yoffset = (Math.round( 1.0E5 * a )) * 1.0E-5; ! double slope = (Math.round( 1.0E5 * b )) * 1.0E-5; ! g2d.setPaint( iAxisChartDataSet.getPaint( i ) ); ! g2d.setStroke( lineChartProperties.getLineStrokes()[i] ); ! Line2D.Double line = new Line2D.Double( axisChart.getXAxis().getTickStart(), ! figureY( axisChart.getYAxis(), yoffset ), ! axisChart.getXAxis().getTickStart() + axisChart.getXAxis().getScalePixelWidth() * (v.size()-1), ! figureY( axisChart.getYAxis(), (yoffset + slope * v.size()) ) ); ! g2d.draw( line ); } } *************** *** 189,192 **** --- 172,179 ---- + /************************************************************************************ + * + * @return + ************************************************************************************/ private ArrayList regress() { *************** *** 201,204 **** --- 188,192 ---- a = (sumy - b * sumx) / n; + //LOOP for( int i=0; i < v.size(); i++ ) { *************** *** 213,216 **** --- 201,208 ---- + /*************************************************************************************** + * + * @param numLocs + **************************************************************************************/ private void calculate( int numLocs ) { *************** *** 222,225 **** --- 214,221 ---- + /*************************************************************************************** + * + * @param p + **************************************************************************************/ private void addLoc( Loc p ) { |
From: Nathaniel G. A. <nat...@us...> - 2004-10-27 20:44:25
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10592/src/java/org/krysalis/jcharts/axisChart Modified Files: RegressionChart.java Log Message: Changed Vector to ArrayList for speed improvement. Still does not work correctly though. Index: RegressionChart.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/axisChart/RegressionChart.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RegressionChart.java 13 Aug 2004 01:57:05 -0000 1.2 --- RegressionChart.java 27 Oct 2004 20:44:13 -0000 1.3 *************** *** 38,47 **** import java.awt.*; import java.awt.geom.*; ! import java.util.Vector; ! import java.util.Enumeration; import org.krysalis.jcharts.axisChart.axis.YAxis; import org.krysalis.jcharts.chartData.interfaces.IAxisChartDataSet; - import org.krysalis.jcharts.chartData.interfaces.IDataSeries; import org.krysalis.jcharts.imageMap.CircleMapArea; import org.krysalis.jcharts.properties.LineChartProperties; --- 38,45 ---- import java.awt.*; import java.awt.geom.*; ! import java.util.ArrayList; import org.krysalis.jcharts.axisChart.axis.YAxis; import org.krysalis.jcharts.chartData.interfaces.IAxisChartDataSet; import org.krysalis.jcharts.imageMap.CircleMapArea; import org.krysalis.jcharts.properties.LineChartProperties; *************** *** 66,77 **** double Sxx, Sxy, Syy; double a, b; //regression coefficients ! Vector v = new Vector(); //vector of points ! Vector residuals = new Vector(); //vector of residuals - public RegressionChart() - { - }; - private double figureY( YAxis yAxis, double num ) --- 64,71 ---- double Sxx, Sxy, Syy; double a, b; //regression coefficients ! ArrayList v = new ArrayList(); //vector of points ! ArrayList residuals = new ArrayList(); //vector of residuals private double figureY( YAxis yAxis, double num ) *************** *** 95,102 **** lineChartProperties.validate( iAxisChartDataSet ); ! //DataAxisProperties dataAxisProperties= (DataAxisProperties) ! // axisChart.getAxisProperties().getYAxisProperties(); ! IDataSeries iDataSeries = (IDataSeries) axisChart.getIAxisDataSeries(); ! //---cache the computed values float[][] yAxisCoordinates = new float[iAxisChartDataSet.getNumberOfDataSets()][iAxisChartDataSet.getNumberOfDataItems()]; --- 89,93 ---- lineChartProperties.validate( iAxisChartDataSet ); ! //---cache the computed values float[][] yAxisCoordinates = new float[iAxisChartDataSet.getNumberOfDataSets()][iAxisChartDataSet.getNumberOfDataItems()]; *************** *** 113,121 **** if( iAxisChartDataSet.getValue( i, j ) != Double.NaN ) { ! yAxisCoordinates[i][j] = axisChart.getYAxis().computeAxisCoordinate( axisChart.getYAxis().getOrigin(), ! iAxisChartDataSet.getValue( i, j ), ! axisChart .getYAxis() ! .getScaleCalculator() ! .getMinValue() ); addLoc( new Loc( j, iAxisChartDataSet.getValue( i, j ) ) ); --- 104,110 ---- if( iAxisChartDataSet.getValue( i, j ) != Double.NaN ) { ! yAxisCoordinates[i][j] = axisChart.getYAxis().computeAxisCoordinate( axisChart.getYAxis().getOrigin(), ! iAxisChartDataSet.getValue( i, j ), ! axisChart.getYAxis().getScaleCalculator().getMinValue() ); addLoc( new Loc( j, iAxisChartDataSet.getValue( i, j ) ) ); *************** *** 135,142 **** axisChart.getImageMap().addImageMapArea( new CircleMapArea( xMapCoordinate, ! yAxisCoordinates[i][j], ! iAxisChartDataSet.getValue( i, j ), ! label, ! iAxisChartDataSet.getLegendLabel( i ) ) ); } } --- 124,131 ---- axisChart.getImageMap().addImageMapArea( new CircleMapArea( xMapCoordinate, ! yAxisCoordinates[i][j], ! iAxisChartDataSet.getValue( i, j ), ! label, ! iAxisChartDataSet.getLegendLabel( i ) ) ); } } *************** *** 150,156 **** } ! AffineTransform originalTransform = null; ! double[] cornerXOffset = null; ! double[] cornerYOffset = null; //---check if there are any points to display --- 139,145 ---- } ! // AffineTransform originalTransform = null; ! // double[] cornerXOffset = null; ! // double[] cornerYOffset = null; //---check if there are any points to display *************** *** 158,281 **** { //---when centering the shapes on the points, need x and y offset to do this ! cornerXOffset = new double[iAxisChartDataSet.getNumberOfDataSets()]; ! cornerYOffset = new double[iAxisChartDataSet.getNumberOfDataSets()]; //---get the original transform so can reset it. ! originalTransform = g2d.getTransform(); ! Rectangle2D rectangle; //LOOP - //---pre-compute the dimensions of each Shape so do not do it in loop. for( int i = 0; i < iAxisChartDataSet.getNumberOfDataSets(); i++ ) { ! if( lineChartProperties.getShapes()[i] != null ) { ! rectangle = lineChartProperties.getShapes()[i].getBounds2D(); ! cornerXOffset[i] = rectangle.getWidth() / 2; ! cornerYOffset[i] = rectangle.getHeight() / 2; ! Vector v = regress(); ! // y = yoffset + slope(x) ! double yoffset, slope; // round to 5 places ! yoffset = (Math.round( 1.0E5 * a )) * 1.0E-5; ! slope = (Math.round( 1.0E5 * b )) * 1.0E-5; g2d.setPaint( iAxisChartDataSet.getPaint( i ) ); //g2d.fill( lineChartProperties.getShapes()[ i ] ); g2d.setStroke( lineChartProperties.getLineStrokes()[i] ); ! //Line2D.Double line = new Line2D.Double(start.x, start.y, end.x, end.y); Line2D.Double line = new Line2D.Double( axisChart.getXAxis().getTickStart(), figureY( axisChart.getYAxis(), (yoffset + slope * 0) ), axisChart.getXAxis().getTickStart() ! + axisChart.getXAxis().getScalePixelWidth() * (v.size()-1), figureY( axisChart.getYAxis(), (yoffset + slope * v.size()) ) ); //g2d.fill( line ); g2d.draw( line ); ! g2d.setTransform( originalTransform ); } } } - - //String form = "formula y = "+String.valueOf(yoffset)+" + - // "+String.valueOf(slope)+"x"; - //g2d.drawString(form , 151, 156); - - //---init for first segment - /* - * Line2D.Float line=new Line2D.Float( axisChart.getXAxis().getTickStart(), - * yAxisCoordinates[ 0 ][ 0 ], axisChart.getXAxis().getTickStart(), yAxisCoordinates[ - * 0 ][ 0 ] ); - */ - //---make sure not plotting a chart with only one data point. - /* - * if( yAxisCoordinates[ 0 ].length > 1 ) { line.y2= yAxisCoordinates[ 0 ][ 1 ]; } - */ - - //LOOP - //---draw each line to the image - /* - * for( int i=0; i < yAxisCoordinates.length; i++ ) { - * line.x1=axisChart.getXAxis().getTickStart(); line.y1=yAxisCoordinates[ i ][ 0 ]; - * line.x2=line.x1; - * - * //LOOP for( int j=1; j < yAxisCoordinates[ 0 ].length; j++ ) { //---if current - * point on line should be drawn if( !Float.isNaN( yAxisCoordinates[ i ][ j ] ) ) { - * //---if the previous point was not drawn, no line if( Float.isNaN( - * yAxisCoordinates[ i ][ j - 1 ] ) ) { - * line.x2+=axisChart.getXAxis().getScalePixelWidth(); line.x1=line.x2; - * line.y1=yAxisCoordinates[ i ][ j ]; line.y2=yAxisCoordinates[ i ][ j ]; - * - * continue; } - * - * - * line.x2+=axisChart.getXAxis().getScalePixelWidth(); line.y2=yAxisCoordinates[ i ][ - * j ]; - * - * g2d.setPaint( iAxisChartDataSet.getPaint( i ) ); g2d.setStroke( - * lineChartProperties.getLineStrokes()[ i ] ); g2d.draw( line ); - * - * //---plot the Point if( lineChartProperties.getShapes()[ i ] != null ) { - * //---translate the Shape into position. g2d.translate( line.x1 - cornerXOffset[ i ], - * line.y1 - cornerYOffset[ i ] ); - * - * g2d.setPaint( iAxisChartDataSet.getPaint( i ) ); g2d.fill( - * lineChartProperties.getShapes()[ i ] ); - * - * //---translate back to the original position g2d.setTransform( originalTransform ); } - * - * line.x1=line.x2; line.y1=line.y2; } else { if( ( !Float.isNaN( yAxisCoordinates[ i ][ - * j - 1 ] ) ) && ( lineChartProperties.getShapes()[ i ] != null ) ) { //---translate - * the Shape into position. g2d.translate( line.x1 - cornerXOffset[ i ], line.y1 - - * cornerYOffset[ i ] ); - * - * g2d.setPaint( iAxisChartDataSet.getPaint( i ) ); g2d.fill( - * lineChartProperties.getShapes()[ i ] ); - * - * //---translate back to the original position g2d.setTransform( originalTransform ); } - * - * line.x2+=axisChart.getXAxis().getScalePixelWidth(); line.x1=line.x2; } } - * - * - * //---put the last shape on the line if( ( !Float.isNaN( yAxisCoordinates[ i ][ - * yAxisCoordinates[ i ].length - 1 ] ) ) && ( lineChartProperties.getShapes()[ i ] != - * null ) ) { //---translate the Shape into position. g2d.translate( line.x2 - - * cornerXOffset[ i ], line.y2 - cornerYOffset[ i ] ); - * - * g2d.setPaint( iAxisChartDataSet.getPaint( i ) ); g2d.fill( - * lineChartProperties.getShapes()[ i ] ); - * - * //---translate back to the original position g2d.setTransform( originalTransform ); } } - */ } ! private Vector regress() { ! Vector resid = new Vector(); Loc p, q; double currentResidual; ! double n = (double) numberLocs; Sxx = sumxx - sumx * sumx / n; Syy = sumyy - sumy * sumy / n; --- 147,198 ---- { //---when centering the shapes on the points, need x and y offset to do this ! // cornerXOffset = new double[iAxisChartDataSet.getNumberOfDataSets()]; ! // cornerYOffset = new double[iAxisChartDataSet.getNumberOfDataSets()]; //---get the original transform so can reset it. ! // originalTransform = g2d.getTransform(); ! // Rectangle2D rectangle; //LOOP for( int i = 0; i < iAxisChartDataSet.getNumberOfDataSets(); i++ ) { ! // if( lineChartProperties.getShapes()[i] != null ) { ! // rectangle = lineChartProperties.getShapes()[i].getBounds2D(); ! // cornerXOffset[i] = rectangle.getWidth() / 2; ! // cornerYOffset[i] = rectangle.getHeight() / 2; ! ArrayList v = regress(); ! ! // round to 5 places ! double yoffset = (Math.round( 1.0E5 * a )) * 1.0E-5; ! double slope = (Math.round( 1.0E5 * b )) * 1.0E-5; g2d.setPaint( iAxisChartDataSet.getPaint( i ) ); //g2d.fill( lineChartProperties.getShapes()[ i ] ); g2d.setStroke( lineChartProperties.getLineStrokes()[i] ); ! Line2D.Double line = new Line2D.Double( axisChart.getXAxis().getTickStart(), figureY( axisChart.getYAxis(), (yoffset + slope * 0) ), axisChart.getXAxis().getTickStart() ! + axisChart.getXAxis().getScalePixelWidth() * (v.size()-2), figureY( axisChart.getYAxis(), (yoffset + slope * v.size()) ) ); //g2d.fill( line ); g2d.draw( line ); ! // g2d.setTransform( originalTransform ); } } } } ! private ArrayList regress() { ! ArrayList resid = new ArrayList(); Loc p, q; double currentResidual; ! double n = numberLocs; Sxx = sumxx - sumx * sumx / n; Syy = sumyy - sumy * sumy / n; *************** *** 283,296 **** b = Sxy / Sxx; a = (sumy - b * sumx) / n; ! for( Enumeration e = v.elements(); e.hasMoreElements(); ) { ! p = (Loc) e.nextElement(); currentResidual = p.y - (a + b * p.x); q = new Loc( p.x, (int) currentResidual ); ! resid.addElement( q ); ! } return resid; - } --- 200,213 ---- b = Sxy / Sxx; a = (sumy - b * sumx) / n; ! ! for( int i=0; i < v.size(); i++ ) { ! p = (Loc) v.get( i ); currentResidual = p.y - (a + b * p.x); q = new Loc( p.x, (int) currentResidual ); ! resid.add( q ); } + return resid; } *************** *** 307,311 **** private void addLoc( Loc p ) { ! v.addElement( p ); numberLocs++; sumx += p.x; --- 224,228 ---- private void addLoc( Loc p ) { ! v.add( p ); numberLocs++; sumx += p.x; |
From: Nathaniel G. A. <nat...@us...> - 2004-10-25 02:30:27
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8136/src/java/org/krysalis/jcharts/legend Modified Files: Legend.java Symbol.java LineSymbol.java Item.java Log Message: Index: Item.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend/Item.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Item.java 23 Oct 2004 17:38:36 -0000 1.1 --- Item.java 25 Oct 2004 02:30:18 -0000 1.2 *************** *** 67,74 **** --- 67,87 ---- /************************************************************************************** * + * @return + **************************************************************************************/ + public float getWidth() + { + return this.width; + } + + + /************************************************************************************** + * * @param g2d *************************************************************************************/ public void render( Graphics2D g2d ) { + this.symbol.render( g2d ); + + } Index: Symbol.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend/Symbol.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Symbol.java 23 Oct 2004 17:38:59 -0000 1.1 --- Symbol.java 25 Oct 2004 02:30:18 -0000 1.2 *************** *** 48,54 **** class Symbol { ! private Shape shape; ! private Paint fillPaint; ! private Paint outlinePaint; private float width; --- 48,54 ---- class Symbol { ! Shape shape; ! Paint fillPaint; ! Paint outlinePaint; private float width; *************** *** 74,78 **** ****************************************************************************************/ public void render( Graphics2D g2d ) ! { } --- 74,89 ---- ****************************************************************************************/ public void render( Graphics2D g2d ) ! { ! if( this.fillPaint != null ) ! { ! g2d.setPaint( this.fillPaint ); ! g2d.fill( shape ); ! } ! ! if( this.outlinePaint != null ) ! { ! g2d.setPaint( this.outlinePaint ); ! g2d.draw( shape ); ! } } Index: LineSymbol.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend/LineSymbol.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LineSymbol.java 23 Oct 2004 17:38:50 -0000 1.1 --- LineSymbol.java 25 Oct 2004 02:30:18 -0000 1.2 *************** *** 41,44 **** --- 41,45 ---- import java.awt.Stroke; import java.awt.geom.Line2D; + import java.awt.geom.Rectangle2D; *************** *** 51,54 **** --- 52,56 ---- { private Stroke stroke; + private int lineLength; *************** *** 56,69 **** * * @param shape * @param lineStroke *************************************************************************************/ ! public LineSymbol( Shape shape, Paint fillPaint, Stroke lineStroke ) { super( shape, fillPaint, null ); this.stroke= lineStroke; } - /************************************************************************************* * --- 58,73 ---- * * @param shape + * @param fillPaint * @param lineStroke + * @param lineLength *************************************************************************************/ ! public LineSymbol( Shape shape, Paint fillPaint, Stroke lineStroke, int lineLength ) { super( shape, fillPaint, null ); this.stroke= lineStroke; + this.lineLength= lineLength; } /************************************************************************************* * *************** *** 72,80 **** public void render( Graphics2D g2d ) { ! Line2D.Double line; ! //TODO draw the line ! super.render( g2d ); } --- 76,102 ---- public void render( Graphics2D g2d ) { ! Rectangle2D shapeBounds = super.shape.getBounds2D(); ! double xOffset = shapeBounds.getWidth() / 2; ! double yOffset = shapeBounds.getHeight() / 2; ! g2d.setStroke( this.stroke ); ! g2d.draw( new Line2D.Double( 0, yOffset, this.lineLength, yOffset ) ); ! //---translate the Shape to adjust for the lineLength ! g2d.translate( xOffset, 0 ); ! ! ! if( super.fillPaint != null ) ! { ! g2d.setPaint( super.fillPaint ); ! g2d.fill( super.shape ); ! } ! ! if( super.outlinePaint != null ) ! { ! g2d.setPaint( super.outlinePaint ); ! g2d.draw( super.shape ); ! } ! } Index: Legend.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend/Legend.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Legend.java 23 Oct 2004 17:44:48 -0000 1.1 --- Legend.java 25 Oct 2004 02:30:17 -0000 1.2 *************** *** 100,103 **** --- 100,104 ---- ChartType chartType; ArrayList shapes, fillPointsFlags, strokes, pointOutlinePaints, labels, paints; + *************** *** 271,275 **** } ! LineSymbol lineSymbol= new LineSymbol( shape, iAxisPlotDataSet.getPaint( i ), lineChartProperties.getLineStrokes()[ i ] ); this.items.add( new Item( lineSymbol, iAxisPlotDataSet.getLegendLabel( i ) ) ); } --- 272,279 ---- } ! LineSymbol lineSymbol= new LineSymbol( shape, ! iAxisPlotDataSet.getPaint( i ), ! lineChartProperties.getLineStrokes()[ i ], ! this.legendProperties.getIconLineStrokeLength() ); this.items.add( new Item( lineSymbol, iAxisPlotDataSet.getLegendLabel( i ) ) ); } *************** *** 300,306 **** { //TODO this probably should be moved into the Item Class. ! this.textProcessor.addLabel( iPieChartDataSet.getLegendLabel( i ), ! this.legendProperties.getChartFont().getFont(), ! this.chart.getGraphics2D().getFontRenderContext() ); Symbol symbol= new Symbol( PointChartProperties.SHAPE_SQUARE, --- 304,310 ---- { //TODO this probably should be moved into the Item Class. ! this.textProcessor.addLabel( iPieChartDataSet.getLegendLabel( i ), ! this.legendProperties.getChartFont().getFont(), ! this.chart.getGraphics2D().getFontRenderContext() ); Symbol symbol= new Symbol( PointChartProperties.SHAPE_SQUARE, *************** *** 347,352 **** //---make the icon proportional to the Font being used. this.iconSide = (float) .50 * this.textProcessor.getTallestLabel(); ! //---for POINT and LINE charts, set iconSide to max width of legend shapes if( (chartType == ChartType.POINT) || (chartType == ChartType.LINE) ) --- 351,359 ---- //---make the icon proportional to the Font being used. this.iconSide = (float) .50 * this.textProcessor.getTallestLabel(); + + //TODO we probably do not even need to look at all the shapes because we just need a scale factor for the shape. + //TODO do we need to be concerned about the line length? ! /* //---for POINT and LINE charts, set iconSide to max width of legend shapes if( (chartType == ChartType.POINT) || (chartType == ChartType.LINE) ) *************** *** 367,371 **** this.iconSide = Math.max( this.iconSide, (float) shape.getBounds2D().getWidth() ); ! /* --- 374,378 ---- this.iconSide = Math.max( this.iconSide, (float) shape.getBounds2D().getWidth() ); ! */ /* *************** *** 384,390 **** } */ ! } } ! this.determineWidthAndHeight( numberOfLabels ); } --- 391,397 ---- } */ ! /* } } ! */ this.determineWidthAndHeight( numberOfLabels ); } *************** *** 522,526 **** int labelIndex = 0; ! Shape shape = (Shape) this.shapes.get( labelIndex ); //---get the original transform so can reset it --- 529,534 ---- int labelIndex = 0; ! Shape shape= null; ! Item item; //---get the original transform so can reset it *************** *** 535,544 **** { rectangle.x = posX; - shape = (Shape) this.shapes.get( labelIndex ); ! //---display icon ! g2d.setPaint( (Paint) this.paints.get( labelIndex ) ); //TODO still need to draw a line for Line Charts if( shape != null ) --- 543,561 ---- { rectangle.x = posX; ! item= (Item) this.items.get( labelIndex ); + //---translate the Shape into position + g2d.translate( rectangle.x, rectangle.y ); + + + item.render( g2d ); + + + posX+= item.getWidth(); + + + //TODO still need to draw a line for Line Charts if( shape != null ) *************** *** 548,602 **** if( this.shapes.size() > 0 && this.shapes.size() > labelIndex && !shape.equals( barShape ) ) { - //---translate the Shape into position - g2d.translate( rectangle.x, rectangle.y ); if( this.fillPointsFlags.size() > 0 ) { - if( ((Boolean) this.fillPointsFlags.get( labelIndex )).booleanValue() ) - { - g2d.fill( shape ); - - //---if we are filling the points, see if we should outline the Shape - //---applicable only to POINt charts - if( this.pointOutlinePaints.get( labelIndex ) != null ) - { - g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) ); - g2d.draw( shape ); - } - } } else { - //---get the bounds of the shape - Rectangle2D shapeBounds = shape.getBounds2D(); - double xOffset = shapeBounds.getWidth() / 2; - double yOffset = shapeBounds.getHeight() / 2; - - g2d.setStroke( (Stroke) this.strokes.get( labelIndex ) ); - g2d.draw( new Line2D.Double( 0, yOffset, this.legendProperties.getIconLineStrokeLength(), yOffset ) ); - - // move posX to account for the lineStroke before the shape. for example: ---o - //posX += this.legendProperties.getIconLineStrokeLength(); - - //---translate the Shape to adjust for the IconLineStrokeLength - //g2d.translate( this.legendProperties.getIconLineStrokeLength() - xOffset, 0 ); - g2d.translate( xOffset, 0 ); - - //line.x1 = xOffset; - //g2d.draw( line ); - - //---Line Charts fill with the same Paint as the lines are drawn with - g2d.fill( (Shape) this.shapes.get( labelIndex ) ); - - //---border around icon - if( this.legendProperties.getIconBorderStroke() != null && this.pointOutlinePaints.size() != 0 ) - { - if( this.pointOutlinePaints != null ) - { - g2d.setStroke( this.legendProperties.getIconBorderStroke() ); - g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) ); - g2d.draw( shape ); - } - } //---move posX to account for the lineStroke after the shape. for example: o--- --- 565,574 ---- *************** *** 610,622 **** else { ! g2d.fill( rectangle ); ! ! //---border around icon ! if( this.legendProperties.getIconBorderStroke() != null ) ! { ! g2d.setStroke( this.legendProperties.getIconBorderStroke() ); ! g2d.setPaint( this.legendProperties.getIconBorderPaint() ); ! g2d.draw( rectangle ); ! } posX += iconAndPaddingWidth; --- 582,586 ---- else { ! posX += iconAndPaddingWidth; |
From: Nathaniel G. A. <nat...@us...> - 2004-10-23 17:44:57
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4384/src/java/org/krysalis/jcharts/legend Added Files: Legend.java Log Message: needs a lot more work --- NEW FILE: Legend.java --- /*********************************************************************************************** * Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved. * * Redistribution and use of this software and associated documentation ("Software"), with or * without modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain copyright statements and notices. * Redistributions must also contain a copy of this document. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote * products derived from this Software without prior written permission of Nathaniel G. * Auvil. For written permission, please contact nat...@us... * * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear * in their names without prior written permission of Nathaniel G. Auvil. jCharts is a * registered trademark of Nathaniel G. Auvil. * * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/). * * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE ************************************************************************************************/ package org.krysalis.jcharts.legend; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.BasicStroke; import java.awt.geom.AffineTransform; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import org.krysalis.jcharts.Chart; import org.krysalis.jcharts.chartData.interfaces.IAxisDataSeries; import org.krysalis.jcharts.chartData.interfaces.IAxisPlotDataSet; import org.krysalis.jcharts.chartData.interfaces.IData; import org.krysalis.jcharts.chartData.interfaces.IPieChartDataSet; import org.krysalis.jcharts.chartData.processors.TextProcessor; import org.krysalis.jcharts.properties.LegendAreaProperties; import org.krysalis.jcharts.properties.LegendProperties; import org.krysalis.jcharts.properties.LineChartProperties; import org.krysalis.jcharts.properties.PointChartProperties; import org.krysalis.jcharts.test.HTMLGenerator; import org.krysalis.jcharts.test.HTMLTestable; import org.krysalis.jcharts.types.ChartType; /***************************************************************************************** * * @author Nathaniel Auvil, Sandor Dornbush, Sundar Balasubramanian * @version $Id: Legend.java,v 1.1 2004/10/23 17:44:48 nathaniel_auvil Exp $ ****************************************************************************************/ public class Legend implements HTMLTestable, Serializable { private Chart chart; private LegendProperties legendProperties; private ArrayList items; private float iconSide; //---derived values private float widestLabelAndColumnPadding; private int numColumns; private int numRows; private TextProcessor textProcessor; private float x; private float y; private float width = 0; private float height = 0; // for Bar chart legend shape - size is automatically calculated later on private Rectangle2D barShape = new Rectangle2D.Double( 0, 0, 0, 0 ); private Stroke barStroke = new BasicStroke(); ChartType chartType; ArrayList shapes, fillPointsFlags, strokes, pointOutlinePaints, labels, paints; /*************************************************************************************** * * @param chart * @param legendProperties **************************************************************************************/ public Legend( Chart chart, LegendProperties legendProperties ) { this.chart = chart; this.legendProperties = legendProperties; this.items= new ArrayList(); } /************************************************************************************** * * @param x *************************************************************************************/ private void setX( float x ) { this.x = x; } /************************************************************************************** * * @param y *************************************************************************************/ private void setY( float y ) { this.y = y; } /*************************************************************************************** * * @param iAxisDataSeries * @param chartTitleHeight **************************************************************************************/ public void computeLegendXY( IAxisDataSeries iAxisDataSeries, float chartTitleHeight ) { //---PROCESS the size needed for drawing the legend. this.calculateDrawingValues( iAxisDataSeries ); if( (this.getLegendProperties().getPlacement() == LegendAreaProperties.RIGHT) || (this.getLegendProperties().getPlacement() == LegendAreaProperties.LEFT) ) { if( this.getHeight() > this.chart.getImageHeight() - this.chart.getChartProperties().getEdgePadding() * 2 ) { this.setY( this.chart.getChartProperties().getEdgePadding() ); } else { this.setY( (this.chart.getImageHeight() / 2) - (this.getHeight() / 2) ); } if( this.getLegendProperties().getPlacement() == LegendAreaProperties.RIGHT ) { this.setX( this.chart.getImageWidth() - this.getWidth() - this.chart.getChartProperties().getEdgePadding() ); } else //---else, LegendAreaProperties.LEFT { this.setX( this.chart.getChartProperties().getEdgePadding() ); } } else //---LegendAreaProperties.BOTTOM, OR LegendAreaProperties.TOP { if( this.getWidth() + this.chart.getChartProperties().getEdgePadding() * 2 > this.chart.getImageWidth() ) { this.setX( this.chart.getChartProperties().getEdgePadding() ); } else { this.setX( (this.chart.getImageWidth() / 2) - (this.getWidth() / 2) ); } if( this.getLegendProperties().getPlacement() == LegendAreaProperties.BOTTOM ) { this.setY( this.chart.getImageHeight() - this.getHeight() - this.chart.getChartProperties().getEdgePadding() ); } else //---else, LegendAreaProperties.TOP { this.setY( this.chart.getChartProperties().getEdgePadding() + chartTitleHeight ); } } } /*************************************************************************************** * Central method for processing data; try to minimize looping. 1) calculate the maximum * height of labels 2) find the maximum label width * * @param iAxisDataSeries **************************************************************************************/ private void processData( IAxisDataSeries iAxisDataSeries ) { this.textProcessor = new TextProcessor(); Iterator iterator = iAxisDataSeries.getIAxisPlotDataSetIterator(); //LOOP while( iterator.hasNext() ) { this.processLegendLabels( (IAxisPlotDataSet) iterator.next() ); } } /*************************************************************************************** * Central method for processing data; try to minimize looping. 1) calculate the maximum * height of labels 2) find the maximum label width * * @param iPieChartDataSet **************************************************************************************/ private void processData( IPieChartDataSet iPieChartDataSet ) { this.textProcessor = new TextProcessor(); this.processLegendLabels( iPieChartDataSet ); } /*************************************************************************************** * Method for processing data for AxisPlot datasets; try to minimize looping. * 1) calculate the maximum height of labels * 2) find the maximum label width * * @param iAxisPlotDataSet **************************************************************************************/ private void processLegendLabels( IAxisPlotDataSet iAxisPlotDataSet ) { for( int i = 0; i < iAxisPlotDataSet.getNumberOfLegendLabels(); i++ ) { //---StockChartDataSets could have NULLs depending on the data if( iAxisPlotDataSet.getLegendLabel( i ) != null ) { //TODO this probably should be moved into the Item Class. this.textProcessor.addLabel( iAxisPlotDataSet.getLegendLabel( i ), this.legendProperties.getChartFont().getFont(), this.chart.getGraphics2D().getFontRenderContext() ); if( iAxisPlotDataSet.getChartType().equals( ChartType.POINT ) || iAxisPlotDataSet.getChartType().equals( ChartType.POINT_RHS ) ) { PointChartProperties pointChartProperties = (PointChartProperties) iAxisPlotDataSet.getChartTypeProperties(); Symbol symbol= new Symbol( pointChartProperties.getShape( i ), iAxisPlotDataSet.getPaint( i ), pointChartProperties.getPointOutlinePaints( i ) ); this.items.add( new Item( symbol, iAxisPlotDataSet.getLegendLabel( i ) ) ); } else if( iAxisPlotDataSet.getChartType().equals( ChartType.LINE ) || iAxisPlotDataSet.getChartType().equals( ChartType.LINE_RHS ) ) { LineChartProperties lineChartProperties = (LineChartProperties) iAxisPlotDataSet.getChartTypeProperties(); Shape shape; if( lineChartProperties.getShapes() != null ) { shape= lineChartProperties.getShapes()[ i ]; } else { shape= null; } LineSymbol lineSymbol= new LineSymbol( shape, iAxisPlotDataSet.getPaint( i ), lineChartProperties.getLineStrokes()[ i ] ); this.items.add( new Item( lineSymbol, iAxisPlotDataSet.getLegendLabel( i ) ) ); } else { Symbol symbol= new Symbol( PointChartProperties.SHAPE_SQUARE, iAxisPlotDataSet.getPaint( i ), this.legendProperties.getIconBorderPaint() ); this.items.add( new Item( symbol, iAxisPlotDataSet.getLegendLabel( i ) ) ); } } } } /*************************************************************************************** * Method for processing data for PieCharts; try to minimize looping. 1) calculate the * maximum height of labels 2) find the maximum label width * * @param iPieChartDataSet **************************************************************************************/ private void processLegendLabels( IPieChartDataSet iPieChartDataSet ) { for( int i = 0; i < iPieChartDataSet.getNumberOfLegendLabels(); i++ ) { //---StockChartDataSets could have NULLs depending on the data if( iPieChartDataSet.getLegendLabel( i ) != null ) { //TODO this probably should be moved into the Item Class. this.textProcessor.addLabel( iPieChartDataSet.getLegendLabel( i ), this.legendProperties.getChartFont().getFont(), this.chart.getGraphics2D().getFontRenderContext() ); Symbol symbol= new Symbol( PointChartProperties.SHAPE_SQUARE, iPieChartDataSet.getPaint( i ), this.legendProperties.getIconBorderPaint() ); this.items.add( new Item( symbol, iPieChartDataSet.getLegendLabel( i ) ) ); } } } /*************************************************************************************** * **************************************************************************************/ public LegendProperties getLegendProperties() { return this.legendProperties; } /*************************************************************************************** * Calculates the width and height needed to display the Legend. Use the getWidth() and * getHeight() methods to extract this information. * * @param iData can pass either the IPieChartDataSet or the IChartDataSeries to this. **************************************************************************************/ public void calculateDrawingValues( IData iData ) { int numberOfLabels; if( iData instanceof IAxisDataSeries ) { IAxisDataSeries iAxisDataSeries = (IAxisDataSeries) iData; this.processData( iAxisDataSeries ); numberOfLabels = iAxisDataSeries.getTotalNumberOfDataSets(); } else { IPieChartDataSet iPieChartDataSet = (IPieChartDataSet) iData; this.processData( iPieChartDataSet ); numberOfLabels = iPieChartDataSet.getNumberOfLegendLabels(); } //---make the icon proportional to the Font being used. this.iconSide = (float) .50 * this.textProcessor.getTallestLabel(); //---for POINT and LINE charts, set iconSide to max width of legend shapes if( (chartType == ChartType.POINT) || (chartType == ChartType.LINE) ) { for( int i = 0; i < this.shapes.size(); i++ ) { Shape shape; //---get the bounds of the shape if( this.shapes.get( i ) != null ) { shape = (Shape) this.shapes.get( i ); } else { shape = PointChartProperties.SHAPE_SQUARE; } this.iconSide = Math.max( this.iconSide, (float) shape.getBounds2D().getWidth() ); /* //---get the bounds of the shape try { Double shapeWidthDouble = new Double( ( ( (Shape) this.shapes.get( i ) ).getBounds2D().getWidth() ) ); float shapeWidth = shapeWidthDouble.floatValue(); this.iconSide = Math.max(this.iconSide, shapeWidth); } catch (NullPointerException npe) { // Looks like in 0.74 it was quite acceptable to make shape = null // we should probably catch all these and render a "null" shape to the legend System.err.println("Warning: legend shape is null"); npe.printStackTrace(); } */ } } this.determineWidthAndHeight( numberOfLabels ); } /*************************************************************************************** * **************************************************************************************/ public float getWidth() { return this.width; } /*************************************************************************************** * **************************************************************************************/ public int getHeight() { //why not return a float here? return ((int) Math.ceil( this.height )); } /*************************************************************************************** * Determines the dimensions needed for the Legend and creates the image for it. * **************************************************************************************/ private void determineWidthAndHeight( int numberOfLabels ) { //---start with the padding no matter how many columns or specified width width = this.legendProperties.getEdgePadding() * 2; height = width; //---if don't care how many columns or the number of labels is less than num columns specified, all in one row. if( this.legendProperties.getNumColumns() == LegendAreaProperties.COLUMNS_AS_MANY_AS_NEEDED || this.legendProperties.getNumColumns() >= numberOfLabels ) { this.numColumns = numberOfLabels; width += this.textProcessor.getTotalLabelWidths(); this.numRows = 1; } //---else, more than one row else { //---one less addition to do when looping. this.widestLabelAndColumnPadding = this.textProcessor.getWidestLabel() + this.legendProperties.getColumnPadding(); if( legendProperties.getNumColumns() == LegendAreaProperties.COLUMNS_FIT_TO_IMAGE ) { // calculate that the columns match exactly float actualWidth = legendProperties.getSize().width; float widestLabelColumnAndIcon = widestLabelAndColumnPadding + iconSide + legendProperties.getIconPadding() + legendProperties.getColumnPadding(); numColumns = (int) (actualWidth / widestLabelColumnAndIcon); numColumns = Math.min( numColumns, numberOfLabels ); } else { numColumns = this.legendProperties.getNumColumns(); } width += this.textProcessor.getWidestLabel() * this.numColumns; this.numRows = (int) Math.ceil( (double) numberOfLabels / (double) this.numColumns ); } //---account for icons width += (this.iconSide + this.legendProperties.getIconPadding()) * this.numColumns; //---account for space between each column width += this.legendProperties.getColumnPadding() * (this.numColumns - 1); //---account for lineStrokes for LINE charts //TODO this is NOT correct. What about a combo chart? if( chartType == ChartType.LINE ) { //width += this.legendProperties.getIconLineStrokeLength() * 2 * this.numColumns; width += this.legendProperties.getIconLineStrokeLength() * this.numColumns; } //---account for each row height += (this.textProcessor.getTallestLabel() * this.numRows); //---account for each row padding height += (this.legendProperties.getRowPadding() * (this.numRows - 1)); } /*************************************************************************************** * Renders the legend. * **************************************************************************************/ public void render() { Graphics2D g2d = this.chart.getGraphics2D(); //---get the bounds of the image Rectangle2D.Float rectangle = new Rectangle2D.Float( this.x, this.y, width - 1, this.height - 1 ); //---fill the background of the Legend with the specified Paint if( this.legendProperties.getBackgroundPaint() != null ) { g2d.setPaint( this.legendProperties.getBackgroundPaint() ); g2d.fill( rectangle ); } //---draw Legend border if( this.legendProperties.getBorderStroke() != null ) { this.legendProperties.getBorderStroke().draw( g2d, rectangle ); } //---dont think we want this so text will be clean but leave commented out. //g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF ); //---set the font and text color. g2d.setFont( this.legendProperties.getChartFont().getFont() ); //---icon coordinates rectangle.y += this.legendProperties.getEdgePadding() + (this.textProcessor.getTallestLabel() / 2) - (this.iconSide / 2); rectangle.width = this.iconSide; rectangle.height = this.iconSide; float posX = this.x + this.legendProperties.getEdgePadding(); float fontY = rectangle.y + rectangle.height; //---pre calculate utility values float yIncrement = this.textProcessor.getTallestLabel() + this.legendProperties.getRowPadding(); float iconAndPaddingWidth = this.iconSide + this.legendProperties.getIconPadding(); int labelIndex = 0; Shape shape = (Shape) this.shapes.get( labelIndex ); //---get the original transform so can reset it AffineTransform affineTransform = g2d.getTransform(); //LOOP for( int j = 0; j < this.numRows; j++ ) { //LOOP for( int i = 0; i < this.numColumns; i++ ) { rectangle.x = posX; shape = (Shape) this.shapes.get( labelIndex ); //---display icon g2d.setPaint( (Paint) this.paints.get( labelIndex ) ); //TODO still need to draw a line for Line Charts if( shape != null ) { //TODO what about scatter plots? //TODO what about NULL shapes on a Line Chart? if( this.shapes.size() > 0 && this.shapes.size() > labelIndex && !shape.equals( barShape ) ) { //---translate the Shape into position g2d.translate( rectangle.x, rectangle.y ); if( this.fillPointsFlags.size() > 0 ) { if( ((Boolean) this.fillPointsFlags.get( labelIndex )).booleanValue() ) { g2d.fill( shape ); //---if we are filling the points, see if we should outline the Shape //---applicable only to POINt charts if( this.pointOutlinePaints.get( labelIndex ) != null ) { g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) ); g2d.draw( shape ); } } } else { //---get the bounds of the shape Rectangle2D shapeBounds = shape.getBounds2D(); double xOffset = shapeBounds.getWidth() / 2; double yOffset = shapeBounds.getHeight() / 2; g2d.setStroke( (Stroke) this.strokes.get( labelIndex ) ); g2d.draw( new Line2D.Double( 0, yOffset, this.legendProperties.getIconLineStrokeLength(), yOffset ) ); // move posX to account for the lineStroke before the shape. for example: ---o //posX += this.legendProperties.getIconLineStrokeLength(); //---translate the Shape to adjust for the IconLineStrokeLength //g2d.translate( this.legendProperties.getIconLineStrokeLength() - xOffset, 0 ); g2d.translate( xOffset, 0 ); //line.x1 = xOffset; //g2d.draw( line ); //---Line Charts fill with the same Paint as the lines are drawn with g2d.fill( (Shape) this.shapes.get( labelIndex ) ); //---border around icon if( this.legendProperties.getIconBorderStroke() != null && this.pointOutlinePaints.size() != 0 ) { if( this.pointOutlinePaints != null ) { g2d.setStroke( this.legendProperties.getIconBorderStroke() ); g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) ); g2d.draw( shape ); } } //---move posX to account for the lineStroke after the shape. for example: o--- posX += this.legendProperties.getIconLineStrokeLength(); } //---reset original transform g2d.setTransform( affineTransform ); } // for other charts, just draw a rectangle else { g2d.fill( rectangle ); //---border around icon if( this.legendProperties.getIconBorderStroke() != null ) { g2d.setStroke( this.legendProperties.getIconBorderStroke() ); g2d.setPaint( this.legendProperties.getIconBorderPaint() ); g2d.draw( rectangle ); } posX += iconAndPaddingWidth; } } //---draw the label g2d.setPaint( this.legendProperties.getChartFont().getPaint() ); //posX += iconAndPaddingWidth; g2d.drawString( (String) this.labels.get( labelIndex ), posX, fontY ); if( this.legendProperties.getNumColumns() == LegendAreaProperties.COLUMNS_AS_MANY_AS_NEEDED || this.legendProperties.getNumColumns() >= this.labels.size() ) { //---each column is as wide as it needs to be posX += this.textProcessor.getTextTag( labelIndex ).getWidth() + this.legendProperties.getColumnPadding(); } else { //---all columns have the same width posX += this.widestLabelAndColumnPadding; } labelIndex++; //---if no more labels, we are done. if( labelIndex == this.labels.size() ) break; } posX = this.x + this.legendProperties.getEdgePadding(); fontY += yIncrement; rectangle.y += yIncrement; } } /*************************************************************************************** * Enables the testing routines to display the contents of this Object. * * @param htmlGenerator **************************************************************************************/ public void toHTML( HTMLGenerator htmlGenerator ) { htmlGenerator.legendTableStart(); htmlGenerator.addTableRow( "X", Float.toString( this.x ) ); htmlGenerator.addTableRow( "Y", Float.toString( this.y ) ); htmlGenerator.addTableRow( "numColumns", Integer.toString( this.numColumns ) ); htmlGenerator.addTableRow( "numRows", Integer.toString( this.numRows ) ); htmlGenerator.addTableRow( "Width", Float.toString( this.width ) ); htmlGenerator.addTableRow( "Height", Float.toString( this.height ) ); htmlGenerator.addTableRow( "Icon Side", Float.toString( this.iconSide ) ); htmlGenerator.innerTableRowStart(); this.legendProperties.toHTML( htmlGenerator ); htmlGenerator.innerTableRowEnd(); htmlGenerator.legendTableEnd(); } } |
From: Nathaniel G. A. <nat...@us...> - 2004-10-23 17:39:08
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2584/src/java/org/krysalis/jcharts/legend Added Files: Symbol.java Log Message: --- NEW FILE: Symbol.java --- /*********************************************************************************************** * Copyright 2004 (C) Nathaniel G. Auvil. All Rights Reserved. * * Redistribution and use of this software and associated documentation ("Software"), with or * without modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain copyright statements and notices. * Redistributions must also contain a copy of this document. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote * products derived from this Software without prior written permission of Nathaniel G. * Auvil. For written permission, please contact nat...@us... * * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear * in their names without prior written permission of Nathaniel G. Auvil. jCharts is a * registered trademark of Nathaniel G. Auvil. * * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/). * * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE ************************************************************************************************/ package org.krysalis.jcharts.legend; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; /***************************************************************************************** * * @author Nathaniel Auvil * @version $Id: Symbol.java,v 1.1 2004/10/23 17:38:59 nathaniel_auvil Exp $ ****************************************************************************************/ class Symbol { private Shape shape; private Paint fillPaint; private Paint outlinePaint; private float width; /*************************************************************************************** * * @param shape * @param fillPaint * @param outlinePaint if this is NULL we know not to outline **************************************************************************************/ public Symbol( Shape shape, Paint fillPaint, Paint outlinePaint ) { this.shape= shape; this.fillPaint= fillPaint; this.outlinePaint= outlinePaint; } /**************************************************************************************** * * @param g2d ****************************************************************************************/ public void render( Graphics2D g2d ) { } } |
From: Nathaniel G. A. <nat...@us...> - 2004-10-23 17:38:58
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2536/src/java/org/krysalis/jcharts/legend Added Files: LineSymbol.java Log Message: --- NEW FILE: LineSymbol.java --- /*********************************************************************************************** * Copyright 2004 (C) Nathaniel G. Auvil. All Rights Reserved. * * Redistribution and use of this software and associated documentation ("Software"), with or * without modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain copyright statements and notices. * Redistributions must also contain a copy of this document. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote * products derived from this Software without prior written permission of Nathaniel G. * Auvil. For written permission, please contact nat...@us... * * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear * in their names without prior written permission of Nathaniel G. Auvil. jCharts is a * registered trademark of Nathaniel G. Auvil. * * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/). * * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE ************************************************************************************************/ package org.krysalis.jcharts.legend; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Line2D; /***************************************************************************************** * * @author Nathaniel Auvil * @version $Id: LineSymbol.java,v 1.1 2004/10/23 17:38:50 nathaniel_auvil Exp $ ****************************************************************************************/ class LineSymbol extends Symbol { private Stroke stroke; /************************************************************************************** * * @param shape * @param lineStroke *************************************************************************************/ public LineSymbol( Shape shape, Paint fillPaint, Stroke lineStroke ) { super( shape, fillPaint, null ); this.stroke= lineStroke; } /************************************************************************************* * * @param g2d *************************************************************************************/ public void render( Graphics2D g2d ) { Line2D.Double line; //TODO draw the line super.render( g2d ); } } |
From: Nathaniel G. A. <nat...@us...> - 2004-10-23 17:38:44
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2475/src/java/org/krysalis/jcharts/legend Added Files: Item.java Log Message: --- NEW FILE: Item.java --- /*********************************************************************************************** * Copyright 2004 (C) Nathaniel G. Auvil. All Rights Reserved. * * Redistribution and use of this software and associated documentation ("Software"), with or * without modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain copyright statements and notices. * Redistributions must also contain a copy of this document. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote * products derived from this Software without prior written permission of Nathaniel G. * Auvil. For written permission, please contact nat...@us... * * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear * in their names without prior written permission of Nathaniel G. Auvil. jCharts is a * registered trademark of Nathaniel G. Auvil. * * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/). * * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE ************************************************************************************************/ package org.krysalis.jcharts.legend; import java.awt.Graphics2D; /***************************************************************************************** * * @author Nathaniel Auvil * @version $Id: Item.java,v 1.1 2004/10/23 17:38:36 nathaniel_auvil Exp $ ****************************************************************************************/ class Item { private Symbol symbol; private String text; private float width; /**************************************************************************************** * * @param symbol * @param text ****************************************************************************************/ public Item( Symbol symbol, String text ) { this.symbol= symbol; this.text= text; } /************************************************************************************** * * @param g2d *************************************************************************************/ public void render( Graphics2D g2d ) { } } |
From: Nathaniel G. A. <nat...@us...> - 2004-10-23 17:38:23
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2371/src/java/org/krysalis/jcharts/legend Log Message: Directory /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/legend added to the repository |
From: Nathaniel G. A. <nat...@us...> - 2004-10-22 00:43:34
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21688/src/java/org/krysalis/jcharts/test Modified Files: LineTestDriver.java ChartTestDriver.java RegressionTestDriver.java Log Message: Index: RegressionTestDriver.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/test/RegressionTestDriver.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RegressionTestDriver.java 13 Aug 2004 01:47:46 -0000 1.1 --- RegressionTestDriver.java 22 Oct 2004 00:43:23 -0000 1.2 *************** *** 164,174 **** Paint[] paints= { Color.blue }; String[] legendLabels= { "Test Legend Label" }; ! AxisChartDataSet axisChartDataSet = new AxisChartDataSet( data, legendLabels, paints, ChartType.LINE_REGRESSION, lineChartProperties ); ! LineChartProperties lineChartProperties2= (LineChartProperties) getChartTypeProperties( 1 ); ! double[][] data2= { { 280, 16, 150, 90 } }; ! Paint[] paints2= { Color.red }; ! String[] legendLabels2= { "Test Legend Label" }; ! AxisChartDataSet axisChartDataSet2 = new AxisChartDataSet( data2, legendLabels2, paints2, ChartType.LINE, lineChartProperties2 ); --- 164,174 ---- Paint[] paints= { Color.blue }; String[] legendLabels= { "Test Legend Label" }; ! AxisChartDataSet axisChartDataSet = new AxisChartDataSet( data, legendLabels, paints, ChartType.LINE, lineChartProperties ); ! LineChartProperties lineChartProperties2= (LineChartProperties) getChartTypeProperties( 2 ); ! double[][] data2= { { 280, 16, 150, 90 }, { 28, 90, -60, 210 } }; ! Paint[] paints2= { Color.red, Color.green }; ! String[] legendLabels2= { "Test Legend Label", "Timbuku Bitches" }; ! AxisChartDataSet axisChartDataSet2 = new AxisChartDataSet( data2, legendLabels2, paints2, ChartType.LINE_REGRESSION, lineChartProperties2 ); Index: LineTestDriver.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/test/LineTestDriver.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LineTestDriver.java 27 Jul 2004 00:54:06 -0000 1.2 --- LineTestDriver.java 22 Oct 2004 00:43:23 -0000 1.3 *************** *** 1,48 **** /*********************************************************************************************** - * File Info: $Id$ - * Copyright (C) 2000 - * Author: Nathaniel G. Auvil - * Contributor(s): - * * Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved. * ! * Redistribution and use of this software and associated documentation ! * ("Software"), with or without modification, are permitted provided ! * that the following conditions are met: * ! * 1. Redistributions of source code must retain copyright ! * statements and notices. Redistributions must also contain a ! * copy of this document. * ! * 2. Redistributions in binary form must reproduce the ! * above copyright notice, this list of conditions and the ! * following disclaimer in the documentation and/or other ! * materials provided with the distribution. * ! * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to ! * endorse or promote products derived from this Software without ! * prior written permission of Nathaniel G. Auvil. For written ! * permission, please contact nat...@us... * ! * 4. Products derived from this Software may not be called "jCharts" ! * nor may "jCharts" appear in their names without prior written ! * permission of Nathaniel G. Auvil. jCharts is a registered ! * trademark of Nathaniel G. Auvil. * ! * 5. Due credit should be given to the jCharts Project ! * (http://jcharts.sourceforge.net/). * ! * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ! * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT ! * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND ! * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, ! * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ! * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ! * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ! * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ! * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED ! * OF THE POSSIBILITY OF SUCH DAMAGE. ************************************************************************************************/ --- 1,34 ---- /*********************************************************************************************** * Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved. * ! * Redistribution and use of this software and associated documentation ("Software"), with or ! * without modification, are permitted provided that the following conditions are met: * ! * 1. Redistributions of source code must retain copyright statements and notices. ! * Redistributions must also contain a copy of this document. * ! * 2. Redistributions in binary form must reproduce the above copyright notice, this list of ! * conditions and the following disclaimer in the documentation and/or other materials ! * provided with the distribution. * ! * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote ! * products derived from this Software without prior written permission of Nathaniel G. ! * Auvil. For written permission, please contact nat...@us... * ! * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear ! * in their names without prior written permission of Nathaniel G. Auvil. jCharts is a ! * registered trademark of Nathaniel G. Auvil. * ! * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/). * ! * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY ! * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ! * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ! * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ! * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT ! * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN ! * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE ************************************************************************************************/ *************** *** 58,66 **** ! /****************************************************************************************** * This file provides examples of how to create all the different chart types provided by ! * this package. ! * ! *******************************************************************************************/ class LineTestDriver extends AxisChartTestBase { --- 44,54 ---- ! /***************************************************************************************** * This file provides examples of how to create all the different chart types provided by ! * this package. ! * ! * @author Nathaniel Auvil ! * @version $Id$ ! ****************************************************************************************/ class LineTestDriver extends AxisChartTestBase { *************** *** 71,104 **** ! /****************************************************************************************** * Separate this so can use for combo chart test ! * * @param numberOfDataSets ! ******************************************************************************************/ static ChartTypeProperties getChartTypeProperties( int numberOfDataSets ) { ! Stroke[] strokes = new Stroke[ numberOfDataSets ]; for( int j = 0; j < numberOfDataSets; j++ ) { ! strokes[ j ] = LineChartProperties.DEFAULT_LINE_STROKE; } ! strokes[ 0 ] = new BasicStroke( 3.0f ); ! Shape[] shapes = new Shape[ numberOfDataSets ]; for( int j = 0; j < numberOfDataSets; j++ ) { ! shapes[ j ] = PointChartProperties.SHAPE_DIAMOND; } ! shapes[ 0 ] = PointChartProperties.SHAPE_CIRCLE; ! ! return new LineChartProperties( strokes, shapes ); } ! /****************************************************************************************** ! * ! * ! ******************************************************************************************/ DataSeries getDataSeries() throws ChartDataException { --- 59,92 ---- ! /*************************************************************************************** * Separate this so can use for combo chart test ! * * @param numberOfDataSets ! **************************************************************************************/ static ChartTypeProperties getChartTypeProperties( int numberOfDataSets ) { ! Stroke[] strokes = new Stroke[numberOfDataSets]; for( int j = 0; j < numberOfDataSets; j++ ) { ! strokes[j] = LineChartProperties.DEFAULT_LINE_STROKE; } ! strokes[0] = new BasicStroke( 3.0f ); ! Shape[] shapes = new Shape[numberOfDataSets]; for( int j = 0; j < numberOfDataSets; j++ ) { ! shapes[j] = PointChartProperties.SHAPE_DIAMOND; } ! shapes[0] = PointChartProperties.SHAPE_CIRCLE; ! shapes[1] = null; //PointChartProperties.SHAPE_CIRCLE; ! return new LineChartProperties( strokes, shapes ); } ! /*************************************************************************************** ! * ! * ! **************************************************************************************/ DataSeries getDataSeries() throws ChartDataException { *************** *** 107,121 **** int dataSize = (int) TestDataGenerator.getRandomNumber( 3, 3 ); ! int numberOfDataSets = ( int ) TestDataGenerator.getRandomNumber( 1, 1 ); ! dataSeries = super.createDataSeries( dataSize ); ! axisChartDataSet = super.createAxisChartDataSet( ChartType.LINE, ! getChartTypeProperties( numberOfDataSets ), ! numberOfDataSets, ! dataSize, ! 10, ! 5000 ); dataSeries.addIAxisPlotDataSet( axisChartDataSet ); --- 95,108 ---- int dataSize = (int) TestDataGenerator.getRandomNumber( 3, 3 ); ! int numberOfDataSets = (int) TestDataGenerator.getRandomNumber( 1, 1 ); dataSeries = super.createDataSeries( dataSize ); ! axisChartDataSet = super.createAxisChartDataSet( ChartType.LINE, ! getChartTypeProperties( numberOfDataSets ), ! numberOfDataSets, ! dataSize, ! 10, ! 5000 ); dataSeries.addIAxisPlotDataSet( axisChartDataSet ); *************** *** 125,194 **** ! ! /****************************************************************************************** ! * ! * ! ****************************************************************************************** ! DataSeries getDataSeries() throws ChartDataException ! { ! String[] xAxisLabels={"1", "2", "3", "4", "5"}; ! DataSeries dataSeries=new DataSeries( xAxisLabels, "numbers", "numbers", "Bug #559177" ); ! AxisChartDataSet axisChartDataSet; ! ! double[][] data={{1, 2, 3, 4, 5}, ! {7, 8, Double.NaN, Double.NaN, Double.NaN}, ! {Double.NaN, Double.NaN, Double.NaN, Double.NaN, 2}}; ! ! String[] legendLabels={"set 1", "set 2", "set 3"}; ! Paint[] paints={Color.blue, Color.red, Color.green}; ! ! axisChartDataSet=new AxisChartDataSet( data, ! legendLabels, ! paints, ! ChartType.LINE, ! this.getChartTypeProperties( 3 ) ); ! ! dataSeries.addIAxisPlotDataSet( axisChartDataSet ); ! ! return dataSeries; ! ! } */ - - public static void main( String[] args ) throws ChartDataException, PropertyException { ! LineChartProperties lineChartProperties= (LineChartProperties) getChartTypeProperties( 1 ); ! double[][] data= { { 280, 16, 150, 90 } }; ! Paint[] paints= { Color.blue }; ! String[] legendLabels= { "Test Legend Label" }; ! AxisChartDataSet axisChartDataSet = new AxisChartDataSet( data, legendLabels, paints, ChartType.LINE, lineChartProperties ); ! String[] axisLabels= { "1900", "1950", "2000", "2050" }; ! DataSeries dataSeries = new DataSeries( axisLabels, "X-Axis Title", "Y-Axis Title", "Chart Title" ); dataSeries.addIAxisPlotDataSet( axisChartDataSet ); ! ! ChartProperties chartProperties= new ChartProperties(); ! AxisProperties axisProperties= new AxisProperties( false ); axisProperties.getYAxisProperties().setShowAxisLabels( false ); ! ! /* axisProperties.getYAxisProperties().setShowRightAxis( true ); ! axisProperties.getYAxisProperties().setMinRightAxis( 0 ); ! axisProperties.getYAxisProperties().setMaxRightAxis( 1000 ); ! */ ! ! axisProperties.getXAxisProperties().setShowAxisLabels( true ); ! DataAxisProperties yAxis= (DataAxisProperties) axisProperties.getYAxisProperties(); yAxis.setUserDefinedScale( -10, 50 ); ! yAxis.setNumItems( 4 ); yAxis.setRoundToNearest( 1 ); ! LegendProperties legendProperties= new LegendProperties(); ! AxisChart axisChart= new AxisChart( dataSeries, chartProperties, axisProperties, legendProperties, 500, 400 ); ChartTestDriver.exportImage( axisChart, "LineChartTest.png" ); --- 112,173 ---- ! /*************************************************************************************** ! * ! * ! * ***************************************************************************************** ! * DataSeries getDataSeries() throws ChartDataException { String[] xAxisLabels={"1", ! * "2", "3", "4", "5"}; DataSeries dataSeries=new DataSeries( xAxisLabels, "numbers", ! * "numbers", "Bug #559177" ); AxisChartDataSet axisChartDataSet; ! * ! * double[][] data={{1, 2, 3, 4, 5}, {7, 8, Double.NaN, Double.NaN, Double.NaN}, ! * {Double.NaN, Double.NaN, Double.NaN, Double.NaN, 2}}; ! * ! * String[] legendLabels={"set 1", "set 2", "set 3"}; Paint[] paints={Color.blue, ! * Color.red, Color.green}; ! * ! * axisChartDataSet=new AxisChartDataSet( data, legendLabels, paints, ChartType.LINE, ! * this.getChartTypeProperties( 3 ) ); ! * ! * dataSeries.addIAxisPlotDataSet( axisChartDataSet ); ! * ! * return dataSeries; } */ public static void main( String[] args ) throws ChartDataException, PropertyException { ! LineChartProperties lineChartProperties = (LineChartProperties) getChartTypeProperties( 3 ); ! double[][] data = { { 280, 16, 150, 90 }, { 80, 36, 15, 30 }, { 180, 26, 250, 120} }; ! Paint[] paints = { Color.blue, Color.green, Color.red }; ! String[] legendLabels = { "Test Legend Label", "dfsd", "fsd" }; ! AxisChartDataSet axisChartDataSet = new AxisChartDataSet( data, ! legendLabels, ! paints, ! ChartType.LINE, ! lineChartProperties ); ! String[] axisLabels = { "1900", "1950", "2000", "2050"}; ! DataSeries dataSeries = new DataSeries( axisLabels, "X-Axis Title", "Y-Axis Title", "Chart Title" ); dataSeries.addIAxisPlotDataSet( axisChartDataSet ); ! ChartProperties chartProperties = new ChartProperties(); ! AxisProperties axisProperties = new AxisProperties( false ); axisProperties.getYAxisProperties().setShowAxisLabels( false ); ! ! /* ! * axisProperties.getYAxisProperties().setShowRightAxis( true ); ! * axisProperties.getYAxisProperties().setMinRightAxis( 0 ); ! * axisProperties.getYAxisProperties().setMaxRightAxis( 1000 ); ! */ ! axisProperties.getXAxisProperties().setShowAxisLabels( true ); ! DataAxisProperties yAxis = (DataAxisProperties) axisProperties.getYAxisProperties(); yAxis.setUserDefinedScale( -10, 50 ); ! yAxis.setNumItems( 4 ); yAxis.setRoundToNearest( 1 ); ! LegendProperties legendProperties = new LegendProperties(); ! AxisChart axisChart = new AxisChart( dataSeries, chartProperties, axisProperties, legendProperties, 500, 400 ); ChartTestDriver.exportImage( axisChart, "LineChartTest.png" ); *************** *** 196,199 **** } ! ! } --- 175,177 ---- } ! } \ No newline at end of file Index: ChartTestDriver.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/test/ChartTestDriver.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ChartTestDriver.java 27 Jul 2004 00:54:06 -0000 1.5 --- ChartTestDriver.java 22 Oct 2004 00:43:23 -0000 1.6 *************** *** 105,111 **** //ChartTestDriver.testAxisScale(); ! System.out.println( "" + Integer.parseInt( null ) ); - /* stopWatch.stop(); System.out.println( stopWatch ); --- 105,113 ---- //ChartTestDriver.testAxisScale(); ! //System.out.println( "" + Integer.parseInt( null ) ); ! ! AxisChartTestBase.axisChartTest( "lineChart", new LineTestDriver() ); ! /* stopWatch.stop(); System.out.println( stopWatch ); |
From: Nathaniel G. A. <nat...@us...> - 2004-10-22 00:31:43
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19052/src/java/org/krysalis/jcharts Modified Files: Legend.java Log Message: fixing the icon problems. Still needs more work Index: Legend.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/Legend.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Legend.java 20 Oct 2004 13:34:50 -0000 1.13 --- Legend.java 22 Oct 2004 00:31:26 -0000 1.14 *************** *** 229,234 **** /*************************************************************************************** ! * Method for processing data for AxisPlot datasets; try to minimize looping. 1) ! * calculate the maximum height of labels 2) find the maximum label width * * @param iAxisPlotDataSet --- 229,236 ---- /*************************************************************************************** ! * Method for processing data for AxisPlot datasets; try to minimize looping. ! * 1) calculate the maximum height of labels ! * 2) find the maximum label width ! * 3 * * @param iAxisPlotDataSet *************** *** 241,247 **** if( iAxisPlotDataSet.getLegendLabel( i ) != null ) { ! this.textProcessor.addLabel( iAxisPlotDataSet.getLegendLabel( i ), ! this.legendProperties.getChartFont().getFont(), ! this.chart.getGraphics2D().getFontRenderContext() ); //---pair labels with paints to get around ugly piechart vs axischart data structure mess --- 243,249 ---- if( iAxisPlotDataSet.getLegendLabel( i ) != null ) { ! this.textProcessor.addLabel( iAxisPlotDataSet.getLegendLabel( i ), ! this.legendProperties.getChartFont().getFont(), ! this.chart.getGraphics2D().getFontRenderContext() ); //---pair labels with paints to get around ugly piechart vs axischart data structure mess *************** *** 293,302 **** if( iPieChartDataSet.getLegendLabel( i ) != null ) { ! this.textProcessor.addLabel( iPieChartDataSet.getLegendLabel( i ), ! this.legendProperties.getChartFont().getFont(), ! this.chart.getGraphics2D().getFontRenderContext() ); ! //---pair labels with paints to get around ugly piechart vs axischart data ! // structure mess this.labels.add( iPieChartDataSet.getLegendLabel( i ) ); this.paints.add( iPieChartDataSet.getPaint( i ) ); --- 295,303 ---- if( iPieChartDataSet.getLegendLabel( i ) != null ) { ! this.textProcessor.addLabel( iPieChartDataSet.getLegendLabel( i ), ! this.legendProperties.getChartFont().getFont(), ! this.chart.getGraphics2D().getFontRenderContext() ); ! //---pair labels with paints to get around ugly piechart vs axischart data structure mess this.labels.add( iPieChartDataSet.getLegendLabel( i ) ); this.paints.add( iPieChartDataSet.getPaint( i ) ); *************** *** 452,458 **** //---account for lineStrokes for LINE charts if( chartType == ChartType.LINE ) { ! width += this.legendProperties.getIconLineStrokeLength() * 2 * this.numColumns; } --- 453,461 ---- //---account for lineStrokes for LINE charts + //TODO this is NOT correct. if( chartType == ChartType.LINE ) { ! //width += this.legendProperties.getIconLineStrokeLength() * 2 * this.numColumns; ! width += this.legendProperties.getIconLineStrokeLength() * this.numColumns; } *************** *** 490,495 **** //---dont think we want this so text will be clean but leave commented out. ! //g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, ! // RenderingHints.VALUE_ANTIALIAS_OFF ); //---set the font and text color. --- 493,497 ---- //---dont think we want this so text will be clean but leave commented out. ! //g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF ); //---set the font and text color. *************** *** 512,515 **** --- 514,521 ---- Shape shape = (Shape) this.shapes.get( labelIndex ); + //---get the original transform so can reset it + AffineTransform affineTransform = g2d.getTransform(); + + //LOOP for( int j = 0; j < this.numRows; j++ ) *************** *** 530,539 **** if( this.shapes.size() > 0 && this.shapes.size() > labelIndex && !shape.equals( barShape ) ) { - //---get the original transform so can reset it - AffineTransform affineTransform = g2d.getTransform(); - //---translate the Shape into position g2d.translate( rectangle.x, rectangle.y ); ! if( this.fillPointsFlags.size() > 0 ) { --- 536,542 ---- if( this.shapes.size() > 0 && this.shapes.size() > labelIndex && !shape.equals( barShape ) ) { //---translate the Shape into position g2d.translate( rectangle.x, rectangle.y ); ! if( this.fillPointsFlags.size() > 0 ) { *************** *** 553,600 **** else { ! // for Point Charts, only draw shape ! if( chartType == ChartType.POINT ) ! { ! g2d.draw( shape ); ! } ! else ! // chartType == ChartType.LINE ! // for Line Charts, fill the shape ! { ! //---get the bounds of the shape ! Rectangle2D shapeBounds = shape.getBounds2D(); ! double xOffset = shapeBounds.getWidth() / 2; ! double yOffset = shapeBounds.getHeight() / 2; ! g2d.setStroke( (Stroke) this.strokes.get( labelIndex ) ); ! Line2D.Double line = new Line2D.Double( 0, ! yOffset, ! this.legendProperties.getIconLineStrokeLength(), ! yOffset ); ! g2d.draw( line ); ! // move posX to account for the lineStroke before the shape. for example: ---o ! posX += this.legendProperties.getIconLineStrokeLength(); ! //---translate the Shape to adjust for the IconLineStrokeLength ! g2d.translate( this.legendProperties.getIconLineStrokeLength() - xOffset, 0 ); ! ! line.x1 = xOffset; ! g2d.draw( line ); ! g2d.fill( (Shape) this.shapes.get( labelIndex ) ); ! //---border around icon ! if( this.legendProperties.getIconBorderStroke() != null && this.pointOutlinePaints.size() != 0 ) { ! if( this.pointOutlinePaints != null ) ! { ! g2d.setStroke( this.legendProperties.getIconBorderStroke() ); ! g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) ); ! g2d.draw( shape ); ! } } - - //---move posX to account for the lineStroke after the shape. for example: o--- - posX += this.legendProperties.getIconLineStrokeLength(); } } //---reset original transform g2d.setTransform( affineTransform ); --- 556,599 ---- else { ! //---get the bounds of the shape ! Rectangle2D shapeBounds = shape.getBounds2D(); ! double xOffset = shapeBounds.getWidth() / 2; ! double yOffset = shapeBounds.getHeight() / 2; ! g2d.setStroke( (Stroke) this.strokes.get( labelIndex ) ); ! ! Line2D.Double line = new Line2D.Double( 0, ! yOffset, ! this.legendProperties.getIconLineStrokeLength(), ! yOffset ); ! g2d.draw( line ); ! ! // move posX to account for the lineStroke before the shape. for example: ---o ! //posX += this.legendProperties.getIconLineStrokeLength(); ! ! //---translate the Shape to adjust for the IconLineStrokeLength ! //g2d.translate( this.legendProperties.getIconLineStrokeLength() - xOffset, 0 ); ! g2d.translate( xOffset, 0 ); ! ! //line.x1 = xOffset; ! //g2d.draw( line ); ! //---Line Charts fill with the same Paint as the lines are drawn with ! g2d.fill( (Shape) this.shapes.get( labelIndex ) ); ! //---border around icon ! if( this.legendProperties.getIconBorderStroke() != null && this.pointOutlinePaints.size() != 0 ) ! { ! if( this.pointOutlinePaints != null ) { ! g2d.setStroke( this.legendProperties.getIconBorderStroke() ); ! g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) ); ! g2d.draw( shape ); } } + + //---move posX to account for the lineStroke after the shape. for example: o--- + posX += this.legendProperties.getIconLineStrokeLength(); } + //---reset original transform g2d.setTransform( affineTransform ); *************** *** 655,658 **** --- 654,661 ---- htmlGenerator.legendTableStart(); + htmlGenerator.addTableRow( "X", Float.toString( this.x ) ); + htmlGenerator.addTableRow( "Y", Float.toString( this.y ) ); + htmlGenerator.addTableRow( "numColumns", Integer.toString( this.numColumns ) ); + htmlGenerator.addTableRow( "numRows", Integer.toString( this.numRows ) ); htmlGenerator.addTableRow( "Width", Float.toString( this.width ) ); htmlGenerator.addTableRow( "Height", Float.toString( this.height ) ); |
From: Nathaniel G. A. <nat...@us...> - 2004-10-20 13:35:02
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30339/src/java/org/krysalis/jcharts Modified Files: Legend.java Log Message: partial fix for null shapes on lines Index: Legend.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/Legend.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Legend.java 1 Jul 2004 00:06:17 -0000 1.12 --- Legend.java 20 Oct 2004 13:34:50 -0000 1.13 *************** *** 33,37 **** ************************************************************************************************/ - package org.krysalis.jcharts; --- 33,36 ---- *************** *** 64,72 **** ! /************************************************************************************* ! * * @author Nathaniel Auvil, Sandor Dornbush, Sundar Balasubramanian * @version $Id$ ! ************************************************************************************/ final public class Legend implements HTMLTestable, Serializable { --- 63,71 ---- ! /***************************************************************************************** ! * * @author Nathaniel Auvil, Sandor Dornbush, Sundar Balasubramanian * @version $Id$ ! ****************************************************************************************/ final public class Legend implements HTMLTestable, Serializable { *************** *** 76,80 **** private float iconSide; - //---derived values private float widestLabelAndColumnPadding; --- 75,78 ---- *************** *** 82,86 **** private int numRows; - private TextProcessor textProcessor; --- 80,83 ---- *************** *** 89,95 **** private float width = 0; private float height = 0; ! // for Bar chart legend shape - size is automatically calculated later on ! private Rectangle2D barShape = new Rectangle2D.Double(0, 0, 0, 0); private Stroke barStroke = new BasicStroke(); --- 86,92 ---- private float width = 0; private float height = 0; ! // for Bar chart legend shape - size is automatically calculated later on ! private Rectangle2D barShape = new Rectangle2D.Double( 0, 0, 0, 0 ); private Stroke barStroke = new BasicStroke(); *************** *** 106,114 **** ! /********************************************************************************************* ! * * @param chart * @deprecated ! **********************************************************************************************/ public Legend( Chart chart ) { --- 103,111 ---- ! /*************************************************************************************** ! * * @param chart * @deprecated ! **************************************************************************************/ public Legend( Chart chart ) { *************** *** 117,125 **** ! /********************************************************************************************* ! * * @param chart * @param legendProperties ! **********************************************************************************************/ public Legend( Chart chart, LegendProperties legendProperties ) { --- 114,122 ---- ! /*************************************************************************************** ! * * @param chart * @param legendProperties ! **************************************************************************************/ public Legend( Chart chart, LegendProperties legendProperties ) { *************** *** 141,149 **** ! /***************************************************************************************** ! * * @param iAxisDataSeries * @param chartTitleHeight ! ****************************************************************************************/ public void computeLegendXY( IAxisDataSeries iAxisDataSeries, float chartTitleHeight ) { --- 138,146 ---- ! /*************************************************************************************** ! * * @param iAxisDataSeries * @param chartTitleHeight ! **************************************************************************************/ public void computeLegendXY( IAxisDataSeries iAxisDataSeries, float chartTitleHeight ) { *************** *** 152,156 **** if( (this.getLegendProperties().getPlacement() == LegendAreaProperties.RIGHT) ! || (this.getLegendProperties().getPlacement() == LegendAreaProperties.LEFT) ) { if( this.getHeight() > this.chart.getImageHeight() - this.chart.getChartProperties().getEdgePadding() * 2 ) --- 149,153 ---- if( (this.getLegendProperties().getPlacement() == LegendAreaProperties.RIGHT) ! || (this.getLegendProperties().getPlacement() == LegendAreaProperties.LEFT) ) { if( this.getHeight() > this.chart.getImageHeight() - this.chart.getChartProperties().getEdgePadding() * 2 ) *************** *** 167,176 **** this.setX( this.chart.getImageWidth() - this.getWidth() - this.chart.getChartProperties().getEdgePadding() ); } ! else //---else, LegendAreaProperties.LEFT { this.setX( this.chart.getChartProperties().getEdgePadding() ); } } ! else //---LegendAreaProperties.BOTTOM, OR LegendAreaProperties.TOP { if( this.getWidth() + this.chart.getChartProperties().getEdgePadding() * 2 > this.chart.getImageWidth() ) --- 164,175 ---- this.setX( this.chart.getImageWidth() - this.getWidth() - this.chart.getChartProperties().getEdgePadding() ); } ! else ! //---else, LegendAreaProperties.LEFT { this.setX( this.chart.getChartProperties().getEdgePadding() ); } } ! else ! //---LegendAreaProperties.BOTTOM, OR LegendAreaProperties.TOP { if( this.getWidth() + this.chart.getChartProperties().getEdgePadding() * 2 > this.chart.getImageWidth() ) *************** *** 187,191 **** this.setY( this.chart.getImageHeight() - this.getHeight() - this.chart.getChartProperties().getEdgePadding() ); } ! else //---else, LegendAreaProperties.TOP { this.setY( this.chart.getChartProperties().getEdgePadding() + chartTitleHeight ); --- 186,191 ---- this.setY( this.chart.getImageHeight() - this.getHeight() - this.chart.getChartProperties().getEdgePadding() ); } ! else ! //---else, LegendAreaProperties.TOP { this.setY( this.chart.getChartProperties().getEdgePadding() + chartTitleHeight ); *************** *** 195,205 **** ! /********************************************************************************************** ! * Central method for processing data; try to minimize looping. ! * 1) calculate the maximum height of labels ! * 2) find the maximum label width ! * * @param iAxisDataSeries ! **********************************************************************************************/ private void processData( IAxisDataSeries iAxisDataSeries ) { --- 195,204 ---- ! /*************************************************************************************** ! * Central method for processing data; try to minimize looping. 1) calculate the maximum ! * height of labels 2) find the maximum label width ! * * @param iAxisDataSeries ! **************************************************************************************/ private void processData( IAxisDataSeries iAxisDataSeries ) { *************** *** 216,226 **** ! /********************************************************************************************** ! * Central method for processing data; try to minimize looping. ! * 1) calculate the maximum height of labels ! * 2) find the maximum label width ! * * @param iPieChartDataSet ! **********************************************************************************************/ private void processData( IPieChartDataSet iPieChartDataSet ) { --- 215,224 ---- ! /*************************************************************************************** ! * Central method for processing data; try to minimize looping. 1) calculate the maximum ! * height of labels 2) find the maximum label width ! * * @param iPieChartDataSet ! **************************************************************************************/ private void processData( IPieChartDataSet iPieChartDataSet ) { *************** *** 230,241 **** ! /********************************************************************************************** ! * Method for processing data for AxisPlot datasets; try to minimize ! * looping. ! * 1) calculate the maximum height of labels ! * 2) find the maximum label width ! * * @param iAxisPlotDataSet ! * *********************************************************************************************/ private void processLegendLabels( IAxisPlotDataSet iAxisPlotDataSet ) { --- 228,237 ---- ! /*************************************************************************************** ! * Method for processing data for AxisPlot datasets; try to minimize looping. 1) ! * calculate the maximum height of labels 2) find the maximum label width ! * * @param iAxisPlotDataSet ! **************************************************************************************/ private void processLegendLabels( IAxisPlotDataSet iAxisPlotDataSet ) { *************** *** 245,249 **** if( iAxisPlotDataSet.getLegendLabel( i ) != null ) { ! this.textProcessor.addLabel( iAxisPlotDataSet.getLegendLabel( i ), this.legendProperties.getChartFont().getFont(), this.chart.getGraphics2D().getFontRenderContext() ); //---pair labels with paints to get around ugly piechart vs axischart data structure mess --- 241,247 ---- if( iAxisPlotDataSet.getLegendLabel( i ) != null ) { ! this.textProcessor.addLabel( iAxisPlotDataSet.getLegendLabel( i ), ! this.legendProperties.getChartFont().getFont(), ! this.chart.getGraphics2D().getFontRenderContext() ); //---pair labels with paints to get around ugly piechart vs axischart data structure mess *************** *** 259,267 **** this.pointOutlinePaints.add( pointChartProperties.getPointOutlinePaints( i ) ); } ! if( iAxisPlotDataSet.getChartType().equals( ChartType.LINE ) ) { this.chartType = ChartType.LINE; this.lineChartProperties = (LineChartProperties) iAxisPlotDataSet.getChartTypeProperties(); ! this.strokes.add( lineChartProperties.getLineStrokes()[ i ] ); if( lineChartProperties.getShapes() != null ) { --- 257,265 ---- this.pointOutlinePaints.add( pointChartProperties.getPointOutlinePaints( i ) ); } ! else if( iAxisPlotDataSet.getChartType().equals( ChartType.LINE ) ) { this.chartType = ChartType.LINE; this.lineChartProperties = (LineChartProperties) iAxisPlotDataSet.getChartTypeProperties(); ! this.strokes.add( lineChartProperties.getLineStrokes()[i] ); if( lineChartProperties.getShapes() != null ) { *************** *** 269,279 **** } } ! else { // just put place holder shape in as well as stroke so that order is maintained ! // for combo bar and line charts. If we allow point/line/bar combos then we'll // also have to add fillPointsFlags and Paints ! this.shapes.add(barShape); ! this.strokes.add(barStroke); } } --- 267,277 ---- } } ! else { // just put place holder shape in as well as stroke so that order is maintained ! // for combo bar and line charts. If we allow point/line/bar combos then we'll // also have to add fillPointsFlags and Paints ! this.shapes.add( barShape ); ! this.strokes.add( barStroke ); } } *************** *** 282,291 **** ! /********************************************************************************************** ! * Method for processing data for PieCharts; try to minimize looping. ! * 1) calculate the maximum height of labels ! * 2) find the maximum label width * @param iPieChartDataSet ! * ********************************************************************************************/ private void processLegendLabels( IPieChartDataSet iPieChartDataSet ) { --- 280,289 ---- ! /*************************************************************************************** ! * Method for processing data for PieCharts; try to minimize looping. 1) calculate the ! * maximum height of labels 2) find the maximum label width ! * * @param iPieChartDataSet ! **************************************************************************************/ private void processLegendLabels( IPieChartDataSet iPieChartDataSet ) { *************** *** 295,301 **** if( iPieChartDataSet.getLegendLabel( i ) != null ) { ! this.textProcessor.addLabel( iPieChartDataSet.getLegendLabel( i ), this.legendProperties.getChartFont().getFont(), this.chart.getGraphics2D().getFontRenderContext() ); ! //---pair labels with paints to get around ugly piechart vs axischart data structure mess this.labels.add( iPieChartDataSet.getLegendLabel( i ) ); this.paints.add( iPieChartDataSet.getPaint( i ) ); --- 293,302 ---- if( iPieChartDataSet.getLegendLabel( i ) != null ) { ! this.textProcessor.addLabel( iPieChartDataSet.getLegendLabel( i ), ! this.legendProperties.getChartFont().getFont(), ! this.chart.getGraphics2D().getFontRenderContext() ); ! //---pair labels with paints to get around ugly piechart vs axischart data ! // structure mess this.labels.add( iPieChartDataSet.getLegendLabel( i ) ); this.paints.add( iPieChartDataSet.getPaint( i ) ); *************** *** 305,311 **** ! /************************************************************************************************ ! * ! *************************************************************************************************/ public LegendProperties getLegendProperties() { --- 306,312 ---- ! /*************************************************************************************** ! * ! **************************************************************************************/ public LegendProperties getLegendProperties() { *************** *** 314,323 **** ! /************************************************************************************************ ! * Calculates the width and height needed to display the Legend. Use the getWidth() and ! * getHeight() methods to extract this information. ! * * @param iData can pass either the IPieChartDataSet or the IChartDataSeries to this. ! ************************************************************************************************/ public void calculateDrawingValues( IData iData ) { --- 315,324 ---- ! /*************************************************************************************** ! * Calculates the width and height needed to display the Legend. Use the getWidth() and ! * getHeight() methods to extract this information. ! * * @param iData can pass either the IPieChartDataSet or the IChartDataSeries to this. ! **************************************************************************************/ public void calculateDrawingValues( IData iData ) { *************** *** 326,330 **** this.paints = new ArrayList(); - if( iData instanceof IAxisDataSeries ) { --- 327,330 ---- *************** *** 340,344 **** } - //---make the icon proportional to the Font being used. this.iconSide = (float) .50 * this.textProcessor.getTallestLabel(); --- 340,343 ---- *************** *** 349,367 **** for( int i = 0; i < this.shapes.size(); i++ ) { //---get the bounds of the shape ! try ! { ! Double shapeWidthDouble = new Double( ( ( (Shape) this.shapes.get( i ) ).getBounds2D().getWidth() ) ); ! float shapeWidth = shapeWidthDouble.floatValue(); ! this.iconSide = Math.max(this.iconSide, shapeWidth); ! } ! catch (NullPointerException npe) ! { ! // Looks like in 0.74 it was quite acceptable to make shape = null ! // we should probably catch all these and render a "null" shape to the legend ! System.err.println("Warning: legend shape is null"); ! npe.printStackTrace(); ! } ! } } --- 348,377 ---- for( int i = 0; i < this.shapes.size(); i++ ) { + Double shapeWidthDouble; + Shape shape; + //---get the bounds of the shape ! if( this.shapes.get( i ) != null ) ! { ! shape = (Shape) this.shapes.get( i ); ! } ! else ! { ! shape = PointChartProperties.SHAPE_SQUARE; ! } ! ! shapeWidthDouble = new Double( shape.getBounds2D().getWidth() ); ! float shapeWidth = shapeWidthDouble.floatValue(); ! this.iconSide = Math.max( this.iconSide, shapeWidth ); ! ! /* ! * //---get the bounds of the shape try { Double shapeWidthDouble = new Double( ( ( ! * (Shape) this.shapes.get( i ) ).getBounds2D().getWidth() ) ); float shapeWidth = ! * shapeWidthDouble.floatValue(); this.iconSide = Math.max(this.iconSide, ! * shapeWidth); } catch (NullPointerException npe) { // Looks like in 0.74 it was ! * quite acceptable to make shape = null // we should probably catch all these and ! * render a "null" shape to the legend System.err.println("Warning: legend shape ! * is null"); npe.printStackTrace(); } ! */} } *************** *** 370,376 **** ! /******************************************************************************************** ! * ! ********************************************************************************************/ public float getWidth() { --- 380,386 ---- ! /*************************************************************************************** ! * ! **************************************************************************************/ public float getWidth() { *************** *** 379,396 **** ! /******************************************************************************************** ! * ! ********************************************************************************************/ public int getHeight() { ! //why not return a float here? return ((int) Math.ceil( this.height )); } ! /********************************************************************************************** * Determines the dimensions needed for the Legend and creates the image for it. ! * ! **********************************************************************************************/ private void determineWidthAndHeight( int numberOfLabels ) { --- 389,406 ---- ! /*************************************************************************************** ! * ! **************************************************************************************/ public int getHeight() { ! //why not return a float here? return ((int) Math.ceil( this.height )); } ! /*************************************************************************************** * Determines the dimensions needed for the Legend and creates the image for it. ! * ! **************************************************************************************/ private void determineWidthAndHeight( int numberOfLabels ) { *************** *** 399,406 **** height = width; - //---if don't care how many columns or the number of labels is less than num columns specified, all in one row. if( this.legendProperties.getNumColumns() == LegendAreaProperties.COLUMNS_AS_MANY_AS_NEEDED ! || this.legendProperties.getNumColumns() >= numberOfLabels ) { this.numColumns = numberOfLabels; --- 409,415 ---- height = width; //---if don't care how many columns or the number of labels is less than num columns specified, all in one row. if( this.legendProperties.getNumColumns() == LegendAreaProperties.COLUMNS_AS_MANY_AS_NEEDED ! || this.legendProperties.getNumColumns() >= numberOfLabels ) { this.numColumns = numberOfLabels; *************** *** 420,428 **** float actualWidth = legendProperties.getSize().width; ! float widestLabelColumnAndIcon = ! widestLabelAndColumnPadding + ! iconSide + ! legendProperties.getIconPadding() + ! legendProperties.getColumnPadding(); numColumns = (int) (actualWidth / widestLabelColumnAndIcon); --- 429,434 ---- float actualWidth = legendProperties.getSize().width; ! float widestLabelColumnAndIcon = widestLabelAndColumnPadding + iconSide + legendProperties.getIconPadding() ! + legendProperties.getColumnPadding(); numColumns = (int) (actualWidth / widestLabelColumnAndIcon); *************** *** 439,443 **** } - //---account for icons width += (this.iconSide + this.legendProperties.getIconPadding()) * this.numColumns; --- 445,448 ---- *************** *** 447,451 **** //---account for lineStrokes for LINE charts ! if( chartType == ChartType.LINE) { width += this.legendProperties.getIconLineStrokeLength() * 2 * this.numColumns; --- 452,456 ---- //---account for lineStrokes for LINE charts ! if( chartType == ChartType.LINE ) { width += this.legendProperties.getIconLineStrokeLength() * 2 * this.numColumns; *************** *** 460,467 **** ! /********************************************************************************************** * Renders the legend. ! * ! **********************************************************************************************/ public void render() { --- 465,472 ---- ! /*************************************************************************************** * Renders the legend. ! * ! **************************************************************************************/ public void render() { *************** *** 485,489 **** //---dont think we want this so text will be clean but leave commented out. ! //g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF ); //---set the font and text color. --- 490,495 ---- //---dont think we want this so text will be clean but leave commented out. ! //g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, ! // RenderingHints.VALUE_ANTIALIAS_OFF ); //---set the font and text color. *************** *** 495,503 **** rectangle.height = this.iconSide; - float posX = this.x + this.legendProperties.getEdgePadding(); float fontY = rectangle.y + rectangle.height; - //---pre calculate utility values float yIncrement = this.textProcessor.getTallestLabel() + this.legendProperties.getRowPadding(); --- 501,507 ---- *************** *** 506,509 **** --- 510,515 ---- int labelIndex = 0; + Shape shape = (Shape) this.shapes.get( labelIndex ); + //LOOP for( int j = 0; j < this.numRows; j++ ) *************** *** 513,528 **** { rectangle.x = posX; ! //---display icon g2d.setPaint( (Paint) this.paints.get( labelIndex ) ); ! // only Point and Line Charts will have shapes drawn ! ! if( this.shapes.size() > 0 && this.shapes.size() > labelIndex && ! !((Shape)this.shapes.get( labelIndex)).equals(barShape)) ! { - //Shape shape = (Shape)this.shapes.get( labelIndex); - //---get the original transform so can reset it AffineTransform affineTransform = g2d.getTransform(); --- 519,533 ---- { rectangle.x = posX; ! shape = (Shape) this.shapes.get( labelIndex ); ! //---display icon g2d.setPaint( (Paint) this.paints.get( labelIndex ) ); ! if( shape != null ) ! { ! //TODO what about scatter plots? ! //TODO what about NULL shapes on a Line Chart? ! if( this.shapes.size() > 0 && this.shapes.size() > labelIndex && !shape.equals( barShape ) ) { //---get the original transform so can reset it AffineTransform affineTransform = g2d.getTransform(); *************** *** 535,539 **** if( ((Boolean) this.fillPointsFlags.get( labelIndex )).booleanValue() ) { ! g2d.fill( (Shape) this.shapes.get( labelIndex ) ); //---if we are filling the points, see if we should outline the Shape --- 540,544 ---- if( ((Boolean) this.fillPointsFlags.get( labelIndex )).booleanValue() ) { ! g2d.fill( shape ); //---if we are filling the points, see if we should outline the Shape *************** *** 542,546 **** { g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) ); ! g2d.draw( (Shape) this.shapes.get( labelIndex ) ); } } --- 547,551 ---- { g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) ); ! g2d.draw( shape ); } } *************** *** 549,579 **** { // for Point Charts, only draw shape ! if( chartType == ChartType.POINT) { ! g2d.draw( (Shape) this.shapes.get( labelIndex ) ); ! } else // chartType == ChartType.LINE // for Line Charts, fill the shape { //---get the bounds of the shape ! Rectangle2D shapeBounds = ( (Shape) this.shapes.get( labelIndex ) ).getBounds2D(); ! double XOffset = shapeBounds.getWidth() / 2; ! double YOffset = shapeBounds.getHeight() / 2; ! ! // g2d.setStroke(this.lineChartProperties.getLineStrokes()[ labelIndex]); ! g2d.setStroke((Stroke)this.strokes.get( labelIndex )); ! ! Line2D.Double line = new Line2D.Double(0, YOffset, this.legendProperties.getIconLineStrokeLength(), YOffset); g2d.draw( line ); ! // move posX to account for the lineStroke before the shape. for example, ---o posX += this.legendProperties.getIconLineStrokeLength(); //---translate the Shape to adjust for the IconLineStrokeLength ! g2d.translate( this.legendProperties.getIconLineStrokeLength() - XOffset , 0 ); ! ! line.x1 = XOffset; g2d.draw( line ); - g2d.fill( (Shape) this.shapes.get( labelIndex ) ); --- 554,583 ---- { // for Point Charts, only draw shape ! if( chartType == ChartType.POINT ) { ! g2d.draw( shape ); ! } ! else // chartType == ChartType.LINE // for Line Charts, fill the shape { //---get the bounds of the shape ! Rectangle2D shapeBounds = shape.getBounds2D(); ! double xOffset = shapeBounds.getWidth() / 2; ! double yOffset = shapeBounds.getHeight() / 2; ! g2d.setStroke( (Stroke) this.strokes.get( labelIndex ) ); ! Line2D.Double line = new Line2D.Double( 0, ! yOffset, ! this.legendProperties.getIconLineStrokeLength(), ! yOffset ); g2d.draw( line ); ! // move posX to account for the lineStroke before the shape. for example: ---o posX += this.legendProperties.getIconLineStrokeLength(); //---translate the Shape to adjust for the IconLineStrokeLength ! g2d.translate( this.legendProperties.getIconLineStrokeLength() - xOffset, 0 ); ! line.x1 = xOffset; g2d.draw( line ); g2d.fill( (Shape) this.shapes.get( labelIndex ) ); *************** *** 581,593 **** if( this.legendProperties.getIconBorderStroke() != null && this.pointOutlinePaints.size() != 0 ) { ! if( this.pointOutlinePaints != null ) { g2d.setStroke( this.legendProperties.getIconBorderStroke() ); g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) ); ! g2d.draw( (Shape) this.shapes.get( labelIndex ) ); } } ! ! // move posX to account for the lineStroke after the shape. for example, o--- posX += this.legendProperties.getIconLineStrokeLength(); } --- 585,597 ---- if( this.legendProperties.getIconBorderStroke() != null && this.pointOutlinePaints.size() != 0 ) { ! if( this.pointOutlinePaints != null ) ! { g2d.setStroke( this.legendProperties.getIconBorderStroke() ); g2d.setPaint( (Paint) this.pointOutlinePaints.get( labelIndex ) ); ! g2d.draw( shape ); } } ! //---move posX to account for the lineStroke after the shape. for example: o--- posX += this.legendProperties.getIconLineStrokeLength(); } *************** *** 609,612 **** --- 613,617 ---- } } + } *************** *** 616,622 **** g2d.drawString( (String) this.labels.get( labelIndex ), posX, fontY ); - if( this.legendProperties.getNumColumns() == LegendAreaProperties.COLUMNS_AS_MANY_AS_NEEDED ! || this.legendProperties.getNumColumns() >= this.labels.size() ) { //---each column is as wide as it needs to be --- 621,626 ---- g2d.drawString( (String) this.labels.get( labelIndex ), posX, fontY ); if( this.legendProperties.getNumColumns() == LegendAreaProperties.COLUMNS_AS_MANY_AS_NEEDED ! || this.legendProperties.getNumColumns() >= this.labels.size() ) { //---each column is as wide as it needs to be *************** *** 642,650 **** ! /********************************************************************************************* * Enables the testing routines to display the contents of this Object. ! * * @param htmlGenerator ! **********************************************************************************************/ public void toHTML( HTMLGenerator htmlGenerator ) { --- 646,654 ---- ! /*************************************************************************************** * Enables the testing routines to display the contents of this Object. ! * * @param htmlGenerator ! **************************************************************************************/ public void toHTML( HTMLGenerator htmlGenerator ) { *************** *** 662,664 **** } ! } --- 666,668 ---- } ! } \ No newline at end of file |
From: Nathaniel G. A. <nat...@us...> - 2004-10-19 20:10:13
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/documentation/content/xdocs/userGuide/axisCharts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9103/src/documentation/content/xdocs/userGuide/axisCharts Modified Files: book.xml Log Message: Index: book.xml =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/documentation/content/xdocs/userGuide/axisCharts/book.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** book.xml 5 Jun 2004 14:25:57 -0000 1.1 --- book.xml 19 Oct 2004 20:10:04 -0000 1.2 *************** *** 15,18 **** --- 15,19 ---- <menu-item label="Bar Charts" href="./bar/index.html"/> <menu-item label="Line Charts" href="./line/index.html"/> + <menu-item label="Line Regression Charts" href="./line/index.html"/> <menu-item label="Point Charts" href="./point/index.html"/> <menu-item label="Stock Charts" href="./stock/index.html"/> |
From: Nathaniel G. A. <nat...@us...> - 2004-10-19 20:09:53
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/documentation/content/xdocs/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8966/src/documentation/content/xdocs/samples Modified Files: book.xml index.xml Log Message: Index: index.xml =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/documentation/content/xdocs/samples/index.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** index.xml 27 Jul 2004 00:50:02 -0000 1.5 --- index.xml 19 Oct 2004 20:09:34 -0000 1.6 *************** *** 28,31 **** --- 28,32 ---- <li>Point</li> <li>Radar</li> + <li>Regression Line</li> <li>XY Plot</li> </ul> Index: book.xml =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/documentation/content/xdocs/samples/book.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** book.xml 16 Aug 2003 20:47:18 -0000 1.6 --- book.xml 19 Oct 2004 20:09:34 -0000 1.7 *************** *** 39,42 **** --- 39,46 ---- <menu-item label="Radar Chart (CVS)" href="radar.html"/> </menu> + <menu label="Regression Charts"> + <menu-item label="Line Chart (CVS)" href="radar.html"/> + </menu> + <menu label="Stock Charts"> <menu-item label="Hi/Low Open/Close" href="stock.html"/> |
From: Gann B. <ga...@us...> - 2004-10-18 03:04:24
|
Update of /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/chartData/processors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10190/src/java/org/krysalis/jcharts/chartData/processors Modified Files: AxisChartDataProcessor.java Log Message: Allow horizontal/bar combo charts. Allow rendering of combo charts in order of addition. Fixed bug when rending axis chart with no data. Index: AxisChartDataProcessor.java =================================================================== RCS file: /cvsroot/jcharts/krysalis-jcharts/src/java/org/krysalis/jcharts/chartData/processors/AxisChartDataProcessor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AxisChartDataProcessor.java 21 Sep 2004 03:49:50 -0000 1.4 --- AxisChartDataProcessor.java 18 Oct 2004 03:04:15 -0000 1.5 *************** *** 128,134 **** //---need to set the number of items on the scale in case there are no labels displayed Iterator iterator = axisChart.getIAxisDataSeries().getIAxisPlotDataSetIterator(); ! IAxisPlotDataSet iAxisPlotDataSet = ( IAxisPlotDataSet ) iterator.next(); ! this.numberOfElementsInADataSet= iAxisPlotDataSet.getNumberOfDataItems(); ! //todo does it make sense to do the legend label processing here? --- 128,138 ---- //---need to set the number of items on the scale in case there are no labels displayed Iterator iterator = axisChart.getIAxisDataSeries().getIAxisPlotDataSetIterator(); ! if (iterator.hasNext()) { ! IAxisPlotDataSet iAxisPlotDataSet = ( IAxisPlotDataSet ) iterator.next(); ! this.numberOfElementsInADataSet= iAxisPlotDataSet.getNumberOfDataItems(); ! } else { ! this.numberOfElementsInADataSet= 0; ! } ! //todo does it make sense to do the legend label processing here? |