Source Code Cross Referenced for PieChart2DProperties.java in  » Chart » Chart2D_1.9.6k » net » sourceforge » chart2d » 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 » Chart2D_1.9.6k » net.sourceforge.chart2d 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * Chart2D, a java library for drawing two dimensional charts.
0003:         * Copyright (C) 2001 Jason J. Simas
0004:         *
0005:         * This library is free software; you can redistribute it and/or
0006:         * modify it under the terms of the GNU Lesser General Public
0007:         * License as published by the Free Software Foundation; either
0008:         * version 2.1 of the License, or (at your option) any later version.
0009:         *
0010:         * This library is distributed in the hope that it will be useful,
0011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013:         * Lesser General Public License for more details.
0014:         * You should have received a copy of the GNU Lesser General Public
0015:         * License along with this library; if not, write to the Free Software
0016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0017:         *
0018:         * The author of this library may be contacted at:
0019:         * E-mail:  jjsimas@users.sourceforge.net
0020:         * Street Address:  J J Simas, 887 Tico Road, Ojai, CA 93023-3555 USA
0021:         */package net.sourceforge.chart2d;
0022:
0023:        import java.awt.Color;
0024:        import java.awt.Dimension;
0025:        import java.util.Vector;
0026:        import java.awt.Font;
0027:
0028:        /**
0029:         * A data structure for holding the properties common to all PieChart2D charts.
0030:         * A PieChart2D object is an enclosed are with a title, pie sectors, pie labels, and a legend.
0031:         * Pass this to any number of PieChart2D objects.
0032:         */
0033:        final public class PieChart2DProperties extends Properties {
0034:
0035:            /**
0036:             * Indicates the pie numbers labels should have raw numbers.
0037:             */
0038:            public static final int RAW = 1;
0039:
0040:            /**
0041:             * Indicates the pie numbers labels should have percent ratios.
0042:             */
0043:            public static final int PERCENT = 2;
0044:
0045:            /**
0046:             * Signifies left.
0047:             */
0048:            public static final int LEFT = 0;
0049:
0050:            /**
0051:             * Signifies right.
0052:             */
0053:            public static final int RIGHT = 1;
0054:
0055:            /**
0056:             * Signifies top.
0057:             */
0058:            public static final int TOP = 2;
0059:
0060:            /**
0061:             * Signifies bottom.
0062:             */
0063:            public static final int BOTTOM = 3;
0064:
0065:            /**
0066:             * Signifies none.
0067:             */
0068:            public static final int NONE = 6;
0069:
0070:            /**
0071:             * The default is true.
0072:             */
0073:            public static final boolean CHART_BETWEEN_PIE_LABELS_AND_PIE_GAP_EXISTENCE_DEFAULT = true;
0074:
0075:            /**
0076:             * The default is 6.
0077:             */
0078:            public static final int CHART_BETWEEN_PIE_LABELS_AND_PIE_GAP_THICKNESS_MODEL_DEFAULT = 6;
0079:
0080:            /**
0081:             * The default is 30.
0082:             */
0083:            public static final int PIE_PREFERRED_SIZE_DEFAULT = 30;
0084:
0085:            /**
0086:             * The default is false.
0087:             */
0088:            public static final boolean PIE_SECTORS_OUTLINE_EXISTENCE_DEFAULT = false;
0089:
0090:            /**
0091:             * The default is Color.black.
0092:             */
0093:            public static final Color PIE_SECTORS_OUTLINE_COLOR_DEFAULT = Color.black;
0094:
0095:            /**
0096:             * The default is true.
0097:             */
0098:            public static final boolean PIE_LABELS_EXISTENCE_DEFAULT = true;
0099:
0100:            /**
0101:             * The default is RAW + PERCENT.
0102:             */
0103:            public static final int PIE_LABELS_TYPE_DEFAULT = RAW + PERCENT;
0104:
0105:            /**
0106:             * The default is true.
0107:             */
0108:            public static final boolean PIE_LABELS_BETWEEN_LABELS_GAP_EXISTENCE_DEFAULT = true;
0109:
0110:            /**
0111:             * The default is 3.
0112:             */
0113:            public static final int PIE_LABELS_BETWEEN_LABELS_GAP_THICKNESS_MODEL_DEFAULT = 3;
0114:
0115:            /**
0116:             * The default is true.
0117:             */
0118:            public static final boolean PIE_LABELS_POINTS_GAP_OFFSET_EXISTENCE_DEFAULT = true;
0119:
0120:            /**
0121:             * The default is .50f.
0122:             */
0123:            public static final float PIE_LABELS_POINTS_GAP_OFFSET_MODEL_RATIO_DEFAULT = .50f;
0124:
0125:            /**
0126:             * The default is .125f.
0127:             */
0128:            public static final float PIE_LABELS_POINTS_PIE_SECTORS_DEPTH_RATIO_DEFAULT = .125f;
0129:
0130:            /**
0131:             * The default is .25f.
0132:             */
0133:            public static final float PIE_LABELS_POINTS_BETWEEN_PIE_AND_LABEL_GAPS_DEPTH_RATIO_DEFAULT = .25f;
0134:
0135:            /**
0136:             * The default is true.
0137:             */
0138:            public static final boolean PIE_LABELS_LINES_EXISTENCE_DEFAULT = true;
0139:
0140:            /**
0141:             * The default is 1.
0142:             */
0143:            public static final int PIE_LABELS_LINES_THICKNESS_MODEL_DEFAULT = 1;
0144:
0145:            /**
0146:             * The default is Color.black.
0147:             */
0148:            public static final Color PIE_LABELS_LINES_COLOR_DEFAULT = Color.black;
0149:
0150:            /**
0151:             * The default is false.
0152:             */
0153:            public static final boolean PIE_LABELS_LINES_DOTS_EXISTENCE_DEFAULT = false;
0154:
0155:            /**
0156:             * The default is 2.
0157:             */
0158:            public static final int PIE_LABELS_LINES_DOTS_THICKNESS_MODEL_DEFAULT = 2;
0159:
0160:            /**
0161:             * The default is Color.black.
0162:             */
0163:            public static final Color PIE_LABELS_LINES_DOTS_COLOR_DEFAULT = Color.black;
0164:
0165:            /**
0166:             * The default is TOP.
0167:             */
0168:            public static final int PIE_SECTOR_LIGHT_SOURCE_DEFAULT = TOP;
0169:
0170:            /**
0171:             * The default is 10.
0172:             */
0173:            public final static int PIE_LABELS_FONT_POINT_MODEL_DEFAULT = 10;
0174:
0175:            /**
0176:             * The default is "SansSerif".
0177:             */
0178:            public final static String PIE_LABELS_FONT_NAME_DEFAULT = "SansSerif";
0179:
0180:            /**
0181:             * The default is Color.black.
0182:             */
0183:            public final static Color PIE_LABELS_FONT_COLOR_DEFAULT = Color.black;
0184:
0185:            /**
0186:             * The default is Font.PLAIN.
0187:             */
0188:            public final static int PIE_LABELS_FONT_STYLE_DEFAULT = Font.PLAIN;
0189:
0190:            private boolean chartBetweenPieLabelsAndPieGapExistence;
0191:            private int chartBetweenPieLabelsAndPieGapThicknessModel;
0192:            private int piePreferredSize;
0193:
0194:            private boolean pieLabelsExistence;
0195:            private int pieLabelsType;
0196:            private boolean pieLabelsBetweenLabelsGapExistence;
0197:            private int pieLabelsBetweenLabelsGapThicknessModel;
0198:            private boolean pieLabelsPointsGapOffsetExistence;
0199:            private float pieLabelsPointsGapOffsetModelRatio;
0200:            private float pieLabelsPointsPieSectorsDepthRatio;
0201:            private float pieLabelsPointsBetweenPieAndLabelGapsDepthRatio;
0202:
0203:            private boolean pieLabelsLinesExistence;
0204:            private int pieLabelsLinesThicknessModel;
0205:            private Color pieLabelsLinesColor;
0206:            private boolean pieLabelsLinesDotsExistence;
0207:            private int pieLabelsLinesDotsThicknessModel;
0208:            private Color pieLabelsLinesDotsColor;
0209:
0210:            private boolean pieSectorsOutlineExistence;
0211:            private Color pieSectorsOutlineColor;
0212:            private int pieSectorLightSource;
0213:
0214:            private int pieLabelsFontPointModel;
0215:            private String pieLabelsFontName;
0216:            private Color pieLabelsFontColor;
0217:            private int pieLabelsFontStyle;
0218:
0219:            private boolean needsUpdate = true;
0220:            private final Vector needsUpdateVector = new Vector(5, 5);
0221:            private final Vector pieChart2DVector = new Vector(5, 5);
0222:
0223:            /**
0224:             * Creates a PieChart2DProperties object with the documented default values.
0225:             */
0226:            public PieChart2DProperties() {
0227:
0228:                needsUpdate = true;
0229:                setPieChart2DPropertiesToDefaults();
0230:            }
0231:
0232:            /**
0233:             * Creates a PieChart2DProperties object with property values copied from another object.
0234:             * The copying is a deep copy.
0235:             * @param pieChart2DProps The properties to copy.
0236:             */
0237:            public PieChart2DProperties(PieChart2DProperties pieChart2DProps) {
0238:
0239:                needsUpdate = true;
0240:                setPieChart2DProperties(pieChart2DProps);
0241:            }
0242:
0243:            /**
0244:             * Sets all properties to their default values.
0245:             */
0246:            public final void setPieChart2DPropertiesToDefaults() {
0247:
0248:                needsUpdate = true;
0249:                setChartBetweenPieLabelsAndPieGapExistence(CHART_BETWEEN_PIE_LABELS_AND_PIE_GAP_EXISTENCE_DEFAULT);
0250:                setChartBetweenPieLabelsAndPieGapThicknessModel(CHART_BETWEEN_PIE_LABELS_AND_PIE_GAP_THICKNESS_MODEL_DEFAULT);
0251:                setPiePreferredSize(PIE_PREFERRED_SIZE_DEFAULT);
0252:                setPieSectorsOutlineExistence(PIE_SECTORS_OUTLINE_EXISTENCE_DEFAULT);
0253:                setPieSectorsOutlineColor(PIE_SECTORS_OUTLINE_COLOR_DEFAULT);
0254:                setPieLabelsExistence(PIE_LABELS_EXISTENCE_DEFAULT);
0255:                setPieLabelsType(PIE_LABELS_TYPE_DEFAULT);
0256:                setPieLabelsBetweenLabelsGapExistence(PIE_LABELS_BETWEEN_LABELS_GAP_EXISTENCE_DEFAULT);
0257:                setPieLabelsBetweenLabelsGapThicknessModel(PIE_LABELS_BETWEEN_LABELS_GAP_THICKNESS_MODEL_DEFAULT);
0258:                setPieLabelsPointsGapOffsetExistence(PIE_LABELS_POINTS_GAP_OFFSET_EXISTENCE_DEFAULT);
0259:                setPieLabelsPointsGapOffsetModelRatio(PIE_LABELS_POINTS_GAP_OFFSET_MODEL_RATIO_DEFAULT);
0260:                setPieLabelsPointsPieSectorsDepthRatio(PIE_LABELS_POINTS_PIE_SECTORS_DEPTH_RATIO_DEFAULT);
0261:                setPieLabelsPointsBetweenPieAndLabelGapsDepthRatio(PIE_LABELS_POINTS_BETWEEN_PIE_AND_LABEL_GAPS_DEPTH_RATIO_DEFAULT);
0262:                setPieLabelsLinesExistence(PIE_LABELS_LINES_EXISTENCE_DEFAULT);
0263:                setPieLabelsLinesThicknessModel(PIE_LABELS_LINES_THICKNESS_MODEL_DEFAULT);
0264:                setPieLabelsLinesColor(PIE_LABELS_LINES_COLOR_DEFAULT);
0265:                setPieLabelsLinesDotsExistence(PIE_LABELS_LINES_DOTS_EXISTENCE_DEFAULT);
0266:                setPieLabelsLinesDotsThicknessModel(PIE_LABELS_LINES_DOTS_THICKNESS_MODEL_DEFAULT);
0267:                setPieLabelsLinesDotsColor(PIE_LABELS_LINES_DOTS_COLOR_DEFAULT);
0268:                setPieSectorLightSource(PIE_SECTOR_LIGHT_SOURCE_DEFAULT);
0269:                setPieLabelsFontPointModel(PIE_LABELS_FONT_POINT_MODEL_DEFAULT);
0270:                setPieLabelsFontName(PIE_LABELS_FONT_NAME_DEFAULT);
0271:                setPieLabelsFontColor(PIE_LABELS_FONT_COLOR_DEFAULT);
0272:                setPieLabelsFontStyle(PIE_LABELS_FONT_STYLE_DEFAULT);
0273:            }
0274:
0275:            /**
0276:             * Sets all the properties to be the values of another PieChart2DProperties object.
0277:             * The copying is a deep copy.
0278:             * @param pieChart2DProps The properties to copy.
0279:             */
0280:            public final void setPieChart2DProperties(
0281:                    PieChart2DProperties pieChart2DProps) {
0282:
0283:                needsUpdate = true;
0284:                setChartBetweenPieLabelsAndPieGapExistence(pieChart2DProps
0285:                        .getChartBetweenPieLabelsAndPieGapExistence());
0286:                setChartBetweenPieLabelsAndPieGapThicknessModel(pieChart2DProps
0287:                        .getChartBetweenPieLabelsAndPieGapThicknessModel());
0288:                setPiePreferredSize(pieChart2DProps.getPiePreferredSize());
0289:                setPieSectorsOutlineExistence(pieChart2DProps
0290:                        .getPieSectorsOutlineExistence());
0291:                setPieSectorsOutlineColor(pieChart2DProps
0292:                        .getPieSectorsOutlineColor());
0293:                setPieLabelsExistence(pieChart2DProps.getPieLabelsExistence());
0294:                setPieLabelsType(pieChart2DProps.getPieLabelsType());
0295:                setPieLabelsBetweenLabelsGapExistence(pieChart2DProps
0296:                        .getPieLabelsBetweenLabelsGapExistence());
0297:                setPieLabelsBetweenLabelsGapThicknessModel(pieChart2DProps
0298:                        .getPieLabelsBetweenLabelsGapThicknessModel());
0299:                setPieLabelsPointsGapOffsetExistence(pieChart2DProps
0300:                        .getPieLabelsPointsGapOffsetExistence());
0301:                setPieLabelsPointsGapOffsetModelRatio(pieChart2DProps
0302:                        .getPieLabelsPointsGapOffsetModelRatio());
0303:                setPieLabelsPointsPieSectorsDepthRatio(pieChart2DProps
0304:                        .getPieLabelsPointsPieSectorsDepthRatio());
0305:                setPieLabelsPointsBetweenPieAndLabelGapsDepthRatio(pieChart2DProps
0306:                        .getPieLabelsPointsBetweenPieAndLabelGapsDepthRatio());
0307:                setPieLabelsLinesExistence(pieChart2DProps
0308:                        .getPieLabelsLinesExistence());
0309:                setPieLabelsLinesThicknessModel(pieChart2DProps
0310:                        .getPieLabelsLinesThicknessModel());
0311:                setPieLabelsLinesColor(pieChart2DProps.getPieLabelsLinesColor());
0312:                setPieLabelsLinesDotsExistence(pieChart2DProps
0313:                        .getPieLabelsLinesDotsExistence());
0314:                setPieLabelsLinesDotsThicknessModel(pieChart2DProps
0315:                        .getPieLabelsLinesDotsThicknessModel());
0316:                setPieLabelsLinesDotsColor(pieChart2DProps
0317:                        .getPieLabelsLinesDotsColor());
0318:                setPieSectorLightSource(pieSectorLightSource);
0319:                setPieLabelsFontPointModel(pieChart2DProps
0320:                        .getPieLabelsFontPointModel());
0321:                setPieLabelsFontName(pieChart2DProps.getPieLabelsFontName());
0322:                setPieLabelsFontColor(pieChart2DProps.getPieLabelsFontColor());
0323:                setPieLabelsFontStyle(pieChart2DProps.getPieLabelsFontStyle());
0324:            }
0325:
0326:            /**
0327:             * Sets from which direction the light is coming for shading of the pie sectors.
0328:             * Uses fields TOP, BOTTOM, LEFT, RIGHT, and NONE.
0329:             * @param source The direction of the light.
0330:             */
0331:            final void setPieSectorLightSource(int source) {
0332:
0333:                needsUpdate = true;
0334:                pieSectorLightSource = source;
0335:            }
0336:
0337:            /**
0338:             * Specifies whether the gap between each pie label and the pie exists.
0339:             * @param existence If true, the gap exists.
0340:             */
0341:            public final void setChartBetweenPieLabelsAndPieGapExistence(
0342:                    boolean existence) {
0343:
0344:                needsUpdate = true;
0345:                chartBetweenPieLabelsAndPieGapExistence = existence;
0346:            }
0347:
0348:            /**
0349:             * Specifies the thickness of the gap between each pie label and the pie for the chart's model
0350:             * size.
0351:             * @param int The model thickness of the gap.
0352:             */
0353:            public final void setChartBetweenPieLabelsAndPieGapThicknessModel(
0354:                    int thickness) {
0355:
0356:                needsUpdate = true;
0357:                chartBetweenPieLabelsAndPieGapThicknessModel = thickness;
0358:            }
0359:
0360:            /**
0361:             * Specifies the preffered size of the pie in the pie chart.  A pie does not
0362:             * have a calculable preferred size so one must be explicitly provided in this
0363:             * method.  The size indicates the length of the diameter of the pie.
0364:             * This length must be >= 10.
0365:             * @param size The preferred size of the pie.
0366:             */
0367:            public final void setPiePreferredSize(int size) {
0368:
0369:                needsUpdate = true;
0370:                piePreferredSize = size;
0371:            }
0372:
0373:            /**
0374:             * Specifies whether the sectors of the pie should have a thin outline.
0375:             * @param existence If true, then the pie will have a thin outline.
0376:             */
0377:            public final void setPieSectorsOutlineExistence(boolean existence) {
0378:
0379:                needsUpdate = true;
0380:                pieSectorsOutlineExistence = existence;
0381:            }
0382:
0383:            /**
0384:             * Specifies the color of the outline of the pie sectors.
0385:             * @param color The color of the outline of the pie sectors.
0386:             */
0387:            public final void setPieSectorsOutlineColor(Color color) {
0388:
0389:                needsUpdate = true;
0390:                pieSectorsOutlineColor = color;
0391:            }
0392:
0393:            /**
0394:             * Specifies whether the pie sectors of the pie chart will be labeled.
0395:             * The labels can be raw numbers or percents.  They encircle the pie.
0396:             * Methods that specify properties of these labels are setPieLabelsType (int)
0397:             * and Chart2DProperties.setChartDataLabelsPrecision (int).
0398:             * @param existence If true, the pie sectors will be labeled.
0399:             */
0400:            public final void setPieLabelsExistence(boolean existence) {
0401:
0402:                needsUpdate = true;
0403:                pieLabelsExistence = existence;
0404:            }
0405:
0406:            /**
0407:             * Specifies the type of pie sector labels of the pie chart.  The possible
0408:             * types are RAW, PERCENT, and RAW+PERCENT.  The format for RAW+PERCENT is
0409:             * v (p%) where v is a data value and p is a percent value.
0410:             * @param type The type of the pie labels.
0411:             */
0412:            public final void setPieLabelsType(int type) {
0413:
0414:                needsUpdate = true;
0415:                pieLabelsType = type;
0416:            }
0417:
0418:            /**
0419:             * Specifies whether a gap between each pie sector label exists.
0420:             * The gap is applied both vertically and horizontally.
0421:             * @param existence If true, then the gap exists.
0422:             */
0423:            public final void setPieLabelsBetweenLabelsGapExistence(
0424:                    boolean existence) {
0425:
0426:                needsUpdate = true;
0427:                pieLabelsBetweenLabelsGapExistence = existence;
0428:            }
0429:
0430:            /**
0431:             * Specifies the thickness of the gap between each pie label for the chart's
0432:             * model size.
0433:             * @param thickness The thickness of the gap.
0434:             */
0435:            public final void setPieLabelsBetweenLabelsGapThicknessModel(
0436:                    int thickness) {
0437:
0438:                needsUpdate = true;
0439:                pieLabelsBetweenLabelsGapThicknessModel = thickness;
0440:            }
0441:
0442:            /**
0443:             * Specifies whether the gap between each pie label and a point from which a
0444:             * line may be drawn and/or on which a dot may be placed to relate each label
0445:             * with a particular pie sector exists.
0446:             * @param existence If true, the gap exists.
0447:             */
0448:            public final void setPieLabelsPointsGapOffsetExistence(
0449:                    boolean existence) {
0450:
0451:                needsUpdate = true;
0452:                pieLabelsPointsGapOffsetExistence = existence;
0453:            }
0454:
0455:            /**
0456:             * Specifies the ratio on the gap between the pie and the labels, for the gap between the
0457:             * labels and the labels point.
0458:             * @param ratio The ratio.
0459:             */
0460:            public final void setPieLabelsPointsGapOffsetModelRatio(float ratio) {
0461:
0462:                needsUpdate = true;
0463:                pieLabelsPointsGapOffsetModelRatio = ratio;
0464:            }
0465:
0466:            /**
0467:             * Specifies the depth within each pie sector a point is placed from which a
0468:             * line may be drawn and/or on which a dot may be placed to relate each label
0469:             * with a particular pie sector for the chart's model size.
0470:             * @param ratio The depth into the pie sector to the pie sector depth for
0471:             * the point's placement.
0472:             */
0473:            public final void setPieLabelsPointsPieSectorsDepthRatio(float ratio) {
0474:
0475:                needsUpdate = true;
0476:                pieLabelsPointsPieSectorsDepthRatio = ratio;
0477:            }
0478:
0479:            /**
0480:             * Specifies the depth within each gap between each pie sector and label,
0481:             * from each pie, of the point at which a line coming from a label and a line
0482:             * coming from a pie, meet.
0483:             * @param ratio The depth into the gap where the lines labeling lines meet.
0484:             */
0485:            public final void setPieLabelsPointsBetweenPieAndLabelGapsDepthRatio(
0486:                    float ratio) {
0487:
0488:                needsUpdate = true;
0489:                pieLabelsPointsBetweenPieAndLabelGapsDepthRatio = ratio;
0490:            }
0491:
0492:            /**
0493:             * Specifies whether lines relating each pie sector with its particular label exists.
0494:             * @param existence If true, then the pie labels lines exist.
0495:             */
0496:            public final void setPieLabelsLinesExistence(boolean existence) {
0497:
0498:                needsUpdate = true;
0499:                pieLabelsLinesExistence = existence;
0500:            }
0501:
0502:            /**
0503:             * Specifies the thickness of the lines relating each pie sector with its
0504:             * particular label for the model size of the chart.
0505:             * @param thickness The thickness of the line.
0506:             */
0507:            public final void setPieLabelsLinesThicknessModel(int thickness) {
0508:
0509:                needsUpdate = true;
0510:                pieLabelsLinesThicknessModel = thickness;
0511:            }
0512:
0513:            /**
0514:             * Specifies the color of the lines relating each pie sector with its particular label.
0515:             * @param color The color of the lines.
0516:             */
0517:            public final void setPieLabelsLinesColor(Color color) {
0518:
0519:                needsUpdate = true;
0520:                pieLabelsLinesColor = color;
0521:            }
0522:
0523:            /**
0524:             * Specifies whether dots exist at the beginning and ending of the lines
0525:             * relating each pie sector with its particular label.
0526:             * @param existence If true, then two dots per line will exist.
0527:             */
0528:            public final void setPieLabelsLinesDotsExistence(boolean existence) {
0529:
0530:                needsUpdate = true;
0531:                pieLabelsLinesDotsExistence = existence;
0532:            }
0533:
0534:            /**
0535:             * Specifies the thickness (ie diameter) of the dots that exist at the
0536:             * beginning and ending of the lines releating each pie sector with its
0537:             * particular label for the chart's model size.
0538:             * @param thickness The thickness of the dots.
0539:             */
0540:            public final void setPieLabelsLinesDotsThicknessModel(int thickness) {
0541:
0542:                needsUpdate = true;
0543:                pieLabelsLinesDotsThicknessModel = thickness;
0544:            }
0545:
0546:            /**
0547:             * Specifies the color of the dots that exist at the beginning and ending of
0548:             * the lines relating each pie sector with its particular label.
0549:             * @param color The color of the dots.
0550:             */
0551:            public final void setPieLabelsLinesDotsColor(Color color) {
0552:
0553:                needsUpdate = true;
0554:                pieLabelsLinesDotsColor = color;
0555:            }
0556:
0557:            /**
0558:             * Sets the point of the font of the pie labels for the chart's model size.
0559:             * @param point The model font point of the pie labels.
0560:             */
0561:            public final void setPieLabelsFontPointModel(int point) {
0562:
0563:                needsUpdate = true;
0564:                pieLabelsFontPointModel = point;
0565:            }
0566:
0567:            /**
0568:             * Sets name of the font of the pie labels.
0569:             * Accepts all values accepted by java.awt.Font.
0570:             * @param name The name of the font for the pie labels.
0571:             */
0572:            public final void setPieLabelsFontName(String name) {
0573:
0574:                needsUpdate = true;
0575:                pieLabelsFontName = name;
0576:            }
0577:
0578:            /**
0579:             *  Sets the color of the font of the pie labels.
0580:             *  @param color The color of the font of the pie labels.
0581:             */
0582:            public final void setPieLabelsFontColor(Color color) {
0583:
0584:                needsUpdate = true;
0585:                pieLabelsFontColor = color;
0586:            }
0587:
0588:            /**
0589:             * Sets the style of the font of the pie labels.
0590:             * Accepts all values that java.awt.Font accepts.
0591:             * @param style The style of the font of the pie labels.
0592:             */
0593:            public final void setPieLabelsFontStyle(int style) {
0594:
0595:                needsUpdate = true;
0596:                pieLabelsFontStyle = style;
0597:            }
0598:
0599:            /**
0600:             * Returns whether the gap between each pie label and the pie exists.
0601:             * @return If true, the gap exists.
0602:             */
0603:            public final boolean getChartBetweenPieLabelsAndPieGapExistence() {
0604:                return chartBetweenPieLabelsAndPieGapExistence;
0605:            }
0606:
0607:            /**
0608:             * Returns the thickness of the gap between each pie label and the pie
0609:             * for the chart's model size.
0610:             * @return The model thickness of the gap.
0611:             */
0612:            public final int getChartBetweenPieLabelsAndPieGapThicknessModel() {
0613:                return chartBetweenPieLabelsAndPieGapThicknessModel;
0614:            }
0615:
0616:            /**
0617:             * Returns the preffered size of the pie in the pie chart.  A pie does not
0618:             * have a calculable preferred size so one must be explicitly provided in this
0619:             * method.  The size indicates the length of the diameter of the pie.
0620:             * This length must be >= 10.
0621:             * @return The preferred size of the pie.
0622:             */
0623:            public final int getPiePreferredSize() {
0624:                return piePreferredSize;
0625:            }
0626:
0627:            /**
0628:             * Returns whether the sectors of the pie should have a thin outline.
0629:             * @return If true, then the pie will have a thin outline.
0630:             */
0631:            public final boolean getPieSectorsOutlineExistence() {
0632:                return pieSectorsOutlineExistence;
0633:            }
0634:
0635:            /**
0636:             * Returns the color of the outline of the pie sectors.
0637:             * @return The color of the outline of the pie sectors.
0638:             */
0639:            public final Color getPieSectorsOutlineColor() {
0640:                return pieSectorsOutlineColor;
0641:            }
0642:
0643:            /**
0644:             * Returns whether the pie sectors of the pie chart will be labeled.
0645:             * The labels can be raw numbers or percents.  They encircle the pie.
0646:             * Methods that specify properties of these labels are setPieLabelsType (int)
0647:             * and Chart2DProperties.setChartDataLabelsPrecision (int).
0648:             * @return If true, the pie sectors will be labeled.
0649:             */
0650:            public final boolean getPieLabelsExistence() {
0651:                return pieLabelsExistence;
0652:            }
0653:
0654:            /**
0655:             * Returns the type of pie sector labels of the pie chart.  The possible
0656:             * types are RAW, PERCENT, and RAW+PERCENT.  The format for RAW+PERCENT is
0657:             * v (p%) where v is a data value and p is a percent value.
0658:             * @return The type of the pie labels.
0659:             */
0660:            public final int getPieLabelsType() {
0661:                return pieLabelsType;
0662:            }
0663:
0664:            /**
0665:             * Returns whether a gap between each pie sector label exists.
0666:             * The gap is applied both vertically and horizontally.
0667:             * @return If true, then the gap exists.
0668:             */
0669:            public final boolean getPieLabelsBetweenLabelsGapExistence() {
0670:                return pieLabelsBetweenLabelsGapExistence;
0671:            }
0672:
0673:            /**
0674:             * Returns the thickness of the gap between each pie label for the chart's model size.
0675:             * @return The thickness of the gap.
0676:             */
0677:            public final int getPieLabelsBetweenLabelsGapThicknessModel() {
0678:                return pieLabelsBetweenLabelsGapThicknessModel;
0679:            }
0680:
0681:            /**
0682:             * Returns whether the gap between each pie label and a point from which a
0683:             * line may be drawn and/or on which a dot may be placed to relate each label
0684:             * with a particular pie sector exists.
0685:             * @return If true, the gap exists.
0686:             */
0687:            public final boolean getPieLabelsPointsGapOffsetExistence() {
0688:                return pieLabelsPointsGapOffsetExistence;
0689:            }
0690:
0691:            /**
0692:             * Gets the ratio on the gap between the pie and the labels, for the gap between the
0693:             * labels and the labels point.
0694:             * @return The ratio.
0695:             */
0696:            public final float getPieLabelsPointsGapOffsetModelRatio() {
0697:                return pieLabelsPointsGapOffsetModelRatio;
0698:            }
0699:
0700:            /**
0701:             * Returns the depth within each pie sector a point is placed from which a
0702:             * line may be drawn and/or on which a dot may be placed to relate each label
0703:             * with a particular pie sector for the chart's model size.
0704:             * @return The depth into the pie sector to the pie sector depth for the point's placement.
0705:             */
0706:            public final float getPieLabelsPointsPieSectorsDepthRatio() {
0707:                return pieLabelsPointsPieSectorsDepthRatio;
0708:            }
0709:
0710:            /**
0711:             * Returns the depth within each gap between each pie sector and label,
0712:             * from each pie, of the point at which a line coming from a label and a line
0713:             * coming from a pie, meet.
0714:             * @return The depth into the gap where the lines labeling lines meet.
0715:             */
0716:            public final float getPieLabelsPointsBetweenPieAndLabelGapsDepthRatio() {
0717:                return pieLabelsPointsBetweenPieAndLabelGapsDepthRatio;
0718:            }
0719:
0720:            /**
0721:             * Returns whether lines relating each pie sector with its particular label exists.
0722:             * @return If true, then the pie labels lines exist.
0723:             */
0724:            public final boolean getPieLabelsLinesExistence() {
0725:                return pieLabelsLinesExistence;
0726:            }
0727:
0728:            /**
0729:             * Returns the thickness of the lines relating each pie sector with its
0730:             * particular label for the model size of the chart.
0731:             * @return The thickness of the line.
0732:             */
0733:            public final int getPieLabelsLinesThicknessModel() {
0734:                return pieLabelsLinesThicknessModel;
0735:            }
0736:
0737:            /**
0738:             * Returns the color of the lines relating each pie sector with its particular label.
0739:             * @return The color of the lines.
0740:             */
0741:            public final Color getPieLabelsLinesColor() {
0742:                return pieLabelsLinesColor;
0743:            }
0744:
0745:            /**
0746:             * Returns whether dots exist at the beginning and ending of the lines
0747:             * relating each pie sector with its particular label.
0748:             * @return If true, then two dots per line will exist.
0749:             */
0750:            public final boolean getPieLabelsLinesDotsExistence() {
0751:                return pieLabelsLinesDotsExistence;
0752:            }
0753:
0754:            /**
0755:             * Returns the thickness (ie diameter) of the dots that exist at the
0756:             * beginning and ending of the lines releating each pie sector with its
0757:             * particular label for the chart's model size.
0758:             * @return The thickness of the dots.
0759:             */
0760:            public final int getPieLabelsLinesDotsThicknessModel() {
0761:                return pieLabelsLinesDotsThicknessModel;
0762:            }
0763:
0764:            /**
0765:             * Returns the color of the dots that exist at the beginning and ending of
0766:             * the lines relating each pie sector with its particular label.
0767:             * @return The color of the dots.
0768:             */
0769:            public final Color getPieLabelsLinesDotsColor() {
0770:                return pieLabelsLinesDotsColor;
0771:            }
0772:
0773:            /**
0774:             * Gets from which direction the light is coming for shading of the pie sectors.
0775:             * Uses fields TOP, BOTTOM, LEFT, RIGHT, and NONE.
0776:             * @return The direction of the light.
0777:             */
0778:            public final int getPieSectorLightSource() {
0779:                return pieSectorLightSource;
0780:            }
0781:
0782:            /**
0783:             * Gets the point of the font of the pie labels for the chart's model size.
0784:             * @return int The model font point of the pie labels.
0785:             */
0786:            public final int getPieLabelsFontPointModel() {
0787:                return pieLabelsFontPointModel;
0788:            }
0789:
0790:            /**
0791:             * Gets name of the font of the pie labels.
0792:             * Accepts all values accepted by java.awt.Font.
0793:             * @return String The name of the font for the pie labels.
0794:             */
0795:            public final String getPieLabelsFontName() {
0796:                return pieLabelsFontName;
0797:            }
0798:
0799:            /**
0800:             *  Gets the color of the font of the pie labels.
0801:             *  @return Color The color of the font of the pie labels.
0802:             */
0803:            public final Color getPieLabelsFontColor() {
0804:                return pieLabelsFontColor;
0805:            }
0806:
0807:            /**
0808:             * Gets the style of the font of the pie labels.
0809:             * Accepts all values that java.awt.Font accepts.
0810:             * @return int The style of the font of the pie labels.
0811:             */
0812:            public final int getPieLabelsFontStyle() {
0813:                return pieLabelsFontStyle;
0814:            }
0815:
0816:            /**
0817:             * Gets whether this object needs to be updated with new properties.
0818:             * @param pieChart2D  The object that might need to be updated.
0819:             * @return If true the object needs to be udpated.
0820:             */
0821:            final boolean getPieChart2DNeedsUpdate(PieChart2D pieChart2D) {
0822:
0823:                if (needsUpdate)
0824:                    return true;
0825:                int index = -1;
0826:                if ((index = pieChart2DVector.indexOf(pieChart2D)) != -1) {
0827:                    return ((Boolean) needsUpdateVector.get(index))
0828:                            .booleanValue();
0829:                }
0830:                return false;
0831:            }
0832:
0833:            /**
0834:             * Adds a PieChart2D to the set of objects using these properties.
0835:             * @param pieChart2D The object to add.
0836:             */
0837:            final void addPieChart2D(PieChart2D pieChart2D) {
0838:
0839:                if (!pieChart2DVector.contains(pieChart2D)) {
0840:                    pieChart2DVector.add(pieChart2D);
0841:                    needsUpdateVector.add(new Boolean(true));
0842:                }
0843:            }
0844:
0845:            /**
0846:             * Removes a PieChart2D from the set of objects using these properties.
0847:             * @param pieChart2D The object to remove.
0848:             */
0849:            final void removePieChart2D(PieChart2D pieChart2D) {
0850:
0851:                int index = -1;
0852:                if ((index = pieChart2DVector.indexOf(pieChart2D)) != -1) {
0853:                    pieChart2DVector.remove(index);
0854:                    needsUpdateVector.remove(index);
0855:                }
0856:            }
0857:
0858:            /**
0859:             * Validates the properties of this object.
0860:             * If debug is true then prints a messages indicating whether each property is valid.
0861:             * Returns true if all the properties were valid and false otherwise.
0862:             * @param debug If true then will print status messages.
0863:             * @return If true then valid.
0864:             */
0865:            final boolean validate(boolean debug) {
0866:
0867:                if (debug)
0868:                    System.out.println("Validating PieChart2DProperties");
0869:
0870:                boolean valid = true;
0871:
0872:                if (chartBetweenPieLabelsAndPieGapThicknessModel < 0) {
0873:                    valid = false;
0874:                    if (debug)
0875:                        System.out
0876:                                .println("ChartBetweenPieLabelsAndPieGapThicknessModel < 0");
0877:                }
0878:                if (piePreferredSize < 0) {
0879:                    valid = false;
0880:                    if (debug)
0881:                        System.out.println("Problem with PiePreferredSize");
0882:                }
0883:                if (pieLabelsType != RAW && pieLabelsType != PERCENT
0884:                        && pieLabelsType != (RAW + PERCENT)) {
0885:                    valid = false;
0886:                    if (debug)
0887:                        System.out.println("Problem with PieLabelsType");
0888:                }
0889:                if (pieLabelsBetweenLabelsGapThicknessModel < 0) {
0890:                    valid = false;
0891:                    if (debug)
0892:                        System.out
0893:                                .println("PieLabelsBetweenLabelsGapThicknessModel < 0");
0894:                }
0895:                if (pieLabelsPointsGapOffsetModelRatio < 0f
0896:                        || pieLabelsPointsGapOffsetModelRatio > 1f) {
0897:                    valid = false;
0898:                    if (debug)
0899:                        System.out
0900:                                .println("Problem with PieLabelsPointsGapOffsetModelRatio");
0901:                }
0902:                if (pieLabelsPointsPieSectorsDepthRatio < 0f
0903:                        || pieLabelsPointsPieSectorsDepthRatio > 1f) {
0904:                    valid = false;
0905:                    if (debug)
0906:                        System.out
0907:                                .println("Problem with pieLabelsPointsPieSectorsDepthRatio");
0908:                }
0909:                if (pieLabelsPointsBetweenPieAndLabelGapsDepthRatio < 0f
0910:                        || pieLabelsPointsBetweenPieAndLabelGapsDepthRatio > 1f) {
0911:                    valid = false;
0912:                    if (debug)
0913:                        System.out
0914:                                .println("Problem with pieLabelsPointsBetweenPieAndLabelGapsDepthRatio");
0915:                }
0916:                if (pieLabelsLinesThicknessModel < 0) {
0917:                    valid = false;
0918:                    if (debug)
0919:                        System.out.println("PieLabelsLinesThicknessModel < 0");
0920:                }
0921:                if (pieLabelsLinesColor == null) {
0922:                    valid = false;
0923:                    if (debug)
0924:                        System.out.println("PieLabelsLinesColor == null");
0925:                }
0926:                if (pieLabelsLinesDotsThicknessModel < 0) {
0927:                    valid = false;
0928:                    if (debug)
0929:                        System.out
0930:                                .println("PieLabelsLinesDotsThicknessModel < 0");
0931:                }
0932:                if (pieLabelsLinesDotsColor == null) {
0933:                    valid = false;
0934:                    if (debug)
0935:                        System.out.println("PieLabelsLinesDotsColor == null");
0936:                }
0937:                if (pieSectorsOutlineColor == null) {
0938:                    valid = false;
0939:                    if (debug)
0940:                        System.out.println("PieSectorsOutlineColor == null");
0941:                }
0942:                if (pieSectorLightSource != TOP
0943:                        && pieSectorLightSource != BOTTOM
0944:                        && pieSectorLightSource != LEFT
0945:                        && pieSectorLightSource != RIGHT
0946:                        && pieSectorLightSource != NONE) {
0947:                    valid = false;
0948:                    if (debug)
0949:                        System.out.println("Problem with PieSectorLightSource");
0950:                }
0951:                if (pieLabelsFontPointModel < 0) {
0952:                    valid = false;
0953:                    if (debug)
0954:                        System.out.println("PieLabelsFontPointModel < 0");
0955:                }
0956:                if (pieLabelsFontName == null
0957:                        || !isFontNameExists(pieLabelsFontName)) {
0958:                    valid = false;
0959:                    if (debug)
0960:                        System.out.println("Problem with PieLabelsFontName");
0961:                }
0962:                if (pieLabelsFontColor == null) {
0963:                    valid = false;
0964:                    if (debug)
0965:                        System.out.println("PieLabelsFontColor == null");
0966:                }
0967:                if (pieLabelsFontStyle != Font.PLAIN
0968:                        && pieLabelsFontStyle != Font.ITALIC
0969:                        && pieLabelsFontStyle != Font.BOLD
0970:                        && pieLabelsFontStyle != (Font.ITALIC | Font.BOLD)) {
0971:                    valid = false;
0972:                    if (debug)
0973:                        System.out.println("Problem with PieLabelsFontStyle");
0974:                }
0975:
0976:                if (debug) {
0977:                    if (valid)
0978:                        System.out.println("PieChart2DProperties was valid");
0979:                    else
0980:                        System.out.println("PieChart2DProperties was invalid");
0981:                }
0982:
0983:                return valid;
0984:            }
0985:
0986:            /**
0987:             * Updates the properties of this PieChart2D.
0988:             * @param pieChart2D The object to update.
0989:             */
0990:            final void updatePieChart2D(PieChart2D pieChart2D) {
0991:
0992:                if (getPieChart2DNeedsUpdate(pieChart2D)) {
0993:
0994:                    if (needsUpdate) {
0995:                        for (int i = 0; i < needsUpdateVector.size(); ++i) {
0996:                            needsUpdateVector.set(i, new Boolean(true));
0997:                        }
0998:                        needsUpdate = false;
0999:                    }
1000:
1001:                    int index = -1;
1002:                    if ((index = pieChart2DVector.indexOf(pieChart2D)) != -1) {
1003:                        needsUpdateVector.set(index, new Boolean(false));
1004:                    }
1005:                }
1006:            }
1007:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.