2 * FinSetVisitorStrategy.java
4 package net.sf.openrocket.gui.print.visitor;
6 import com.itextpdf.text.Document;
7 import com.itextpdf.text.pdf.PdfContentByte;
8 import com.itextpdf.text.pdf.PdfWriter;
9 import net.sf.openrocket.gui.print.PrintableFinSet;
10 import net.sf.openrocket.rocketcomponent.EllipticalFinSet;
11 import net.sf.openrocket.rocketcomponent.FinSet;
12 import net.sf.openrocket.rocketcomponent.FreeformFinSet;
13 import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
15 import java.awt.Graphics2D;
19 * A visitor strategy for drawing fin templates.
21 public class FinSetVisitorStrategy extends BaseVisitorStrategy {
26 * @param doc The iText document
27 * @param theWriter The direct iText writer
28 * @param theStagesToVisit The stages to be visited by this strategy
30 public FinSetVisitorStrategy (Document doc, PdfWriter theWriter, Set<Integer> theStagesToVisit) {
31 super(doc, theWriter, theStagesToVisit);
38 public void visit (final TrapezoidFinSet visitable) {
46 public void visit (final EllipticalFinSet visitable) {
54 public void visit (final FreeformFinSet visitable) {
59 * The core behavior of this visitor.
61 * @param visitable the object to extract info about; a graphical image of the fin shape is drawn to the document
63 private void doVisit (final FinSet visitable) {
64 if (shouldVisitStage(visitable.getStageNumber())) {
65 PrintableFinSet pfs = new PrintableFinSet(visitable);
67 net.sf.openrocket.gui.print.visitor.Dimension d = getPageSize();
68 PdfContentByte cb = writer.getDirectContent();
69 Graphics2D g2 = cb.createGraphics(d.width, d.height);