Merge pull request #156 from openrocket/13.09dev

Make 13.09dev master
This commit is contained in:
kruland2607 2013-10-11 12:14:08 -07:00
commit 9f20889688
499 changed files with 6104 additions and 3166 deletions

7
.gitignore vendored
View File

@ -37,9 +37,6 @@
/core/resources-src/pix/sormus.xcf.gz
/core/resources-src/pix/splashscreen-sormus.png
/core/resources-src/pix/splashscreen-sormus.xcf.gz
<<<<<<< HEAD
/*/bin/
/android-libraries/*/bin/
=======
>>>>>>> Convert svn:ignore properties to .gitignore.
/swing/build
/swing/tmp

View File

@ -2,6 +2,4 @@ language: java
jdk:
- oraclejdk7
script:
- "cd core"
- "ant -buildfile build.xml clean checkascii build jar"
- "ant -buildfile build.xml unittest-no-junit-report"
- "ant -buildfile build.xml clean check jar unittest"

121
build.xml Normal file
View File

@ -0,0 +1,121 @@
<project name="OpenRocket" basedir="." default="jar">
<!-- CLEAN -->
<target name="clean" depends="clean-core, clean-swing">
</target>
<target name="clean-core">
<ant dir="core" target="clean"/>
</target>
<target name="clean-swing">
<ant dir="swing" target="clean"/>
</target>
<!-- BUILD -->
<target name="build" depends="build-core, build-swing">
</target>
<target name="build-core">
<ant dir="core" target="build"/>
</target>
<target name="build-swing" depends="jar-core">
<ant dir="swing" target="build"/>
</target>
<!-- JAR -->
<target name="jar" depends="jar-core,jar-swing">
</target>
<target name="jar-core" depends="build-core">
<ant dir="core" target="jar"/>
</target>
<target name="jar-swing" depends="build-swing">
<ant dir="swing" target="jar"/>
</target>
<!-- TEST -->
<target name="unittest" depends="unittest-core, unittest-swing">
</target>
<target name="unittest-core" depends="jar-core">
<ant dir="core" target="unittest" inheritAll="false" />
</target>
<target name="unittest-swing" depends="jar-swing">
<ant dir="swing" target="unittest" inheritAll="false" />
</target>
<!-- CHECK -->
<target name="check" depends="checktodo,checkascii"/>
<!-- CHECK TODOs -->
<target name="todo" depends="checktodo"/>
<target name="checktodo">
<tempfile property="todo.file" prefix="checktodo-" destDir="${basedir}"/>
<echo>Checking project for FIXMEs.</echo>
<concat destfile="${todo.file}">
<fileset dir="core/src">
<include name="**/*.java"/>
</fileset>
<fileset dir="core/test">
<include name="**/*.java"/>
</fileset>
<fileset dir="swing/src">
<include name="**/*.java"/>
</fileset>
<fileset dir="swing/test">
<include name="**/*.java"/>
</fileset>
<filterchain>
<linecontainsregexp>
<regexp pattern="(FIXME|TODO:.*CRITICAL)"/>
</linecontainsregexp>
</filterchain>
</concat>
<loadfile srcfile="${todo.file}" property="criticaltodos"/>
<delete file="${todo.file}"/>
<fail if="criticaltodos">CRITICAL TODOs exist in project:
${criticaltodos}</fail>
<echo>No critical TODOs in project.</echo>
</target>
<!-- CHECK ASCII -->
<target name="ascii" depends="checkascii"/>
<target name="checkascii">
<tempfile property="ascii.file" prefix="checkascii-" destDir="${basedir}"/>
<echo>Checking project for non-ASCII characters.</echo>
<concat destfile="${ascii.file}">
<fileset dir="core/src">
<include name="**/*.java"/>
</fileset>
<fileset dir="core/test">
<include name="**/*.java"/>
</fileset>
<fileset dir="swing/src">
<include name="**/*.java"/>
</fileset>
<fileset dir="swing/test">
<include name="**/*.java"/>
</fileset>
<filterchain>
<linecontainsregexp>
<regexp pattern="\P{ASCII}"/>
</linecontainsregexp>
</filterchain>
</concat>
<loadfile srcfile="${ascii.file}" property="nonascii"/>
<delete file="${ascii.file}"/>
<fail if="nonascii">Non-ASCII characters exist in project:
${nonascii}</fail>
<echo>No non-ASCII characters in project.</echo>
</target>
</project>

View File

@ -10,29 +10,20 @@
</accessrules>
</classpathentry>
<classpathentry kind="lib" path="lib-extra/RXTXcomm.jar"/>
<classpathentry kind="lib" path="lib/miglayout15-swing.jar"/>
<classpathentry kind="lib" path="lib/iText-5.0.2.jar"/>
<classpathentry kind="lib" path="lib-test/hamcrest-core-1.3.0RC1.jar"/>
<classpathentry kind="lib" path="lib-test/hamcrest-library-1.3.0RC1.jar"/>
<classpathentry kind="lib" path="lib-test/jmock-2.6.0-RC2.jar"/>
<classpathentry kind="lib" path="lib-test/jmock-junit4-2.6.0-RC2.jar"/>
<classpathentry kind="lib" path="lib-test/junit-dep-4.8.2.jar"/>
<classpathentry kind="lib" path="lib-test/uispec4j-2.3-jdk16.jar"/>
<classpathentry kind="lib" path="resources"/>
<classpathentry kind="lib" path="lib/opencsv-2.3.jar"/>
<classpathentry kind="lib" path="lib/OrangeExtensions-1.2.jar"/>
<classpathentry kind="lib" path="lib/guice-3.0.jar"/>
<classpathentry kind="lib" path="lib/guice-multibindings-3.0.jar"/>
<classpathentry kind="lib" path="lib/javax.inject.jar"/>
<classpathentry kind="lib" path="lib/aopalliance.jar"/>
<classpathentry kind="lib" path="lib/jogl/gluegen-rt.jar" sourcepath="reference/gluegen-v2.0-rc11-sources.jar"/>
<classpathentry kind="lib" path="lib/jogl/jogl-all.jar" sourcepath="reference/jogl-all-2.0.2-sources.jar"/>
<classpathentry kind="lib" path="lib-test/test-plugin.jar"/>
<classpathentry kind="lib" path="lib/annotation-detector-3.0.2-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="lib/logback-classic-1.0.12.jar" sourcepath="reference/logback-classic-1.0.12-sources.jar"/>
<classpathentry kind="lib" path="lib/logback-core-1.0.12.jar" sourcepath="reference/logback-core-1.0.12-sources.jar"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.7.5.jar"/>
<classpathentry kind="lib" path="lib/jcommon-1.0.18.jar"/>
<classpathentry kind="lib" path="lib/jfreechart-1.0.15.jar" sourcepath="reference/jfreechart-1.0.15-sources.jar"/>
<classpathentry kind="lib" path="lib/annotation-detector-3.0.2.jar"/>
<classpathentry kind="lib" path="D:/Profiles/Administrator/git/openrocket/lib-test/uispec4j-2.3-jdk16.jar"/>
<classpathentry kind="lib" path="D:/Profiles/Administrator/git/openrocket/lib-test/hamcrest-core-1.3.0RC1.jar"/>
<classpathentry kind="lib" path="D:/Profiles/Administrator/git/openrocket/lib-test/hamcrest-library-1.3.0RC1.jar"/>
<classpathentry kind="lib" path="D:/Profiles/Administrator/git/openrocket/lib-test/jmock-2.6.0-RC2.jar"/>
<classpathentry kind="lib" path="D:/Profiles/Administrator/git/openrocket/lib-test/jmock-junit4-2.6.0-RC2.jar"/>
<classpathentry kind="lib" path="D:/Profiles/Administrator/git/openrocket/lib-test/junit-dep-4.8.2.jar"/>
<classpathentry kind="lib" path="D:/Profiles/Administrator/git/openrocket/lib-test/test-plugin.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OpenRocket</name>
<name>OpenRocket Core</name>
<comment></comment>
<projects>
</projects>

View File

