From: David G. <mu...@us...> - 2005-12-12 14:11:46
|
Update of /cvsroot/jfreechart/jfreechart/source/org/jfree/chart In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20728/source/org/jfree/chart Modified Files: LegendItem.java Log Message: 2005-12-12 David Gilbert <dav...@ob...> * source/org/jfree/chart/LegendItem.java: (LegendItem(String, AttributedString, String, String, String, Shape, Paint)): Removed AttributedString argument, (LegendItem(String, AttributedString, String, String, String, Shape, Paint, Stroke, Paint)): Likewise, (LegendItem(String, AttributedString, String, String, String, Shape, Stroke, Paint)): Likewise, (LegendItem(String, AttributedString, String, String, String, boolean, Shape, boolean, Paint, boolean, Paint, Stroke, boolean, Shape, Stroke, Paint)): Likewise, (LegendItem(AttributedString, String, String, String, Shape, Paint)): New constructor, (LegendItem(AttributedString, String, String, String, Shape, Paint, Stroke, Paint)): Likewise, (LegendItem(AttributedString, String, String, String, Shape, Stroke, Paint)): Likewise, (LegendItem(AttributedString, String, String, String, boolean, Shape, boolean, Paint, boolean, Paint, Stroke, boolean, Shape, Stroke, Paint)): Likewise, (characterIteratorToString): New method, * source/org/jfree/chart/junit/LegendItemCollectionTests.java (testEquals): Updated for change to LegendItem constructor, (testSerialization): Likewise, (testCloning): Likewise, * source/org/jfree/chart/junit/LegendItemTests.java (testEquals): Updated for change to LegendItem constructor, (testSerialization): Likewise, (testCloning): Likewise, * source/org/jfree/chart/plot/MeterPlot.java (getLegendItems): Update for change to LegendItem constructor, * source/org/jfree/chart/plot/MultiplePiePlot.java (getLegendItems): Likewise, * source/org/jfree/chart/plot/PiePlot.java (drawItem): Use sectionOutlinesVisible flag, fix potential NullPointerException for entities, (getLegendItems): Update for change to LegendItem constructor, * source/org/jfree/chart/plot/SpiderWebPlot.java (getLegendItems): Likewise, * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/WaferMapRenderer.java (getLegendCollection): Likewise, * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/AreaRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/BarRenderer.java (getLegendItem): Likewise, plus reformatting, * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBarRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java (getLegendItem): Likewise, * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (getLegendItem): Likewise. ---------------------------------------------------------------------- Index: LegendItem.java =================================================================== RCS file: /cvsroot/jfreechart/jfreechart/source/org/jfree/chart/LegendItem.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** LegendItem.java 28 Oct 2005 10:23:24 -0000 1.12 --- LegendItem.java 12 Dec 2005 14:11:31 -0000 1.13 *************** *** 17,23 **** * License for more details. * ! * You should have received a copy of the GNU Lesser General Public License ! * along with this library; if not, write to the Free Software Foundation, ! * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. --- 17,24 ---- * License for more details. * ! * You should have received a copy of the GNU Lesser General Public ! * License along with this library; if not, write to the Free Software ! * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, ! * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. *************** *** 50,53 **** --- 51,55 ---- * 20-Apr-2005 : Added tooltip and URL text (DG); * 01-Jul-2005 : Added attributedLabel (DG); + * 28-Nov-2005 : Separated constructors for AttributedString labels (DG); * */ *************** *** 66,69 **** --- 68,72 ---- import java.io.Serializable; import java.text.AttributedString; + import java.text.CharacterIterator; import org.jfree.io.SerialUtilities; *************** *** 151,156 **** * * @param label the label (<code>null</code> not permitted). - * @param attributedLabel the attributed label (<code>null</code> - * permitted). * @param description the description (<code>null</code> permitted). * @param toolTipText the tool tip text (<code>null</code> permitted). --- 154,157 ---- *************** *** 160,185 **** * not permitted). */ ! public LegendItem(String label, AttributedString attributedLabel, ! String description, String toolTipText, String urlText, ! Shape shape, Paint fillPaint) { ! this( ! label, ! attributedLabel, ! description, ! toolTipText, ! urlText, ! true, // shape visible ! shape, ! true, // shape filled ! fillPaint, ! false, // shape not outlined ! Color.black, ! UNUSED_STROKE, ! false, // line not visible ! UNUSED_SHAPE, ! UNUSED_STROKE, ! Color.black ! ); } --- 161,175 ---- * not permitted). */ ! public LegendItem(String label, String description, String toolTipText, String urlText, ! Shape shape, Paint fillPaint) { ! ! this(label, description, toolTipText, urlText, ! /* shape visible = */ true, shape, ! /* shape filled = */ true, fillPaint, ! /* shape outlined */ false, Color.black, UNUSED_STROKE, ! /* line visible */ false, UNUSED_SHAPE, UNUSED_STROKE, ! Color.black); ! } *************** *** 188,193 **** * * @param label the label (<code>null</code> not permitted). - * @param attributedLabel the attributed label (<code>null</code> - * permitted). * @param description the description (<code>null</code> permitted). * @param toolTipText the tool tip text (<code>null</code> permitted). --- 178,181 ---- *************** *** 201,227 **** * permitted). */ ! public LegendItem(String label, AttributedString attributedLabel, ! String description, String toolTipText, String urlText, Shape shape, Paint fillPaint, Stroke outlineStroke, Paint outlinePaint) { ! this( ! label, ! attributedLabel, ! description, ! toolTipText, ! urlText, ! true, // shape visible ! shape, ! true, // shape filled ! fillPaint, ! true, // shape outlined ! outlinePaint, ! outlineStroke, ! false, // line not visible ! UNUSED_SHAPE, ! UNUSED_STROKE, ! Color.black ! ); } --- 189,204 ---- * permitted). */ ! public LegendItem(String label, String description, String toolTipText, String urlText, Shape shape, Paint fillPaint, Stroke outlineStroke, Paint outlinePaint) { ! ! this(label, description, toolTipText, urlText, ! /* shape visible = */ true, shape, ! /* shape filled = */ true, fillPaint, ! /* shape outlined = */ true, outlinePaint, outlineStroke, ! /* line visible */ false, UNUSED_SHAPE, UNUSED_STROKE, ! Color.black); ! } *************** *** 230,235 **** * * @param label the label (<code>null</code> not permitted). - * @param attributedLabel the attributed label (<code>null</code> - * permitted). * @param description the description (<code>null</code> permitted). * @param toolTipText the tool tip text (<code>null</code> permitted). --- 207,210 ---- *************** *** 239,263 **** * @param linePaint the line paint (<code>null</code> not permitted). */ ! public LegendItem(String label, AttributedString attributedLabel, ! String description, String toolTipText, String urlText, Shape line, Stroke lineStroke, Paint linePaint) { ! this( ! label, ! attributedLabel, ! description, ! toolTipText, ! urlText, ! false, // shape not visible ! UNUSED_SHAPE, ! false, // shape not filled ! Color.black, ! false, // shape not outlined ! Color.black, ! UNUSED_STROKE, ! true, // line visible ! line, ! lineStroke, ! linePaint ); } --- 214,369 ---- * @param linePaint the line paint (<code>null</code> not permitted). */ ! public LegendItem(String label, String description, String toolTipText, String urlText, Shape line, Stroke lineStroke, Paint linePaint) { ! ! this(label, description, toolTipText, urlText, ! /* shape visible = */ false, UNUSED_SHAPE, ! /* shape filled = */ false, Color.black, ! /* shape outlined = */ false, Color.black, UNUSED_STROKE, ! /* line visible = */ true, line, lineStroke, linePaint); ! } ! ! /** ! * Creates a new legend item. ! * ! * @param label the label (<code>null</code> not permitted). ! * @param description the description (not currently used, ! * <code>null</code> permitted). ! * @param toolTipText the tool tip text (<code>null</code> permitted). ! * @param urlText the URL text (<code>null</code> permitted). ! * @param shapeVisible a flag that controls whether or not the shape is ! * displayed. ! * @param shape the shape (<code>null</code> permitted). ! * @param shapeFilled a flag that controls whether or not the shape is ! * filled. ! * @param fillPaint the fill paint (<code>null</code> not permitted). ! * @param shapeOutlineVisible a flag that controls whether or not the ! * shape is outlined. ! * @param outlinePaint the outline paint (<code>null</code> not permitted). ! * @param outlineStroke the outline stroke (<code>null</code> not ! * permitted). ! * @param lineVisible a flag that controls whether or not the line is ! * visible. ! * @param line the line. ! * @param lineStroke the stroke (<code>null</code> not permitted). ! * @param linePaint the line paint (<code>null</code> not permitted). ! */ ! public LegendItem(String label, String description, ! String toolTipText, String urlText, ! boolean shapeVisible, Shape shape, ! boolean shapeFilled, Paint fillPaint, ! boolean shapeOutlineVisible, Paint outlinePaint, ! Stroke outlineStroke, ! boolean lineVisible, Shape line, ! Stroke lineStroke, Paint linePaint) { ! ! if (label == null) { ! throw new IllegalArgumentException("Null 'label' argument."); ! } ! if (fillPaint == null) { ! throw new IllegalArgumentException("Null 'fillPaint' argument."); ! } ! if (lineStroke == null) { ! throw new IllegalArgumentException("Null 'lineStroke' argument."); ! } ! if (outlinePaint == null) { ! throw new IllegalArgumentException("Null 'outlinePaint' argument."); ! } ! if (outlineStroke == null) { ! throw new IllegalArgumentException( ! "Null 'outlineStroke' argument."); ! } ! this.label = label; ! this.attributedLabel = null; ! this.description = description; ! this.shapeVisible = shapeVisible; ! this.shape = shape; ! this.shapeFilled = shapeFilled; ! this.fillPaint = fillPaint; ! this.shapeOutlineVisible = shapeOutlineVisible; ! this.outlinePaint = outlinePaint; ! this.outlineStroke = outlineStroke; ! this.lineVisible = lineVisible; ! this.line = line; ! this.lineStroke = lineStroke; ! this.linePaint = linePaint; ! this.toolTipText = toolTipText; ! this.urlText = urlText; ! } ! ! /** ! * Creates a legend item with a filled shape. The shape is not outlined, ! * and no line is visible. ! * ! * @param label the label (<code>null</code> not permitted). ! * @param description the description (<code>null</code> permitted). ! * @param toolTipText the tool tip text (<code>null</code> permitted). ! * @param urlText the URL text (<code>null</code> permitted). ! * @param shape the shape (<code>null</code> not permitted). ! * @param fillPaint the paint used to fill the shape (<code>null</code> ! * not permitted). ! */ ! public LegendItem(AttributedString label, String description, ! String toolTipText, String urlText, ! Shape shape, Paint fillPaint) { ! ! this(label, description, toolTipText, urlText, ! /* shape visible = */ true, shape, ! /* shape filled = */ true, fillPaint, ! /* shape outlined = */ false, Color.black, UNUSED_STROKE, ! /* line visible = */ false, UNUSED_SHAPE, UNUSED_STROKE, ! Color.black); ! ! } ! ! /** ! * Creates a legend item with a filled and outlined shape. ! * ! * @param label the label (<code>null</code> not permitted). ! * @param description the description (<code>null</code> permitted). ! * @param toolTipText the tool tip text (<code>null</code> permitted). ! * @param urlText the URL text (<code>null</code> permitted). ! * @param shape the shape (<code>null</code> not permitted). ! * @param fillPaint the paint used to fill the shape (<code>null</code> ! * not permitted). ! * @param outlineStroke the outline stroke (<code>null</code> not ! * permitted). ! * @param outlinePaint the outline paint (<code>null</code> not ! * permitted). ! */ ! public LegendItem(AttributedString label, String description, ! String toolTipText, String urlText, ! Shape shape, Paint fillPaint, ! Stroke outlineStroke, Paint outlinePaint) { ! ! this(label, description, toolTipText, urlText, ! /* shape visible = */ true, shape, ! /* shape filled = */ true, fillPaint, ! /* shape outlined = */ true, outlinePaint, outlineStroke, ! /* line visible = */ false, UNUSED_SHAPE, UNUSED_STROKE, ! Color.black); ! } ! ! /** ! * Creates a legend item using a line. ! * ! * @param label the label (<code>null</code> not permitted). ! * @param description the description (<code>null</code> permitted). ! * @param toolTipText the tool tip text (<code>null</code> permitted). ! * @param urlText the URL text (<code>null</code> permitted). ! * @param line the line (<code>null</code> not permitted). ! * @param lineStroke the line stroke (<code>null</code> not permitted). ! * @param linePaint the line paint (<code>null</code> not permitted). ! */ ! public LegendItem(AttributedString label, String description, ! String toolTipText, String urlText, ! Shape line, Stroke lineStroke, Paint linePaint) { ! ! this(label, description, toolTipText, urlText, ! /* shape visible = */ false, UNUSED_SHAPE, ! /* shape filled = */ false, Color.black, ! /* shape outlined = */ false, Color.black, UNUSED_STROKE, ! /* line visible = */ true, line, lineStroke, linePaint ); } *************** *** 288,306 **** * @param linePaint the line paint (<code>null</code> not permitted). */ ! public LegendItem(String label, ! AttributedString attributedLabel, ! String description, ! String toolTipText, ! String urlText, ! boolean shapeVisible, ! Shape shape, ! boolean shapeFilled, ! Paint fillPaint, ! boolean shapeOutlineVisible, ! Paint outlinePaint, Stroke outlineStroke, ! boolean lineVisible, ! Shape line, ! Stroke lineStroke, Paint linePaint) { --- 394,404 ---- * @param linePaint the line paint (<code>null</code> not permitted). */ ! public LegendItem(AttributedString label, String description, ! String toolTipText, String urlText, ! boolean shapeVisible, Shape shape, ! boolean shapeFilled, Paint fillPaint, ! boolean shapeOutlineVisible, Paint outlinePaint, Stroke outlineStroke, ! boolean lineVisible, Shape line, Stroke lineStroke, Paint linePaint) { *************** *** 319,327 **** if (outlineStroke == null) { throw new IllegalArgumentException( ! "Null 'outlineStroke' argument." ! ); } ! this.label = label; ! this.attributedLabel = attributedLabel; this.description = description; this.shapeVisible = shapeVisible; --- 417,424 ---- if (outlineStroke == null) { throw new IllegalArgumentException( ! "Null 'outlineStroke' argument."); } ! this.label = characterIteratorToString(label.getIterator()); ! this.attributedLabel = label; this.description = description; this.shapeVisible = shapeVisible; *************** *** 341,344 **** --- 438,466 ---- /** + * Returns a string containing the characters from the given iterator. + * + * @param iterator the iterator (<code>null</code> not permitted). + * + * @return A string. + */ + private String characterIteratorToString(CharacterIterator iterator) { + int endIndex = iterator.getEndIndex(); + int beginIndex = iterator.getBeginIndex(); + int count = endIndex - beginIndex; + if (count <= 0) { + return ""; + } + char[] chars = new char[count]; + int i = 0; + char c = iterator.first(); + while (c != CharacterIterator.DONE) { + chars[i] = c; + i++; + c = iterator.next(); + } + return new String(chars); + } + + /** * Returns the label. * |