Source Code Cross Referenced for XYLineAndShapeRenderer.java in  » Chart » jfreechart » org » jfree » chart » renderer » xy » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Chart » jfreechart » org.jfree.chart.renderer.xy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /* ===========================================================
0002:         * JFreeChart : a free chart library for the Java(tm) platform
0003:         * ===========================================================
0004:         *
0005:         * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
0006:         *
0007:         * Project Info:  http://www.jfree.org/jfreechart/index.html
0008:         *
0009:         * This library is free software; you can redistribute it and/or modify it 
0010:         * under the terms of the GNU Lesser General Public License as published by 
0011:         * the Free Software Foundation; either version 2.1 of the License, or 
0012:         * (at your option) any later version.
0013:         *
0014:         * This library is distributed in the hope that it will be useful, but 
0015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
0016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
0017:         * License for more details.
0018:         *
0019:         * You should have received a copy of the GNU Lesser General Public
0020:         * License along with this library; if not, write to the Free Software
0021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
0022:         * USA.  
0023:         *
0024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
0025:         * in the United States and other countries.]
0026:         *
0027:         * ---------------------------
0028:         * XYLineAndShapeRenderer.java
0029:         * ---------------------------
0030:         * (C) Copyright 2004-2007, by Object Refinery Limited.
0031:         *
0032:         * Original Author:  David Gilbert (for Object Refinery Limited);
0033:         * Contributor(s):   -;
0034:         *
0035:         * $Id: XYLineAndShapeRenderer.java,v 1.20.2.13 2007/06/08 13:29:38 mungady Exp $
0036:         *
0037:         * Changes:
0038:         * --------
0039:         * 27-Jan-2004 : Version 1 (DG);
0040:         * 10-Feb-2004 : Minor change to drawItem() method to make cut-and-paste 
0041:         *               overriding easier (DG);
0042:         * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG);
0043:         * 25-Aug-2004 : Added support for chart entities (required for tooltips) (DG);
0044:         * 24-Sep-2004 : Added flag to allow whole series to be drawn as a path 
0045:         *               (necessary when using a dashed stroke with many data 
0046:         *               items) (DG);
0047:         * 04-Oct-2004 : Renamed BooleanUtils --> BooleanUtilities (DG);
0048:         * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG);
0049:         * 27-Jan-2005 : The getLegendItem() method now omits hidden series (DG);
0050:         * 28-Jan-2005 : Added new constructor (DG);
0051:         * 09-Mar-2005 : Added fillPaint settings (DG);
0052:         * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG);
0053:         * 22-Jul-2005 : Renamed defaultLinesVisible --> baseLinesVisible, 
0054:         *               defaultShapesVisible --> baseShapesVisible and
0055:         *               defaultShapesFilled --> baseShapesFilled (DG);
0056:         * 29-Jul-2005 : Added code to draw item labels (DG);
0057:         * ------------- JFREECHART 1.0.x ---------------------------------------------
0058:         * 20-Jul-2006 : Set dataset and series indices in LegendItem (DG);
0059:         * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG);
0060:         * 21-Feb-2007 : Fixed bugs in clone() and equals() (DG);
0061:         * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG);
0062:         * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG);
0063:         * 08-Jun-2007 : Fix for bug 1731912 where entities are created even for data
0064:         *               items that are not displayed (DG);
0065:         *
0066:         */
0067:
0068:        package org.jfree.chart.renderer.xy;
0069:
0070:        import java.awt.Graphics2D;
0071:        import java.awt.Paint;
0072:        import java.awt.Shape;
0073:        import java.awt.Stroke;
0074:        import java.awt.geom.GeneralPath;
0075:        import java.awt.geom.Line2D;
0076:        import java.awt.geom.Rectangle2D;
0077:        import java.io.IOException;
0078:        import java.io.ObjectInputStream;
0079:        import java.io.ObjectOutputStream;
0080:        import java.io.Serializable;
0081:
0082:        import org.jfree.chart.LegendItem;
0083:        import org.jfree.chart.axis.ValueAxis;
0084:        import org.jfree.chart.entity.EntityCollection;
0085:        import org.jfree.chart.event.RendererChangeEvent;
0086:        import org.jfree.chart.plot.CrosshairState;
0087:        import org.jfree.chart.plot.PlotOrientation;
0088:        import org.jfree.chart.plot.PlotRenderingInfo;
0089:        import org.jfree.chart.plot.XYPlot;
0090:        import org.jfree.data.xy.XYDataset;
0091:        import org.jfree.io.SerialUtilities;
0092:        import org.jfree.ui.RectangleEdge;
0093:        import org.jfree.util.BooleanList;
0094:        import org.jfree.util.BooleanUtilities;
0095:        import org.jfree.util.ObjectUtilities;
0096:        import org.jfree.util.PublicCloneable;
0097:        import org.jfree.util.ShapeUtilities;
0098:
0099:        /**
0100:         * A renderer that connects data points with lines and/or draws shapes at each
0101:         * data point.  This renderer is designed for use with the {@link XYPlot} 
0102:         * class.
0103:         */
0104:        public class XYLineAndShapeRenderer extends AbstractXYItemRenderer
0105:                implements  XYItemRenderer, Cloneable, PublicCloneable,
0106:                Serializable {
0107:
0108:            /** For serialization. */
0109:            private static final long serialVersionUID = -7435246895986425885L;
0110:
0111:            /** A flag that controls whether or not lines are visible for ALL series. */
0112:            private Boolean linesVisible;
0113:
0114:            /** 
0115:             * A table of flags that control (per series) whether or not lines are 
0116:             * visible. 
0117:             */
0118:            private BooleanList seriesLinesVisible;
0119:
0120:            /** The default value returned by the getLinesVisible() method. */
0121:            private boolean baseLinesVisible;
0122:
0123:            /** The shape that is used to represent a line in the legend. */
0124:            private transient Shape legendLine;
0125:
0126:            /** 
0127:             * A flag that controls whether or not shapes are visible for ALL series. 
0128:             */
0129:            private Boolean shapesVisible;
0130:
0131:            /** 
0132:             * A table of flags that control (per series) whether or not shapes are 
0133:             * visible. 
0134:             */
0135:            private BooleanList seriesShapesVisible;
0136:
0137:            /** The default value returned by the getShapeVisible() method. */
0138:            private boolean baseShapesVisible;
0139:
0140:            /** A flag that controls whether or not shapes are filled for ALL series. */
0141:            private Boolean shapesFilled;
0142:
0143:            /** 
0144:             * A table of flags that control (per series) whether or not shapes are 
0145:             * filled. 
0146:             */
0147:            private BooleanList seriesShapesFilled;
0148:
0149:            /** The default value returned by the getShapeFilled() method. */
0150:            private boolean baseShapesFilled;
0151:
0152:            /** A flag that controls whether outlines are drawn for shapes. */
0153:            private boolean drawOutlines;
0154:
0155:            /** 
0156:             * A flag that controls whether the fill paint is used for filling 
0157:             * shapes. 
0158:             */
0159:            private boolean useFillPaint;
0160:
0161:            /** 
0162:             * A flag that controls whether the outline paint is used for drawing shape 
0163:             * outlines. 
0164:             */
0165:            private boolean useOutlinePaint;
0166:
0167:            /** 
0168:             * A flag that controls whether or not each series is drawn as a single 
0169:             * path. 
0170:             */
0171:            private boolean drawSeriesLineAsPath;
0172:
0173:            /**
0174:             * Creates a new renderer with both lines and shapes visible.
0175:             */
0176:            public XYLineAndShapeRenderer() {
0177:                this (true, true);
0178:            }
0179:
0180:            /**
0181:             * Creates a new renderer.
0182:             * 
0183:             * @param lines  lines visible?
0184:             * @param shapes  shapes visible?
0185:             */
0186:            public XYLineAndShapeRenderer(boolean lines, boolean shapes) {
0187:                this .linesVisible = null;
0188:                this .seriesLinesVisible = new BooleanList();
0189:                this .baseLinesVisible = lines;
0190:                this .legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0);
0191:
0192:                this .shapesVisible = null;
0193:                this .seriesShapesVisible = new BooleanList();
0194:                this .baseShapesVisible = shapes;
0195:
0196:                this .shapesFilled = null;
0197:                this .useFillPaint = false; // use item paint for fills by default
0198:                this .seriesShapesFilled = new BooleanList();
0199:                this .baseShapesFilled = true;
0200:
0201:                this .drawOutlines = true;
0202:                this .useOutlinePaint = false; // use item paint for outlines by 
0203:                // default, not outline paint
0204:
0205:                this .drawSeriesLineAsPath = false;
0206:            }
0207:
0208:            /**
0209:             * Returns a flag that controls whether or not each series is drawn as a 
0210:             * single path.
0211:             * 
0212:             * @return A boolean.
0213:             * 
0214:             * @see #setDrawSeriesLineAsPath(boolean)
0215:             */
0216:            public boolean getDrawSeriesLineAsPath() {
0217:                return this .drawSeriesLineAsPath;
0218:            }
0219:
0220:            /**
0221:             * Sets the flag that controls whether or not each series is drawn as a 
0222:             * single path.
0223:             * 
0224:             * @param flag  the flag.
0225:             * 
0226:             * @see #getDrawSeriesLineAsPath()
0227:             */
0228:            public void setDrawSeriesLineAsPath(boolean flag) {
0229:                if (this .drawSeriesLineAsPath != flag) {
0230:                    this .drawSeriesLineAsPath = flag;
0231:                    notifyListeners(new RendererChangeEvent(this ));
0232:                }
0233:            }
0234:
0235:            /**
0236:             * Returns the number of passes through the data that the renderer requires 
0237:             * in order to draw the chart.  Most charts will require a single pass, but 
0238:             * some require two passes.
0239:             * 
0240:             * @return The pass count.
0241:             */
0242:            public int getPassCount() {
0243:                return 2;
0244:            }
0245:
0246:            // LINES VISIBLE
0247:
0248:            /**
0249:             * Returns the flag used to control whether or not the shape for an item is 
0250:             * visible.
0251:             *
0252:             * @param series  the series index (zero-based).
0253:             * @param item  the item index (zero-based).
0254:             *
0255:             * @return A boolean.
0256:             */
0257:            public boolean getItemLineVisible(int series, int item) {
0258:                Boolean flag = this .linesVisible;
0259:                if (flag == null) {
0260:                    flag = getSeriesLinesVisible(series);
0261:                }
0262:                if (flag != null) {
0263:                    return flag.booleanValue();
0264:                } else {
0265:                    return this .baseLinesVisible;
0266:                }
0267:            }
0268:
0269:            /**
0270:             * Returns a flag that controls whether or not lines are drawn for ALL 
0271:             * series.  If this flag is <code>null</code>, then the "per series" 
0272:             * settings will apply.
0273:             * 
0274:             * @return A flag (possibly <code>null</code>).
0275:             * 
0276:             * @see #setLinesVisible(Boolean) 
0277:             */
0278:            public Boolean getLinesVisible() {
0279:                return this .linesVisible;
0280:            }
0281:
0282:            /**
0283:             * Sets a flag that controls whether or not lines are drawn between the 
0284:             * items in ALL series, and sends a {@link RendererChangeEvent} to all 
0285:             * registered listeners.  You need to set this to <code>null</code> if you 
0286:             * want the "per series" settings to apply.
0287:             *
0288:             * @param visible  the flag (<code>null</code> permitted).
0289:             * 
0290:             * @see #getLinesVisible()
0291:             */
0292:            public void setLinesVisible(Boolean visible) {
0293:                this .linesVisible = visible;
0294:                notifyListeners(new RendererChangeEvent(this ));
0295:            }
0296:
0297:            /**
0298:             * Sets a flag that controls whether or not lines are drawn between the 
0299:             * items in ALL series, and sends a {@link RendererChangeEvent} to all 
0300:             * registered listeners.
0301:             *
0302:             * @param visible  the flag.
0303:             * 
0304:             * @see #getLinesVisible()
0305:             */
0306:            public void setLinesVisible(boolean visible) {
0307:                // we use BooleanUtilities here to preserve JRE 1.3.1 compatibility
0308:                setLinesVisible(BooleanUtilities.valueOf(visible));
0309:            }
0310:
0311:            /**
0312:             * Returns the flag used to control whether or not the lines for a series 
0313:             * are visible.
0314:             *
0315:             * @param series  the series index (zero-based).
0316:             *
0317:             * @return The flag (possibly <code>null</code>).
0318:             * 
0319:             * @see #setSeriesLinesVisible(int, Boolean)
0320:             */
0321:            public Boolean getSeriesLinesVisible(int series) {
0322:                return this .seriesLinesVisible.getBoolean(series);
0323:            }
0324:
0325:            /**
0326:             * Sets the 'lines visible' flag for a series and sends a 
0327:             * {@link RendererChangeEvent} to all registered listeners.
0328:             *
0329:             * @param series  the series index (zero-based).
0330:             * @param flag  the flag (<code>null</code> permitted).
0331:             * 
0332:             * @see #getSeriesLinesVisible(int)
0333:             */
0334:            public void setSeriesLinesVisible(int series, Boolean flag) {
0335:                this .seriesLinesVisible.setBoolean(series, flag);
0336:                notifyListeners(new RendererChangeEvent(this ));
0337:            }
0338:
0339:            /**
0340:             * Sets the 'lines visible' flag for a series and sends a 
0341:             * {@link RendererChangeEvent} to all registered listeners.
0342:             * 
0343:             * @param series  the series index (zero-based).
0344:             * @param visible  the flag.
0345:             * 
0346:             * @see #getSeriesLinesVisible(int)
0347:             */
0348:            public void setSeriesLinesVisible(int series, boolean visible) {
0349:                setSeriesLinesVisible(series, BooleanUtilities.valueOf(visible));
0350:            }
0351:
0352:            /**
0353:             * Returns the base 'lines visible' attribute.
0354:             *
0355:             * @return The base flag.
0356:             * 
0357:             * @see #setBaseLinesVisible(boolean)
0358:             */
0359:            public boolean getBaseLinesVisible() {
0360:                return this .baseLinesVisible;
0361:            }
0362:
0363:            /**
0364:             * Sets the base 'lines visible' flag and sends a 
0365:             * {@link RendererChangeEvent} to all registered listeners.
0366:             *
0367:             * @param flag  the flag.
0368:             * 
0369:             * @see #getBaseLinesVisible()
0370:             */
0371:            public void setBaseLinesVisible(boolean flag) {
0372:                this .baseLinesVisible = flag;
0373:                notifyListeners(new RendererChangeEvent(this ));
0374:            }
0375:
0376:            /**
0377:             * Returns the shape used to represent a line in the legend.
0378:             * 
0379:             * @return The legend line (never <code>null</code>).
0380:             * 
0381:             * @see #setLegendLine(Shape)
0382:             */
0383:            public Shape getLegendLine() {
0384:                return this .legendLine;
0385:            }
0386:
0387:            /**
0388:             * Sets the shape used as a line in each legend item and sends a 
0389:             * {@link RendererChangeEvent} to all registered listeners.
0390:             * 
0391:             * @param line  the line (<code>null</code> not permitted).
0392:             * 
0393:             * @see #getLegendLine()
0394:             */
0395:            public void setLegendLine(Shape line) {
0396:                if (line == null) {
0397:                    throw new IllegalArgumentException("Null 'line' argument.");
0398:                }
0399:                this .legendLine = line;
0400:                notifyListeners(new RendererChangeEvent(this ));
0401:            }
0402:
0403:            // SHAPES VISIBLE
0404:
0405:            /**
0406:             * Returns the flag used to control whether or not the shape for an item is
0407:             * visible.
0408:             * <p>
0409:             * The default implementation passes control to the 
0410:             * <code>getSeriesShapesVisible</code> method. You can override this method
0411:             * if you require different behaviour.
0412:             *
0413:             * @param series  the series index (zero-based).
0414:             * @param item  the item index (zero-based).
0415:             *
0416:             * @return A boolean.
0417:             */
0418:            public boolean getItemShapeVisible(int series, int item) {
0419:                Boolean flag = this .shapesVisible;
0420:                if (flag == null) {
0421:                    flag = getSeriesShapesVisible(series);
0422:                }
0423:                if (flag != null) {
0424:                    return flag.booleanValue();
0425:                } else {
0426:                    return this .baseShapesVisible;
0427:                }
0428:            }
0429:
0430:            /**
0431:             * Returns the flag that controls whether the shapes are visible for the 
0432:             * items in ALL series.
0433:             * 
0434:             * @return The flag (possibly <code>null</code>).
0435:             * 
0436:             * @see #setShapesVisible(Boolean)
0437:             */
0438:            public Boolean getShapesVisible() {
0439:                return this .shapesVisible;
0440:            }
0441:
0442:            /**
0443:             * Sets the 'shapes visible' for ALL series and sends a 
0444:             * {@link RendererChangeEvent} to all registered listeners.
0445:             *
0446:             * @param visible  the flag (<code>null</code> permitted).
0447:             * 
0448:             * @see #getShapesVisible()
0449:             */
0450:            public void setShapesVisible(Boolean visible) {
0451:                this .shapesVisible = visible;
0452:                notifyListeners(new RendererChangeEvent(this ));
0453:            }
0454:
0455:            /**
0456:             * Sets the 'shapes visible' for ALL series and sends a 
0457:             * {@link RendererChangeEvent} to all registered listeners.
0458:             * 
0459:             * @param visible  the flag.
0460:             * 
0461:             * @see #getShapesVisible()
0462:             */
0463:            public void setShapesVisible(boolean visible) {
0464:                setShapesVisible(BooleanUtilities.valueOf(visible));
0465:            }
0466:
0467:            /**
0468:             * Returns the flag used to control whether or not the shapes for a series
0469:             * are visible.
0470:             *
0471:             * @param series  the series index (zero-based).
0472:             *
0473:             * @return A boolean.
0474:             * 
0475:             * @see #setSeriesShapesVisible(int, Boolean)
0476:             */
0477:            public Boolean getSeriesShapesVisible(int series) {
0478:                return this .seriesShapesVisible.getBoolean(series);
0479:            }
0480:
0481:            /**
0482:             * Sets the 'shapes visible' flag for a series and sends a 
0483:             * {@link RendererChangeEvent} to all registered listeners.
0484:             * 
0485:             * @param series  the series index (zero-based).
0486:             * @param visible  the flag.
0487:             * 
0488:             * @see #getSeriesShapesVisible(int)
0489:             */
0490:            public void setSeriesShapesVisible(int series, boolean visible) {
0491:                setSeriesShapesVisible(series, BooleanUtilities
0492:                        .valueOf(visible));
0493:            }
0494:
0495:            /**
0496:             * Sets the 'shapes visible' flag for a series and sends a 
0497:             * {@link RendererChangeEvent} to all registered listeners.
0498:             *
0499:             * @param series  the series index (zero-based).
0500:             * @param flag  the flag.
0501:             * 
0502:             * @see #getSeriesShapesVisible(int)
0503:             */
0504:            public void setSeriesShapesVisible(int series, Boolean flag) {
0505:                this .seriesShapesVisible.setBoolean(series, flag);
0506:                notifyListeners(new RendererChangeEvent(this ));
0507:            }
0508:
0509:            /**
0510:             * Returns the base 'shape visible' attribute.
0511:             *
0512:             * @return The base flag.
0513:             * 
0514:             * @see #setBaseShapesVisible(boolean)
0515:             */
0516:            public boolean getBaseShapesVisible() {
0517:                return this .baseShapesVisible;
0518:            }
0519:
0520:            /**
0521:             * Sets the base 'shapes visible' flag and sends a 
0522:             * {@link RendererChangeEvent} to all registered listeners.
0523:             *
0524:             * @param flag  the flag.
0525:             * 
0526:             * @see #getBaseShapesVisible()
0527:             */
0528:            public void setBaseShapesVisible(boolean flag) {
0529:                this .baseShapesVisible = flag;
0530:                notifyListeners(new RendererChangeEvent(this ));
0531:            }
0532:
0533:            // SHAPES FILLED
0534:
0535:            /**
0536:             * Returns the flag used to control whether or not the shape for an item 
0537:             * is filled.
0538:             * <p>
0539:             * The default implementation passes control to the 
0540:             * <code>getSeriesShapesFilled</code> method. You can override this method
0541:             * if you require different behaviour.
0542:             *
0543:             * @param series  the series index (zero-based).
0544:             * @param item  the item index (zero-based).
0545:             *
0546:             * @return A boolean.
0547:             */
0548:            public boolean getItemShapeFilled(int series, int item) {
0549:                Boolean flag = this .shapesFilled;
0550:                if (flag == null) {
0551:                    flag = getSeriesShapesFilled(series);
0552:                }
0553:                if (flag != null) {
0554:                    return flag.booleanValue();
0555:                } else {
0556:                    return this .baseShapesFilled;
0557:                }
0558:            }
0559:
0560:            // FIXME: Why no getShapesFilled()?  An oversight probably
0561:
0562:            /**
0563:             * Sets the 'shapes filled' for ALL series and sends a 
0564:             * {@link RendererChangeEvent} to all registered listeners.
0565:             *
0566:             * @param filled  the flag.
0567:             */
0568:            public void setShapesFilled(boolean filled) {
0569:                setShapesFilled(BooleanUtilities.valueOf(filled));
0570:            }
0571:
0572:            /**
0573:             * Sets the 'shapes filled' for ALL series and sends a 
0574:             * {@link RendererChangeEvent} to all registered listeners.
0575:             *
0576:             * @param filled  the flag (<code>null</code> permitted).
0577:             */
0578:            public void setShapesFilled(Boolean filled) {
0579:                this .shapesFilled = filled;
0580:                notifyListeners(new RendererChangeEvent(this ));
0581:            }
0582:
0583:            /**
0584:             * Returns the flag used to control whether or not the shapes for a series
0585:             * are filled.
0586:             *
0587:             * @param series  the series index (zero-based).
0588:             *
0589:             * @return A boolean.
0590:             * 
0591:             * @see #setSeriesShapesFilled(int, Boolean)
0592:             */
0593:            public Boolean getSeriesShapesFilled(int series) {
0594:                return this .seriesShapesFilled.getBoolean(series);
0595:            }
0596:
0597:            /**
0598:             * Sets the 'shapes filled' flag for a series and sends a 
0599:             * {@link RendererChangeEvent} to all registered listeners.
0600:             *
0601:             * @param series  the series index (zero-based).
0602:             * @param flag  the flag.
0603:             * 
0604:             * @see #getSeriesShapesFilled(int)
0605:             */
0606:            public void setSeriesShapesFilled(int series, boolean flag) {
0607:                setSeriesShapesFilled(series, BooleanUtilities.valueOf(flag));
0608:            }
0609:
0610:            /**
0611:             * Sets the 'shapes filled' flag for a series and sends a 
0612:             * {@link RendererChangeEvent} to all registered listeners.
0613:             *
0614:             * @param series  the series index (zero-based).
0615:             * @param flag  the flag.
0616:             * 
0617:             * @see #getSeriesShapesFilled(int)
0618:             */
0619:            public void setSeriesShapesFilled(int series, Boolean flag) {
0620:                this .seriesShapesFilled.setBoolean(series, flag);
0621:                notifyListeners(new RendererChangeEvent(this ));
0622:            }
0623:
0624:            /**
0625:             * Returns the base 'shape filled' attribute.
0626:             *
0627:             * @return The base flag.
0628:             * 
0629:             * @see #setBaseShapesFilled(boolean)
0630:             */
0631:            public boolean getBaseShapesFilled() {
0632:                return this .baseShapesFilled;
0633:            }
0634:
0635:            /**
0636:             * Sets the base 'shapes filled' flag and sends a 
0637:             * {@link RendererChangeEvent} to all registered listeners.
0638:             *
0639:             * @param flag  the flag.
0640:             * 
0641:             * @see #getBaseShapesFilled()
0642:             */
0643:            public void setBaseShapesFilled(boolean flag) {
0644:                this .baseShapesFilled = flag;
0645:                notifyListeners(new RendererChangeEvent(this ));
0646:            }
0647:
0648:            /**
0649:             * Returns <code>true</code> if outlines should be drawn for shapes, and 
0650:             * <code>false</code> otherwise.
0651:             * 
0652:             * @return A boolean.
0653:             * 
0654:             * @see #setDrawOutlines(boolean)
0655:             */
0656:            public boolean getDrawOutlines() {
0657:                return this .drawOutlines;
0658:            }
0659:
0660:            /**
0661:             * Sets the flag that controls whether outlines are drawn for 
0662:             * shapes, and sends a {@link RendererChangeEvent} to all registered 
0663:             * listeners. 
0664:             * <P>
0665:             * In some cases, shapes look better if they do NOT have an outline, but 
0666:             * this flag allows you to set your own preference.
0667:             * 
0668:             * @param flag  the flag.
0669:             * 
0670:             * @see #getDrawOutlines()
0671:             */
0672:            public void setDrawOutlines(boolean flag) {
0673:                this .drawOutlines = flag;
0674:                notifyListeners(new RendererChangeEvent(this ));
0675:            }
0676:
0677:            /**
0678:             * Returns <code>true</code> if the renderer should use the fill paint 
0679:             * setting to fill shapes, and <code>false</code> if it should just
0680:             * use the regular paint.
0681:             * 
0682:             * @return A boolean.
0683:             * 
0684:             * @see #setUseFillPaint(boolean)
0685:             * @see #getUseOutlinePaint()
0686:             */
0687:            public boolean getUseFillPaint() {
0688:                return this .useFillPaint;
0689:            }
0690:
0691:            /**
0692:             * Sets the flag that controls whether the fill paint is used to fill 
0693:             * shapes, and sends a {@link RendererChangeEvent} to all 
0694:             * registered listeners.
0695:             * 
0696:             * @param flag  the flag.
0697:             * 
0698:             * @see #getUseFillPaint()
0699:             */
0700:            public void setUseFillPaint(boolean flag) {
0701:                this .useFillPaint = flag;
0702:                notifyListeners(new RendererChangeEvent(this ));
0703:            }
0704:
0705:            /**
0706:             * Returns <code>true</code> if the renderer should use the outline paint 
0707:             * setting to draw shape outlines, and <code>false</code> if it should just
0708:             * use the regular paint.
0709:             * 
0710:             * @return A boolean.
0711:             * 
0712:             * @see #setUseOutlinePaint(boolean)
0713:             * @see #getUseFillPaint()
0714:             */
0715:            public boolean getUseOutlinePaint() {
0716:                return this .useOutlinePaint;
0717:            }
0718:
0719:            /**
0720:             * Sets the flag that controls whether the outline paint is used to draw 
0721:             * shape outlines, and sends a {@link RendererChangeEvent} to all 
0722:             * registered listeners.
0723:             * 
0724:             * @param flag  the flag.
0725:             * 
0726:             * @see #getUseOutlinePaint()
0727:             */
0728:            public void setUseOutlinePaint(boolean flag) {
0729:                this .useOutlinePaint = flag;
0730:                notifyListeners(new RendererChangeEvent(this ));
0731:            }
0732:
0733:            /**
0734:             * Records the state for the renderer.  This is used to preserve state 
0735:             * information between calls to the drawItem() method for a single chart 
0736:             * drawing.
0737:             */
0738:            public static class State extends XYItemRendererState {
0739:
0740:                /** The path for the current series. */
0741:                public GeneralPath seriesPath;
0742:
0743:                /** 
0744:                 * A flag that indicates if the last (x, y) point was 'good' 
0745:                 * (non-null). 
0746:                 */
0747:                private boolean lastPointGood;
0748:
0749:                /**
0750:                 * Creates a new state instance.
0751:                 * 
0752:                 * @param info  the plot rendering info.
0753:                 */
0754:                public State(PlotRenderingInfo info) {
0755:                    super (info);
0756:                }
0757:
0758:                /**
0759:                 * Returns a flag that indicates if the last point drawn (in the 
0760:                 * current series) was 'good' (non-null).
0761:                 * 
0762:                 * @return A boolean.
0763:                 */
0764:                public boolean isLastPointGood() {
0765:                    return this .lastPointGood;
0766:                }
0767:
0768:                /**
0769:                 * Sets a flag that indicates if the last point drawn (in the current 
0770:                 * series) was 'good' (non-null).
0771:                 * 
0772:                 * @param good  the flag.
0773:                 */
0774:                public void setLastPointGood(boolean good) {
0775:                    this .lastPointGood = good;
0776:                }
0777:            }
0778:
0779:            /**
0780:             * Initialises the renderer.
0781:             * <P>
0782:             * This method will be called before the first item is rendered, giving the
0783:             * renderer an opportunity to initialise any state information it wants to 
0784:             * maintain.  The renderer can do nothing if it chooses.
0785:             *
0786:             * @param g2  the graphics device.
0787:             * @param dataArea  the area inside the axes.
0788:             * @param plot  the plot.
0789:             * @param data  the data.
0790:             * @param info  an optional info collection object to return data back to 
0791:             *              the caller.
0792:             *
0793:             * @return The renderer state.
0794:             */
0795:            public XYItemRendererState initialise(Graphics2D g2,
0796:                    Rectangle2D dataArea, XYPlot plot, XYDataset data,
0797:                    PlotRenderingInfo info) {
0798:
0799:                State state = new State(info);
0800:                state.seriesPath = new GeneralPath();
0801:                return state;
0802:
0803:            }
0804:
0805:            /**
0806:             * Draws the visual representation of a single data item.
0807:             *
0808:             * @param g2  the graphics device.
0809:             * @param state  the renderer state.
0810:             * @param dataArea  the area within which the data is being drawn.
0811:             * @param info  collects information about the drawing.
0812:             * @param plot  the plot (can be used to obtain standard color 
0813:             *              information etc).
0814:             * @param domainAxis  the domain axis.
0815:             * @param rangeAxis  the range axis.
0816:             * @param dataset  the dataset.
0817:             * @param series  the series index (zero-based).
0818:             * @param item  the item index (zero-based).
0819:             * @param crosshairState  crosshair information for the plot 
0820:             *                        (<code>null</code> permitted).
0821:             * @param pass  the pass index.
0822:             */
0823:            public void drawItem(Graphics2D g2, XYItemRendererState state,
0824:                    Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot,
0825:                    ValueAxis domainAxis, ValueAxis rangeAxis,
0826:                    XYDataset dataset, int series, int item,
0827:                    CrosshairState crosshairState, int pass) {
0828:
0829:                // do nothing if item is not visible
0830:                if (!getItemVisible(series, item)) {
0831:                    return;
0832:                }
0833:
0834:                // first pass draws the background (lines, for instance)
0835:                if (isLinePass(pass)) {
0836:                    if (item == 0) {
0837:                        if (this .drawSeriesLineAsPath) {
0838:                            State s = (State) state;
0839:                            s.seriesPath.reset();
0840:                            s.lastPointGood = false;
0841:                        }
0842:                    }
0843:
0844:                    if (getItemLineVisible(series, item)) {
0845:                        if (this .drawSeriesLineAsPath) {
0846:                            drawPrimaryLineAsPath(state, g2, plot, dataset,
0847:                                    pass, series, item, domainAxis, rangeAxis,
0848:                                    dataArea);
0849:                        } else {
0850:                            drawPrimaryLine(state, g2, plot, dataset, pass,
0851:                                    series, item, domainAxis, rangeAxis,
0852:                                    dataArea);
0853:                        }
0854:                    }
0855:                }
0856:                // second pass adds shapes where the items are ..
0857:                else if (isItemPass(pass)) {
0858:
0859:                    // setup for collecting optional entity info...
0860:                    EntityCollection entities = null;
0861:                    if (info != null) {
0862:                        entities = info.getOwner().getEntityCollection();
0863:                    }
0864:
0865:                    drawSecondaryPass(g2, plot, dataset, pass, series, item,
0866:                            domainAxis, dataArea, rangeAxis, crosshairState,
0867:                            entities);
0868:                }
0869:            }
0870:
0871:            /**
0872:             * Returns <code>true</code> if the specified pass is the one for drawing 
0873:             * lines.
0874:             * 
0875:             * @param pass  the pass.
0876:             * 
0877:             * @return A boolean.
0878:             */
0879:            protected boolean isLinePass(int pass) {
0880:                return pass == 0;
0881:            }
0882:
0883:            /**
0884:             * Returns <code>true</code> if the specified pass is the one for drawing 
0885:             * items.
0886:             * 
0887:             * @param pass  the pass.
0888:             * 
0889:             * @return A boolean.
0890:             */
0891:            protected boolean isItemPass(int pass) {
0892:                return pass == 1;
0893:            }
0894:
0895:            /**
0896:             * Draws the item (first pass). This method draws the lines
0897:             * connecting the items.
0898:             *
0899:             * @param g2  the graphics device.
0900:             * @param state  the renderer state.
0901:             * @param dataArea  the area within which the data is being drawn.
0902:             * @param plot  the plot (can be used to obtain standard color 
0903:             *              information etc).
0904:             * @param domainAxis  the domain axis.
0905:             * @param rangeAxis  the range axis.
0906:             * @param dataset  the dataset.
0907:             * @param pass  the pass.
0908:             * @param series  the series index (zero-based).
0909:             * @param item  the item index (zero-based).
0910:             */
0911:            protected void drawPrimaryLine(XYItemRendererState state,
0912:                    Graphics2D g2, XYPlot plot, XYDataset dataset, int pass,
0913:                    int series, int item, ValueAxis domainAxis,
0914:                    ValueAxis rangeAxis, Rectangle2D dataArea) {
0915:                if (item == 0) {
0916:                    return;
0917:                }
0918:
0919:                // get the data point...
0920:                double x1 = dataset.getXValue(series, item);
0921:                double y1 = dataset.getYValue(series, item);
0922:                if (Double.isNaN(y1) || Double.isNaN(x1)) {
0923:                    return;
0924:                }
0925:
0926:                double x0 = dataset.getXValue(series, item - 1);
0927:                double y0 = dataset.getYValue(series, item - 1);
0928:                if (Double.isNaN(y0) || Double.isNaN(x0)) {
0929:                    return;
0930:                }
0931:
0932:                RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
0933:                RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
0934:
0935:                double transX0 = domainAxis.valueToJava2D(x0, dataArea,
0936:                        xAxisLocation);
0937:                double transY0 = rangeAxis.valueToJava2D(y0, dataArea,
0938:                        yAxisLocation);
0939:
0940:                double transX1 = domainAxis.valueToJava2D(x1, dataArea,
0941:                        xAxisLocation);
0942:                double transY1 = rangeAxis.valueToJava2D(y1, dataArea,
0943:                        yAxisLocation);
0944:
0945:                // only draw if we have good values
0946:                if (Double.isNaN(transX0) || Double.isNaN(transY0)
0947:                        || Double.isNaN(transX1) || Double.isNaN(transY1)) {
0948:                    return;
0949:                }
0950:
0951:                PlotOrientation orientation = plot.getOrientation();
0952:                if (orientation == PlotOrientation.HORIZONTAL) {
0953:                    state.workingLine.setLine(transY0, transX0, transY1,
0954:                            transX1);
0955:                } else if (orientation == PlotOrientation.VERTICAL) {
0956:                    state.workingLine.setLine(transX0, transY0, transX1,
0957:                            transY1);
0958:                }
0959:
0960:                if (state.workingLine.intersects(dataArea)) {
0961:                    drawFirstPassShape(g2, pass, series, item,
0962:                            state.workingLine);
0963:                }
0964:            }
0965:
0966:            /**
0967:             * Draws the first pass shape.
0968:             * 
0969:             * @param g2  the graphics device.
0970:             * @param pass  the pass.
0971:             * @param series  the series index.
0972:             * @param item  the item index.
0973:             * @param shape  the shape.
0974:             */
0975:            protected void drawFirstPassShape(Graphics2D g2, int pass,
0976:                    int series, int item, Shape shape) {
0977:                g2.setStroke(getItemStroke(series, item));
0978:                g2.setPaint(getItemPaint(series, item));
0979:                g2.draw(shape);
0980:            }
0981:
0982:            /**
0983:             * Draws the item (first pass). This method draws the lines
0984:             * connecting the items. Instead of drawing separate lines,
0985:             * a GeneralPath is constructed and drawn at the end of
0986:             * the series painting.
0987:             *
0988:             * @param g2  the graphics device.
0989:             * @param state  the renderer state.
0990:             * @param plot  the plot (can be used to obtain standard color information 
0991:             *              etc).
0992:             * @param dataset  the dataset.
0993:             * @param pass  the pass.
0994:             * @param series  the series index (zero-based).
0995:             * @param item  the item index (zero-based).
0996:             * @param domainAxis  the domain axis.
0997:             * @param rangeAxis  the range axis.
0998:             * @param dataArea  the area within which the data is being drawn.
0999:             */
1000:            protected void drawPrimaryLineAsPath(XYItemRendererState state,
1001:                    Graphics2D g2, XYPlot plot, XYDataset dataset, int pass,
1002:                    int series, int item, ValueAxis domainAxis,
1003:                    ValueAxis rangeAxis, Rectangle2D dataArea) {
1004:
1005:                RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
1006:                RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
1007:
1008:                // get the data point...
1009:                double x1 = dataset.getXValue(series, item);
1010:                double y1 = dataset.getYValue(series, item);
1011:                double transX1 = domainAxis.valueToJava2D(x1, dataArea,
1012:                        xAxisLocation);
1013:                double transY1 = rangeAxis.valueToJava2D(y1, dataArea,
1014:                        yAxisLocation);
1015:
1016:                State s = (State) state;
1017:                // update path to reflect latest point
1018:                if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) {
1019:                    float x = (float) transX1;
1020:                    float y = (float) transY1;
1021:                    PlotOrientation orientation = plot.getOrientation();
1022:                    if (orientation == PlotOrientation.HORIZONTAL) {
1023:                        x = (float) transY1;
1024:                        y = (float) transX1;
1025:                    }
1026:                    if (s.isLastPointGood()) {
1027:                        s.seriesPath.lineTo(x, y);
1028:                    } else {
1029:                        s.seriesPath.moveTo(x, y);
1030:                    }
1031:                    s.setLastPointGood(true);
1032:                } else {
1033:                    s.setLastPointGood(false);
1034:                }
1035:                // if this is the last item, draw the path ...
1036:                if (item == dataset.getItemCount(series) - 1) {
1037:                    // draw path
1038:                    drawFirstPassShape(g2, pass, series, item, s.seriesPath);
1039:                }
1040:            }
1041:
1042:            /**
1043:             * Draws the item shapes and adds chart entities (second pass). This method 
1044:             * draws the shapes which mark the item positions. If <code>entities</code> 
1045:             * is not <code>null</code> it will be populated with entity information
1046:             * for points that fall within the data area.
1047:             *
1048:             * @param g2  the graphics device.
1049:             * @param plot  the plot (can be used to obtain standard color 
1050:             *              information etc).
1051:             * @param domainAxis  the domain axis.
1052:             * @param dataArea  the area within which the data is being drawn.
1053:             * @param rangeAxis  the range axis.
1054:             * @param dataset  the dataset.
1055:             * @param pass  the pass.
1056:             * @param series  the series index (zero-based).
1057:             * @param item  the item index (zero-based).
1058:             * @param crosshairState  the crosshair state.
1059:             * @param entities the entity collection.
1060:             */
1061:            protected void drawSecondaryPass(Graphics2D g2, XYPlot plot,
1062:                    XYDataset dataset, int pass, int series, int item,
1063:                    ValueAxis domainAxis, Rectangle2D dataArea,
1064:                    ValueAxis rangeAxis, CrosshairState crosshairState,
1065:                    EntityCollection entities) {
1066:
1067:                Shape entityArea = null;
1068:
1069:                // get the data point...
1070:                double x1 = dataset.getXValue(series, item);
1071:                double y1 = dataset.getYValue(series, item);
1072:                if (Double.isNaN(y1) || Double.isNaN(x1)) {
1073:                    return;
1074:                }
1075:
1076:                PlotOrientation orientation = plot.getOrientation();
1077:                RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
1078:                RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
1079:                double transX1 = domainAxis.valueToJava2D(x1, dataArea,
1080:                        xAxisLocation);
1081:                double transY1 = rangeAxis.valueToJava2D(y1, dataArea,
1082:                        yAxisLocation);
1083:
1084:                if (getItemShapeVisible(series, item)) {
1085:                    Shape shape = getItemShape(series, item);
1086:                    if (orientation == PlotOrientation.HORIZONTAL) {
1087:                        shape = ShapeUtilities.createTranslatedShape(shape,
1088:                                transY1, transX1);
1089:                    } else if (orientation == PlotOrientation.VERTICAL) {
1090:                        shape = ShapeUtilities.createTranslatedShape(shape,
1091:                                transX1, transY1);
1092:                    }
1093:                    entityArea = shape;
1094:                    if (shape.intersects(dataArea)) {
1095:                        if (getItemShapeFilled(series, item)) {
1096:                            if (this .useFillPaint) {
1097:                                g2.setPaint(getItemFillPaint(series, item));
1098:                            } else {
1099:                                g2.setPaint(getItemPaint(series, item));
1100:                            }
1101:                            g2.fill(shape);
1102:                        }
1103:                        if (this .drawOutlines) {
1104:                            if (getUseOutlinePaint()) {
1105:                                g2.setPaint(getItemOutlinePaint(series, item));
1106:                            } else {
1107:                                g2.setPaint(getItemPaint(series, item));
1108:                            }
1109:                            g2.setStroke(getItemOutlineStroke(series, item));
1110:                            g2.draw(shape);
1111:                        }
1112:                    }
1113:                }
1114:
1115:                double xx = transX1;
1116:                double yy = transY1;
1117:                if (orientation == PlotOrientation.HORIZONTAL) {
1118:                    xx = transY1;
1119:                    yy = transX1;
1120:                }
1121:
1122:                // draw the item label if there is one...
1123:                if (isItemLabelVisible(series, item)) {
1124:                    drawItemLabel(g2, orientation, dataset, series, item, xx,
1125:                            yy, (y1 < 0.0));
1126:                }
1127:
1128:                int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
1129:                int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
1130:                updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex,
1131:                        rangeAxisIndex, transX1, transY1, plot.getOrientation());
1132:
1133:                // add an entity for the item, but only if it falls within the data
1134:                // area...
1135:                if (entities != null && dataArea.contains(xx, yy)) {
1136:                    addEntity(entities, entityArea, dataset, series, item, xx,
1137:                            yy);
1138:                }
1139:            }
1140:
1141:            /**
1142:             * Returns a legend item for the specified series.
1143:             *
1144:             * @param datasetIndex  the dataset index (zero-based).
1145:             * @param series  the series index (zero-based).
1146:             *
1147:             * @return A legend item for the series.
1148:             */
1149:            public LegendItem getLegendItem(int datasetIndex, int series) {
1150:
1151:                XYPlot plot = getPlot();
1152:                if (plot == null) {
1153:                    return null;
1154:                }
1155:
1156:                LegendItem result = null;
1157:                XYDataset dataset = plot.getDataset(datasetIndex);
1158:                if (dataset != null) {
1159:                    if (getItemVisible(series, 0)) {
1160:                        String label = getLegendItemLabelGenerator()
1161:                                .generateLabel(dataset, series);
1162:                        String description = label;
1163:                        String toolTipText = null;
1164:                        if (getLegendItemToolTipGenerator() != null) {
1165:                            toolTipText = getLegendItemToolTipGenerator()
1166:                                    .generateLabel(dataset, series);
1167:                        }
1168:                        String urlText = null;
1169:                        if (getLegendItemURLGenerator() != null) {
1170:                            urlText = getLegendItemURLGenerator()
1171:                                    .generateLabel(dataset, series);
1172:                        }
1173:                        boolean shapeIsVisible = getItemShapeVisible(series, 0);
1174:                        Shape shape = lookupSeriesShape(series);
1175:                        boolean shapeIsFilled = getItemShapeFilled(series, 0);
1176:                        Paint fillPaint = (this .useFillPaint ? lookupSeriesFillPaint(series)
1177:                                : lookupSeriesPaint(series));
1178:                        boolean shapeOutlineVisible = this .drawOutlines;
1179:                        Paint outlinePaint = (this .useOutlinePaint ? lookupSeriesOutlinePaint(series)
1180:                                : lookupSeriesPaint(series));
1181:                        Stroke outlineStroke = lookupSeriesOutlineStroke(series);
1182:                        boolean lineVisible = getItemLineVisible(series, 0);
1183:                        Stroke lineStroke = lookupSeriesStroke(series);
1184:                        Paint linePaint = lookupSeriesPaint(series);
1185:                        result = new LegendItem(label, description,
1186:                                toolTipText, urlText, shapeIsVisible, shape,
1187:                                shapeIsFilled, fillPaint, shapeOutlineVisible,
1188:                                outlinePaint, outlineStroke, lineVisible,
1189:                                this .legendLine, lineStroke, linePaint);
1190:                        result.setSeriesKey(dataset.getSeriesKey(series));
1191:                        result.setSeriesIndex(series);
1192:                        result.setDataset(dataset);
1193:                        result.setDatasetIndex(datasetIndex);
1194:                    }
1195:                }
1196:
1197:                return result;
1198:
1199:            }
1200:
1201:            /**
1202:             * Returns a clone of the renderer.
1203:             * 
1204:             * @return A clone.
1205:             * 
1206:             * @throws CloneNotSupportedException if the clone cannot be created.
1207:             */
1208:            public Object clone() throws CloneNotSupportedException {
1209:                XYLineAndShapeRenderer clone = (XYLineAndShapeRenderer) super 
1210:                        .clone();
1211:                clone.seriesLinesVisible = (BooleanList) this .seriesLinesVisible
1212:                        .clone();
1213:                if (this .legendLine != null) {
1214:                    clone.legendLine = ShapeUtilities.clone(this .legendLine);
1215:                }
1216:                clone.seriesShapesVisible = (BooleanList) this .seriesShapesVisible
1217:                        .clone();
1218:                clone.seriesShapesFilled = (BooleanList) this .seriesShapesFilled
1219:                        .clone();
1220:                return clone;
1221:            }
1222:
1223:            /**
1224:             * Tests this renderer for equality with an arbitrary object.
1225:             *
1226:             * @param obj  the object (<code>null</code> permitted).
1227:             *
1228:             * @return <code>true</code> or <code>false</code>.
1229:             */
1230:            public boolean equals(Object obj) {
1231:
1232:                if (obj == this ) {
1233:                    return true;
1234:                }
1235:                if (!(obj instanceof  XYLineAndShapeRenderer)) {
1236:                    return false;
1237:                }
1238:                if (!super .equals(obj)) {
1239:                    return false;
1240:                }
1241:                XYLineAndShapeRenderer that = (XYLineAndShapeRenderer) obj;
1242:                if (!ObjectUtilities
1243:                        .equal(this .linesVisible, that.linesVisible)) {
1244:                    return false;
1245:                }
1246:                if (!ObjectUtilities.equal(this .seriesLinesVisible,
1247:                        that.seriesLinesVisible)) {
1248:                    return false;
1249:                }
1250:                if (this .baseLinesVisible != that.baseLinesVisible) {
1251:                    return false;
1252:                }
1253:                if (!ShapeUtilities.equal(this .legendLine, that.legendLine)) {
1254:                    return false;
1255:                }
1256:                if (!ObjectUtilities.equal(this .shapesVisible,
1257:                        that.shapesVisible)) {
1258:                    return false;
1259:                }
1260:                if (!ObjectUtilities.equal(this .seriesShapesVisible,
1261:                        that.seriesShapesVisible)) {
1262:                    return false;
1263:                }
1264:                if (this .baseShapesVisible != that.baseShapesVisible) {
1265:                    return false;
1266:                }
1267:                if (!ObjectUtilities
1268:                        .equal(this .shapesFilled, that.shapesFilled)) {
1269:                    return false;
1270:                }
1271:                if (!ObjectUtilities.equal(this .seriesShapesFilled,
1272:                        that.seriesShapesFilled)) {
1273:                    return false;
1274:                }
1275:                if (this .baseShapesFilled != that.baseShapesFilled) {
1276:                    return false;
1277:                }
1278:                if (this .drawOutlines != that.drawOutlines) {
1279:                    return false;
1280:                }
1281:                if (this .useOutlinePaint != that.useOutlinePaint) {
1282:                    return false;
1283:                }
1284:                if (this .useFillPaint != that.useFillPaint) {
1285:                    return false;
1286:                }
1287:                if (this .drawSeriesLineAsPath != that.drawSeriesLineAsPath) {
1288:                    return false;
1289:                }
1290:                return true;
1291:
1292:            }
1293:
1294:            /**
1295:             * Provides serialization support.
1296:             *
1297:             * @param stream  the input stream.
1298:             *
1299:             * @throws IOException  if there is an I/O error.
1300:             * @throws ClassNotFoundException  if there is a classpath problem.
1301:             */
1302:            private void readObject(ObjectInputStream stream)
1303:                    throws IOException, ClassNotFoundException {
1304:                stream.defaultReadObject();
1305:                this .legendLine = SerialUtilities.readShape(stream);
1306:            }
1307:
1308:            /**
1309:             * Provides serialization support.
1310:             *
1311:             * @param stream  the output stream.
1312:             *
1313:             * @throws IOException  if there is an I/O error.
1314:             */
1315:            private void writeObject(ObjectOutputStream stream)
1316:                    throws IOException {
1317:                stream.defaultWriteObject();
1318:                SerialUtilities.writeShape(this.legendLine, stream);
1319:            }
1320:
1321:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.