@ -1,4 +1,4 @@
<project name="OpenRocket" basedir=".">
<project name="OpenRocket-Core" basedir=".">
<property file="resources/build.properties" />
@ -7,7 +7,7 @@
<property name="build.dir" value="${basedir}/build"/> <!-- Build directory -->
<property name="build-test.dir" value="${basedir}/build/test"/> <!-- Build directory -->
<property name="lib.dir" value="${basedir}/lib"/> <!-- Library source directory -->
<property name="libtest.dir" value="${basedir}/lib-test"/> <!-- Library test source directory -->
<property name="libtest.dir" value="${basedir}/../lib-test"/> <!-- Library test source directory -->
<property name="libextra.dir" value="${basedir}/lib-extra"/> <!-- Library extra source directory -->
<property name="tmp.dir" value="${basedir}/tmp"/> <!-- Temporary directory -->
<property name="resources.dir" value="${basedir}/resources"/> <!-- Resources directory -->
@ -23,14 +23,6 @@
<property name="pkgname" value="${ant.project.name}-${build.version}"/>
<property name="jar.file" value="${jar.dir}/${ant.project.name}.jar"/>
<property name="dist.bin" value="${jar.dir}/${pkgname}.jar"/>
<property name="dist.src" value="${jar.dir}/${pkgname}-src.zip"/>
<!-- The main class of the application -->
<property name="main-class" value="net.sf.openrocket.startup.Startup"/>
<property name="expanded-libs" value="${lib.dir}/miglayout15-swing.jar"/>
<!-- Classpath definitions -->
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
@ -51,13 +43,6 @@
<pathelement location="${classes.dir}"/>
</path>
<!-- Add Ant-contrib tasks so we can use for loop -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${libextra.dir}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!-- CLEAN -->
<target name="clean" description="Removes all build artifacts">
@ -74,56 +59,20 @@
</target>
<!-- Executible Eclipse-Jar-In-Jar style JAR -->
<target name="jar" depends="build,serialize-presets,serialize-motors" description="Create the OpenRocket executable JAR">
<target name="jar" depends="build,serialize-motors" description="Create the OpenRocket Core">
<mkdir dir="${jar.dir}" />
<jar destfile="${jar.file}" basedir="${dist.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}" />
<attribute name="SplashScreen-Image" value="pix/splashscreen.png" />
<attribute name="Classpath-Jars" value="lib/gluegen-rt.jar lib/jogl-all.jar" />
</manifest>
<!-- Include, in the root of the JAR, the resources needed by OR -->
<fileset dir="${src.dir}/" includes="META-INF/,logback.xml" />
<fileset dir="${resources.dir}/" />
<!-- Libraries to extract into base JAR -->
<zipfileset src="${lib.dir}/miglayout15-swing.jar" />
<zipfileset src="${lib.dir}/guice-3.0.jar" />
<zipfileset src="${lib.dir}/aopalliance.jar"/>
<zipfileset src="${lib.dir}/guice-3.0.jar"/>
<zipfileset src="${lib.dir}/guice-multibindings-3.0.jar"/>
<zipfileset src="${lib.dir}/iText-5.0.2.jar"/>
<zipfileset src="${lib.dir}/javax.inject.jar"/>
<zipfileset src="${lib.dir}/jcommon-1.0.18.jar"/>
<zipfileset src="${lib.dir}/jfreechart-1.0.15.jar"/>
<zipfileset src="${lib.dir}/miglayout15-swing.jar"/>
<zipfileset src="${lib.dir}/opencsv-2.3.jar"/>
<zipfileset src="${lib.dir}/OrangeExtensions-1.2.jar"/>
<zipfileset src="${lib.dir}/annotation-detector-3.0.2-SNAPSHOT.jar"/>
<zipfileset src="${lib.dir}/slf4j-api-1.7.5.jar"/>
<zipfileset src="${lib.dir}/logback-classic-1.0.12.jar"/>
<zipfileset src="${lib.dir}/logback-core-1.0.12.jar"/>
<!-- JOGL libraries need to be jar-in-jar -->
<zipfileset dir="${lib.dir}/jogl" prefix="lib">
<include name="*.jar"/>
</zipfileset>
<!-- Include metafiles about OR -->
<fileset dir="${basedir}" includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes fileformat.txt" />
</jar>
</target>
<target name="serialize-presets" depends="build" description="Preprocess the orc preset files into serialized form">
<java classname="net.sf.openrocket.utils.SerializePresets"
fork="true"
classpathref="run-classpath"
failonerror="true">
</java>
</target>
<target name="serialize-motors" depends="build" description="Preprocess the motor files into serialized form">
<java classname="net.sf.openrocket.utils.SerializeMotors"
fork="true"
@ -134,141 +83,6 @@
</java>
</target>
<!-- CONVERT vendor csv to ORC files -->
<macrodef name="build-orc-file">
<attribute name="dir"/>
<attribute name="vendor"/>
<sequential>
<echo>Generating ORC file for vendor @{vendor}</echo>
<java classname="net.sf.openrocket.preset.loader.RocksimComponentFileTranslator"
fork="true"
classpathref="run-classpath"
failonerror="true">
<arg value="@{dir}"/>
<arg value="${resources-src.dir}/datafiles/presets/@{vendor}.orc"/>
</java>
</sequential>
</macrodef>
<target name="generate-orc-files"
description="Generate ORC file from vendor csv"
depends="build">
<for param="vendor-dir">
<dirset dir="${resources-src.dir}/datafiles/rocksim_components"
includes="*"/>
<sequential>
<propertyregex property="vendor"
override="true"
input="@{vendor-dir}"
select="\1"
regexp=".*[/\\]([^/\\]*)$"/>
<build-orc-file dir="@{vendor-dir}" vendor="${vendor}"/>
</sequential>
</for>
</target>
<!-- DIST-SRC -->
<target name="dist-src">
<echo>
Building source distribution
</echo>
<mkdir dir="${build.dir}/${pkgname}"/>
<mkdir dir="${jar.dir}"/>
<copy todir="${build.dir}/${pkgname}">
<fileset dir="${basedir}" includes="*" excludes="*.log">
<type type="file"/>
</fileset>
<fileset dir="${basedir}" includes="resources/ lib/ lib-test/ src/ test/ resources-src/datafiles/"/>
</copy>
<zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
<delete dir="${build.dir}/${pkgname}"/>
</target>
<!-- DIST-SRC-TEST -->
<target name="dist-src-test" depends="dist-src">
<echo>
Testing source distribution
</echo>
<delete dir="${dist-test.dir}"/>
<mkdir dir="${dist-test.dir}"/>
<unzip dest="${dist-test.dir}" src="${dist.src}"/>
<ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="jar"/>
<ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="unittest"/>
<delete dir="${dist-test.dir}"/>
<echo>
Source distribution test successful
</echo>
</target>
<!-- DIST-BIN -->
<target name="dist-bin" depends="check,clean,unittest,jar">
<move file="${jar.file}" tofile="${dist.bin}"/>
</target>
<!-- DIST -->
<target name="dist" depends="dist-bin,dist-src,dist-src-test">
<echo>Distribution ${build.version} (${build.source}) built into directory ${jar.dir}</echo>
</target>
<!-- CHECK -->
<target name="check" depends="checktodo,checkascii"/>
<!-- CHECK TODOs -->
<target name="todo" depends="checktodo"/>
<target name="checktodo">
<tempfile property="todo.file" prefix="checktodo-" destDir="${tmp.dir}"/>
<echo>Checking project for FIXMEs.</echo>
<concat destfile="${todo.file}">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${src-test.dir}">
<include name="**/*.java"/>
</fileset>
<filterchain>
<linecontainsregexp>
<regexp pattern="(FIXME|TODO:.*CRITICAL)"/>
</linecontainsregexp>
</filterchain>
</concat>
<loadfile srcfile="${todo.file}" property="criticaltodos"/>
<delete file="${todo.file}"/>
<fail if="criticaltodos">CRITICAL TODOs exist in project:
${criticaltodos}</fail>
<echo>No critical TODOs in project.</echo>
</target>
<!-- CHECK ASCII -->
<target name="ascii" depends="checkascii"/>
<target name="checkascii">
<tempfile property="ascii.file" prefix="checkascii-" destDir="${tmp.dir}"/>
<echo>Checking project for non-ASCII characters.</echo>
<concat destfile="${ascii.file}">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${src-test.dir}">
<include name="**/*.java"/>
</fileset>
<filterchain>
<linecontainsregexp>
<regexp pattern="\P{ASCII}"/>
</linecontainsregexp>
</filterchain>
</concat>
<loadfile srcfile="${ascii.file}" property="nonascii"/>
<delete file="${ascii.file}"/>
<fail if="nonascii">Non-ASCII characters exist in project:
${nonascii}</fail>
<echo>No non-ASCII characters in project.</echo>
</target>
<!-- Unit tests -->
<target name="unittest" description="Execute unit tests" depends="build">
@ -278,7 +92,7 @@ ${nonascii}</fail>
<echo>Running unit tests</echo>
<mkdir dir="${tmp.dir}/rawtestoutput"/>
<junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
<junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure" dir="${basedir}">
<classpath>
<path refid="test-classpath"/>
<path location="${basedir}"/>
@ -291,6 +105,7 @@ ${nonascii}</fail>
<exclude name="Test.class" />
</fileset>
<formatter type="xml"/>
<formatter type="plain" usefile="false" />
</batchtest>
</junit>
<junitreport todir="${tmp.dir}">

Binary file not shown.

View File

@ -52,12 +52,12 @@ RocketPanel.FigTypeAct.Unfinished = 3D Unfinished
RocketPanel.lbl.Flightcfg = Flight configuration:
RocketPanel.but.FlightcfgEdit = Edit
RocketPanel.lbl.infoMessage = <html>Click to select &nbsp;&nbsp; Shift+click to select other &nbsp;&nbsp; Double-click to edit &nbsp;&nbsp; Click+drag to move
RocketPanel.lbl.ViewType = View Type:
! BasicFrame
BasicFrame.tab.Rocketdesign = Rocket design
BasicFrame.tab.Flightconfig = Configurations
BasicFrame.tab.Flightsim = Flight simulations
BasicFrame.title.Addnewcomp = Add new component
BasicFrame.dlg.lbl1 = Design '
@ -174,10 +174,11 @@ debuglogdlg.lbl.Stacktrace = Stack trace:
MotorChooserDialog.title = Select a rocket motor
! Edit Motor configuration dialog
edtmotorconfdlg.but.Removeconfiguration = Remove
edtmotorconfdlg.but.Renameconfiguration = Rename
edtmotorconfdlg.but.Newconfiguration = New
edtmotorconfdlg.but.Copyconfiguration = Copy
edtmotorconfdlg.col.configuration = Configuration
edtmotorconfdlg.but.Removeconfiguration = Remove Configuration
edtmotorconfdlg.but.Renameconfiguration = Rename Configuration
edtmotorconfdlg.but.Newconfiguration = New Configuration
edtmotorconfdlg.but.Copyconfiguration = Copy Configuration
edtmotorconfdlg.title.Editmotorconf = Edit Flight configurations
edtmotorconfdlg.title.Renameconf = Rename Flight Configuration
edtmotorconfdlg.title.Selectdeploymentconf = Select Deployment Configuration
@ -325,7 +326,6 @@ simedtdlg.tab.Plotdata = Plot data
simedtdlg.tab.CustomExpressions = Custom expressions
simedtdlg.tab.Exportdata = Export data
simedtdlg.lbl.Flightcfg = Flight configuration:
simedtdlg.but.FlightcfgEdit = Edit
simedtdlg.lbl.ttip.Flightcfg = Select the flight configuration to use.
simedtdlg.combo.ttip.Flightcfg = Select the flight configuration to use.
simedtdlg.lbl.Wind = Wind
@ -1064,9 +1064,6 @@ TrapezoidFinSetCfg.lbl.plus = plus
TrapezoidFinSetCfg.tab.General = General
TrapezoidFinSetCfg.tab.Generalproperties = General properties
!MotorConfigurationModel
MotorCfgModel.Editcfg = Edit configurations
! StorageOptionChooser
StorageOptChooser.lbl.Simdatatostore = Simulated data to store:
StorageOptChooser.rdbut.Allsimdata = All simulated data
@ -1087,10 +1084,15 @@ StorageOptChooser.lbl.Saveopt = Save options
! ThrustCurveMotorSelectionPanel
TCMotorSelPan.lbl.Selrocketmotor = Select rocket motor:
TCMotorSelPan.checkbox.hideSimilar = Hide very similar thrust curves
TCMotorSelPan.SHOW_DESCRIPTIONS.desc1 = Show all motors
TCMotorSelPan.SHOW_DESCRIPTIONS.desc2 = Show motors with diameter less than that of the motor mount
TCMotorSelPan.SHOW_DESCRIPTIONS.desc3 = Show motors with diameter equal to that of the motor mount
TCMotorSelPan.lbl.Motormountdia = Motor mount diameter:
TCMotorSelPan.checkbox.hideUsed = Hide motors already used in the mount
TCMotorSelPan.checkbox.limitlength = Limit motor length to mount length
TCMotorSelPan.checkbox.limitdiameter = Limit motor diameter to mount diameter
TCMotorSelPan.btn.details = Show Details
TCMotorSelPan.btn.filter = Filter Motors
TCMotorSelPan.MotorSize = Motor Dimensions
TCMotorSelPan.Diameter = Daimeter
TCMotorSelPan.Length = Length
TCMotorSelPan.MotorMountDimensions = Motor mount dimensions:
TCMotorSelPan.lbl.Search = Search:
TCMotorSelPan.lbl.Selectthrustcurve = Select thrust curve:
TCMotorSelPan.lbl.Ejectionchargedelay = Ejection charge delay:
@ -1108,6 +1110,10 @@ TCMotorSelPan.title.Thrustcurve = Thrust curve:
TCMotorSelPan.title.Thrust = Thrust
TCMotorSelPan.delayBox.None = None
TCMotorSelPan.noDescription = No description available.
TCMotorSelPan.btn.checkAll = Select All
TCMotorSelPan.btn.checkNone = Clear All
TCMotorSelPan.btn.close = Close
! PlotDialog

View File

