DGP - design report figure honors rotation angle of main figure; added rocksim constants for future use
This commit is contained in:
parent
09067de7cf
commit
3fa0f9ce67
@ -1,3 +1,8 @@
|
|||||||
|
2012-03-25 Doug Pedrick
|
||||||
|
|
||||||
|
* Printed rocket figure in design report now honors rotation angle of main figure; fixed bug in layout where the
|
||||||
|
figure was clipped in the page margin.
|
||||||
|
|
||||||
2012-03-18 Jason Blood
|
2012-03-18 Jason Blood
|
||||||
|
|
||||||
* Updated importing images to freeform fin sets to work with color images with improved description
|
* Updated importing images to freeform fin sets to work with color images with improved description
|
||||||
|
@ -79,6 +79,10 @@ public class RocksimCommonConstants {
|
|||||||
public static final String ROCK_SIM_DOCUMENT = "RockSimDocument";
|
public static final String ROCK_SIM_DOCUMENT = "RockSimDocument";
|
||||||
public static final String FILE_VERSION = "FileVersion";
|
public static final String FILE_VERSION = "FileVersion";
|
||||||
public static final String DESIGN_INFORMATION = "DesignInformation";
|
public static final String DESIGN_INFORMATION = "DesignInformation";
|
||||||
|
public static final String TUBE_FIN_SET = "TubeFinSet";
|
||||||
|
public static final String RING_TAIL = "RingTail";
|
||||||
|
public static final String EXTERNAL_POD = "ExternalPod";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Length conversion. Rocksim is in millimeters, OpenRocket in meters.
|
* Length conversion. Rocksim is in millimeters, OpenRocket in meters.
|
||||||
*/
|
*/
|
||||||
@ -103,7 +107,4 @@ public class RocksimCommonConstants {
|
|||||||
* Radius conversion. Rocksim is always in diameters, OpenRocket mostly in radius.
|
* Radius conversion. Rocksim is always in diameters, OpenRocket mostly in radius.
|
||||||
*/
|
*/
|
||||||
public static final int ROCKSIM_TO_OPENROCKET_RADIUS = 2 * ROCKSIM_TO_OPENROCKET_LENGTH;
|
public static final int ROCKSIM_TO_OPENROCKET_RADIUS = 2 * ROCKSIM_TO_OPENROCKET_LENGTH;
|
||||||
public static final String TUBE_FIN_SET = "TubeFinSet";
|
|
||||||
public static final String RING_TAIL = "RingTail";
|
|
||||||
public static final String EXTERNAL_POD = "ExternalPod";
|
|
||||||
}
|
}
|
||||||
|
@ -62,21 +62,24 @@ public class PrintDialog extends JDialog implements TreeSelectionListener {
|
|||||||
private JButton saveAsPDF;
|
private JButton saveAsPDF;
|
||||||
private JButton cancel;
|
private JButton cancel;
|
||||||
|
|
||||||
|
private double rotation = 0d;
|
||||||
|
|
||||||
private final static SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
private final static SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
* @param parent the parent awt component
|
||||||
* @param orDocument the OR rocket container
|
* @param orDocument the OR rocket container
|
||||||
|
* @param theRotation the angle of rocket figure rotation
|
||||||
*/
|
*/
|
||||||
public PrintDialog(Window parent, OpenRocketDocument orDocument) {
|
public PrintDialog(Window parent, OpenRocketDocument orDocument, double theRotation) {
|
||||||
super(parent, trans.get("title"), ModalityType.APPLICATION_MODAL);
|
super(parent, trans.get("title"), ModalityType.APPLICATION_MODAL);
|
||||||
|
|
||||||
|
|
||||||
JPanel panel = new JPanel(new MigLayout("fill, gap rel unrel"));
|
JPanel panel = new JPanel(new MigLayout("fill, gap rel unrel"));
|
||||||
this.add(panel);
|
this.add(panel);
|
||||||
|
rotation = theRotation;
|
||||||
|
|
||||||
// before any Desktop APIs are used, first check whether the API is
|
// before any Desktop APIs are used, first check whether the API is
|
||||||
// supported by this particular VM on this particular host
|
// supported by this particular VM on this particular host
|
||||||
@ -257,7 +260,7 @@ public class PrintDialog extends JDialog implements TreeSelectionListener {
|
|||||||
/**
|
/**
|
||||||
* Generate a report using a temporary file. The file will be deleted upon JVM exit.
|
* Generate a report using a temporary file. The file will be deleted upon JVM exit.
|
||||||
*
|
*
|
||||||
* @param paper the name of the paper size
|
* @param settings the container of different print settings
|
||||||
*
|
*
|
||||||
* @return a file, populated with the "printed" output (the rocket info)
|
* @return a file, populated with the "printed" output (the rocket info)
|
||||||
*
|
*
|
||||||
@ -273,7 +276,7 @@ public class PrintDialog extends JDialog implements TreeSelectionListener {
|
|||||||
* Generate a report to a specified file.
|
* Generate a report to a specified file.
|
||||||
*
|
*
|
||||||
* @param f the file to which rocket data will be written
|
* @param f the file to which rocket data will be written
|
||||||
* @param paper the name of the paper size
|
* @param settings the container of different print settings
|
||||||
*
|
*
|
||||||
* @return a file, populated with the "printed" output (the rocket info)
|
* @return a file, populated with the "printed" output (the rocket info)
|
||||||
*
|
*
|
||||||
@ -281,7 +284,7 @@ public class PrintDialog extends JDialog implements TreeSelectionListener {
|
|||||||
*/
|
*/
|
||||||
private File generateReport(File f, PrintSettings settings) throws IOException {
|
private File generateReport(File f, PrintSettings settings) throws IOException {
|
||||||
Iterator<PrintableContext> toBePrinted = currentTree.getToBePrinted();
|
Iterator<PrintableContext> toBePrinted = currentTree.getToBePrinted();
|
||||||
new PrintController().print(document, toBePrinted, new FileOutputStream(f), settings);
|
new PrintController().print(document, toBePrinted, new FileOutputStream(f), settings, rotation);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1442,7 +1442,11 @@ public class BasicFrame extends JFrame {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void printAction() {
|
public void printAction() {
|
||||||
new PrintDialog(this, document).setVisible(true);
|
Double rotation = rocketpanel.getFigure().getRotation();
|
||||||
|
if (rotation == null) {
|
||||||
|
rotation = 0d;
|
||||||
|
}
|
||||||
|
new PrintDialog(this, document, rotation).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,6 +97,11 @@ public class DesignReport {
|
|||||||
*/
|
*/
|
||||||
protected Document document;
|
protected Document document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The figure rotation.
|
||||||
|
*/
|
||||||
|
private double rotation = 0d;
|
||||||
|
|
||||||
/** The displayed strings. */
|
/** The displayed strings. */
|
||||||
private static final String STAGES = "Stages: ";
|
private static final String STAGES = "Stages: ";
|
||||||
private static final String MASS_WITH_MOTORS = "Mass (with motors): ";
|
private static final String MASS_WITH_MOTORS = "Mass (with motors): ";
|
||||||
@ -128,11 +133,13 @@ public class DesignReport {
|
|||||||
*
|
*
|
||||||
* @param theRocDoc the OR document
|
* @param theRocDoc the OR document
|
||||||
* @param theIDoc the iText document
|
* @param theIDoc the iText document
|
||||||
|
* @param figureRotation the angle the figure is rotated on the screen; printed report will mimic
|
||||||
*/
|
*/
|
||||||
public DesignReport(OpenRocketDocument theRocDoc, Document theIDoc) {
|
public DesignReport(OpenRocketDocument theRocDoc, Document theIDoc, Double figureRotation) {
|
||||||
document = theIDoc;
|
document = theIDoc;
|
||||||
rocketDocument = theRocDoc;
|
rocketDocument = theRocDoc;
|
||||||
panel = new RocketPanel(rocketDocument);
|
panel = new RocketPanel(rocketDocument);
|
||||||
|
rotation = figureRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,6 +163,7 @@ public class DesignReport {
|
|||||||
PdfContentByte canvas = writer.getDirectContent();
|
PdfContentByte canvas = writer.getDirectContent();
|
||||||
|
|
||||||
final PrintFigure figure = new PrintFigure(configuration);
|
final PrintFigure figure = new PrintFigure(configuration);
|
||||||
|
figure.setRotation(rotation);
|
||||||
|
|
||||||
FigureElement cp = panel.getExtraCP();
|
FigureElement cp = panel.getExtraCP();
|
||||||
FigureElement cg = panel.getExtraCG();
|
FigureElement cg = panel.getExtraCG();
|
||||||
|
@ -35,9 +35,10 @@ public class PrintController {
|
|||||||
* @param toBePrinted the user chosen items to print
|
* @param toBePrinted the user chosen items to print
|
||||||
* @param outputFile the file being written to
|
* @param outputFile the file being written to
|
||||||
* @param settings the print settings
|
* @param settings the print settings
|
||||||
|
* @param rotation the angle the rocket figure is rotated
|
||||||
*/
|
*/
|
||||||
public void print(OpenRocketDocument doc, Iterator<PrintableContext> toBePrinted, OutputStream outputFile,
|
public void print(OpenRocketDocument doc, Iterator<PrintableContext> toBePrinted, OutputStream outputFile,
|
||||||
PrintSettings settings) {
|
PrintSettings settings, double rotation) {
|
||||||
|
|
||||||
Document idoc = new Document(getSize(settings));
|
Document idoc = new Document(getSize(settings));
|
||||||
PdfWriter writer = null;
|
PdfWriter writer = null;
|
||||||
@ -59,20 +60,16 @@ public class PrintController {
|
|||||||
|
|
||||||
switch (printableContext.getPrintable()) {
|
switch (printableContext.getPrintable()) {
|
||||||
case DESIGN_REPORT:
|
case DESIGN_REPORT:
|
||||||
DesignReport dp = new DesignReport(doc, idoc);
|
DesignReport dp = new DesignReport(doc, idoc, rotation);
|
||||||
dp.writeToDocument(writer);
|
dp.writeToDocument(writer);
|
||||||
idoc.newPage();
|
idoc.newPage();
|
||||||
break;
|
break;
|
||||||
case FIN_TEMPLATE:
|
case FIN_TEMPLATE:
|
||||||
final FinSetPrintStrategy finWriter = new FinSetPrintStrategy(idoc,
|
final FinSetPrintStrategy finWriter = new FinSetPrintStrategy(idoc, writer, stages);
|
||||||
writer,
|
|
||||||
stages);
|
|
||||||
finWriter.writeToDocument(doc.getRocket());
|
finWriter.writeToDocument(doc.getRocket());
|
||||||
break;
|
break;
|
||||||
case PARTS_DETAIL:
|
case PARTS_DETAIL:
|
||||||
final PartsDetailVisitorStrategy detailVisitor = new PartsDetailVisitorStrategy(idoc,
|
final PartsDetailVisitorStrategy detailVisitor = new PartsDetailVisitorStrategy(idoc, writer, stages);
|
||||||
writer,
|
|
||||||
stages);
|
|
||||||
detailVisitor.writeToDocument(doc.getRocket());
|
detailVisitor.writeToDocument(doc.getRocket());
|
||||||
detailVisitor.close();
|
detailVisitor.close();
|
||||||
idoc.newPage();
|
idoc.newPage();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user