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 String tex = sd.getSection("tex");
28 for(PumpDescription bbd : sd) {
29 pw.println("{\\bf "+(bbd.isInbox() ? "Input: " : "Output: ")+"{\\tt "+bbd.getName()+"}}\n\n");
38 for(PumpDescription bbd : sd)
39 if (bbd.isLeft()) leftSize += (boxHeight+boxGap);
40 else rightSize += (boxHeight+boxGap);
42 int totalHeight = Math.max(leftSize, rightSize);
43 int shipWidth = (int)(boxWidth * 1.5);
44 int totalWidth = boxGap*2 + boxWidth*2 + shipWidth;
47 pw.println("\\begin{center}");
48 pw.println("\\begin{empfile}["+sd.getName()+"]");
49 pw.println("\\begin{emp}["+sd.getName()+"]("+(totalWidth+10)+","+(totalHeight+10)+")");
50 pw.println(" beginfig(1)");
51 pw.println(" pickup pencircle scaled 1pt;");
53 "("+((totalWidth-shipWidth)/2)+","+0+")--"+
54 "("+((totalWidth-shipWidth)/2)+","+totalHeight+")--"+
55 "("+(totalWidth-((totalWidth-shipWidth)/2))+","+totalHeight+")--"+
56 "("+(totalWidth-((totalWidth-shipWidth)/2))+","+0+")--"+
57 "("+((totalWidth-shipWidth)/2)+","+0+");");
60 for(PumpDescription bbd : sd) {
61 int ypos = (totalHeight - (boxGap/2) - (bbd.isLeft() ? left : right));
62 int half = (totalWidth-shipWidth)/2;
63 int p1 = bbd.isLeft() ? (half-5) : ((totalWidth-half)+5);
64 int p3 = bbd.isLeft() ? (p1 - boxWidth) : (p1 + boxWidth);
70 boolean goo = ((bbd.isLeft() && bbd.isInbox()) || (!bbd.isLeft() && bbd.isOutbox()));
71 int p2 = goo ? (p3 - (boxHeight/2)) : (p3 + (boxHeight/2));
72 if (bbd.isLeft()) left += (boxHeight+boxGap);
73 else right += (boxHeight+boxGap);
75 pw.println(" label.rt(btex \\tt "+bbd.getName()+" etex, ("+(p1+3)+","+(ypos-boxHeight/2)+"));");
77 pw.println(" label.lft(btex \\tt "+bbd.getName()+" etex, ("+(p1-3)+","+(ypos-boxHeight/2)+"));");
80 " ("+p1+","+ypos+")--"+
81 " ("+p2+","+ypos+")--"+
82 " ("+p3+","+(ypos-(boxHeight/2))+")--"+
83 " ("+p2+","+(ypos-boxHeight)+")--"+
84 " ("+p1+","+(ypos-boxHeight)+")--"+
85 " ("+p1+","+ypos+");");
86 if (bbd.isLeft()) leftSize += boxHeight;
87 else rightSize += boxHeight;
89 pw.println(" endfig;");
90 pw.println("\\end{emp}");
91 pw.println("\\end{empfile}");
92 pw.println("\\end{center}");