@ -1,7 +1,12 @@
package net.sf.openrocket.file.rocksim.export;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import net.sf.openrocket.file.rocksim.RocksimCommonConstants;
import net.sf.openrocket.gui.configdialog.InnerTubeConfig;
import net.sf.openrocket.rocketcomponent.BodyTube;
import net.sf.openrocket.rocketcomponent.Bulkhead;
import net.sf.openrocket.rocketcomponent.CenteringRing;
@ -15,110 +20,105 @@ import net.sf.openrocket.rocketcomponent.Transition;
import net.sf.openrocket.rocketcomponent.TubeCoupler;
import net.sf.openrocket.util.Coordinate;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
/**
* This class models the XML element for a Rocksim inside tube.
*/
@XmlRootElement(name = RocksimCommonConstants.BODY_TUBE)
@XmlAccessorType(XmlAccessType.FIELD)
public class InnerBodyTubeDTO extends BodyTubeDTO implements AttachableParts {
/**
* Constructor.
*/
public InnerBodyTubeDTO() {
super.setInsideTube(true);
}
/**
* Full copy constructor.
*
* @param bt the corresponding OR inner body tube
* @param parent the attached parts (subcomponents in Rocksim speak) of the InnerTube's parent. This instance
* is a member of those attached parts, as well as all sibling components. This is passed in the
* event that the inner tube is a cluster. In that situation this instance will be removed and
* individual instances for each cluster member will be added.
*/
public InnerBodyTubeDTO(InnerTube bt, AttachableParts parent) {
super(bt);
setEngineOverhang(bt.getMotorOverhang() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
setID(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setOD(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setMotorMount(bt.isMotorMount());
setInsideTube(true);
setRadialAngle(bt.getRadialDirection());
setRadialLoc(bt.getRadialPosition() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
List<RocketComponent> children = bt.getChildren();
for (int i = 0; i < children.size(); i++) {
RocketComponent rocketComponents = children.get(i);
if (rocketComponents instanceof InnerTube) {
final InnerTube innerTube = (InnerTube) rocketComponents;
//Only if the inner tube is NOT a cluster, then create the corresponding Rocksim DTO and add it
//to the list of attached parts. If it is a cluster, then it is handled specially outside of this
//loop.
if (innerTube.getClusterCount() == 1) {
attachedParts.add(new InnerBodyTubeDTO(innerTube, this));
}
} else if (rocketComponents instanceof BodyTube) {
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
} else if (rocketComponents instanceof Transition) {
attachedParts.add(new TransitionDTO((Transition) rocketComponents));
} else if (rocketComponents instanceof EngineBlock) {
attachedParts.add(new EngineBlockDTO((EngineBlock) rocketComponents));
} else if (rocketComponents instanceof TubeCoupler) {
attachedParts.add(new TubeCouplerDTO((TubeCoupler) rocketComponents));
} else if (rocketComponents instanceof CenteringRing) {
attachedParts.add(new CenteringRingDTO((CenteringRing) rocketComponents));
} else if (rocketComponents instanceof Bulkhead) {
attachedParts.add(new BulkheadDTO((Bulkhead) rocketComponents));
} else if (rocketComponents instanceof Streamer) {
attachedParts.add(new StreamerDTO((Streamer) rocketComponents));
} else if (rocketComponents instanceof Parachute) {
attachedParts.add(new ParachuteDTO((Parachute) rocketComponents));
} else if (rocketComponents instanceof MassObject) {
attachedParts.add(new MassObjectDTO((MassObject) rocketComponents));
}
}
//Do the cluster. For now this splits the cluster into separate tubes, which is how Rocksim represents it.
//The import (from Rocksim to OR) could be augmented to be more intelligent and try to determine if the
//co-located tubes are a cluster.
if (bt.getClusterConfiguration().getClusterCount() > 1) {
handleCluster(bt, parent);
parent.removeAttachedPart(this);
}
}
/**
* Handle the inner tube as a cluster. This amounts to splitting it up so that each motor mount in the cluster
* is created individually to support Rocksim's view of clusters.
*
* @param it the clustered tube
* @param p the collection (parent's attached parts really) to which all cluster tubes will be added
*/
private void handleCluster(InnerTube it, AttachableParts p) {
Coordinate[] coords = {Coordinate.NUL};
coords = it.shiftCoordinates(coords);
for (int x = 0; x < coords.length; x++) {
InnerTube partialClone = InnerTubeConfig.makeIndividualClusterComponent(coords[x], it.getName() + " #" + (x + 1), it);
p.addAttachedPart(new InnerBodyTubeDTO(partialClone, p));
}
}
@Override
public void addAttachedPart(BasePartDTO part) {
attachedParts.add(part);
}
@Override
public void removeAttachedPart(BasePartDTO part) {
attachedParts.remove(part);
}
/**
* Constructor.
*/
public InnerBodyTubeDTO() {
super.setInsideTube(true);
}
/**
* Full copy constructor.
*
* @param bt the corresponding OR inner body tube
* @param parent the attached parts (subcomponents in Rocksim speak) of the InnerTube's parent. This instance
* is a member of those attached parts, as well as all sibling components. This is passed in the
* event that the inner tube is a cluster. In that situation this instance will be removed and
* individual instances for each cluster member will be added.
*/
public InnerBodyTubeDTO(InnerTube bt, AttachableParts parent) {
super(bt);
setEngineOverhang(bt.getMotorOverhang() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
setID(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setOD(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setMotorMount(bt.isMotorMount());
setInsideTube(true);
setRadialAngle(bt.getRadialDirection());
setRadialLoc(bt.getRadialPosition() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
List<RocketComponent> children = bt.getChildren();
for (int i = 0; i < children.size(); i++) {
RocketComponent rocketComponents = children.get(i);
if (rocketComponents instanceof InnerTube) {
final InnerTube innerTube = (InnerTube) rocketComponents;
//Only if the inner tube is NOT a cluster, then create the corresponding Rocksim DTO and add it
//to the list of attached parts. If it is a cluster, then it is handled specially outside of this
//loop.
if (innerTube.getClusterCount() == 1) {
attachedParts.add(new InnerBodyTubeDTO(innerTube, this));
}
} else if (rocketComponents instanceof BodyTube) {
attachedParts.add(new BodyTubeDTO((BodyTube) rocketComponents));
} else if (rocketComponents instanceof Transition) {
attachedParts.add(new TransitionDTO((Transition) rocketComponents));
} else if (rocketComponents instanceof EngineBlock) {
attachedParts.add(new EngineBlockDTO((EngineBlock) rocketComponents));
} else if (rocketComponents instanceof TubeCoupler) {
attachedParts.add(new TubeCouplerDTO((TubeCoupler) rocketComponents));
} else if (rocketComponents instanceof CenteringRing) {
attachedParts.add(new CenteringRingDTO((CenteringRing) rocketComponents));
} else if (rocketComponents instanceof Bulkhead) {
attachedParts.add(new BulkheadDTO((Bulkhead) rocketComponents));
} else if (rocketComponents instanceof Streamer) {
attachedParts.add(new StreamerDTO((Streamer) rocketComponents));
} else if (rocketComponents instanceof Parachute) {
attachedParts.add(new ParachuteDTO((Parachute) rocketComponents));
} else if (rocketComponents instanceof MassObject) {
attachedParts.add(new MassObjectDTO((MassObject) rocketComponents));
}
}
//Do the cluster. For now this splits the cluster into separate tubes, which is how Rocksim represents it.
//The import (from Rocksim to OR) could be augmented to be more intelligent and try to determine if the
//co-located tubes are a cluster.
if (bt.getClusterConfiguration().getClusterCount() > 1) {
handleCluster(bt, parent);
parent.removeAttachedPart(this);
}
}
/**
* Handle the inner tube as a cluster. This amounts to splitting it up so that each motor mount in the cluster
* is created individually to support Rocksim's view of clusters.
*
* @param it the clustered tube
* @param p the collection (parent's attached parts really) to which all cluster tubes will be added
*/
private void handleCluster(InnerTube it, AttachableParts p) {
Coordinate[] coords = { Coordinate.NUL };
coords = it.shiftCoordinates(coords);
for (int x = 0; x < coords.length; x++) {
InnerTube partialClone = InnerTube.makeIndividualClusterComponent(coords[x], it.getName() + " #" + (x + 1), it);
p.addAttachedPart(new InnerBodyTubeDTO(partialClone, p));
}
}
@Override
public void addAttachedPart(BasePartDTO part) {
attachedParts.add(part);
}
@Override
public void removeAttachedPart(BasePartDTO part) {
attachedParts.remove(part);
}
}

View File

@ -1,261 +0,0 @@
package net.sf.openrocket.gui.configdialog;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.gui.SpinnerEditor;
import net.sf.openrocket.gui.adaptors.BooleanModel;
import net.sf.openrocket.gui.adaptors.DoubleModel;
import net.sf.openrocket.gui.adaptors.EnumModel;
import net.sf.openrocket.gui.adaptors.FlightConfigurationModel;
import net.sf.openrocket.gui.components.BasicSlider;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.components.UnitSelector;
import net.sf.openrocket.gui.dialogs.flightconfiguration.FlightConfigurationDialog;
import net.sf.openrocket.gui.dialogs.motor.MotorChooserDialog;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.motor.Motor;
import net.sf.openrocket.motor.ThrustCurveMotor;
import net.sf.openrocket.rocketcomponent.Configuration;
import net.sf.openrocket.rocketcomponent.IgnitionConfiguration;
import net.sf.openrocket.rocketcomponent.MotorConfiguration;
import net.sf.openrocket.rocketcomponent.MotorMount;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup;
public class MotorConfig extends JPanel {
private final Rocket rocket;
private final MotorMount mount;
private final Configuration configuration;
private JPanel panel;
private JLabel motorLabel;
private static final Translator trans = Application.getTranslator();
public MotorConfig(MotorMount motorMount) {
super(new MigLayout("fill"));
this.rocket = ((RocketComponent) motorMount).getRocket();
this.mount = motorMount;
this.configuration = ((RocketComponent) motorMount).getRocket().getDefaultConfiguration();
BooleanModel model;
model = new BooleanModel(motorMount, "MotorMount");
JCheckBox check = new JCheckBox(model);
////This component is a motor mount
check.setText(trans.get("MotorCfg.checkbox.compmotormount"));
this.add(check, "wrap");
panel = new JPanel(new MigLayout("fill"));
this.add(panel, "grow, wrap");
// Motor configuration selector
//// Motor configuration:
panel.add(new JLabel(trans.get("MotorCfg.lbl.Flightcfg")), "shrink");
JComboBox combo = new JComboBox(new FlightConfigurationModel(configuration));
panel.add(combo, "growx");
combo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateFields();
}
});
//// New button
JButton button = new JButton(trans.get("MotorCfg.but.New"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String id = rocket.newFlightConfigurationID();
configuration.setFlightConfigurationID(id);
}
});
panel.add(button, "");
//// Edit button
button = new JButton(trans.get("MotorCfg.but.FlightcfgEdit"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JDialog configDialog = new FlightConfigurationDialog(rocket, SwingUtilities.windowForComponent(MotorConfig.this));
configDialog.show();
}
});
panel.add(button, "wrap unrel");
// Current motor:
panel.add(new JLabel(trans.get("MotorCfg.lbl.Currentmotor")), "shrink");
motorLabel = new JLabel();
motorLabel.setFont(motorLabel.getFont().deriveFont(Font.BOLD));
updateFields();
panel.add(motorLabel, "wrap unrel");
// Overhang
//// Motor overhang:
panel.add(new JLabel(trans.get("MotorCfg.lbl.Motoroverhang")));
DoubleModel dm = new DoubleModel(motorMount, "MotorOverhang", UnitGroup.UNITS_LENGTH);
JSpinner spin = new JSpinner(dm.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin));
panel.add(spin, "span, split, width :65lp:");
panel.add(new UnitSelector(dm), "width :30lp:");
panel.add(new BasicSlider(dm.getSliderModel(-0.02, 0.06)), "w 100lp, wrap unrel");
// Select ignition event
//// Ignition at:
panel.add(new JLabel(trans.get("MotorCfg.lbl.Ignitionat") + " " + CommonStrings.dagger), "");
IgnitionConfiguration ignitionConfig = mount.getIgnitionConfiguration().getDefault();
combo = new JComboBox(new EnumModel<IgnitionConfiguration.IgnitionEvent>(ignitionConfig, "IgnitionEvent"));
panel.add(combo, "growx, wrap");
// ... and delay
//// plus
panel.add(new JLabel(trans.get("MotorCfg.lbl.plus")), "gap indent, skip 1, span, split");
dm = new DoubleModel(ignitionConfig, "IgnitionDelay", 0);
spin = new JSpinner(dm.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin, 3));
panel.add(spin, "gap rel rel");
//// seconds
panel.add(new JLabel(trans.get("MotorCfg.lbl.seconds")), "wrap unrel");
panel.add(new StyledLabel(CommonStrings.override_description, -1), "spanx, wrap para");
// Check stage count
RocketComponent c = (RocketComponent) mount;
c = c.getRocket();
int stages = c.getChildCount();
if (stages == 1) {
//// The current design has only one stage.
//// Stages can be added by clicking \"New stage\".
panel.add(new StyledLabel(trans.get("MotorCfg.lbl.longA1") + " " +
trans.get("MotorCfg.lbl.longA2"), -1),
"spanx, wrap para");
} else {
//// The current design has
//// stages.
panel.add(new StyledLabel(trans.get("MotorCfg.lbl.longB1") + " " + stages + " " +
trans.get("MotorCfg.lbl.longB2"), -1),
"spanx, wrap para");
}
// Select etc. buttons
//// Select motor
button = new JButton(trans.get("MotorCfg.but.Selectmotor"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String id = configuration.getFlightConfigurationID();
MotorChooserDialog dialog = new MotorChooserDialog(mount.getMotor(id),
mount.getMotorDelay(id), mount.getMotorMountDiameter(),
SwingUtilities.getWindowAncestor(MotorConfig.this));
dialog.setVisible(true);
Motor m = dialog.getSelectedMotor();
double d = dialog.getSelectedDelay();
if (m != null) {
if (id == null) {
id = rocket.newFlightConfigurationID();
configuration.setFlightConfigurationID(id);
}
MotorConfiguration config = new MotorConfiguration();
config.setMotor(m);
config.setEjectionDelay(d);
mount.getMotorConfiguration().set(id, config);
}
updateFields();
}
});
panel.add(button, "span, split, growx");
//// Remove motor
button = new JButton(trans.get("MotorCfg.but.Removemotor"));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mount.getMotorConfiguration().resetDefault(configuration.getFlightConfigurationID());
updateFields();
}
});
panel.add(button, "growx, wrap");
// Set enabled status
setDeepEnabled(panel, motorMount.isMotorMount());
check.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
setDeepEnabled(panel, mount.isMotorMount());
}
});
}
public void updateFields() {
String id = configuration.getFlightConfigurationID();
Motor m = mount.getMotor(id);
if (m == null) {
//// None
motorLabel.setText(trans.get("MotorCfg.lbl.motorLabel"));
} else {
String str = "";
if (m instanceof ThrustCurveMotor)
str = ((ThrustCurveMotor) m).getManufacturer() + " ";
str += m.getDesignation(mount.getMotorDelay(id));
motorLabel.setText(str);
}
}
private static void setDeepEnabled(Component component, boolean enabled) {
component.setEnabled(enabled);
if (component instanceof Container) {
for (Component c : ((Container) component).getComponents()) {
setDeepEnabled(c, enabled);
}
}
}
}

