merge fixing

This commit is contained in:
Sampo Niskanen 2011-01-09 09:03:38 +00:00
parent e8abfbd306
commit 683c11072a
4 changed files with 1190 additions and 1188 deletions

View File

@ -3,8 +3,10 @@
*/ */
package net.sf.openrocket.gui.print.visitor; package net.sf.openrocket.gui.print.visitor;
import com.itextpdf.text.Document; import java.util.HashSet;
import com.itextpdf.text.pdf.PdfWriter; import java.util.List;
import java.util.Set;
import net.sf.openrocket.rocketcomponent.BodyComponent; import net.sf.openrocket.rocketcomponent.BodyComponent;
import net.sf.openrocket.rocketcomponent.BodyTube; import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.ComponentVisitor; import net.sf.openrocket.rocketcomponent.ComponentVisitor;
@ -24,8 +26,8 @@ import net.sf.openrocket.rocketcomponent.Stage;
import net.sf.openrocket.rocketcomponent.Transition; import net.sf.openrocket.rocketcomponent.Transition;
import net.sf.openrocket.rocketcomponent.TrapezoidFinSet; import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
import java.util.HashSet; import com.itextpdf.text.Document;
import java.util.Set; import com.itextpdf.text.pdf.PdfWriter;
/** /**
* This abstract class contains boilerplate functionality to support visiting the components of a rocket. It is a * This abstract class contains boilerplate functionality to support visiting the components of a rocket. It is a
@ -123,7 +125,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy {
* @param root the root component; all children will be visited recursively * @param root the root component; all children will be visited recursively
*/ */
protected void goDeep(final RocketComponent root) { protected void goDeep(final RocketComponent root) {
RocketComponent[] rc = root.getChildren(); List<RocketComponent> rc = root.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -133,7 +135,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy {
* *
* @param theRc an array of rocket components; all children will be visited recursively * @param theRc an array of rocket components; all children will be visited recursively
*/ */
protected void goDeep (final RocketComponent[] theRc) { protected void goDeep(final List<RocketComponent> theRc) {
level++; level++;
for (RocketComponent rocketComponent : theRc) { for (RocketComponent rocketComponent : theRc) {
rocketComponent.accept(parent); rocketComponent.accept(parent);

View File

@ -3,18 +3,14 @@
*/ */
package net.sf.openrocket.gui.print.visitor; package net.sf.openrocket.gui.print.visitor;
import com.itextpdf.text.BadElementException; import java.io.IOException;
import com.itextpdf.text.Chunk; import java.text.NumberFormat;
import com.itextpdf.text.Document; import java.util.Collection;
import com.itextpdf.text.DocumentException; import java.util.List;
import com.itextpdf.text.Element; import java.util.Set;
import com.itextpdf.text.Font;
import com.itextpdf.text.Image; import javax.swing.ImageIcon;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import net.sf.openrocket.gui.main.ComponentIcons; import net.sf.openrocket.gui.main.ComponentIcons;
import net.sf.openrocket.gui.print.ITextHelper; import net.sf.openrocket.gui.print.ITextHelper;
import net.sf.openrocket.gui.print.PrintUtilities; import net.sf.openrocket.gui.print.PrintUtilities;
@ -41,11 +37,18 @@ import net.sf.openrocket.unit.Unit;
import net.sf.openrocket.unit.UnitGroup; import net.sf.openrocket.unit.UnitGroup;
import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Coordinate;
import javax.swing.ImageIcon; import com.itextpdf.text.BadElementException;
import java.io.IOException; import com.itextpdf.text.Chunk;
import java.text.NumberFormat; import com.itextpdf.text.Document;
import java.util.Collection; import com.itextpdf.text.DocumentException;
import java.util.Set; import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.Image;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
/** /**
* A visitor strategy for creating documentation about parts details. * A visitor strategy for creating documentation about parts details.
@ -87,11 +90,10 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
grid = new PdfPTable(TABLE_COLUMNS); grid = new PdfPTable(TABLE_COLUMNS);
grid.setWidthPercentage(100); grid.setWidthPercentage(100);
grid.setHorizontalAlignment(Element.ALIGN_LEFT); grid.setHorizontalAlignment(Element.ALIGN_LEFT);
} } catch (DocumentException e) {
catch (DocumentException e) {
} }
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -109,7 +111,7 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
grid.addCell(createLengthCell(visitable.getLength())); grid.addCell(createLengthCell(visitable.getLength()));
grid.addCell(createMassCell(visitable.getMass())); grid.addCell(createMassCell(visitable.getMass()));
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -120,7 +122,7 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
public void visit(final BodyComponent visitable) { public void visit(final BodyComponent visitable) {
grid.addCell(visitable.getName()); grid.addCell(visitable.getName());
grid.completeRow(); grid.completeRow();
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -136,7 +138,7 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
grid.addCell(createLengthCell(visitable.getLength())); grid.addCell(createLengthCell(visitable.getLength()));
grid.addCell(createMassCell(visitable.getMass())); grid.addCell(createMassCell(visitable.getMass()));
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -153,7 +155,7 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
grid.addCell(createLengthCell(visitable.getLength())); grid.addCell(createLengthCell(visitable.getLength()));
grid.addCell(createMassCell(visitable.getMass())); grid.addCell(createMassCell(visitable.getMass()));
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -191,7 +193,7 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
grid.addCell(createLengthCell(visitable.getLength())); grid.addCell(createLengthCell(visitable.getLength()));
grid.addCell(createMassCell(visitable.getMass())); grid.addCell(createMassCell(visitable.getMass()));
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -206,7 +208,7 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
grid.addCell(createOuterDiaCell(visitable)); grid.addCell(createOuterDiaCell(visitable));
grid.addCell(createLengthCell(visitable.getLength())); grid.addCell(createLengthCell(visitable.getLength()));
grid.addCell(createMassCell(visitable.getMass())); grid.addCell(createMassCell(visitable.getMass()));
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -228,7 +230,7 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
grid.addCell(cell); grid.addCell(cell);
grid.addCell(cell); grid.addCell(cell);
grid.addCell(createMassCell(visitable.getMass())); grid.addCell(createMassCell(visitable.getMass()));
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -243,7 +245,7 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
grid.addCell(ITextHelper.createCell(visitable.getType().getName(), PdfPCell.BOTTOM)); grid.addCell(ITextHelper.createCell(visitable.getType().getName(), PdfPCell.BOTTOM));
grid.addCell(createLengthCell(visitable.getLength())); grid.addCell(createLengthCell(visitable.getLength()));
grid.addCell(createMassCell(visitable.getMass())); grid.addCell(createMassCell(visitable.getMass()));
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -258,7 +260,7 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
grid.addCell(createOuterDiaCell(visitable)); grid.addCell(createOuterDiaCell(visitable));
grid.addCell(createLengthCell(visitable.getLength())); grid.addCell(createLengthCell(visitable.getLength()));
grid.addCell(createMassCell(visitable.getMass())); grid.addCell(createMassCell(visitable.getMass()));
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -295,8 +297,7 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
if (grid != null) { if (grid != null) {
document.add(grid); document.add(grid);
} }
} } catch (DocumentException e) {
catch (DocumentException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -355,11 +356,9 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
try { try {
img = Image.getInstance(writer, awtImage, 0.25f); img = Image.getInstance(writer, awtImage, 0.25f);
} } catch (BadElementException e) {
catch (BadElementException e) {
e.printStackTrace(); e.printStackTrace();
} } catch (IOException e) {
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -374,7 +373,7 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
grid.addCell(ITextHelper.createCell()); grid.addCell(ITextHelper.createCell());
grid.addCell(createMassCell(visitable.getMass())); grid.addCell(createMassCell(visitable.getMass()));
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -428,10 +427,8 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy {
cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
cell.setBorder(PdfPCell.NO_BORDER); cell.setBorder(PdfPCell.NO_BORDER);
return cell; return cell;
} } catch (BadElementException e) {
catch (BadElementException e) { } catch (IOException e) {
}
catch (IOException e) {
} }
return null; return null;
} }

View File

@ -3,8 +3,11 @@
*/ */
package net.sf.openrocket.gui.print.visitor; package net.sf.openrocket.gui.print.visitor;
import com.itextpdf.text.Document; import java.util.HashMap;
import com.itextpdf.text.pdf.PdfWriter; import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sf.openrocket.rocketcomponent.BodyTube; import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.Coaxial; import net.sf.openrocket.rocketcomponent.Coaxial;
import net.sf.openrocket.rocketcomponent.ComponentVisitor; import net.sf.openrocket.rocketcomponent.ComponentVisitor;
@ -19,9 +22,8 @@ import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.Transition; import net.sf.openrocket.rocketcomponent.Transition;
import net.sf.openrocket.rocketcomponent.TrapezoidFinSet; import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
import java.util.HashMap; import com.itextpdf.text.Document;
import java.util.Map; import com.itextpdf.text.pdf.PdfWriter;
import java.util.Set;
/** /**
* A visitor strategy for creating documentation about a parts list. * A visitor strategy for creating documentation about a parts list.
@ -56,7 +58,7 @@ public class PartsListVisitorStrategy extends BaseVisitorStrategy {
crap.put(pa, pa); crap.put(pa, pa);
} }
pa.increment(); pa.increment();
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -72,7 +74,7 @@ public class PartsListVisitorStrategy extends BaseVisitorStrategy {
crap.put(pa, pa); crap.put(pa, pa);
} }
pa.increment(); pa.increment();
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -102,7 +104,7 @@ public class PartsListVisitorStrategy extends BaseVisitorStrategy {
crap.put(pa, pa); crap.put(pa, pa);
} }
pa.increment(); pa.increment();
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -118,7 +120,7 @@ public class PartsListVisitorStrategy extends BaseVisitorStrategy {
crap.put(pa, pa); crap.put(pa, pa);
} }
pa.increment(); pa.increment();
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -134,7 +136,7 @@ public class PartsListVisitorStrategy extends BaseVisitorStrategy {
crap.put(pa, pa); crap.put(pa, pa);
} }
pa.increment(); pa.increment();
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -150,7 +152,7 @@ public class PartsListVisitorStrategy extends BaseVisitorStrategy {
crap.put(pa, pa); crap.put(pa, pa);
} }
pa.increment(); pa.increment();
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -213,6 +215,7 @@ class PartsAccumulator {
return quantity; return quantity;
} }
@Override
public boolean equals(final Object o1) { public boolean equals(final Object o1) {
if (this == o1) { if (this == o1) {
return true; return true;
@ -221,11 +224,9 @@ class PartsAccumulator {
RocketComponent that; RocketComponent that;
if (o1 instanceof net.sf.openrocket.gui.print.visitor.PartsAccumulator) { if (o1 instanceof net.sf.openrocket.gui.print.visitor.PartsAccumulator) {
that = ((net.sf.openrocket.gui.print.visitor.PartsAccumulator) o1).component; that = ((net.sf.openrocket.gui.print.visitor.PartsAccumulator) o1).component;
} } else if (o1 instanceof RocketComponent) {
else if (o1 instanceof RocketComponent) {
that = (RocketComponent) o1; that = (RocketComponent) o1;
} } else {
else {
return false; return false;
} }
@ -250,6 +251,7 @@ class PartsAccumulator {
return false; return false;
} }
@Override
public int hashCode() { public int hashCode() {
return component.getComponentName().hashCode(); return component.getComponentName().hashCode();
} }

View File

@ -3,6 +3,9 @@
*/ */
package net.sf.openrocket.gui.print.visitor; package net.sf.openrocket.gui.print.visitor;
import java.util.ArrayList;
import java.util.List;
import net.sf.openrocket.rocketcomponent.BodyComponent; import net.sf.openrocket.rocketcomponent.BodyComponent;
import net.sf.openrocket.rocketcomponent.BodyTube; import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.ComponentVisitor; import net.sf.openrocket.rocketcomponent.ComponentVisitor;
@ -22,9 +25,6 @@ import net.sf.openrocket.rocketcomponent.Stage;
import net.sf.openrocket.rocketcomponent.Transition; import net.sf.openrocket.rocketcomponent.Transition;
import net.sf.openrocket.rocketcomponent.TrapezoidFinSet; import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
import java.util.ArrayList;
import java.util.List;
/** /**
* This visitor strategy accumulates Stage references in a Rocket hierarchy. * This visitor strategy accumulates Stage references in a Rocket hierarchy.
*/ */
@ -85,7 +85,7 @@ public class StageVisitorStrategy implements ComponentVisitorStrategy {
stageComponents.add(mass); stageComponents.add(mass);
} }
mass = 0d; mass = 0d;
RocketComponent[] rc = visitable.getChildren(); List<RocketComponent> rc = visitable.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -104,7 +104,7 @@ public class StageVisitorStrategy implements ComponentVisitorStrategy {
* @param root the root component; all children will be visited recursively * @param root the root component; all children will be visited recursively
*/ */
protected void goDeep(final RocketComponent root) { protected void goDeep(final RocketComponent root) {
RocketComponent[] rc = root.getChildren(); List<RocketComponent> rc = root.getChildren();
goDeep(rc); goDeep(rc);
} }
@ -114,7 +114,7 @@ public class StageVisitorStrategy implements ComponentVisitorStrategy {
* *
* @param theRc an array of rocket components; all children will be visited recursively * @param theRc an array of rocket components; all children will be visited recursively
*/ */
protected void goDeep (final RocketComponent[] theRc) { protected void goDeep(final List<RocketComponent> theRc) {
for (RocketComponent rocketComponent : theRc) { for (RocketComponent rocketComponent : theRc) {
rocketComponent.accept(parent); rocketComponent.accept(parent);
} }
@ -250,6 +250,7 @@ public class StageVisitorStrategy implements ComponentVisitorStrategy {
/** /**
* Close by setting the last stage. * Close by setting the last stage.
*/ */
@Override
public void close() { public void close() {
if (mass > 0d) { if (mass > 0d) {
stageComponents.add(mass); stageComponents.add(mass);