@@ -91,6 +91,8 @@ public static void main(String[] args) {
91
91
boolean writeChartData = false ;
92
92
93
93
int granularity = -1 ;
94
+ int width = -1 ;
95
+ int height = -1 ;
94
96
95
97
for (int i = 0 ; i < args .length ; i ++) {
96
98
String arg = args [i ];
@@ -147,7 +149,7 @@ public static void main(String[] args) {
147
149
++i ;
148
150
149
151
if (i > args .length ) {
150
- System .err .println ("Chart format properties must be specified " + '-' + 'f' );
152
+ System .err .println ("Chart format properties" + " must be specified for " + '-' + 'f' );
151
153
return ;
152
154
}
153
155
@@ -159,15 +161,15 @@ public static void main(String[] args) {
159
161
++i ;
160
162
161
163
if (i > args .length ) {
162
- System .err .println ("Granularity value must be specified " + '-' + 'g' );
164
+ System .err .println ("Granularity" + " must be specified for " + '-' + 'g' );
163
165
return ;
164
166
}
165
167
166
168
try {
167
169
granularity = Integer .parseInt (args [i ]) * 1000 ;
168
170
}
169
171
catch (NumberFormatException e ) {
170
- System .err .println ("Granularity value must be an integer " + args [i ]);
172
+ System .err .println ("Granularity" + " value " + args [i ] + " must be an integer" );
171
173
}
172
174
173
175
break nextarg ;
@@ -176,7 +178,7 @@ public static void main(String[] args) {
176
178
++i ;
177
179
178
180
if (i > args .length ) {
179
- System .err .println ("file must be specified for " + '-' + 'h' );
181
+ System .err .println ("file" + " must be specified for " + '-' + 'h' );
180
182
return ;
181
183
}
182
184
@@ -187,7 +189,7 @@ public static void main(String[] args) {
187
189
++i ;
188
190
189
191
if (i > args .length ) {
190
- System .err .println ("file must be specified for " + '-' + 'i' );
192
+ System .err .println ("file" + " must be specified for " + '-' + 'i' );
191
193
return ;
192
194
}
193
195
@@ -204,6 +206,36 @@ public static void main(String[] args) {
204
206
else if ("nosummary" .equals (param )) {
205
207
summaryCharts = false ;
206
208
}
209
+ else if ("width" .equals (param )) {
210
+ ++i ;
211
+
212
+ if (i > args .length ) {
213
+ System .err .println ("Width" + " must be specified for " + '-' + '-' + "width" );
214
+ return ;
215
+ }
216
+
217
+ try {
218
+ width = Integer .parseInt (args [i ]);
219
+ }
220
+ catch (NumberFormatException e ) {
221
+ System .err .println ("Width" + " value " + args [i ] + " must be an integer" );
222
+ }
223
+ }
224
+ else if ("height" .equals (param )) {
225
+ ++i ;
226
+
227
+ if (i > args .length ) {
228
+ System .err .println ("Height" + " must be specified for " + '-' + '-' + "height" );
229
+ return ;
230
+ }
231
+
232
+ try {
233
+ height = Integer .parseInt (args [i ]);
234
+ }
235
+ catch (NumberFormatException e ) {
236
+ System .err .println ("Height" + " value " + args [i ] + " must be an integer" );
237
+ }
238
+ }
207
239
else if ("mf" .equals (param )) {
208
240
++i ;
209
241
@@ -283,7 +315,7 @@ else if ("chartdata".equals(param)) {
283
315
}
284
316
285
317
ReportGenerator generator = new ReportGenerator (customSummaryCharts , customDataCharts , multiplexedFieldCharts ,
286
- multiplexedTypeCharts , granularity );
318
+ multiplexedTypeCharts , granularity , width , height );
287
319
288
320
File outputDirectory = null ;
289
321
@@ -406,8 +438,23 @@ private static long parseTime(String[] args, int index, char param) {
406
438
407
439
private boolean writeChartData = false ;
408
440
441
+ private final int width ;
442
+ private final int height ;
443
+
409
444
private ReportGenerator (List <String > customSummaryCharts , List <String > customDataCharts ,
410
- List <String > multiplexedFieldCharts , List <String > multiplexedTypeCharts , int granularity ) {
445
+ List <String > multiplexedFieldCharts , List <String > multiplexedTypeCharts , int granularity , int width ,
446
+ int height ) {
447
+ // use -1 to default to sized set in BaseChartDefinition
448
+ if ((width < 1 ) && (width != -1 )) {
449
+ throw new IllegalArgumentException ("width" + " must be > 0" );
450
+ }
451
+ if (height < 1 && (height != -1 )) {
452
+ throw new IllegalArgumentException ("height" + " must be > 0" );
453
+ }
454
+
455
+ this .width = width ;
456
+ this .height = height ;
457
+
411
458
factory = new ChartFactory (this );
412
459
cache = new ReportCache ();
413
460
@@ -457,7 +504,8 @@ private void parse(List<String> filesToParse) {
457
504
if (fileToParse .endsWith (".log" ) && fileToParse .contains ("ReportGenerator" )) {
458
505
continue ;
459
506
}
460
- // ignore chart directories from previous executions which may contain CSV files from --rawdata or --chartdata
507
+ // ignore chart directories from previous executions
508
+ // these may contain CSV files from --rawdata or --chartdata
461
509
if (fileToParse .endsWith (".csv" ) && fileToParse .contains ("/charts/" )) {
462
510
continue ;
463
511
}
@@ -733,7 +781,8 @@ private boolean saveChart(BaseChartDefinition definition, Iterable<? extends Dat
733
781
File chartFile = new File (saveDirectory , definition .getShortName ().replace (" " , "_" ) + ".png" );
734
782
735
783
try {
736
- ChartUtilities .saveChartAsPNG (chartFile , chart , definition .getWidth (), definition .getHeight ());
784
+ ChartUtilities .saveChartAsPNG (chartFile , chart , width == -1 ? definition .getWidth () : width ,
785
+ height == -1 ? definition .getHeight () : height );
737
786
}
738
787
catch (IOException ioe ) {
739
788
System .err .println ("cannot create chart " + chartFile .getName ());
0 commit comments