View File

@ -1,34 +0,0 @@
package net.sf.openrocket.gui.configdialog;
import javax.swing.JPanel;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
public class ThicknessRingComponentConfig extends RingComponentConfig {
private static final Translator trans = Application.getTranslator();
public ThicknessRingComponentConfig(OpenRocketDocument d, RocketComponent c) {
super(d, c);
JPanel tab;
//// Outer diameter:
//// Inner diameter:
//// Wall thickness:
//// Length:
tab = generalTab(trans.get("ThicknessRingCompCfg.tab.Outerdiam"),
trans.get("ThicknessRingCompCfg.tab.Innerdiam"),
trans.get("ThicknessRingCompCfg.tab.Wallthickness"), trans.get("ThicknessRingCompCfg.tab.Length"));
//// General and General properties
tabbedPane.insertTab(trans.get("ThicknessRingCompCfg.tab.General"), null, tab,
trans.get("ThicknessRingCompCfg.tab.Generalprop"), 0);
tabbedPane.setSelectedIndex(0);
}
}

View File

@ -1,318 +0,0 @@
package net.sf.openrocket.gui.dialogs.flightconfiguration;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.gui.components.DescriptionArea;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.components.StyledLabel.Style;
import net.sf.openrocket.gui.dialogs.motor.MotorChooserDialog;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.motor.Motor;
import net.sf.openrocket.rocketcomponent.MotorConfiguration;
import net.sf.openrocket.rocketcomponent.MotorMount;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
public class MotorConfigurationPanel extends JPanel {
private static final Translator trans = Application.getTranslator();
private final FlightConfigurationDialog flightConfigurationDialog;
private final Rocket rocket;
private final JTable configurationTable;
private final MotorConfigurationTableModel configurationTableModel;
private final JButton selectMotorButton, removeMotorButton, selectIgnitionButton, resetIgnitionButton;
MotorConfigurationPanel(FlightConfigurationDialog flightConfigurationDialog, Rocket rocket) {
super(new MigLayout("fill"));
this.flightConfigurationDialog = flightConfigurationDialog;
this.rocket = rocket;
DescriptionArea desc = new DescriptionArea(trans.get("description"), 3, -1);
this.add(desc, "spanx, growx, wrap para");
//// Motor mount selection
JLabel label = new StyledLabel(trans.get("lbl.motorMounts"), Style.BOLD);
this.add(label, "");
//// Motor selection
label = new StyledLabel(trans.get("lbl.motorConfiguration"), Style.BOLD);
this.add(label, "wrap rel");
//// Motor Mount selection
JTable table = new JTable(new MotorMountTableModel(this, rocket));
table.setTableHeader(null);
table.setShowVerticalLines(false);
table.setRowSelectionAllowed(false);
table.setColumnSelectionAllowed(false);
TableColumnModel columnModel = table.getColumnModel();
TableColumn col0 = columnModel.getColumn(0);
int w = table.getRowHeight() + 2;
col0.setMinWidth(w);
col0.setPreferredWidth(w);
col0.setMaxWidth(w);
table.addMouseListener(new GUIUtil.BooleanTableClickListener(table));
JScrollPane scroll = new JScrollPane(table);
this.add(scroll, "w 200lp, h 150lp, grow");
//// Motor selection table.
configurationTableModel = new MotorConfigurationTableModel(rocket);
configurationTable = new JTable(configurationTableModel);
configurationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
configurationTable.setRowSelectionAllowed(true);
configurationTable.setDefaultRenderer(Object.class, new MotorTableCellRenderer());
configurationTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
updateButtonState();
int selectedColumn = configurationTable.getSelectedColumn();
if (e.getClickCount() == 2) {
if (selectedColumn == 2) {
// user double clicked in ignition column
selectIgnition();
} else {
// Double-click edits motor
selectMotor();
}
}
}
});
scroll = new JScrollPane(configurationTable);
this.add(scroll, "w 500lp, h 150lp, grow, wrap");
//// Select motor
selectMotorButton = new JButton(trans.get("MotorConfigurationPanel.btn.selectMotor"));
selectMotorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectMotor();
}
});
this.add(selectMotorButton, "skip, split, sizegroup button");
//// Remove motor button
removeMotorButton = new JButton(trans.get("MotorConfigurationPanel.btn.removeMotor"));
removeMotorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeMotor();
}
});
this.add(removeMotorButton, "sizegroup button");
//// Select Ignition button
selectIgnitionButton = new JButton(trans.get("MotorConfigurationPanel.btn.selectIgnition"));
selectIgnitionButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectIgnition();
}
});
this.add(selectIgnitionButton, "sizegroup button");
//// Reset Ignition button
resetIgnitionButton = new JButton(trans.get("MotorConfigurationPanel.btn.resetIgnition"));
resetIgnitionButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
resetIgnition();
}
});
this.add(resetIgnitionButton, "sizegroup button, wrap");
}
public void fireTableDataChanged() {
int selected = configurationTable.getSelectedRow();
configurationTableModel.fireTableDataChanged();
if (selected >= 0) {
selected = Math.min(selected, configurationTable.getRowCount() - 1);
configurationTable.getSelectionModel().setSelectionInterval(selected, selected);
}
updateButtonState();
}
private void updateButtonState() {
String currentID = rocket.getDefaultConfiguration().getFlightConfigurationID();
MotorMount currentMount = getCurrentMount();
selectMotorButton.setEnabled(currentMount != null && currentID != null);
removeMotorButton.setEnabled(currentMount != null && currentID != null);
selectIgnitionButton.setEnabled(currentMount != null && currentID != null);
resetIgnitionButton.setEnabled(currentMount != null && currentID != null);
}
private MotorMount getCurrentMount() {
int row = configurationTable.getSelectedRow();
if (row < 0) {
return null;
}
return getMount(row);
}
private MotorMount getMount(int row) {
int count = 0;
for (RocketComponent c : rocket) {
if (c instanceof MotorMount) {
MotorMount mount = (MotorMount) c;
if (mount.isMotorMount()) {
count++;
}
if (count > row) {
return mount;
}
}
}
throw new IndexOutOfBoundsException("Invalid row, row=" + row + " count=" + count);
}
private void selectMotor() {
String id = rocket.getDefaultConfiguration().getFlightConfigurationID();
MotorMount mount = getCurrentMount();
if (id == null || mount == null)
return;
MotorConfiguration config = mount.getMotorConfiguration().get(id);
MotorChooserDialog dialog = new MotorChooserDialog(
config.getMotor(),
config.getEjectionDelay(),
mount.getMotorMountDiameter(),
flightConfigurationDialog);
dialog.setVisible(true);
Motor m = dialog.getSelectedMotor();
double d = dialog.getSelectedDelay();
if (m != null) {
config = new MotorConfiguration();
config.setMotor(m);
config.setEjectionDelay(d);
mount.getMotorConfiguration().set(id, config);
}
fireTableDataChanged();
}
private void removeMotor() {
String id = rocket.getDefaultConfiguration().getFlightConfigurationID();
MotorMount mount = getCurrentMount();
if (id == null || mount == null)
return;
mount.getMotorConfiguration().resetDefault(id);
fireTableDataChanged();
}
private void selectIgnition() {
String currentID = rocket.getDefaultConfiguration().getFlightConfigurationID();
MotorMount currentMount = getCurrentMount();
if (currentID == null || currentMount == null)
return;
IgnitionSelectionDialog dialog = new IgnitionSelectionDialog(
this.flightConfigurationDialog,
rocket,
currentMount);
dialog.setVisible(true);
fireTableDataChanged();
}
private void resetIgnition() {
String currentID = rocket.getDefaultConfiguration().getFlightConfigurationID();
MotorMount currentMount = getCurrentMount();
if (currentID == null || currentMount == null)
return;
currentMount.getIgnitionConfiguration().resetDefault(currentID);
fireTableDataChanged();
}
private class MotorTableCellRenderer extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (!(c instanceof JLabel)) {
return c;
}
JLabel label = (JLabel) c;
MotorMount mount = getMount(row);
String id = rocket.getDefaultConfiguration().getFlightConfigurationID();
switch (column) {
case 0:
regular(label);
break;
case 1:
if (mount.getMotorConfiguration().get(id).getMotor() != null) {
regular(label);
} else {
shaded(label);
}
break;
case 2:
if (mount.getIgnitionConfiguration().isDefault(id)) {
shaded(label);
} else {
regular(label);
}
break;
}
return label;
}
private void shaded(JLabel label) {
GUIUtil.changeFontStyle(label, Font.ITALIC);
label.setForeground(Color.GRAY);
}
private void regular(JLabel label) {
GUIUtil.changeFontStyle(label, Font.PLAIN);
label.setForeground(Color.BLACK);
}
}
}

View File

@ -1,146 +0,0 @@
package net.sf.openrocket.gui.dialogs.flightconfiguration;
import javax.swing.table.AbstractTableModel;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.motor.Motor;
import net.sf.openrocket.rocketcomponent.IgnitionConfiguration;
import net.sf.openrocket.rocketcomponent.MotorConfiguration;
import net.sf.openrocket.rocketcomponent.MotorMount;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup;
import net.sf.openrocket.util.Chars;
import net.sf.openrocket.util.Coordinate;
/**
* The table model for selecting and editing the motor configurations.
*/
class MotorConfigurationTableModel extends AbstractTableModel {
private static final Translator trans = Application.getTranslator();
private static final String NONE = trans.get("edtmotorconfdlg.tbl.None");
private static final String MOTOR_MOUNT = trans.get("edtmotorconfdlg.tbl.Mountheader");
private static final String MOTOR = trans.get("edtmotorconfdlg.tbl.Motorheader");
private static final String IGNITION = trans.get("edtmotorconfdlg.tbl.Ignitionheader");
private final Rocket rocket;
public MotorConfigurationTableModel(Rocket rocket) {
this.rocket = rocket;
}
@Override
public int getColumnCount() {
return 3;
}
@Override
public int getRowCount() {
int count = 0;
for (RocketComponent c : rocket) {
if (c instanceof MotorMount && ((MotorMount) c).isMotorMount()) {
count++;
}
}
return count;
}
@Override
public Object getValueAt(int row, int column) {
switch (column) {
case 0: {
MotorMount mount = findMount(row);
String name = mount.toString();
int count = getMountMultiplicity(mount);
if (count > 1) {
name = name + " (" + Chars.TIMES + count + ")";
}
return name;
}
case 1: {
MotorMount mount = findMount(row);
String id = rocket.getDefaultConfiguration().getFlightConfigurationID();
MotorConfiguration config = mount.getMotorConfiguration().get(id);
Motor motor = config.getMotor();
if (motor == null)
return NONE;
String str = motor.getDesignation(config.getEjectionDelay());
int count = getMountMultiplicity(mount);
if (count > 1) {
str = "" + count + Chars.TIMES + " " + str;
}
return str;
}
case 2: {
return getIgnitionEventString(row);
}
default:
throw new IndexOutOfBoundsException("column=" + column);
}
}
@Override
public String getColumnName(int column) {
switch (column) {
case 0:
return MOTOR_MOUNT;
case 1:
return MOTOR;
case 2:
return IGNITION;
default:
throw new IndexOutOfBoundsException("column=" + column);
}
}
private MotorMount findMount(int row) {
int count = row;
for (RocketComponent c : rocket) {
if (c instanceof MotorMount && ((MotorMount) c).isMotorMount()) {
count--;
if (count < 0) {
return (MotorMount) c;
}
}
}
throw new IndexOutOfBoundsException("Requesting row=" + row + " but only " + getRowCount() + " rows exist");
}
private int getMountMultiplicity(MotorMount mount) {
RocketComponent c = (RocketComponent) mount;
return c.toAbsolute(Coordinate.NUL).length;
}
private String getIgnitionEventString(int row) {
String id = rocket.getDefaultConfiguration().getFlightConfigurationID();
MotorMount mount = findMount(row);
IgnitionConfiguration ignitionConfig = mount.getIgnitionConfiguration().get(id);
IgnitionConfiguration.IgnitionEvent ignitionEvent = ignitionConfig.getIgnitionEvent();
Double ignitionDelay = ignitionConfig.getIgnitionDelay();
boolean isDefault = mount.getIgnitionConfiguration().isDefault(id);
String str = trans.get("MotorMount.IgnitionEvent.short." + ignitionEvent.name());
if (ignitionDelay > 0.001) {
str = str + " + " + UnitGroup.UNITS_SHORT_TIME.toStringUnit(ignitionDelay);
}
if (isDefault) {
String def = trans.get("table.ignition.default");
str = def.replace("{0}", str);
}
return str;
}
}

