Revision: 105
http://polepos.svn.sourceforge.net/polepos/?rev=105&view=rev
Author: carlrosenberger
Date: 2010-06-10 14:10:44 +0000 (Thu, 10 Jun 2010)
Log Message:
-----------
cr + pr: Made PDF output nicer and added capability to show code snippet for each lap.
Modified Paths:
--------------
trunk/polepos/src/org/polepos/framework/CircuitBase.java
trunk/polepos/src/org/polepos/framework/Lap.java
trunk/polepos/src/org/polepos/reporters/PDFReporter.java
trunk/polepos/src/org/polepos/reporters/ReporterConstants.java
Added Paths:
-----------
trunk/polepos/pseudocode/
trunk/polepos/pseudocode/melbourne.write.txt
Added: trunk/polepos/pseudocode/melbourne.write.txt
===================================================================
--- trunk/polepos/pseudocode/melbourne.write.txt (rev 0)
+++ trunk/polepos/pseudocode/melbourne.write.txt 2010-06-10 14:10:44 UTC (rev 105)
@@ -0,0 +1,10 @@
+class FlatObject {
+ String _string;
+ int _int;
+}
+
+// OO
+db.store(new FlatObject());
+
+// SQL
+insert into flatobject (_string, _int ) values ( ?, ? )
Property changes on: trunk/polepos/pseudocode/melbourne.write.txt
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/polepos/src/org/polepos/framework/CircuitBase.java
===================================================================
--- trunk/polepos/src/org/polepos/framework/CircuitBase.java 2010-06-10 12:15:21 UTC (rev 104)
+++ trunk/polepos/src/org/polepos/framework/CircuitBase.java 2010-06-10 14:10:44 UTC (rev 105)
@@ -116,6 +116,7 @@
protected void add(Lap lap){
mLaps.add(lap);
+ lap.circuit(this);
}
/**
Modified: trunk/polepos/src/org/polepos/framework/Lap.java
===================================================================
--- trunk/polepos/src/org/polepos/framework/Lap.java 2010-06-10 12:15:21 UTC (rev 104)
+++ trunk/polepos/src/org/polepos/framework/Lap.java 2010-06-10 14:10:44 UTC (rev 105)
@@ -19,6 +19,7 @@
package org.polepos.framework;
+import java.io.*;
/**
* a single (timed) test
*/
@@ -32,6 +33,8 @@
private boolean _concurrent = true;
+ private String _code;
+
public Lap(String name){
this.mName = name;
mHot = false;
@@ -83,5 +86,38 @@
public boolean concurrent(){
return _concurrent;
}
+
+ public void code(String code){
+ _code = code;
+ }
+ public void circuit(CircuitBase circuitBase) {
+ String fileName = "pseudocode/" + circuitBase.internalName() + "." + mName + ".txt";
+ File file = new File(fileName);
+ if(file.exists()){
+ try {
+ FileReader fileReader = new FileReader(file);
+ BufferedReader bufferedReader = new BufferedReader(fileReader);
+ StringBuffer sb = new StringBuffer();
+ String line = null;
+ while( (line = bufferedReader.readLine()) != null){
+ sb.append(line);
+ sb.append("\n");
+ }
+ _code = sb.toString();
+ System.out.println(_code);
+ bufferedReader.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ public String code(){
+ return _code;
+ }
+
}
Modified: trunk/polepos/src/org/polepos/reporters/PDFReporter.java
===================================================================
--- trunk/polepos/src/org/polepos/reporters/PDFReporter.java 2010-06-10 12:15:21 UTC (rev 104)
+++ trunk/polepos/src/org/polepos/reporters/PDFReporter.java 2010-06-10 14:10:44 UTC (rev 105)
@@ -43,6 +43,7 @@
private static final com.lowagie.text.Font h2Font = FontFactory.getFont(FontFactory.HELVETICA,12,Font.BOLD);
private static final com.lowagie.text.Font bigFont = FontFactory.getFont(FontFactory.HELVETICA,10,Font.BOLD);
private static final com.lowagie.text.Font smallFont = FontFactory.getFont(FontFactory.HELVETICA,9,Font.PLAIN);
+ private static final com.lowagie.text.Font codeFont = FontFactory.getFont(FontFactory.COURIER,8,Font.PLAIN);
public PDFReporter(String path) {
super(path);
@@ -59,7 +60,7 @@
}
JFreeChart timeChart = createTimeChart(graph);
- timeChart.setBackgroundPaint(null);
+ // timeChart.setBackgroundPaint(null);
try {
renderTimeTable(graph);
_pdfData.add(renderChart(timeChart));
@@ -169,15 +170,30 @@
Circuit circuit = graph.circuit();
Lap lap = graph.lap();
- para.add(new Chunk("Circuit: " + circuit.name()+ "\n",bigFont));
- para.add(new Chunk(circuit.description() + "\n",smallFont));
- para.add(new Chunk("Lap: " + lap.name()+ "\n\n",bigFont));
+ // para.add(new Chunk("Circuit: " + circuit.name()+ "\n",bigFont));
+ para.add(new Chunk(circuit.name()+ "\n",bigFont));
+ para.add(new Chunk(circuit.description() + "\n\n",smallFont));
+ // para.add(new Chunk("Lap: " + lap.name()+ "\n",bigFont));
+ para.add(new Chunk(lap.name()+ "\n",bigFont));
+ _pdfData.add(para);
+
+
+ String code = lap.code();
+ if(code != null){
+ para=new Paragraph();
+ para.setLeading(11f);
+ Chunk chunk = new Chunk("\n" + code,codeFont);
+ para.add(chunk);
+ _pdfData.add(para);
+ }
+
+ para=new Paragraph();
List<TeamCar> teamCars=graph.teamCars();
List<TurnSetup> setups=graph.setups();
Table table = setupTable(graph);
- int idx=1;
- addTableCell(table, 0, 0,unitsLegend , null,false,true);
+ addTableCell(table, 0, 0, 2, unitsLegend , null,false,true, Element.ALIGN_LEFT);
+ int idx=2;
for(TurnSetup setup : setups) {
StringBuffer header = new StringBuffer();
boolean first = true;
@@ -193,17 +209,17 @@
first = false;
}
}
- addTableCell(table, idx, 0, header.toString(),null, true,true);
+ addTableCell(table, idx, 0, 1, header.toString(),null, true,true, Element.ALIGN_RIGHT);
idx++;
}
table.endHeaders();
int vidx=1;
for(TeamCar teamCar : teamCars) {
- addTableCell(table,0,vidx,teamCar.toString(),teamCar.website(),true,false);
- int hidx=1;
+ addTableCell(table,0,vidx,2, teamCar.toString(),teamCar.website(),true,false, Element.ALIGN_LEFT);
+ int hidx=2;
for(TurnSetup setup : setups) {
String text = reportText(type, graph, teamCar, setup);
- addTableCell(table,hidx,vidx,text, null,false,false);
+ addTableCell(table,hidx,vidx,1, text, null,false,false, Element.ALIGN_RIGHT);
hidx++;
}
vidx++;
@@ -226,7 +242,7 @@
}
- private void addTableCell(Table table, int hidx, int vidx, String text, String link, boolean bold,boolean header) throws BadElementException {
+ private void addTableCell(Table table, int hidx, int vidx, int colspan, String text, String link, boolean bold, boolean header, int hAlign ) throws BadElementException {
Chunk chunk = new Chunk(text,FontFactory.getFont(FontFactory.HELVETICA,9,(bold ? Font.BOLD : Font.PLAIN)));
chunk.setTextRise(3);
Cell cell=new Cell(linked(chunk, link));
@@ -234,12 +250,14 @@
if(! header){
cell.setNoWrap(true);
}
- cell.setVerticalAlignment(Element.ALIGN_CENTER);
+ cell.setVerticalAlignment(Element.ALIGN_BASELINE);
+ cell.setHorizontalAlignment(hAlign);
+ cell.setColspan(colspan);
table.addCell(cell,new Point(vidx,hidx));
}
private Element renderChart(JFreeChart chart) throws DocumentException, BadElementException {
- return renderChart(chart, 500, 300);
+ return renderChart(chart, 522, 300);
}
private Element renderChart(JFreeChart chart, int width, int height) throws DocumentException, BadElementException {
@@ -253,11 +271,12 @@
}
private Table setupTable(Graph graph) throws BadElementException {
- Table table=new Table(graph.setups().size()+1);
+ Table table=new Table(graph.setups().size()+2);
table.setAutoFillEmptyCells(true);
table.setSpaceInsideCell(2);
table.setBorderWidth(0);
+ table.setWidth(100);
table.setDefaultCellBorder(1);
table.setTableFitsPage(true);
return table;
Modified: trunk/polepos/src/org/polepos/reporters/ReporterConstants.java
===================================================================
--- trunk/polepos/src/org/polepos/reporters/ReporterConstants.java 2010-06-10 12:15:21 UTC (rev 104)
+++ trunk/polepos/src/org/polepos/reporters/ReporterConstants.java 2010-06-10 14:10:44 UTC (rev 105)
@@ -33,7 +33,7 @@
public static final String MEMORY_OVERVIEW_LEGEND = "Memory Overview\n\n";
public static final String SIZE_OVERVIEW_LEGEND = "Database Size Overview\n\n";
public static final Font TITLE_FONT = new Font("SansSerif", Font.BOLD, 14);
- public static final Font LEGEND_FONT = new Font("SansSerif", Font.PLAIN, 12);
+ public static final Font LEGEND_FONT = new Font("SansSerif", Font.PLAIN, 9);
public static final Font VALUE_LABEL_FONT = new Font("SansSerif", Font.ITALIC, 12);
public static final Font VALUE_TICKLABEL_FONT = new Font("SansSerif", Font.PLAIN, 10);
public static final Font CATEGORY_LABEL_FONT = new Font("SansSerif", Font.ITALIC, 12);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|