1 34 35 package org.krysalis.jcharts.demo.userGuide; 36 37 38 import java.io.FileOutputStream ; 39 40 import org.krysalis.jcharts.Chart; 41 import org.krysalis.jcharts.encoders.PNGEncoder; 42 43 44 49 public class UserGuideBase 50 { 51 private static String path= "./src/documentation/resources/images/userGuide/"; 52 private static String subdir; 53 54 55 59 public static void main( String [] args ) throws Throwable 60 { 61 if( args.length > 2 ) 62 { 63 System.out.println( "Usage - java UserGuideBase <whatToRun>" ); 64 return; 65 } 66 else 67 { 68 if( args.length == 1 ) 69 { 70 String whatToRun = args[0]; 71 System.out.println( "running user guide charts for section: " + whatToRun ); 72 73 if( whatToRun.equals( "all" ) ) 74 { 75 UserGuideBase.subdir= "allCharts/"; 76 AllChartsGuide allCharts = new AllChartsGuide(); 77 allCharts.run(); 78 } 79 80 if( whatToRun.equals( "legend" ) ) 81 { 82 UserGuideBase.subdir= "legends/"; 83 LegendsGuide legends = new LegendsGuide(); 84 legends.run(); 85 } 86 87 if( whatToRun.equals( "stock" ) ) 88 { 89 UserGuideBase.subdir= "allCharts/"; 90 StockChartsGuide stockCharts = new StockChartsGuide(); 91 stockCharts.run(); 92 } 93 94 if( whatToRun.equals( "pie" ) ) 95 { 96 UserGuideBase.subdir= "pieCharts/"; 97 PieChartsGuide pieChart = new PieChartsGuide(); 98 pieChart.run(); 99 } 100 101 if( whatToRun.equals( "pie3d" ) ) 102 { 103 UserGuideBase.subdir= "pieChart3d/"; 104 PieChart3DGuide pieChart3D = new PieChart3DGuide(); 105 pieChart3D.run(); 106 } 107 108 if( whatToRun.equals( "axis" ) ) 109 { 110 UserGuideBase.subdir= "axisCharts/"; 111 AxisChartsGuide axisCharts = new AxisChartsGuide(); 112 axisCharts.run(); 113 } 114 115 if( whatToRun.equals( "area" ) ) 116 { 117 UserGuideBase.subdir= "areaCharts/"; 118 AreaChartsGuide areaCharts = new AreaChartsGuide(); 119 areaCharts.run(); 120 } 121 122 if( whatToRun.equals( "bar" ) ) 123 { 124 UserGuideBase.subdir= "barCharts/"; 125 BarChartsGuide barCharts = new BarChartsGuide(); 126 barCharts.run(); 127 } 128 129 if( whatToRun.equals( "line" ) ) 130 { 131 UserGuideBase.subdir= "lineCharts/"; 132 LineChartsGuide lineCharts = new LineChartsGuide(); 133 lineCharts.run(); 134 } 135 136 if( whatToRun.equals( "point" ) ) 137 { 138 UserGuideBase.subdir= "pointCharts/"; 139 PointChartsGuide pointCharts = new PointChartsGuide(); 140 pointCharts.run(); 141 } 142 143 if( whatToRun.equals( "combo" ) ) 144 { 145 UserGuideBase.subdir= "comboCharts/"; 146 ComboChartsGuide comboCharts = new ComboChartsGuide(); 147 comboCharts.run(); 148 } 149 } 150 else 151 { 152 AllChartsGuide allCharts = new AllChartsGuide(); 153 allCharts.run(); 154 155 LegendsGuide legends = new LegendsGuide(); 156 legends.run(); 157 158 StockChartsGuide stockCharts = new StockChartsGuide(); 159 stockCharts.run(); 160 161 PieChartsGuide pieChart = new PieChartsGuide(); 162 pieChart.run(); 163 164 PieChart3DGuide pieChart3d = new PieChart3DGuide(); 165 pieChart3d.run(); 166 167 AxisChartsGuide axisCharts = new AxisChartsGuide(); 168 axisCharts.run(); 169 170 AreaChartsGuide areaCharts = new AreaChartsGuide(); 171 areaCharts.run(); 172 173 BarChartsGuide barCharts = new BarChartsGuide(); 174 barCharts.run(); 175 176 LineChartsGuide lineCharts = new LineChartsGuide(); 177 lineCharts.run(); 178 179 PointChartsGuide pointCharts = new PointChartsGuide(); 180 pointCharts.run(); 181 182 ComboChartsGuide comboCharts = new ComboChartsGuide(); 183 comboCharts.run(); 184 } 185 } 186 } 187 188 189 196 void exportImage( Chart chart, String fileName ) 197 { 198 String extension = ".png"; 199 FileOutputStream fileOutputStream; 200 201 try 202 { 203 fileOutputStream = new FileOutputStream ( UserGuideBase.path + UserGuideBase.subdir + fileName + extension ); 204 PNGEncoder.encode( chart, fileOutputStream ); 205 fileOutputStream.flush(); 207 fileOutputStream.close(); 208 } 209 catch( Throwable throwable ) 210 { 211 throwable.printStackTrace(); 212 } 213 } 214 } | Popular Tags |