001: /***********************************************************************************************
002: * Copyright 2002 (C) Nathaniel G. Auvil. All Rights Reserved.
003: *
004: * Redistribution and use of this software and associated documentation ("Software"), with or
005: * without modification, are permitted provided that the following conditions are met:
006: *
007: * 1. Redistributions of source code must retain copyright statements and notices.
008: * Redistributions must also contain a copy of this document.
009: *
010: * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
011: * conditions and the following disclaimer in the documentation and/or other materials
012: * provided with the distribution.
013: *
014: * 3. The name "jCharts" or "Nathaniel G. Auvil" must not be used to endorse or promote
015: * products derived from this Software without prior written permission of Nathaniel G.
016: * Auvil. For written permission, please contact nathaniel_auvil@users.sourceforge.net
017: *
018: * 4. Products derived from this Software may not be called "jCharts" nor may "jCharts" appear
019: * in their names without prior written permission of Nathaniel G. Auvil. jCharts is a
020: * registered trademark of Nathaniel G. Auvil.
021: *
022: * 5. Due credit should be given to the jCharts Project (http://jcharts.sourceforge.net/).
023: *
024: * THIS SOFTWARE IS PROVIDED BY Nathaniel G. Auvil AND CONTRIBUTORS ``AS IS'' AND ANY
025: * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
026: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * jCharts OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
028: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
029: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
030: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,STRICT LIABILITY, OR TORT
031: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
032: * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
033: ************************************************************************************************/package org.krysalis.jcharts.demo.userGuide;
034:
035: import java.io.FileOutputStream;
036:
037: import org.krysalis.jcharts.Chart;
038: import org.krysalis.jcharts.encoders.PNGEncoder;
039:
040: /*************************************************************************************
041: *
042: * @author Nathaniel Auvil
043: * @version $Id: UserGuideBase.java,v 1.5 2003/09/03 02:40:13 nathaniel_auvil Exp $
044: ************************************************************************************/
045: public class UserGuideBase {
046: private static String path = "./src/documentation/resources/images/userGuide/";
047: private static String subdir;
048:
049: /*******************************************************************************************
050: *
051: *
052: ******************************************************************************************/
053: public static void main(String[] args) throws Throwable {
054: if (args.length > 2) {
055: System.out
056: .println("Usage - java UserGuideBase <whatToRun>");
057: return;
058: } else {
059: if (args.length == 1) {
060: String whatToRun = args[0];
061: System.out
062: .println("running user guide charts for section: "
063: + whatToRun);
064:
065: if (whatToRun.equals("all")) {
066: UserGuideBase.subdir = "allCharts/";
067: AllChartsGuide allCharts = new AllChartsGuide();
068: allCharts.run();
069: }
070:
071: if (whatToRun.equals("legend")) {
072: UserGuideBase.subdir = "legends/";
073: LegendsGuide legends = new LegendsGuide();
074: legends.run();
075: }
076:
077: if (whatToRun.equals("stock")) {
078: UserGuideBase.subdir = "allCharts/";
079: StockChartsGuide stockCharts = new StockChartsGuide();
080: stockCharts.run();
081: }
082:
083: if (whatToRun.equals("pie")) {
084: UserGuideBase.subdir = "pieCharts/";
085: PieChartsGuide pieChart = new PieChartsGuide();
086: pieChart.run();
087: }
088:
089: if (whatToRun.equals("pie3d")) {
090: UserGuideBase.subdir = "pieChart3d/";
091: PieChart3DGuide pieChart3D = new PieChart3DGuide();
092: pieChart3D.run();
093: }
094:
095: if (whatToRun.equals("axis")) {
096: UserGuideBase.subdir = "axisCharts/";
097: AxisChartsGuide axisCharts = new AxisChartsGuide();
098: axisCharts.run();
099: }
100:
101: if (whatToRun.equals("area")) {
102: UserGuideBase.subdir = "areaCharts/";
103: AreaChartsGuide areaCharts = new AreaChartsGuide();
104: areaCharts.run();
105: }
106:
107: if (whatToRun.equals("bar")) {
108: UserGuideBase.subdir = "barCharts/";
109: BarChartsGuide barCharts = new BarChartsGuide();
110: barCharts.run();
111: }
112:
113: if (whatToRun.equals("line")) {
114: UserGuideBase.subdir = "lineCharts/";
115: LineChartsGuide lineCharts = new LineChartsGuide();
116: lineCharts.run();
117: }
118:
119: if (whatToRun.equals("point")) {
120: UserGuideBase.subdir = "pointCharts/";
121: PointChartsGuide pointCharts = new PointChartsGuide();
122: pointCharts.run();
123: }
124:
125: if (whatToRun.equals("combo")) {
126: UserGuideBase.subdir = "comboCharts/";
127: ComboChartsGuide comboCharts = new ComboChartsGuide();
128: comboCharts.run();
129: }
130: } else {
131: AllChartsGuide allCharts = new AllChartsGuide();
132: allCharts.run();
133:
134: LegendsGuide legends = new LegendsGuide();
135: legends.run();
136:
137: StockChartsGuide stockCharts = new StockChartsGuide();
138: stockCharts.run();
139:
140: PieChartsGuide pieChart = new PieChartsGuide();
141: pieChart.run();
142:
143: PieChart3DGuide pieChart3d = new PieChart3DGuide();
144: pieChart3d.run();
145:
146: AxisChartsGuide axisCharts = new AxisChartsGuide();
147: axisCharts.run();
148:
149: AreaChartsGuide areaCharts = new AreaChartsGuide();
150: areaCharts.run();
151:
152: BarChartsGuide barCharts = new BarChartsGuide();
153: barCharts.run();
154:
155: LineChartsGuide lineCharts = new LineChartsGuide();
156: lineCharts.run();
157:
158: PointChartsGuide pointCharts = new PointChartsGuide();
159: pointCharts.run();
160:
161: ComboChartsGuide comboCharts = new ComboChartsGuide();
162: comboCharts.run();
163: }
164: }
165: }
166:
167: /******************************************************************************************
168: * Utility method to write the image to file so I do not have to deal with file i/o
169: * every time I write a demo.
170: *
171: * @param chart everything that is renderable extends this class.
172: * @param fileName what to name the file
173: ******************************************************************************************/
174: void exportImage(Chart chart, String fileName) {
175: String extension = ".png";
176: FileOutputStream fileOutputStream;
177:
178: try {
179: fileOutputStream = new FileOutputStream(UserGuideBase.path
180: + UserGuideBase.subdir + fileName + extension);
181: PNGEncoder.encode(chart, fileOutputStream);
182: //JPEGEncoder13.encode( chart, 1.0f, fileOutputStream );
183: fileOutputStream.flush();
184: fileOutputStream.close();
185: } catch (Throwable throwable) {
186: throwable.printStackTrace();
187: }
188: }
189: }
|