1 package edu.berkeley.fleet.doc;
9 public static void print() throws Exception {
10 if (!new File(".tmp").exists())
11 new File(".tmp").mkdirs();
12 PrintWriter pw = new PrintWriter(new FileOutputStream(".tmp/FleetTwo.Manual.tex"));
13 BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("doc/archman.tex")));
14 for(String s = br.readLine(); s!=null; s = br.readLine())
16 for(String f : new File("ships").list()) {
17 print(pw, new ShipDescription(f, new BufferedReader(new InputStreamReader(new FileInputStream(new File("ships/"+f))))));
19 pw.println("\\end{document}");
23 private static void print(PrintWriter pw, ShipDescription sd) throws Exception {
24 pw.println("\\pagebreak");
25 pw.println("\\section*{The {\\tt "+sd.getName()+"} Ship}");
26 pw.println("\\addcontentsline{toc}{subsection}{"+sd.getName()+"}");
27 String tex = sd.getSection("tex");
29 for(PumpDescription bbd : sd) {
30 pw.println("{\\bf "+(bbd.isInbox() ? "Input: " : "Output: ")+"{\\tt "+bbd.getName()+"}}\n\n");
39 for(PumpDescription bbd : sd)
40 if (bbd.isLeft()) leftSize += (boxHeight+boxGap);
41 else rightSize += (boxHeight+boxGap);
43 int totalHeight = Math.max(leftSize, rightSize);
44 int shipWidth = (int)(boxWidth * 1.5);
45 int totalWidth = boxGap*2 + boxWidth*2 + shipWidth;
48 pw.println("\\begin{center}");
49 pw.println("\\begin{empfile}["+sd.getName()+"]");
50 pw.println("\\begin{emp}["+sd.getName()+"]("+(totalWidth+10)+","+(totalHeight+10)+")");
51 pw.println(" beginfig(1)");
52 pw.println(" pickup pencircle scaled 1pt;");
54 "("+((totalWidth-shipWidth)/2)+","+0+")--"+
55 "("+((totalWidth-shipWidth)/2)+","+totalHeight+")--"+
56 "("+(totalWidth-((totalWidth-shipWidth)/2))+","+totalHeight+")--"+
57 "("+(totalWidth-((totalWidth-shipWidth)/2))+","+0+")--"+
58 "("+((totalWidth-shipWidth)/2)+","+0+");");
61 for(PumpDescription bbd : sd) {
62 int ypos = (totalHeight - (boxGap/2) - (bbd.isLeft() ? left : right));
63 int half = (totalWidth-shipWidth)/2;
64 int p1 = bbd.isLeft() ? (half-5) : ((totalWidth-half)+5);
65 int p3 = bbd.isLeft() ? (p1 - boxWidth) : (p1 + boxWidth);
71 boolean goo = ((bbd.isLeft() && bbd.isInbox()) || (!bbd.isLeft() && bbd.isOutbox()));
72 int p2 = goo ? (p3 - (boxHeight/2)) : (p3 + (boxHeight/2));
73 if (bbd.isLeft()) left += (boxHeight+boxGap);
74 else right += (boxHeight+boxGap);
76 pw.println(" label.rt(btex \\tt "+bbd.getName()+" etex, ("+(p1+3)+","+(ypos-boxHeight/2)+"));");
78 pw.println(" label.lft(btex \\tt "+bbd.getName()+" etex, ("+(p1-3)+","+(ypos-boxHeight/2)+"));");
81 " ("+p1+","+ypos+")--"+
82 " ("+p2+","+ypos+")--"+
83 " ("+p3+","+(ypos-(boxHeight/2))+")--"+
84 " ("+p2+","+(ypos-boxHeight)+")--"+
85 " ("+p1+","+(ypos-boxHeight)+")--"+
86 " ("+p1+","+ypos+");");
87 if (bbd.isLeft()) leftSize += boxHeight;
88 else rightSize += boxHeight;
90 pw.println(" endfig;");
91 pw.println("\\end{emp}");
92 pw.println("\\end{empfile}");
93 pw.println("\\end{center}");