Rework source structure to separate swing gui code from core code.
Separate swing application code from core code. Moved a bunch of sources and libraries around. Created new eclipse project. Further refinements to make it build. Update gitignore.
This commit is contained in:
parent
f300c3a6be
commit
26fb295554
6
.gitignore
vendored
6
.gitignore
vendored
@ -37,9 +37,3 @@
|
||||
/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.
|
||||
|
@ -10,8 +10,6 @@
|
||||
</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"/>
|
||||
@ -20,19 +18,12 @@
|
||||
<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="output" path="bin"/>
|
||||
</classpath>
|
||||
|
135
core/build.xml
135
core/build.xml
@ -1,4 +1,4 @@
|
||||
<project name="OpenRocket" basedir=".">
|
||||
<project name="OpenRocket-Core" basedir=".">
|
||||
|
||||
<property file="resources/build.properties" />
|
||||
|
||||
@ -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,86 +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"/>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
155
core/test/net/sf/openrocket/ServicesForTesting.java
Normal file
155
core/test/net/sf/openrocket/ServicesForTesting.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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")) {
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
23
swing/.classpath
Normal file
23
swing/.classpath
Normal file
@ -0,0 +1,23 @@
|
||||
<?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/annotation-detector-3.0.2-SNAPSHOT.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="output" path="bin"/>
|
||||
</classpath>
|
2
swing/.gitignore
vendored
Normal file
2
swing/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/build
|
||||
/bin
|
17
swing/.project
Normal file
17
swing/.project
Normal 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>
|
89
swing/.settings/org.eclipse.jdt.core.prefs
Normal file
89
swing/.settings/org.eclipse.jdt.core.prefs
Normal 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
|
331
swing/build.xml
Normal file
331
swing/build.xml
Normal file
@ -0,0 +1,331 @@
|
||||
<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="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 -->
|
||||
<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"/>
|
||||
</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="${libextra.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-SNAPSHOT.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"/>
|
||||
</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
Loading…
x
Reference in New Issue
Block a user