Source Code Cross Referenced for GraphChart2D.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) 


001:        /**
002:         * Chart2D, a java library for drawing two dimensional charts.
003:         * Copyright (C) 2001 Jason J. Simas
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         *
018:         * The author of this library may be contacted at:
019:         * E-mail:  jjsimas@users.sourceforge.net
020:         * Street Address:  J J Simas, 887 Tico Road, Ojai, CA 93023-3555 USA
021:         */package net.sourceforge.chart2d;
022:
023:        import java.awt.*;
024:        import java.util.*;
025:
026:        /**
027:         * An abstract class for the common methods of LBChart2D and LLChart2D.
028:         * A GraphChart2D object is an area that contains axes and one or more overlaid graphs.
029:         * Changes through its set methods are updated upon next repaint() or getImage() calls.
030:         */
031:        public abstract class GraphChart2D extends Chart2D {
032:
033:            /**
034:             * Indicates a LBGraphArea.
035:             */
036:            static final int LABELS_BOTTOM = 0;
037:
038:            /**
039:             * Indicates a LLGraphArea.
040:             */
041:            static final int LABELS_LEFT = 1;
042:
043:            private GraphChart2DProperties graphChart2DProps;
044:            private Vector graphPropsVector = new Vector(5, 5);
045:            private Vector datasetsVector = new Vector(5, 5);
046:            private Vector multiColorsPropsVector = new Vector(5, 5);
047:            private Vector warningRegionPropsVector = new Vector(5, 5);
048:            private boolean needsUpdate;
049:
050:            /**
051:             * Creates a GraphChart2D object with its defaults.
052:             * A GraphChart2DProperties object must be set for this object before it is used.
053:             * A GraphProperties object must be added for this object before it is used.
054:             * A Dataset object must be added for this object before it is used.
055:             * A MultiColorsProperties object must be added for this object before it is used.
056:             */
057:            public GraphChart2D() {
058:                needsUpdate = true;
059:            }
060:
061:            /**
062:             * Sets the GraphChart2DProperties for this GraphChart2D.
063:             * @param props The GraphChart2DProperties.
064:             */
065:            public final void setGraphChart2DProperties(
066:                    GraphChart2DProperties props) {
067:
068:                needsUpdate = true;
069:                props.addGraphChart2D(this );
070:                if (graphChart2DProps != null)
071:                    graphChart2DProps.removeGraphChart2D(this );
072:                graphChart2DProps = props;
073:            }
074:
075:            /**
076:             * Sets the allocation of space to each component of a graph chart.
077:             * There are four components:  numbers axis, labels axis, graph, and legend.
078:             * The ratios of the axes can be determined from the ratios of the graph and the legend.
079:             * Depending on the chart type, the left and bottom axes can be the numbers axis and labels axis.
080:             * The width of the left axis is 1f - graphW - legendW.
081:             * The width of the bottom axis is graphW.
082:             * The height of the left axis is graphH.
083:             * The ratio of the legend height is always 1f.
084:             * @param graphW   The ratio of graph width to total.
085:             * @param graphH   The ratio of graph height to total.
086:             * @param legendW  The ratio of graph width to total.
087:             * @param legendH  The ratio of legend height to total.
088:             */
089:            public final void setLayoutRatios(float graphW, float graphH,
090:                    float legendW) {
091:
092:                needsUpdate = true;
093:                GraphChartArea chart = (GraphChartArea) getObjectArea();
094:
095:                chart.setGraphToWidthRatio(graphW);
096:                chart.setGraphToHeightRatio(graphH);
097:                chart.setLegendToWidthRatio(legendW);
098:                chart.setLegendToHeightRatio(1f);
099:
100:                float numbersW, numbersH, labelsW, labelsH;
101:                if (getGraphChartType() == LABELS_BOTTOM) {
102:
103:                    numbersW = 1f - graphW - legendW;
104:                    numbersH = graphH;
105:                    labelsW = graphW;
106:                    labelsH = 1f - graphH;
107:
108:                    chart.setYAxisToWidthRatio(numbersW);
109:                    chart.setYAxisToHeightRatio(numbersH);
110:                    chart.setXAxisToWidthRatio(labelsW);
111:                    chart.setXAxisToHeightRatio(labelsH);
112:                } else {
113:
114:                    numbersW = graphW;
115:                    numbersH = 1 - graphH;
116:                    labelsW = 1 - graphW - legendW;
117:                    labelsH = graphH;
118:
119:                    chart.setYAxisToWidthRatio(labelsW);
120:                    chart.setYAxisToHeightRatio(labelsH);
121:                    chart.setXAxisToWidthRatio(numbersW);
122:                    chart.setXAxisToHeightRatio(numbersH);
123:                }
124:
125:                chart.setAutoSetLayoutRatios(true);
126:            }
127:
128:            /**
129:             * Gets the GraphChart2DProperties for this Chart2D.
130:             * @param props The GraphChart2DProperties.
131:             */
132:            public final GraphChart2DProperties getGraphChart2DProperties() {
133:                return graphChart2DProps;
134:            }
135:
136:            /**
137:             * Gets a graph properties based on the order the graph properties were added.
138:             * First added is number zero.
139:             * @return The graph properties object added to this chart.
140:             */
141:            public final GraphProperties getGraphProperties(int i) {
142:                return (GraphProperties) graphPropsVector.get(i);
143:            }
144:
145:            /**
146:             * Gets a dataset based on the order the dataset was added.
147:             * First added is number zero.
148:             * @return The dataset added to this chart.
149:             */
150:            public final Dataset getDataset(int i) {
151:                return (Dataset) datasetsVector.get(i);
152:            }
153:
154:            /**
155:             * Gets a multiColorsProps based on the order the multiColorsProps was added.
156:             * First added is number zero.
157:             * @return The multiColorsProps added to this chart.
158:             */
159:            public final MultiColorsProperties getMultiColorsProperties(int i) {
160:                return (MultiColorsProperties) multiColorsPropsVector.get(i);
161:            }
162:
163:            /**
164:             * Gets a warning region properties based on the order the properties were added.
165:             * First added is number zero.
166:             * @return The warning region properties object added to this chart.
167:             */
168:            public final WarningRegionProperties getWarningRegionProperties(
169:                    int i) {
170:                return (WarningRegionProperties) warningRegionPropsVector
171:                        .get(i);
172:            }
173:
174:            /**
175:             * Adds a GraphProperties object to this chart.
176:             * @param graphProps The graph properties to add to this chart.
177:             */
178:            public final void addGraphProperties(GraphProperties graphProps) {
179:                needsUpdate = true;
180:                graphProps.addGraphChart2D(this );
181:                graphPropsVector.add(graphProps);
182:            }
183:
184:            /**
185:             * Adds a Dataset object to this chart.
186:             * @param dataset The dataset to add to this chart.
187:             */
188:            public final void addDataset(Dataset dataset) {
189:                needsUpdate = true;
190:                dataset.addChart2D(this );
191:                datasetsVector.add(dataset);
192:            }
193:
194:            /**
195:             * Adds a MultiColorsProperties object to this chart.
196:             * @param multiColorsProps The multi colors properties to add to this chart.
197:             */
198:            public final void addMultiColorsProperties(
199:                    MultiColorsProperties multiColorsProps) {
200:                needsUpdate = true;
201:                multiColorsProps.addObject2D(this );
202:                multiColorsPropsVector.add(multiColorsProps);
203:            }
204:
205:            /**
206:             * Adds a WarningRegionProperties object to this chart.
207:             * @param warningRegion The warning region properties to add to this chart.
208:             */
209:            public final void addWarningRegionProperties(
210:                    WarningRegionProperties warningRegionProps) {
211:                needsUpdate = true;
212:                warningRegionProps.addGraphChart2D(this );
213:                warningRegionPropsVector.add(warningRegionProps);
214:            }
215:
216:            /**
217:             * Removes GraphProperties object from this chart.
218:             * @param graphProps The graph properties to remove from this chart.
219:             */
220:            public final void removeGraphProperties(GraphProperties graphProps) {
221:                needsUpdate = true;
222:                graphProps.removeGraphChart2D(this );
223:                graphPropsVector.remove(graphProps);
224:            }
225:
226:            /**
227:             * Removes a Dataset object from this chart.
228:             * @param dataset The dataset to remove from this chart.
229:             */
230:            public final void removeDataset(Dataset dataset) {
231:                needsUpdate = true;
232:                dataset.removeChart2D(this );
233:                datasetsVector.remove(dataset);
234:            }
235:
236:            /**
237:             * Removes a MultiColorsProperties object from this chart.
238:             * @param multiColorsProperties The multi colors properties to remove from this chart.
239:             */
240:            public final void removeMultiColorsProperties(
241:                    MultiColorsProperties multiColorsProps) {
242:                needsUpdate = true;
243:                multiColorsProps.removeObject2D(this );
244:                multiColorsPropsVector.remove(multiColorsProps);
245:            }
246:
247:            /**
248:             * Removes a warning region with the specified properties to this chart.
249:             * @param warningRegion The warning region to remove from this chart.
250:             */
251:            public final void removeWarningRegionProperties(
252:                    WarningRegionProperties warningRegionProps) {
253:                needsUpdate = true;
254:                warningRegionProps.removeGraphChart2D(this );
255:                warningRegionPropsVector.remove(warningRegionProps);
256:            }
257:
258:            /**
259:             * Returns either LABELS_BOTTOM or LABELS_LEFT depending on whether LBChart2D or LLChart2D.
260:             * @return The type of the chart.
261:             */
262:            abstract int getGraphChartType();
263:
264:            /**
265:             * Gets the number of sets total over all the Dataset objects.
266:             * @return The total number of sets.
267:             */
268:            final int getNumSetsTotal() {
269:
270:                int numSets = 0;
271:                for (int i = 0; i < datasetsVector.size(); ++i) {
272:                    numSets += ((Dataset) datasetsVector.get(i)).getNumSets();
273:                }
274:                return numSets;
275:            }
276:
277:            /**
278:             * Gets the vector of GraphProperties objects that were added.
279:             * @return The graph properties objects vector.
280:             */
281:            final Vector getGraphPropertiesVector() {
282:                return graphPropsVector;
283:            }
284:
285:            /**
286:             * Gets the vector of Dataset objects that were added.
287:             * @return The dataset objects vector.
288:             */
289:            final Vector getDatasetsVector() {
290:                return datasetsVector;
291:            }
292:
293:            /**
294:             * Gets the vector of MultiColorsProperties objects that were added.
295:             * @return The multi colors properties objects vector.
296:             */
297:            final Vector getMultiColorsPropertiesVector() {
298:                return multiColorsPropsVector;
299:            }
300:
301:            /**
302:             * Gets the vector of WarningRegionProperties objects that were added.
303:             * @return The warning region properties objects vector.
304:             */
305:            final Vector getWarningRegionPropertiesVector() {
306:                return warningRegionPropsVector;
307:            }
308:
309:            /**
310:             * Gets whether this object needs to be updated.
311:             * @return If true then needs update.
312:             */
313:            final boolean getNeedsUpdateGraphChart2D() {
314:
315:                if (needsUpdate)
316:                    return true;
317:                if (getNeedsUpdateChart2D())
318:                    return true;
319:                if (graphChart2DProps.getGraphChart2DNeedsUpdate(this ))
320:                    return true;
321:
322:                for (int i = 0; i < graphPropsVector.size(); ++i) {
323:                    if (((GraphProperties) graphPropsVector.get(i))
324:                            .getGraphChart2DNeedsUpdate(this ))
325:                        return true;
326:                }
327:                for (int i = 0; i < datasetsVector.size(); ++i) {
328:                    if (((Dataset) datasetsVector.get(i))
329:                            .getChart2DNeedsUpdate(this ))
330:                        return true;
331:                }
332:                for (int i = 0; i < multiColorsPropsVector.size(); ++i) {
333:                    if (((MultiColorsProperties) multiColorsPropsVector.get(i))
334:                            .getObject2DNeedsUpdate(this ))
335:                        return true;
336:                }
337:                for (int i = 0; i < warningRegionPropsVector.size(); ++i) {
338:                    if (((WarningRegionProperties) warningRegionPropsVector
339:                            .get(i)).getGraphChart2DNeedsUpdate(this ))
340:                        return true;
341:                }
342:
343:                return false;
344:            }
345:
346:            /**
347:             * Validates the properties of this object.
348:             * If debug is true then prints a messages indicating whether each property is valid.
349:             * Returns true if all the properties were valid and false otherwise.
350:             * @param debug If true then will print status messages.
351:             * @return If true then valid.
352:             */
353:            final boolean validateGraphChart2D(boolean debug) {
354:
355:                if (debug)
356:                    System.out.println("Validating GraphChart2D");
357:
358:                boolean valid = true;
359:
360:                if (!validateChart2D(debug))
361:                    valid = false;
362:
363:                GraphChartArea chart = (GraphChartArea) getObjectArea();
364:
365:                if (chart.getXAxisToWidthRatio() < 0f
366:                        || chart.getXAxisToWidthRatio() > 1f
367:                        || chart.getXAxisToHeightRatio() < 0f
368:                        || chart.getXAxisToHeightRatio() > 1f
369:                        || chart.getYAxisToWidthRatio() < 0f
370:                        || chart.getYAxisToWidthRatio() > 1f
371:                        || chart.getYAxisToHeightRatio() < 0f
372:                        || chart.getYAxisToHeightRatio() > 1f
373:                        || chart.getGraphToWidthRatio() < 0f
374:                        || chart.getGraphToWidthRatio() > 1f
375:                        || chart.getGraphToHeightRatio() < 0f
376:                        || chart.getGraphToHeightRatio() > 1f
377:                        || chart.getLegendToWidthRatio() < 0f
378:                        || chart.getLegendToWidthRatio() > 1f
379:                        || chart.getLegendToHeightRatio() < 0f
380:                        || chart.getLegendToHeightRatio() > 1f) {
381:                    valid = false;
382:                    if (debug)
383:                        System.out
384:                                .println("Chart components ratios need to be between 0 and 1");
385:                }
386:
387:                if (graphChart2DProps == null) {
388:                    valid = false;
389:                    if (debug)
390:                        System.out.println("GraphChart2DProperties is null");
391:                } else if (!graphChart2DProps.validate(debug))
392:                    valid = false;
393:
394:                //Restriction:  Number of GraphProperties must equal number of Datasets and MultiColorsProps
395:                if (graphPropsVector.size() != datasetsVector.size()
396:                        || datasetsVector.size() != multiColorsPropsVector
397:                                .size()) {
398:                    valid = false;
399:                    if (debug)
400:                        System.out
401:                                .println("Number of GraphProperties, Datasets, and MultiColorsPropertes objects must be equal");
402:                }
403:
404:                //Restriction:  At least one object of each GraphProperties, Dataset, and MultiColorsProperties
405:                if (valid) {
406:                    if (graphPropsVector.size() < 1) {
407:                        valid = false;
408:                        if (debug)
409:                            System.out
410:                                    .println("Need at least one of each GraphProperties, Dataset, and MultiColorsProperties");
411:                    }
412:                }
413:
414:                if (valid) {
415:
416:                    for (int i = 0; i < graphPropsVector.size(); ++i) {
417:
418:                        if (debug)
419:                            System.out
420:                                    .println("Checking GraphProperties Object "
421:                                            + i);
422:                        if (!((GraphProperties) graphPropsVector.get(i))
423:                                .validate(debug))
424:                            valid = false;
425:                    }
426:                    for (int i = 0; i < datasetsVector.size(); ++i) {
427:
428:                        if (debug)
429:                            System.out.println("Checking Datasets Object " + i);
430:                        if (!((Dataset) datasetsVector.get(i)).validate(debug))
431:                            valid = false;
432:                    }
433:                    for (int i = 0; i < multiColorsPropsVector.size(); ++i) {
434:
435:                        if (debug)
436:                            System.out
437:                                    .println("Checking MultiColorsProperties Object "
438:                                            + i);
439:                        if (!((MultiColorsProperties) multiColorsPropsVector
440:                                .get(i)).validate(debug))
441:                            valid = false;
442:                    }
443:                    for (int i = 0; i < warningRegionPropsVector.size(); ++i) {
444:
445:                        if (debug)
446:                            System.out
447:                                    .println("Checking WarningRegionProperties Object "
448:                                            + i);
449:                        if (!((WarningRegionProperties) warningRegionPropsVector
450:                                .get(i)).validate(debug)) {
451:                            valid = false;
452:                        }
453:                    }
454:                }
455:
456:                //Restriction:  There must be a legend label for each dataset, if the legend exists.
457:                if (valid) {
458:
459:                    if (getLegendProperties().getLegendExistence()
460:                            && getLegendProperties().getLegendLabelsTexts().length != getNumSetsTotal()) {
461:                        valid = false;
462:                        if (debug)
463:                            System.out
464:                                    .println("Number of legend labels must equal total number of sets for all datasets");
465:                    }
466:                }
467:
468:                //Restriction:  If dataset at least one and multi colors custom, then at least one custom color
469:                if (valid) {
470:
471:                    for (int i = 0; i < datasetsVector.size(); ++i) {
472:
473:                        MultiColorsProperties multiColorsProps = (MultiColorsProperties) multiColorsPropsVector
474:                                .get(i);
475:                        if (((Dataset) datasetsVector.get(i)).getNumSets() > 0
476:                                && multiColorsProps.getColorsCustomize()
477:                                && multiColorsProps.getColorsCustom().length < 1) {
478:                            valid = false;
479:                            if (debug)
480:                                System.out
481:                                        .println("Not enough custom colors for MultiColorsProperties "
482:                                                + i);
483:                        }
484:                    }
485:                }
486:
487:                //Restriction:  All datasets must have equal num cats.
488:                if (valid) {
489:
490:                    int numCats = ((Dataset) datasetsVector.get(0))
491:                            .getNumCats();
492:                    for (int i = 1; i < datasetsVector.size(); ++i) {
493:
494:                        if (numCats != ((Dataset) datasetsVector.get(i))
495:                                .getNumCats()) {
496:                            valid = false;
497:                            if (debug)
498:                                System.out
499:                                        .println("Dataset doesn't have same number of cats as first dataset "
500:                                                + i);
501:                        }
502:                    }
503:                }
504:
505:                //Restriction:  If labels axis exists, then num labels must equal num dataset cats
506:                if (valid) {
507:
508:                    if (graphChart2DProps.getLabelsAxisExistence()
509:                            && graphChart2DProps.getLabelsAxisLabelsTexts().length != ((Dataset) datasetsVector
510:                                    .get(0)).getNumCats()) {
511:                        valid = false;
512:                        if (debug)
513:                            System.out
514:                                    .println("Number of labels axis labels must equal number of cats in each dataset");
515:                    }
516:                }
517:
518:                //Restriction:  If cat coloring and num cats > 0, then cat colors > 0
519:                if (valid) {
520:
521:                    if (graphChart2DProps.getGraphComponentsColoringByCat()
522:                            && ((Dataset) datasetsVector.get(0)).getNumCats() > 0
523:                            && graphChart2DProps
524:                                    .getGraphComponentsColorsByCat()
525:                                    .getColorsCustomize()
526:                            && graphChart2DProps
527:                                    .getGraphComponentsColorsByCat()
528:                                    .getColorsCustom().length < 1) {
529:                        valid = false;
530:                        if (debug)
531:                            System.out
532:                                    .println("Not enough custom colors for cat coloring");
533:                    }
534:                }
535:
536:                if (debug) {
537:                    if (valid)
538:                        System.out.println("GraphChart2D was valid");
539:                    else {
540:                        System.out
541:                                .println("Possibly unable to check for all invalidities because of early invalidity");
542:                        System.out.println("GraphChart2D was invalid");
543:                    }
544:                }
545:
546:                return valid;
547:            }
548:
549:            /**
550:             * Updates this object.
551:             */
552:            final void updateGraphChart2D() {
553:
554:                if (getNeedsUpdateGraphChart2D()) {
555:
556:                    needsUpdate = false;
557:
558:                    updateChart2D();
559:
560:                    graphChart2DProps.updateGraphChart2D(this );
561:                    for (int i = 0; i < datasetsVector.size(); ++i) {
562:                        ((Dataset) datasetsVector.get(i)).updateChart2D(this );
563:                    }
564:                    for (int i = 0; i < multiColorsPropsVector.size(); ++i) {
565:                        ((MultiColorsProperties) multiColorsPropsVector.get(i))
566:                                .updateObject2D(this );
567:                    }
568:                    for (int i = 0; i < graphPropsVector.size(); ++i) {
569:                        ((GraphProperties) graphPropsVector.get(i))
570:                                .updateGraphChart2D(this );
571:                    }
572:                    for (int i = 0; i < warningRegionPropsVector.size(); ++i) {
573:                        ((WarningRegionProperties) warningRegionPropsVector
574:                                .get(i)).updateGraphChart2D(this );
575:                    }
576:
577:                    int chartType = getGraphChartType();
578:                    GraphChartArea graphChart = (GraphChartArea) getObjectArea();
579:
580:                    //configure chart's data
581:                    graphChart.setDatasetVector(datasetsVector);
582:
583:                    //configure chart's graph properties
584:                    GraphProperties backgroundGraphProps = (GraphProperties) graphPropsVector
585:                            .get(graphPropsVector.size() - 1);
586:                    Vector graphVector = new Vector(graphPropsVector.size(), 0);
587:
588:                    for (int i = graphPropsVector.size() - 2; i >= 0; --i) {
589:                        GraphArea graph = chartType == LABELS_BOTTOM ? (GraphArea) new LBGraphArea()
590:                                : (GraphArea) new LLGraphArea();
591:                        ((GraphProperties) graphPropsVector.get(i))
592:                                .configureGraphArea(backgroundGraphProps,
593:                                        chartType, graph);
594:                        graphVector.add(graph);
595:                    }
596:
597:                    GraphArea graph = chartType == LABELS_BOTTOM ? (GraphArea) new LBGraphArea()
598:                            : (GraphArea) new LLGraphArea();
599:                    backgroundGraphProps.configureGraphArea(chartType, graph);
600:                    graphVector.add(graph);
601:
602:                    graphChart.setGraphVector(graphVector);
603:
604:                    //configure warning regions for background graph only
605:                    Vector warningRegionsVector = new Vector(
606:                            warningRegionPropsVector.size(), 0);
607:                    for (int i = 0; i < warningRegionPropsVector.size(); ++i) {
608:                        WarningRegion warningRegion = ((WarningRegionProperties) warningRegionPropsVector
609:                                .get(i)).configureWarningRegion();
610:                        warningRegion.setGraphType(chartType);
611:                        warningRegionsVector.add(warningRegion);
612:
613:                    }
614:                    graphChart.setWarningRegions(warningRegionsVector);
615:
616:                    //create color array from multi colors, one color for each set
617:                    int numSets = getNumSetsTotal();
618:                    Color[] multiColors = new Color[numSets];
619:                    int k = 0;
620:                    for (int i = 0; i < multiColorsPropsVector.size(); ++i) {
621:                        MultiColorsProperties multiColorsProps = (MultiColorsProperties) multiColorsPropsVector
622:                                .get(i);
623:                        int numSetsThis = ((Dataset) datasetsVector.get(i))
624:                                .getNumSets();
625:                        Color[] producer = multiColorsProps
626:                                .getColorsArray(numSetsThis);
627:                        for (int j = 0; j < producer.length; ++j) {
628:                            multiColors[k] = producer[j];
629:                            ++k;
630:                        }
631:                    }
632:                    graphChart.setDatasetColors(multiColors);
633:
634:                    graphChart.setCustomGreatestValue(graphChart2DProps
635:                            .getChartDatasetCustomizeGreatestValue(),
636:                            graphChart2DProps
637:                                    .getChartDatasetCustomGreatestValue());
638:                    graphChart
639:                            .setCustomLeastValue(graphChart2DProps
640:                                    .getChartDatasetCustomizeLeastValue(),
641:                                    graphChart2DProps
642:                                            .getChartDatasetCustomLeastValue());
643:                    graphChart.setGraphableToAvailableRatio(graphChart2DProps
644:                            .getChartGraphableToAvailableRatio());
645:                    graphChart.setNumPlotAxisLabels(graphChart2DProps
646:                            .getNumbersAxisNumLabels());
647:
648:                    graphChart
649:                            .setGraphComponentsColoringByCat(graphChart2DProps
650:                                    .getGraphComponentsColoringByCat());
651:                    if (graphChart2DProps.getGraphComponentsColoringByCat()) {
652:                        graphChart
653:                                .setGraphComponentsColorsByCat(graphChart2DProps
654:                                        .getGraphComponentsColorsByCat()
655:                                        .getColorsArray(
656:                                                ((Dataset) datasetsVector
657:                                                        .get(0)).getNumCats()));
658:                    }
659:
660:                    AxisArea labelsAxis;
661:                    AxisArea numbersAxis;
662:                    TextListArea labelsAxisTextList;
663:                    TextListArea numbersAxisTextList;
664:                    if (chartType == LABELS_BOTTOM) {
665:                        labelsAxis = graphChart.getXAxis();
666:                        numbersAxis = graphChart.getYAxis();
667:                        labelsAxisTextList = ((XAxisArea) labelsAxis)
668:                                .getTextList();
669:                        numbersAxisTextList = ((YAxisArea) numbersAxis)
670:                                .getTextList();
671:                    } else {
672:                        labelsAxis = graphChart.getYAxis();
673:                        numbersAxis = graphChart.getXAxis();
674:                        labelsAxisTextList = ((YAxisArea) labelsAxis)
675:                                .getTextList();
676:                        numbersAxisTextList = ((XAxisArea) numbersAxis)
677:                                .getTextList();
678:                    }
679:
680:                    labelsAxis.setTicksAlignment(graphChart2DProps
681:                            .getLabelsAxisTicksAlignment());
682:                    labelsAxisTextList.setLabels(graphChart2DProps
683:                            .getLabelsAxisLabelsTexts());
684:
685:                    labelsAxis.setTitleExistence(graphChart2DProps
686:                            .getLabelsAxisTitleExistence());
687:                    labelsAxis.setTitle(graphChart2DProps
688:                            .getLabelsAxisTitleText());
689:                    labelsAxis.setFontPointModel(graphChart2DProps
690:                            .getLabelsAxisTitleFontPointModel());
691:                    labelsAxis.setFontName(graphChart2DProps
692:                            .getLabelsAxisTitleFontName());
693:                    labelsAxis.setFontColor(graphChart2DProps
694:                            .getLabelsAxisTitleFontColor());
695:                    labelsAxis.setFontStyle(graphChart2DProps
696:                            .getLabelsAxisTitleFontStyle());
697:                    labelsAxis
698:                            .setBetweenTitleAndSpaceGapExistence(graphChart2DProps
699:                                    .getLabelsAxisTitleBetweenRestGapExistence());
700:                    labelsAxis
701:                            .setBetweenTitleAndSpaceGapThicknessModel(graphChart2DProps
702:                                    .getLabelsAxisTitleBetweenRestGapThicknessModel());
703:                    labelsAxis.setTicksSizeModel(graphChart2DProps
704:                            .getLabelsAxisTicksExistence() ? graphChart2DProps
705:                            .getLabelsAxisTicksSizeModel() : new Dimension());
706:                    labelsAxis.setTicksColor(graphChart2DProps
707:                            .getLabelsAxisTicksColor());
708:                    labelsAxisTextList.setBulletsOutline(graphChart2DProps
709:                            .getLabelsAxisTicksOutlineExistence());
710:                    labelsAxisTextList.setBulletsOutlineColor(graphChart2DProps
711:                            .getLabelsAxisTicksOutlineColor());
712:                    labelsAxisTextList.setFontPointModel(graphChart2DProps
713:                            .getLabelsAxisLabelsFontPointModel());
714:                    labelsAxisTextList.setFontName(graphChart2DProps
715:                            .getLabelsAxisLabelsFontName());
716:                    labelsAxisTextList.setFontColor(graphChart2DProps
717:                            .getLabelsAxisLabelsFontColor());
718:                    labelsAxisTextList.setFontStyle(graphChart2DProps
719:                            .getLabelsAxisLabelsFontStyle());
720:                    labelsAxisTextList
721:                            .setBetweenBulletsGapExistence(graphChart2DProps
722:                                    .getLabelsAxisBetweenLabelsOrTicksGapExistence());
723:                    labelsAxisTextList
724:                            .setBetweenLabelsGapExistence(graphChart2DProps
725:                                    .getLabelsAxisBetweenLabelsOrTicksGapExistence());
726:                    labelsAxisTextList
727:                            .setBetweenBulletsGapThicknessModel(graphChart2DProps
728:                                    .getLabelsAxisBetweenLabelsOrTicksGapThicknessModel());
729:                    labelsAxisTextList
730:                            .setBetweenLabelsGapThicknessModel(graphChart2DProps
731:                                    .getLabelsAxisBetweenLabelsOrTicksGapThicknessModel());
732:                    labelsAxisTextList
733:                            .setBetweenBulletsAndLabelsGapExistence(graphChart2DProps
734:                                    .getLabelsAxisBetweenLabelsAndTicksGapExistence());
735:                    labelsAxisTextList
736:                            .setBetweenBulletsAndLabelsGapThicknessModel(graphChart2DProps
737:                                    .getLabelsAxisBetweenLabelsAndTicksGapThicknessModel());
738:
739:                    if (!graphChart2DProps.getLabelsAxisExistence()) {
740:                        int numCats = ((Dataset) datasetsVector.get(0))
741:                                .getNumCats();
742:                        labelsAxis.setTitleExistence(false);
743:                        labelsAxisTextList
744:                                .setBetweenBulletsAndLabelsGapExistence(false);
745:                        labelsAxisTextList.setBetweenBulletsGapExistence(false);
746:                        labelsAxisTextList.setBetweenLabelsGapExistence(false);
747:                        labelsAxisTextList.setBulletsSizeModel(new Dimension());
748:                        labelsAxisTextList.setFontPointModel(0);
749:                        String[] labels = new String[numCats];
750:                        for (int i = 0; i < numCats; ++i)
751:                            labels[i] = "";
752:                        labelsAxisTextList.setLabels(labels);
753:                    }
754:
755:                    numbersAxis.setTitleExistence(graphChart2DProps
756:                            .getNumbersAxisTitleExistence());
757:                    numbersAxis.setTitle(graphChart2DProps
758:                            .getNumbersAxisTitleText());
759:                    numbersAxis.setFontPointModel(graphChart2DProps
760:                            .getNumbersAxisTitleFontPointModel());
761:                    numbersAxis.setFontName(graphChart2DProps
762:                            .getNumbersAxisTitleFontName());
763:                    numbersAxis.setFontColor(graphChart2DProps
764:                            .getNumbersAxisTitleFontColor());
765:                    numbersAxis.setFontStyle(graphChart2DProps
766:                            .getNumbersAxisTitleFontStyle());
767:                    numbersAxis
768:                            .setBetweenTitleAndSpaceGapExistence(graphChart2DProps
769:                                    .getNumbersAxisTitleBetweenRestGapExistence());
770:                    numbersAxis
771:                            .setBetweenTitleAndSpaceGapThicknessModel(graphChart2DProps
772:                                    .getNumbersAxisTitleBetweenRestGapThicknessModel());
773:                    numbersAxis.setTicksSizeModel(graphChart2DProps
774:                            .getNumbersAxisTicksExistence() ? graphChart2DProps
775:                            .getNumbersAxisTicksSizeModel() : new Dimension());
776:                    numbersAxis.setTicksColor(graphChart2DProps
777:                            .getNumbersAxisTicksColor());
778:                    numbersAxisTextList.setBulletsOutline(graphChart2DProps
779:                            .getNumbersAxisTicksOutlineExistence());
780:                    numbersAxisTextList
781:                            .setBulletsOutlineColor(graphChart2DProps
782:                                    .getNumbersAxisTicksOutlineColor());
783:                    numbersAxisTextList.setFontPointModel(graphChart2DProps
784:                            .getNumbersAxisLabelsFontPointModel());
785:                    numbersAxisTextList.setFontName(graphChart2DProps
786:                            .getNumbersAxisLabelsFontName());
787:                    numbersAxisTextList.setFontColor(graphChart2DProps
788:                            .getNumbersAxisLabelsFontColor());
789:                    numbersAxisTextList.setFontStyle(graphChart2DProps
790:                            .getNumbersAxisLabelsFontStyle());
791:                    numbersAxisTextList
792:                            .setBetweenBulletsGapExistence(graphChart2DProps
793:                                    .getNumbersAxisBetweenLabelsOrTicksGapExistence());
794:                    numbersAxisTextList
795:                            .setBetweenLabelsGapExistence(graphChart2DProps
796:                                    .getNumbersAxisBetweenLabelsOrTicksGapExistence());
797:                    numbersAxisTextList
798:                            .setBetweenBulletsGapThicknessModel(graphChart2DProps
799:                                    .getNumbersAxisBetweenLabelsOrTicksGapThicknessModel());
800:                    numbersAxisTextList
801:                            .setBetweenLabelsGapThicknessModel(graphChart2DProps
802:                                    .getNumbersAxisBetweenLabelsOrTicksGapThicknessModel());
803:                    numbersAxisTextList
804:                            .setBetweenBulletsAndLabelsGapExistence(graphChart2DProps
805:                                    .getNumbersAxisBetweenLabelsAndTicksGapExistence());
806:                    numbersAxisTextList
807:                            .setBetweenBulletsAndLabelsGapThicknessModel(graphChart2DProps
808:                                    .getNumbersAxisBetweenLabelsAndTicksGapThicknessModel());
809:                }
810:            }
811:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.