View File

@ -1,264 +0,0 @@
package net.sf.openrocket.gui.dialogs.flightconfiguration;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Iterator;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.DeploymentConfiguration;
import net.sf.openrocket.rocketcomponent.DeploymentConfiguration.DeployEvent;
import net.sf.openrocket.rocketcomponent.RecoveryDevice;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup;
public class RecoveryConfigurationPanel extends JPanel {
private Translator trans = Application.getTranslator();
private final FlightConfigurationDialog flightConfigurationDialog;
private final Rocket rocket;
private final RecoveryTableModel recoveryTableModel;
private final JTable recoveryTable;
private final JButton selectDeploymentButton;
private final JButton resetDeploymentButton;
RecoveryConfigurationPanel(FlightConfigurationDialog flightConfigurationDialog, Rocket rocket) {
super(new MigLayout("fill"));
this.flightConfigurationDialog = flightConfigurationDialog;
this.rocket = rocket;
//// Recovery selection
recoveryTableModel = new RecoveryTableModel();
recoveryTable = new JTable(recoveryTableModel);
recoveryTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
recoveryTable.setRowSelectionAllowed(true);
recoveryTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
updateButtonState();
if (e.getClickCount() == 2) {
// Double-click edits
selectDeployment();
}
}
});
recoveryTable.setDefaultRenderer(Object.class, new RecoveryTableCellRenderer());
JScrollPane scroll = new JScrollPane(recoveryTable);
this.add(scroll, "span, grow, wrap");
//// Select deployment
selectDeploymentButton = new JButton(trans.get("edtmotorconfdlg.but.Selectdeployment"));
selectDeploymentButton.setEnabled(false);
selectDeploymentButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectDeployment();
}
});
this.add(selectDeploymentButton, "skip, split, sizegroup button");
//// Reset deployment
resetDeploymentButton = new JButton(trans.get("edtmotorconfdlg.but.Resetdeployment"));
resetDeploymentButton.setEnabled(false);
resetDeploymentButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
resetDeployment();
}
});
this.add(resetDeploymentButton, "sizegroup button, wrap");
}
public void fireTableDataChanged() {
int selected = recoveryTable.getSelectedRow();
recoveryTableModel.fireTableDataChanged();
if (selected >= 0) {
selected = Math.min(selected, recoveryTable.getRowCount() - 1);
recoveryTable.getSelectionModel().setSelectionInterval(selected, selected);
}
updateButtonState();
}
private void selectDeployment() {
RecoveryDevice c = getSelectedComponent();
if (c == null) {
return;
}
JDialog d = new DeploymentSelectionDialog(flightConfigurationDialog, rocket, c);
d.setVisible(true);
fireTableDataChanged();
}
private void resetDeployment() {
RecoveryDevice c = getSelectedComponent();
if (c == null) {
return;
}
String id = rocket.getDefaultConfiguration().getFlightConfigurationID();
c.getDeploymentConfiguration().resetDefault(id);
fireTableDataChanged();
}
public void updateButtonState() {
boolean componentSelected = getSelectedComponent() != null;
selectDeploymentButton.setEnabled(componentSelected);
resetDeploymentButton.setEnabled(componentSelected);
}
private RecoveryDevice getSelectedComponent() {
int row = recoveryTable.getSelectedRow();
return findRecoveryDevice(row);
}
private RecoveryDevice findRecoveryDevice(int count) {
RecoveryDevice d = null;
Iterator<RocketComponent> it = rocket.iterator();
while (it.hasNext() && count >= 0) {
RocketComponent c = it.next();
if (c instanceof RecoveryDevice) {
d = (RecoveryDevice) c;
count--;
}
}
return d;
}
private class RecoveryTableModel extends AbstractTableModel {
@Override
public int getRowCount() {
int count = 0;
Iterator<RocketComponent> it = rocket.iterator();
while (it.hasNext()) {
RocketComponent c = it.next();
if (c instanceof RecoveryDevice) {
count++;
}
}
return count;
}
@Override
public int getColumnCount() {
return 2;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
RecoveryDevice d = findRecoveryDevice(rowIndex);
switch (columnIndex) {
case 0:
return d.getName();
case 1:
String id = rocket.getDefaultConfiguration().getFlightConfigurationID();
DeploymentConfiguration config = d.getDeploymentConfiguration().get(id);
boolean isDefault = d.getDeploymentConfiguration().isDefault(id);
String str;
str = trans.get("RecoveryDevice.DeployEvent.short." + config.getDeployEvent().name());
if (config.getDeployEvent() == DeployEvent.ALTITUDE) {
str += " " + UnitGroup.UNITS_DISTANCE.toStringUnit(config.getDeployAltitude());
}
if (config.getDeployDelay() > 0.001) {
str += " + " + UnitGroup.UNITS_SHORT_TIME.toStringUnit(config.getDeployDelay());
}
if (isDefault) {
String def = trans.get("table.deployment.default");
str = def.replace("{0}", str);
}
return str;
default:
throw new IndexOutOfBoundsException("columnIndex=" + columnIndex);
}
}
@Override
public String getColumnName(int column) {
switch (column) {
case 0:
return trans.get("edtmotorconfdlg.tbl.Recoveryheader");
case 1:
return trans.get("edtmotorconfdlg.tbl.Deploymentheader");
default:
return "";
}
}
}
private class RecoveryTableCellRenderer extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (!(c instanceof JLabel)) {
return c;
}
JLabel label = (JLabel) c;
RecoveryDevice recoveryDevice = findRecoveryDevice(row);
String id = rocket.getDefaultConfiguration().getFlightConfigurationID();
switch (column) {
case 0:
regular(label);
break;
case 1:
if (recoveryDevice.getDeploymentConfiguration().isDefault(id)) {
shaded(label);
} else {
regular(label);
}
break;
}
return label;
}
private void shaded(JLabel label) {
GUIUtil.changeFontStyle(label, Font.ITALIC);
label.setForeground(Color.GRAY);
}
private void regular(JLabel label) {
GUIUtil.changeFontStyle(label, Font.PLAIN);
label.setForeground(Color.BLACK);
}
}
}

View File

@ -1,259 +0,0 @@
package net.sf.openrocket.gui.dialogs.flightconfiguration;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Iterator;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.Stage;
import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup;
public class SeparationConfigurationPanel extends JPanel {
private static final Translator trans = Application.getTranslator();
private final FlightConfigurationDialog flightConfigurationDialog;
private final Rocket rocket;
private final Stage[] stages;
private final JTable separationTable;
private final SeparationTableModel separationTableModel;
private final JButton selectSeparationButton;
private final JButton resetDeploymentButton;
SeparationConfigurationPanel(FlightConfigurationDialog flightConfigurationDialog, Rocket rocket) {
super(new MigLayout("fill"));
this.flightConfigurationDialog = flightConfigurationDialog;
this.rocket = rocket;
int stageCount = rocket.getStageCount() - 1;
stages = new Stage[stageCount];
Iterator<RocketComponent> it = rocket.iterator();
{
int stageIndex = -1;
while (it.hasNext()) {
RocketComponent c = it.next();
if (c instanceof Stage) {
if (stageIndex >= 0) {
stages[stageIndex] = (Stage) c;
}
stageIndex++;
}
}
}
//// Recovery selection
separationTableModel = new SeparationTableModel();
separationTable = new JTable(separationTableModel);
separationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
separationTable.setRowSelectionAllowed(true);
separationTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
updateButtonState();
if (e.getClickCount() == 2) {
// Double-click edits
selectDeployment();
}
}
});
separationTable.setDefaultRenderer(Object.class, new SeparationTableCellRenderer());
JScrollPane scroll = new JScrollPane(separationTable);
this.add(scroll, "span, grow, wrap");
//// Select deployment
selectSeparationButton = new JButton(trans.get("edtmotorconfdlg.but.Selectseparation"));
selectSeparationButton.setEnabled(false);
selectSeparationButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectDeployment();
}
});
this.add(selectSeparationButton, "skip, split, sizegroup button");
//// Reset deployment
resetDeploymentButton = new JButton(trans.get("edtmotorconfdlg.but.Resetseparation"));
resetDeploymentButton.setEnabled(false);
resetDeploymentButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
resetDeployment();
}
});
this.add(resetDeploymentButton, "sizegroup button, wrap");
}
public void fireTableDataChanged() {
int selected = separationTable.getSelectedRow();
separationTableModel.fireTableDataChanged();
if (selected >= 0) {
selected = Math.min(selected, separationTable.getRowCount() - 1);
separationTable.getSelectionModel().setSelectionInterval(selected, selected);
}
updateButtonState();
}
private Stage getSelectedStage() {
int row = separationTable.getSelectedRow();
return getStage(row);
}
private Stage getStage(int row) {
if (row >= 0 && row < stages.length) {
return stages[row];
}
return null;
}
private void selectDeployment() {
Stage stage = getSelectedStage();
if (stage == null) {
return;
}
JDialog d = new SeparationSelectionDialog(flightConfigurationDialog, rocket, stage);
d.setVisible(true);
fireTableDataChanged();
}
private void resetDeployment() {
Stage stage = getSelectedStage();
if (stage == null) {
return;
}
String id = rocket.getDefaultConfiguration().getFlightConfigurationID();
stage.getStageSeparationConfiguration().resetDefault(id);
fireTableDataChanged();
}
public void updateButtonState() {
boolean componentSelected = getSelectedStage() != null;
selectSeparationButton.setEnabled(componentSelected);
resetDeploymentButton.setEnabled(componentSelected);
}
private class SeparationTableModel extends AbstractTableModel {
@Override
public int getRowCount() {
return stages.length;
}
@Override
public int getColumnCount() {
return 2;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
Stage d = SeparationConfigurationPanel.this.stages[rowIndex];
switch (columnIndex) {
case 0:
return d.getName();
case 1:
String id = rocket.getDefaultConfiguration().getFlightConfigurationID();
StageSeparationConfiguration config = d.getStageSeparationConfiguration().get(id);
String str;
str = config.getSeparationEvent().toString();
if (config.getSeparationDelay() > 0.001) {
str += " + " + UnitGroup.UNITS_SHORT_TIME.toStringUnit(config.getSeparationDelay());
}
if (d.getStageSeparationConfiguration().isDefault(id)) {
String def = trans.get("SeparationConfigurationPanel.table.separation.default");
str = def.replace("{0}", str);
}
return str;
default:
throw new IndexOutOfBoundsException("column=" + columnIndex);
}
}
@Override
public String getColumnName(int column) {
switch (column) {
case 0:
return trans.get("edtmotorconfdlg.tbl.Stageheader");
case 1:
return trans.get("edtmotorconfdlg.tbl.Separationheader");
default:
return "";
}
}
}
private class SeparationTableCellRenderer extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (!(c instanceof JLabel)) {
return c;
}
JLabel label = (JLabel) c;
Stage stage = getStage(row);
String id = rocket.getDefaultConfiguration().getFlightConfigurationID();
switch (column) {
case 0:
regular(label);
break;
case 1:
if (stage.getStageSeparationConfiguration().isDefault(id)) {
shaded(label);
} else {
regular(label);
}
break;
}
return label;
}
private void shaded(JLabel label) {
GUIUtil.changeFontStyle(label, Font.ITALIC);
label.setForeground(Color.GRAY);
}
private void regular(JLabel label) {
GUIUtil.changeFontStyle(label, Font.PLAIN);
label.setForeground(Color.BLACK);
}
}
}

View File

@ -1,13 +1,5 @@
package net.sf.openrocket.preset.loader;
import au.com.bytecode.opencsv.CSVReader;
import net.sf.openrocket.gui.print.PrintUnit;
import net.sf.openrocket.preset.TypedPropertyMap;
import net.sf.openrocket.unit.Unit;
import net.sf.openrocket.unit.UnitGroup;
import net.sf.openrocket.util.ArrayList;
import net.sf.openrocket.util.StringUtil;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@ -17,19 +9,26 @@ import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.List;
import net.sf.openrocket.preset.TypedPropertyMap;
import net.sf.openrocket.unit.Unit;
import net.sf.openrocket.unit.UnitGroup;
import net.sf.openrocket.util.ArrayList;
import net.sf.openrocket.util.StringUtil;
import au.com.bytecode.opencsv.CSVReader;
/**
* Primary entry point for parsing component CSV files that are in Rocksim format.
*/
public abstract class RocksimComponentFileLoader {
private static final PrintStream LOGGER = System.err;
private static final PrintStream LOGGER = System.err;
private String basePath = "";
private File dir;
protected List<RocksimComponentFileColumnParser> fileColumns = new ArrayList<RocksimComponentFileColumnParser>();
/**
* Constructor.
*
@ -39,7 +38,7 @@ public abstract class RocksimComponentFileLoader {
dir = theBasePathToLoadFrom;
basePath = dir.getAbsolutePath();
}
/**
* Constructor.
*
@ -49,17 +48,17 @@ public abstract class RocksimComponentFileLoader {
dir = new File(basePath);
basePath = theBasePathToLoadFrom;
}
protected abstract RocksimComponentFileType getFileType();
public void load() {
try {
load(getFileType());
} catch (FileNotFoundException fex ) {
LOGGER.println( fex.getLocalizedMessage() );
load(getFileType());
} catch (FileNotFoundException fex) {
LOGGER.println(fex.getLocalizedMessage());
}
}
/**
* Read a comma separated component file and return the parsed contents as a list of string arrays. Not for
* production use - just here for smoke testing.
@ -83,7 +82,7 @@ public abstract class RocksimComponentFileLoader {
FileInputStream fis = new FileInputStream(new File(dir, type.getDefaultFileName()));
load(fis);
}
/**
* Read a comma separated component file and return the parsed contents as a list of string arrays.
*
@ -97,7 +96,7 @@ public abstract class RocksimComponentFileLoader {
private void load(File file) throws FileNotFoundException {
load(new FileInputStream(file));
}
/**
* Read a comma separated component file and return the parsed contents as a list of string arrays.
*
@ -114,13 +113,13 @@ public abstract class RocksimComponentFileLoader {
InputStreamReader r = null;
try {
r = new InputStreamReader(is);
// Create the CSV reader. Use comma separator.
CSVReader reader = new CSVReader(r, ',', '\'', '\\');
//Read and throw away the header row.
parseHeaders(reader.readNext());
String[] data = null;
while ((data = reader.readNext()) != null) {
// detect empty lines and skip:
@ -134,41 +133,38 @@ public abstract class RocksimComponentFileLoader {
}
//Read the rest of the file as data rows.
return;
}
catch (IOException e) {
}
finally {
} catch (IOException e) {
} finally {
if (r != null) {
try {
r.close();
}
catch (IOException e) {
} catch (IOException e) {
}
}
}
}
protected void parseHeaders(String[] headers) {
for (RocksimComponentFileColumnParser column : fileColumns) {
column.configure(headers);
}
}
protected void parseData(String[] data) {
if (data == null || data.length == 0) {
return;
}
TypedPropertyMap props = new TypedPropertyMap();
preProcess(data);
for (RocksimComponentFileColumnParser column : fileColumns) {
column.parse(data, props);
}
postProcess(props);
}
protected void preProcess(String[] data) {
for (int i = 0; i < data.length; i++) {
String d = data[i];
@ -177,13 +173,13 @@ public abstract class RocksimComponentFileLoader {
}
d = d.trim();
d = stripAll(d, '"');
data[i] = d;
}
}
protected abstract void postProcess(TypedPropertyMap props);
/**
* Rocksim CSV units are either inches or mm. A value of 0 or "in." indicate inches. A value of 1 or "mm" indicate
* millimeters.
@ -196,7 +192,7 @@ public abstract class RocksimComponentFileLoader {
String tmp = units.trim().toLowerCase();
return "0".equals(tmp) || tmp.startsWith("in");
}
/**
* Convert inches or millimeters to meters.
*
@ -207,13 +203,13 @@ public abstract class RocksimComponentFileLoader {
*/
protected static double convertLength(String units, double value) {
if (isInches(units)) {
return PrintUnit.INCHES.toMeters(value);
return UnitGroup.UNITS_LENGTH.getUnit("in").fromUnit(value);
}
else {
return PrintUnit.MILLIMETERS.toMeters(value);
return UnitGroup.UNITS_LENGTH.getUnit("mm").fromUnit(value);
}
}
protected static double convertMass(String units, double value) {
if ("oz".equals(units)) {
Unit u = UnitGroup.UNITS_MASS.getUnit(2);
@ -221,7 +217,7 @@ public abstract class RocksimComponentFileLoader {
}
return value;
}
/**
* Remove all occurrences of the given character. Note: this is done because some manufacturers embed double quotes
* in their descriptions or material names. Those are stripped away because they cause all sorts of matching/lookup
@ -242,7 +238,7 @@ public abstract class RocksimComponentFileLoader {
}
return sb.toString();
}
/**
* Convert all words in a given string to Camel Case (first letter capitalized). Words are assumed to be separated
* by a space. Note: this is done because some manufacturers define their material name in Camel Case but the
@ -268,7 +264,7 @@ public abstract class RocksimComponentFileLoader {
return target;
}
}
}
//Errata:

View File

@ -11,7 +11,7 @@ import net.sf.openrocket.util.ChangeSource;
*
* @param <E> the parameter type
*/
public interface FlightConfiguration<E extends ChangeSource> extends FlightConfigurableComponent {
public interface FlightConfiguration<E extends ChangeSource> extends FlightConfigurableComponent, Iterable<E> {
/**
* Return the default parameter value for this FlightConfiguration.

View File

@ -2,6 +2,7 @@ package net.sf.openrocket.rocketcomponent;
import java.util.EventObject;
import java.util.HashMap;
import java.util.Iterator;
import net.sf.openrocket.util.StateChangeListener;
import net.sf.openrocket.util.Utils;
@ -79,6 +80,10 @@ class FlightConfigurationImpl<E extends FlightConfigurableParameter<E>> implemen
fireEvent();
}
@Override
public Iterator<E> iterator() {
return map.values().iterator();
}
@Override

View File

@ -309,6 +309,25 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
return copy;
}
/**
* For a given coordinate that represents one tube in a cluster, create an instance of that tube. Must be called
* once for each tube in the cluster.
*
* @param coord the coordinate of the clustered tube to create
* @param splitName the name of the individual tube
* @param theInnerTube the 'parent' from which this tube will be created.
*
* @return an instance of an inner tube that represents ONE of the clustered tubes in the cluster represented
* by <code>theInnerTube</code>
*/
public static InnerTube makeIndividualClusterComponent(Coordinate coord, String splitName, RocketComponent theInnerTube) {
InnerTube copy = (InnerTube) theInnerTube.copy();
copy.setClusterConfiguration(ClusterConfiguration.SINGLE);
copy.setClusterRotation(0.0);
copy.setClusterScale(1.0);
copy.setRadialShift(coord.y, coord.z);
copy.setName(splitName);
return copy;
}
}

View File

@ -545,7 +545,14 @@ public class Rocket extends RocketComponent {
checkState();
if (id == null)
return;
// Get current configuration:
String currentId = getDefaultConfiguration().getFlightConfigurationID();
// If we're removing the current configuration, we need to switch to a different one first.
if (currentId != null && currentId.equals(id)) {
getDefaultConfiguration().setFlightConfigurationID(null);
}
flightConfigurationIDs.remove(id);
// FIXME - remove corresponding simulations?
fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
}

View File

@ -103,6 +103,10 @@ public abstract class Unit {
}
val = roundForDecimalFormat(val);
// Check for approximate integer
if (Math.abs(val - Math.floor(val)) < 0.0001) {
return intFormat.format(val);
}
return decFormat.format(val);
}

View File

@ -0,0 +1,155 @@
package net.sf.openrocket;
import java.util.Collections;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import net.sf.openrocket.formatting.RocketDescriptor;
import net.sf.openrocket.formatting.RocketDescriptorImpl;
import net.sf.openrocket.l10n.DebugTranslator;
import net.sf.openrocket.l10n.ResourceBundleTranslator;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.preset.ComponentPreset;
import net.sf.openrocket.preset.ComponentPreset.Type;
import net.sf.openrocket.startup.Preferences;
import com.google.inject.AbstractModule;
import com.google.inject.Provider;
public class ServicesForTesting extends AbstractModule {
@Override
protected void configure() {
bind(Preferences.class).to(PreferencesForTesting.class);
bind(Translator.class).toProvider(TranslatorProviderForTesting.class);
bind(RocketDescriptor.class).to(RocketDescriptorImpl.class);
}
public static class TranslatorProviderForTesting implements Provider<Translator> {
private AtomicReference<Translator> translator = new AtomicReference<Translator>();
@Override
public Translator get() {
Translator oldTranslator = translator.get();
if (oldTranslator != null) {
return oldTranslator;
}
Locale.setDefault(Locale.US);
// Setup the translator
Translator newTranslator;
newTranslator = new ResourceBundleTranslator("l10n.messages");
if (Locale.getDefault().getLanguage().equals("xx")) {
newTranslator = new DebugTranslator(newTranslator);
}
if (translator.compareAndSet(null, newTranslator)) {
return newTranslator;
} else {
return translator.get();
}
}
}
public static class PreferencesForTesting extends Preferences {
@Override
public boolean getBoolean(String key, boolean defaultValue) {
// TODO Auto-generated method stub
return false;
}
@Override
public void putBoolean(String key, boolean value) {
// TODO Auto-generated method stub
}
@Override
public int getInt(String key, int defaultValue) {
// TODO Auto-generated method stub
return 0;
}
@Override
public void putInt(String key, int value) {
// TODO Auto-generated method stub
}
@Override
public double getDouble(String key, double defaultValue) {
// TODO Auto-generated method stub
return 0;
}
@Override
public void putDouble(String key, double value) {
// TODO Auto-generated method stub
}
@Override
public String getString(String key, String defaultValue) {
// TODO Auto-generated method stub
return null;
}
@Override
public void putString(String key, String value) {
// TODO Auto-generated method stub
}
@Override
public String getString(String directory, String key, String defaultValue) {
// TODO Auto-generated method stub
return null;
}
@Override
public void putString(String directory, String key, String value) {
// TODO Auto-generated method stub
}
@Override
public void addUserMaterial(Material m) {
// TODO Auto-generated method stub
}
@Override
public Set<Material> getUserMaterials() {
return Collections.<Material> emptySet();
}
@Override
public void removeUserMaterial(Material m) {
// TODO Auto-generated method stub
}
@Override
public void setComponentFavorite(ComponentPreset preset, Type type, boolean favorite) {
// TODO Auto-generated method stub
}
@Override
public Set<String> getComponentFavorites(Type type) {
// TODO Auto-generated method stub
return null;
}
}
}

View File

@ -13,7 +13,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import net.sf.openrocket.IntegrationTest;
import net.sf.openrocket.ServicesForTesting;
import net.sf.openrocket.database.ComponentPresetDao;
import net.sf.openrocket.database.ComponentPresetDatabase;
import net.sf.openrocket.database.motor.MotorDatabase;
@ -30,7 +30,6 @@ import net.sf.openrocket.motor.ThrustCurveMotor;
import net.sf.openrocket.plugin.PluginModule;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.TestRockets;
import net.sf.openrocket.utils.CoreServicesModule;
import org.junit.After;
import org.junit.BeforeClass;
@ -50,7 +49,7 @@ public class OpenRocketSaverTest {
@BeforeClass
public static void setup() {
Module applicationModule = new CoreServicesModule();
Module applicationModule = new ServicesForTesting();
Module pluginModule = new PluginModule();
Module dbOverrides = new AbstractModule() {
@ -307,7 +306,7 @@ public class OpenRocketSaverTest {
private static ThrustCurveMotor readMotor() {
GeneralMotorLoader loader = new GeneralMotorLoader();
InputStream is = IntegrationTest.class.getResourceAsStream("Estes_A8.rse");
InputStream is = OpenRocketSaverTest.class.getResourceAsStream("/net/sf/openrocket/Estes_A8.rse");
assertNotNull("Problem in unit test, cannot find Estes_A8.rse", is);
try {
for (Motor m : loader.load(is, "Estes_A8.rse")) {

View File

@ -1,6 +1,6 @@
package net.sf.openrocket.plugin;
import net.sf.openrocket.utils.CoreServicesModule;
import net.sf.openrocket.ServicesForTesting;
import org.junit.Test;
@ -20,7 +20,7 @@ public class PluginTest {
@Test
public void testPluginModule() {
Module applicationModule = new CoreServicesModule();
Module applicationModule = new ServicesForTesting();
Injector injector = Guice.createInjector(applicationModule, new PluginModule());
PluginTester tester = injector.getInstance(PluginTester.class);

View File

@ -4,10 +4,9 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.awt.Color;
import java.util.Iterator;
import net.sf.openrocket.gui.util.ColorConversion;
import net.sf.openrocket.util.Color;
import net.sf.openrocket.util.Coordinate;
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
@ -41,7 +40,7 @@ public class ComponentCompareTest extends BaseTestCase {
ComponentCompare.assertDeepSimilarity(r1, r2, false);
r1.setColor(ColorConversion.fromAwtColor(Color.YELLOW));
r1.setColor(Color.BLACK);
try {
ComponentCompare.assertEquality(r1, r2);
fail();

View File

@ -3,16 +3,13 @@ package net.sf.openrocket.rocketcomponent;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.awt.Color;
import net.sf.openrocket.gui.util.ColorConversion;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.material.Material.Type;
import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
import net.sf.openrocket.rocketcomponent.FinSet.CrossSection;
import net.sf.openrocket.rocketcomponent.FinSet.TabRelativePosition;
import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
import net.sf.openrocket.util.Color;
import net.sf.openrocket.util.Coordinate;
import net.sf.openrocket.util.LineStyle;
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
@ -20,22 +17,22 @@ import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
import org.junit.Test;
public class FinSetTest extends BaseTestCase {
@Test
public void testTrapezoidCGComputation() {
{
// This is a simple square fin with sides of 1.0.
TrapezoidFinSet fins = new TrapezoidFinSet();
fins.setFinCount(1);
fins.setFinShape(1.0, 1.0, 0.0, 1.0, .005);
Coordinate coords = fins.getCG();
assertEquals(1.0, fins.getFinArea(), 0.001);
assertEquals(0.5, coords.x, 0.001);
assertEquals(0.5, coords.y, 0.001);
}
{
// This is a trapezoid. Height 1, root 1, tip 1/2 no sweep.
// It can be decomposed into a rectangle followed by a triangle
@ -46,18 +43,18 @@ public class FinSetTest extends BaseTestCase {
TrapezoidFinSet fins = new TrapezoidFinSet();
fins.setFinCount(1);
fins.setFinShape(1.0, 0.5, 0.0, 1.0, .005);
Coordinate coords = fins.getCG();
assertEquals(0.75, fins.getFinArea(), 0.001);
assertEquals(0.3889, coords.x, 0.001);
assertEquals(0.4444, coords.y, 0.001);
}
}
@Test
public void testFreeformCGComputation() throws Exception {
{
// This is a trapezoid. Height 1, root 1, tip 1/2 no sweep.
// It can be decomposed into a rectangle followed by a triangle
@ -68,10 +65,10 @@ public class FinSetTest extends BaseTestCase {
FreeformFinSet fins = new FreeformFinSet();
fins.setFinCount(1);
Coordinate[] points = new Coordinate[] {
new Coordinate(0,0),
new Coordinate(0,1),
new Coordinate(.5,1),
new Coordinate(1,0)
new Coordinate(0, 0),
new Coordinate(0, 1),
new Coordinate(.5, 1),
new Coordinate(1, 0)
};
fins.setPoints(points);
Coordinate coords = fins.getCG();
@ -79,20 +76,20 @@ public class FinSetTest extends BaseTestCase {
assertEquals(0.3889, coords.x, 0.001);
assertEquals(0.4444, coords.y, 0.001);
}
{
// This is the same trapezoid as previous free form, but it has
// some extra points along the lines.
FreeformFinSet fins = new FreeformFinSet();
fins.setFinCount(1);
Coordinate[] points = new Coordinate[] {
new Coordinate(0,0),
new Coordinate(0,.5),
new Coordinate(0,1),
new Coordinate(.25,1),
new Coordinate(.5,1),
new Coordinate(.75,.5),
new Coordinate(1,0)
new Coordinate(0, 0),
new Coordinate(0, .5),
new Coordinate(0, 1),
new Coordinate(.25, 1),
new Coordinate(.5, 1),
new Coordinate(.75, .5),
new Coordinate(1, 0)
};
fins.setPoints(points);
Coordinate coords = fins.getCG();
@ -100,7 +97,7 @@ public class FinSetTest extends BaseTestCase {
assertEquals(0.3889, coords.x, 0.001);
assertEquals(0.4444, coords.y, 0.001);
}
{
// This is the same trapezoid as previous free form, but it has
// some extra points which are very close to previous points.
@ -109,14 +106,14 @@ public class FinSetTest extends BaseTestCase {
FreeformFinSet fins = new FreeformFinSet();
fins.setFinCount(1);
Coordinate[] points = new Coordinate[] {
new Coordinate(0,0),
new Coordinate(0,1E-15),
new Coordinate(0,1),
new Coordinate(1E-15,1),
new Coordinate(.5,1),
new Coordinate(.5,1-1E-15),
new Coordinate(1,1E-15),
new Coordinate(1,0)
new Coordinate(0, 0),
new Coordinate(0, 1E-15),
new Coordinate(0, 1),
new Coordinate(1E-15, 1),
new Coordinate(.5, 1),
new Coordinate(.5, 1 - 1E-15),
new Coordinate(1, 1E-15),
new Coordinate(1, 0)
};
fins.setPoints(points);
Coordinate coords = fins.getCG();
@ -124,9 +121,9 @@ public class FinSetTest extends BaseTestCase {
assertEquals(0.3889, coords.x, 0.001);
assertEquals(0.4444, coords.y, 0.001);
}
}
@Test
public void testFreeFormCGWithNegativeY() throws Exception {
// This particular fin shape is currently not allowed in OR since the y values are negative
@ -151,38 +148,38 @@ public class FinSetTest extends BaseTestCase {
FreeformFinSet fins = new FreeformFinSet();
fins.setFinCount(1);
Coordinate[] points = new Coordinate[] {
new Coordinate(0,0),
new Coordinate(0,1),
new Coordinate(2,1),
new Coordinate(2,-1),
new Coordinate(1,-1),
new Coordinate(1,0)
new Coordinate(0, 0),
new Coordinate(0, 1),
new Coordinate(2, 1),
new Coordinate(2, -1),
new Coordinate(1, -1),
new Coordinate(1, 0)
};
fins.setPoints(points);
Coordinate coords = fins.getCG();
assertEquals(3.0, fins.getFinArea(), 0.001);
assertEquals(3.5/3.0, coords.x, 0.001);
assertEquals(0.5/3.0, coords.y, 0.001);
assertEquals(3.5 / 3.0, coords.x, 0.001);
assertEquals(0.5 / 3.0, coords.y, 0.001);
}
@Test
public void testFreeformConvert() {
testFreeformConvert(new TrapezoidFinSet());
testFreeformConvert(new EllipticalFinSet());
testFreeformConvert(new FreeformFinSet());
}
private void testFreeformConvert(FinSet fin) {
FreeformFinSet converted;
Material mat = Material.newMaterial(Type.BULK, "foo", 0.1, true);
fin.setBaseRotation(1.1);
fin.setCantAngle(0.001);
fin.setCGOverridden(true);
fin.setColor(ColorConversion.fromAwtColor(Color.YELLOW));
fin.setColor(Color.BLACK);
fin.setComment("cmt");
fin.setCrossSection(CrossSection.ROUNDED);
fin.setFinCount(5);
@ -200,57 +197,57 @@ public class FinSetTest extends BaseTestCase {
fin.setTabRelativePosition(TabRelativePosition.END);
fin.setTabShift(0.015);
fin.setThickness(0.005);
converted = FreeformFinSet.convertFinSet((FinSet) fin.copy());
ComponentCompare.assertSimilarity(fin, converted, true);
assertEquals(converted.getComponentName(), converted.getName());
// Create test rocket
Rocket rocket = new Rocket();
Stage stage = new Stage();
BodyTube body = new BodyTube();
rocket.addChild(stage);
stage.addChild(body);
body.addChild(fin);
Listener l1 = new Listener("l1");
rocket.addComponentChangeListener(l1);
fin.setName("Custom name");
assertTrue(l1.changed);
assertEquals(ComponentChangeEvent.NONFUNCTIONAL_CHANGE, l1.changetype);
// Create copy
RocketComponent rocketcopy = rocket.copy();
Listener l2 = new Listener("l2");
rocketcopy.addComponentChangeListener(l2);
FinSet fincopy = (FinSet) rocketcopy.getChild(0).getChild(0).getChild(0);
FreeformFinSet.convertFinSet(fincopy);
assertTrue(l2.changed);
assertEquals(ComponentChangeEvent.TREE_CHANGE,
l2.changetype & ComponentChangeEvent.TREE_CHANGE);
}
private static class Listener implements ComponentChangeListener {
private boolean changed = false;
private int changetype = 0;
private final String name;
public Listener(String name) {
this.name = name;
}
@Override
public void componentChanged(ComponentChangeEvent e) {
assertFalse("Ensuring listener " + name + " has not been called.", changed);
@ -258,5 +255,5 @@ public class FinSetTest extends BaseTestCase {
changetype = e.getType();
}
}
}

View File

@ -1,10 +1,10 @@
package net.sf.openrocket.util.BaseTestCase;
import net.sf.openrocket.ServicesForTesting;
import net.sf.openrocket.l10n.DebugTranslator;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.plugin.PluginModule;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.utils.CoreServicesModule;
import org.junit.BeforeClass;
@ -18,7 +18,7 @@ public class BaseTestCase {
@BeforeClass
public static void setUp() throws Exception {
Module applicationModule = new CoreServicesModule();
Module applicationModule = new ServicesForTesting();
Module debugTranslator = new AbstractModule() {
@Override

Binary file not shown.

25
swing/.classpath Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/jogl/jogl-all.jar"/>
<classpathentry kind="lib" path="lib/iText-5.0.2.jar"/>
<classpathentry kind="lib" path="lib/jcommon-1.0.18.jar"/>
<classpathentry kind="lib" path="lib/jfreechart-1.0.15.jar"/>
<classpathentry kind="lib" path="lib/miglayout15-swing.jar"/>
<classpathentry kind="lib" path="lib/OrangeExtensions-1.2.jar"/>
<classpathentry kind="lib" path="lib/jogl/gluegen-rt.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/OpenRocket Core"/>
<classpathentry kind="lib" path="/OpenRocket Core/lib/slf4j-api-1.7.5.jar"/>
<classpathentry kind="lib" path="/OpenRocket Core/lib/aopalliance.jar"/>
<classpathentry kind="lib" path="/OpenRocket Core/lib/guice-3.0.jar"/>
<classpathentry kind="lib" path="/OpenRocket Core/lib/guice-multibindings-3.0.jar"/>
<classpathentry kind="lib" path="/OpenRocket Core/lib/javax.inject.jar"/>
<classpathentry kind="lib" path="/OpenRocket Core/lib/opencsv-2.3.jar"/>
<classpathentry kind="lib" path="lib/logback-classic-1.0.12.jar"/>
<classpathentry kind="lib" path="lib/logback-core-1.0.12.jar"/>
<classpathentry kind="lib" path="/OpenRocket Core/resources"/>
<classpathentry kind="lib" path="resources"/>
<classpathentry kind="lib" path="/OpenRocket Core/lib/annotation-detector-3.0.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

2
swing/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/build
/bin

17
swing/.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OpenRocket Swing</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,89 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=error
org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=error
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning

333
swing/build.xml Normal file
View File

@ -0,0 +1,333 @@
<project name="OpenRocket" basedir=".">
<property file="resources/build.properties" />
<property name="src.dir" value="${basedir}/src"/> <!-- Source directory -->
<property name="src-test.dir" value="${basedir}/test"/> <!-- Test directory -->
<property name="build.dir" value="${basedir}/build"/> <!-- Build directory -->
<property name="build-test.dir" value="${basedir}/build/test"/> <!-- Build directory -->
<property name="lib.dir" value="${basedir}/lib"/> <!-- Library source directory -->
<property name="libtest.dir" value="${basedir}/../lib-test"/> <!-- Library test source directory -->
<property name="libant.dir" value="${basedir}/../lib-ant"/> <!-- Library ant source directory -->
<property name="tmp.dir" value="${basedir}/tmp"/> <!-- Temporary directory -->
<property name="resources.dir" value="${basedir}/resources"/> <!-- Resources directory -->
<property name="resources-src.dir" value="${basedir}/resources-src"/>
<property name="core.dir" value="${basedir}/../core"/>
<!-- Distribution directory, from which stuff is jar'ed -->
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="dist-test.dir" value="${build.dir}/dist-test"/>
<property name="jar.dir" value="${build.dir}/jar"/> <!-- Directory for built jar's -->
<property name="pkgname" value="${ant.project.name}-${build.version}"/>
<property name="jar.file" value="${jar.dir}/${ant.project.name}.jar"/>
<property name="dist.bin" value="${jar.dir}/${pkgname}.jar"/>
<property name="dist.src" value="${jar.dir}/${pkgname}-src.zip"/>
<!-- The main class of the application -->
<property name="main-class" value="net.sf.openrocket.startup.Startup"/>
<property name="expanded-libs" value="${lib.dir}/miglayout15-swing.jar"/>
<!-- Classpath definitions -->
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
<fileset dir="${core.dir}/build/jar" includes="OpenRocket-Core.jar"/>
<fileset dir="${core.dir}/lib" includes="**/*.jar"/>
</path>
<path id="test-classpath">
<path refid="classpath"/>
<pathelement location="${resources.dir}"/>
<pathelement location="${build-test.dir}"/>
<pathelement location="${classes.dir}"/>
<pathelement location="${src-test.dir}"/>
<fileset dir="${libtest.dir}/" includes="*.jar"/>
<pathelement location="../core/build/test"/>
</path>
<path id="run-classpath">
<path refid="classpath"/>
<pathelement location="${resources.dir}"/>
<pathelement location="${classes.dir}"/>
</path>
<!-- Add Ant-contrib tasks so we can use for loop -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${libant.dir}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!-- CLEAN -->
<target name="clean" description="Removes all build artifacts">
<delete dir="${build.dir}"/>
<delete dir="${tmp.dir}/"/>
</target>
<!-- BUILD -->
<target name="build">
<mkdir dir="${classes.dir}"/>
<echo level="info">Compiling main classes</echo>
<javac debug="true" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" includeantruntime="false" source="1.6" target="1.6"/>
</target>
<!-- Executible Eclipse-Jar-In-Jar style JAR -->
<target name="jar" depends="build,serialize-presets" description="Create the OpenRocket executable JAR">
<mkdir dir="${jar.dir}" />
<jar destfile="${jar.file}" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}" />
<attribute name="SplashScreen-Image" value="pix/splashscreen.png" />
<attribute name="Classpath-Jars" value="lib/gluegen-rt.jar lib/jogl-all.jar" />
</manifest>
<!-- Include, in the root of the JAR, the resources needed by OR -->
<fileset dir="${src.dir}/" includes="META-INF/,logback.xml" />
<fileset dir="${resources.dir}/" />
<!-- Libraries to extract into base JAR -->
<zipfileset src="${core.dir}/build/jar/OpenRocket-Core.jar" />
<zipfileset src="${lib.dir}/miglayout15-swing.jar" />
<zipfileset src="${core.dir}/lib/guice-3.0.jar" />
<zipfileset src="${core.dir}/lib/aopalliance.jar"/>
<zipfileset src="${core.dir}/lib/guice-multibindings-3.0.jar"/>
<zipfileset src="${lib.dir}/iText-5.0.2.jar"/>
<zipfileset src="${core.dir}/lib/javax.inject.jar"/>
<zipfileset src="${lib.dir}/jcommon-1.0.18.jar"/>
<zipfileset src="${lib.dir}/jfreechart-1.0.15.jar"/>
<zipfileset src="${lib.dir}/miglayout15-swing.jar"/>
<zipfileset src="${core.dir}/lib/opencsv-2.3.jar"/>
<zipfileset src="${lib.dir}/OrangeExtensions-1.2.jar"/>
<zipfileset src="${core.dir}/lib/annotation-detector-3.0.2.jar"/>
<zipfileset src="${core.dir}/lib/slf4j-api-1.7.5.jar"/>
<zipfileset src="${lib.dir}/logback-classic-1.0.12.jar"/>
<zipfileset src="${lib.dir}/logback-core-1.0.12.jar"/>
<!-- JOGL libraries need to be jar-in-jar -->
<zipfileset dir="${lib.dir}/jogl" prefix="lib">
<include name="*.jar"/>
</zipfileset>
<!-- Include metafiles about OR -->
<fileset dir="${basedir}" includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes fileformat.txt" />
</jar>
</target>
<target name="serialize-presets" depends="build" description="Preprocess the orc preset files into serialized form">
<java classname="net.sf.openrocket.utils.SerializePresets"
fork="true"
classpathref="run-classpath"
failonerror="true">
</java>
</target>
<!-- CONVERT vendor csv to ORC files -->
<macrodef name="build-orc-file">
<attribute name="dir"/>
<attribute name="vendor"/>
<sequential>
<echo>Generating ORC file for vendor @{vendor}</echo>
<java classname="net.sf.openrocket.preset.loader.RocksimComponentFileTranslator"
fork="true"
classpathref="run-classpath"
failonerror="true">
<arg value="@{dir}"/>
<arg value="${resources-src.dir}/datafiles/presets/@{vendor}.orc"/>
</java>
</sequential>
</macrodef>
<target name="generate-orc-files"
description="Generate ORC file from vendor csv"
depends="build">
<for param="vendor-dir">
<dirset dir="${resources-src.dir}/datafiles/rocksim_components"
includes="*"/>
<sequential>
<propertyregex property="vendor"
override="true"
input="@{vendor-dir}"
select="\1"
regexp=".*[/\\]([^/\\]*)$"/>
<build-orc-file dir="@{vendor-dir}" vendor="${vendor}"/>
</sequential>
</for>
</target>
<!-- DIST-SRC -->
<target name="dist-src">
<echo>
Building source distribution
</echo>
<mkdir dir="${build.dir}/${pkgname}"/>
<mkdir dir="${jar.dir}"/>
<copy todir="${build.dir}/${pkgname}">
<fileset dir="${basedir}" includes="*" excludes="*.log">
<type type="file"/>
</fileset>
<fileset dir="${basedir}" includes="resources/ lib/ lib-test/ src/ test/ resources-src/datafiles/"/>
</copy>
<zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
<delete dir="${build.dir}/${pkgname}"/>
</target>
<!-- DIST-SRC-TEST -->
<target name="dist-src-test" depends="dist-src">
<echo>
Testing source distribution
</echo>
<delete dir="${dist-test.dir}"/>
<mkdir dir="${dist-test.dir}"/>
<unzip dest="${dist-test.dir}" src="${dist.src}"/>
<ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="jar"/>
<ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="unittest"/>
<delete dir="${dist-test.dir}"/>
<echo>
Source distribution test successful
</echo>
</target>
<!-- DIST-BIN -->
<target name="dist-bin" depends="check,clean,unittest,jar">
<move file="${jar.file}" tofile="${dist.bin}"/>
</target>
<!-- DIST -->
<target name="dist" depends="dist-bin,dist-src,dist-src-test">
<echo>Distribution ${build.version} (${build.source}) built into directory ${jar.dir}</echo>
</target>
<!-- CHECK -->
<target name="check" depends="checktodo,checkascii"/>
<!-- CHECK TODOs -->
<target name="todo" depends="checktodo"/>
<target name="checktodo">
<tempfile property="todo.file" prefix="checktodo-" destDir="${tmp.dir}"/>
<echo>Checking project for FIXMEs.</echo>
<concat destfile="${todo.file}">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${src-test.dir}">
<include name="**/*.java"/>
</fileset>
<filterchain>
<linecontainsregexp>
<regexp pattern="(FIXME|TODO:.*CRITICAL)"/>
</linecontainsregexp>
</filterchain>
</concat>
<loadfile srcfile="${todo.file}" property="criticaltodos"/>
<delete file="${todo.file}"/>
<fail if="criticaltodos">CRITICAL TODOs exist in project:
${criticaltodos}</fail>
<echo>No critical TODOs in project.</echo>
</target>
<!-- CHECK ASCII -->
<target name="ascii" depends="checkascii"/>
<target name="checkascii">
<tempfile property="ascii.file" prefix="checkascii-" destDir="${tmp.dir}"/>
<echo>Checking project for non-ASCII characters.</echo>
<concat destfile="${ascii.file}">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${src-test.dir}">
<include name="**/*.java"/>
</fileset>
<filterchain>
<linecontainsregexp>
<regexp pattern="\P{ASCII}"/>
</linecontainsregexp>
</filterchain>
</concat>
<loadfile srcfile="${ascii.file}" property="nonascii"/>
<delete file="${ascii.file}"/>
<fail if="nonascii">Non-ASCII characters exist in project:
${nonascii}</fail>
<echo>No non-ASCII characters in project.</echo>
</target>
<!-- Unit tests -->
<target name="unittest" description="Execute unit tests" depends="build">
<echo>Building unit tests</echo>
<mkdir dir="${build-test.dir}"/>
<javac debug="true" srcdir="${src-test.dir}" destdir="${build-test.dir}" classpathref="test-classpath"/>
<echo>Running unit tests</echo>
<mkdir dir="${tmp.dir}/rawtestoutput"/>
<junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
<classpath>
<path refid="test-classpath"/>
<path location="${basedir}"/>
</classpath>
<batchtest todir="${tmp.dir}/rawtestoutput">
<fileset dir="${build-test.dir}">
<include name="**/Test*.class" />
<include name="**/*Test.class" />
<exclude name="**/*$*.class" />
<exclude name="Test.class" />
</fileset>
<formatter type="xml"/>
<formatter type="plain" usefile="false" />
</batchtest>
</junit>
<junitreport todir="${tmp.dir}">
<fileset dir="${tmp.dir}/rawtestoutput"/>
<report todir="${tmp.dir}/test-reports"/>
</junitreport>
<fail if="junit.failure" message="Unit test(s) failed. See report in ${tmp.dir}/test-reports/index.html"/>
<echo>
Unit tests passed successfully.
</echo>
</target>
<!-- Unit test (show errors in output stream instead of junit report) -->
<target name="unittest-no-junit-report" description="Execute unit tests, show report to output stream" depends="build">
<echo>Building unit tests</echo>
<mkdir dir="${build-test.dir}"/>
<javac debug="true" srcdir="${src-test.dir}" destdir="${build-test.dir}" classpathref="test-classpath"/>
<echo>Running unit tests</echo>
<mkdir dir="${tmp.dir}/rawtestoutput"/>
<junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
<classpath>
<path refid="test-classpath"/>
<path location="${basedir}"/>
</classpath>
<batchtest todir="${tmp.dir}/rawtestoutput">
<fileset dir="${build-test.dir}">
<include name="**/Test*.class" />
<include name="**/*Test.class" />
<exclude name="**/*$*.class" />
<exclude name="Test.class" />
</fileset>
<!-- <formatter type="xml"/> -->
<formatter type="plain" usefile="false" />
</batchtest>
<jvmarg value="-Dlogback.configurationFile=config/logback-stdout-level-error.xml"/>
</junit>
<fail if="junit.failure" message="Unit test(s) failed. See output above for failures."/>
<echo>
Unit tests passed successfully.
</echo>
</target>
</project>

Some files were not shown because too many files have changed in this diff Show More