l10n updates

This commit is contained in:
Sampo Niskanen 2011-07-20 15:44:57 +00:00
parent 8d2c5fd6e7
commit 27caf60161
10 changed files with 363 additions and 244 deletions

View File

@ -144,6 +144,9 @@ debuglogdlg.col.Message = Message
debuglogdlg.lbl.Loglinenbr = Log line number: debuglogdlg.lbl.Loglinenbr = Log line number:
debuglogdlg.lbl.Time = Time: debuglogdlg.lbl.Time = Time:
debuglogdlg.lbl.Level = Level: debuglogdlg.lbl.Level = Level:
debuglogdlg.lbl.Location = Location:
debuglogdlg.lbl.Logmessage = Log message:
debuglogdlg.lbl.Stacktrace = Stack trace:
! Edit Motor configuration dialog ! Edit Motor configuration dialog
@ -485,6 +488,7 @@ componentanalysisdlg.println.settingnam = SETTING NAN VALUES
componentanalysisdlg.lbl.reflenght = Reference length: componentanalysisdlg.lbl.reflenght = Reference length:
componentanalysisdlg.lbl.refarea = Reference area: componentanalysisdlg.lbl.refarea = Reference area:
!componentanalysisdlg.But.close =Close !componentanalysisdlg.But.close =Close
componentanalysisdlg.TabStability.Col.Component = Component
! Custom Material dialog ! Custom Material dialog
custmatdlg.title.Custommaterial = Custom material custmatdlg.title.Custommaterial = Custom material
@ -754,6 +758,7 @@ ParachuteCfg.tab.ttip.Radialpos = Radial position configuration
ParachuteCfg.lbl.Radialdistance = Radial distance: ParachuteCfg.lbl.Radialdistance = Radial distance:
ParachuteCfg.lbl.Radialdirection = Radial direction: ParachuteCfg.lbl.Radialdirection = Radial direction:
ParachuteCfg.but.Reset = Reset ParachuteCfg.but.Reset = Reset
ParachuteCfg.lbl.plusdelay = plus
! ShockCordConfig ! ShockCordConfig
ShockCordCfg.lbl.Shockcordlength = Shock cord length ShockCordCfg.lbl.Shockcordlength = Shock cord length
@ -799,6 +804,7 @@ StreamerCfg.tab.ttip.Radialpos = Radial position configuration
StreamerCfg.lbl.Radialdistance = Radial distance: StreamerCfg.lbl.Radialdistance = Radial distance:
StreamerCfg.lbl.Radialdirection = Radial direction: StreamerCfg.lbl.Radialdirection = Radial direction:
StreamerCfg.but.Reset = Reset StreamerCfg.but.Reset = Reset
StreamerCfg.lbl.plusdelay = plus
! ThicknessRingComponentConfig ! ThicknessRingComponentConfig
ThicknessRingCompCfg.tab.Outerdiam = Outer diameter: ThicknessRingCompCfg.tab.Outerdiam = Outer diameter:

13
scripts/checkTranslations.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
#
# Perform all tests for the translation files.
#
# Usage:
# ./scripts/checkTranslations.sh
#
# Test that keys used in Java files are present in English messages
find src/ -name "*.java" -exec ./scripts/verifyTranslationKeys.pl l10n/messages.properties {} +

View File

@ -0,0 +1,31 @@
#!/bin/bash
#
# Rename translation keys in translation files.
#
# Usage:
# renameTranslationKeys.sh <mapping files...>
#
# The mapping files contain "<original> <new>" key pairs.
# Empty lines and lines starting with "#" are ignored.
# All translation files are modified at once.
#
TRANSLATIONS=messages*.properties
cat "$@" | while read line; do
if echo "$line" | grep -q "^\s*$\|^\s*#"; then
continue
fi
if ! echo "$line" | egrep -q "^\s*[a-zA-Z0-9._-]+\s+[a-zA-Z0-9._-]+\s*$"; then
echo "Invalid line: $line"
fi
from="`echo $line | cut -d" " -f1`"
to="`echo $line | cut -d" " -f2`"
sed -i "s/^${from}\s*=\s*/${to} = /" $TRANSLATIONS
done

View File

@ -0,0 +1,67 @@
#!/usr/bin/perl
#
# Verify that keys used in Java files are present in the translation file.
#
# Usage:
# verifyTranslationKeys.pl <property file> <Java files...>
#
# For example:
# find src/ -name "*.java" -exec ./scripts/verifyTranslationKeys.pl l10n/messages.properties {} +
#
# Read the translation file
my %keys;
print "Reading translation keys...\n";
while ($str = <>) {
if ($ARGV!~/\.properties/) {
last;
}
if ($str=~/^\s*($|[#!])/) {
next;
}
if ($str=~/^([a-zA-Z0-9._-]+)\s*=/) {
$keys{$1} = 1;
} else {
print "ERROR: Invalid line in $ARGV: $str";
}
}
# Read Java files
my $oldFile = $ARGV;
my $class="";
print "Reading Java files...\n";
while ($str = <>) {
# Check for new file
if ($ARGV != $oldFile) {
$class = "";
}
# Check for irregular translator definition (exclude /l10n/ and /startup/)
if ($str =~ / Translator / &&
$str !~ /private static final Translator trans = Application.getTranslator\(\);/ &&
$ARGV !~ /\/(l10n|startup)\//) {
print "ERROR: Unusual translator usage in file $ARGV: $str";
}
# Check for new class definition
if ($str =~ /^[\sa-z]*class ([a-zA-Z0-9]+) /) {
$class = $1;
}
# Check for translator usage
if ($str =~ /trans\.get\(\"([^\"]+)\"\)/) {
$key = $1;
if (!(exists $keys{$key}) &&
!(exists $keys{$class . "." . $key})) {
print "ERROR: Missing translation for '$key' in file $ARGV\n";
}
}
}

View File

@ -17,7 +17,8 @@ import net.sf.openrocket.startup.Application;
public class StageSelector extends JPanel implements ChangeListener { public class StageSelector extends JPanel implements ChangeListener {
private static final Translator trans = Application.getTranslator();
private final Configuration configuration; private final Configuration configuration;
private List<JToggleButton> buttons = new ArrayList<JToggleButton>(); private List<JToggleButton> buttons = new ArrayList<JToggleButton>();
@ -40,7 +41,7 @@ public class StageSelector extends JPanel implements ChangeListener {
return; return;
while (buttons.size() > stages) { while (buttons.size() > stages) {
JToggleButton button = buttons.remove(buttons.size()-1); JToggleButton button = buttons.remove(buttons.size() - 1);
this.remove(button); this.remove(button);
} }
@ -53,7 +54,7 @@ public class StageSelector extends JPanel implements ChangeListener {
this.revalidate(); this.revalidate();
} }
@Override @Override
@ -64,8 +65,7 @@ public class StageSelector extends JPanel implements ChangeListener {
private class StageAction extends AbstractAction implements ChangeListener { private class StageAction extends AbstractAction implements ChangeListener {
private final int stage; private final int stage;
private final Translator trans = Application.getTranslator();
public StageAction(final int stage) { public StageAction(final int stage) {
this.stage = stage; this.stage = stage;
configuration.addChangeListener(this); configuration.addChangeListener(this);
@ -76,7 +76,7 @@ public class StageSelector extends JPanel implements ChangeListener {
public Object getValue(String key) { public Object getValue(String key) {
if (key.equals(NAME)) { if (key.equals(NAME)) {
//// Stage //// Stage
return trans.get("StageAction.Stage") + " " + (stage+1); return trans.get("StageAction.Stage") + " " + (stage + 1);
} }
return super.getValue(key); return super.getValue(key);
} }
@ -85,25 +85,25 @@ public class StageSelector extends JPanel implements ChangeListener {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
configuration.setToStage(stage); configuration.setToStage(stage);
// boolean state = (Boolean)getValue(SELECTED_KEY); // boolean state = (Boolean)getValue(SELECTED_KEY);
// if (state == true) { // if (state == true) {
// // Was disabled, now enabled // // Was disabled, now enabled
// configuration.setToStage(stage); // configuration.setToStage(stage);
// } else { // } else {
// // Was enabled, check what to do // // Was enabled, check what to do
// if (configuration.isStageActive(stage + 1)) { // if (configuration.isStageActive(stage + 1)) {
// configuration.setToStage(stage); // configuration.setToStage(stage);
// } else { // } else {
// if (stage == 0) // if (stage == 0)
// configuration.setAllStages(); // configuration.setAllStages();
// else // else
// configuration.setToStage(stage-1); // configuration.setToStage(stage-1);
// } // }
// } // }
// stateChanged(null); // stateChanged(null);
} }
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
this.putValue(SELECTED_KEY, configuration.isStageActive(stage)); this.putValue(SELECTED_KEY, configuration.isStageActive(stage));

View File

@ -23,8 +23,8 @@ import net.sf.openrocket.gui.components.UnitSelector;
import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.material.Material; import net.sf.openrocket.material.Material;
import net.sf.openrocket.rocketcomponent.MassComponent; import net.sf.openrocket.rocketcomponent.MassComponent;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.MotorMount.IgnitionEvent; import net.sf.openrocket.rocketcomponent.MotorMount.IgnitionEvent;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup; import net.sf.openrocket.unit.UnitGroup;
@ -33,247 +33,247 @@ public class StreamerConfig extends RecoveryDeviceConfig {
public StreamerConfig(final RocketComponent component) { public StreamerConfig(final RocketComponent component) {
super(component); super(component);
JPanel primary = new JPanel(new MigLayout()); JPanel primary = new JPanel(new MigLayout());
JPanel panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::][]","")); JPanel panel = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::][]", ""));
//// Strip length: //// Strip length:
panel.add(new JLabel(trans.get("StreamerCfg.lbl.Striplength"))); panel.add(new JLabel(trans.get("StreamerCfg.lbl.Striplength")));
DoubleModel m = new DoubleModel(component,"StripLength",UnitGroup.UNITS_LENGTH,0); DoubleModel m = new DoubleModel(component, "StripLength", UnitGroup.UNITS_LENGTH, 0);
JSpinner spin = new JSpinner(m.getSpinnerModel()); JSpinner spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin)); spin.setEditor(new SpinnerEditor(spin));
panel.add(spin,"growx"); panel.add(spin, "growx");
panel.add(new UnitSelector(m),"growx"); panel.add(new UnitSelector(m), "growx");
panel.add(new BasicSlider(m.getSliderModel(0, 0.6, 1.5)),"w 100lp, wrap"); panel.add(new BasicSlider(m.getSliderModel(0, 0.6, 1.5)), "w 100lp, wrap");
//// Strip width: //// Strip width:
panel.add(new JLabel(trans.get("StreamerCfg.lbl.Stripwidth"))); panel.add(new JLabel(trans.get("StreamerCfg.lbl.Stripwidth")));
m = new DoubleModel(component,"StripWidth",UnitGroup.UNITS_LENGTH,0); m = new DoubleModel(component, "StripWidth", UnitGroup.UNITS_LENGTH, 0);
spin = new JSpinner(m.getSpinnerModel()); spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin)); spin.setEditor(new SpinnerEditor(spin));
panel.add(spin,"growx"); panel.add(spin, "growx");
panel.add(new UnitSelector(m),"growx"); panel.add(new UnitSelector(m), "growx");
panel.add(new BasicSlider(m.getSliderModel(0, 0.2)),"w 100lp, wrap 20lp"); panel.add(new BasicSlider(m.getSliderModel(0, 0.2)), "w 100lp, wrap 20lp");
//// Strip area: //// Strip area:
panel.add(new JLabel(trans.get("StreamerCfg.lbl.Striparea"))); panel.add(new JLabel(trans.get("StreamerCfg.lbl.Striparea")));
m = new DoubleModel(component,"Area",UnitGroup.UNITS_AREA,0); m = new DoubleModel(component, "Area", UnitGroup.UNITS_AREA, 0);
spin = new JSpinner(m.getSpinnerModel()); spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin)); spin.setEditor(new SpinnerEditor(spin));
panel.add(spin,"growx"); panel.add(spin, "growx");
panel.add(new UnitSelector(m),"growx"); panel.add(new UnitSelector(m), "growx");
panel.add(new BasicSlider(m.getSliderModel(0, 0.04, 0.25)),"w 100lp, wrap"); panel.add(new BasicSlider(m.getSliderModel(0, 0.04, 0.25)), "w 100lp, wrap");
//// Aspect ratio: //// Aspect ratio:
panel.add(new JLabel(trans.get("StreamerCfg.lbl.Aspectratio"))); panel.add(new JLabel(trans.get("StreamerCfg.lbl.Aspectratio")));
m = new DoubleModel(component,"AspectRatio",UnitGroup.UNITS_NONE,0); m = new DoubleModel(component, "AspectRatio", UnitGroup.UNITS_NONE, 0);
spin = new JSpinner(m.getSpinnerModel()); spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin)); spin.setEditor(new SpinnerEditor(spin));
panel.add(spin,"growx"); panel.add(spin, "growx");
// panel.add(new UnitSelector(m),"growx"); // panel.add(new UnitSelector(m),"growx");
panel.add(new BasicSlider(m.getSliderModel(2, 15)),"skip, w 100lp, wrap 20lp"); panel.add(new BasicSlider(m.getSliderModel(2, 15)), "skip, w 100lp, wrap 20lp");
//// Material: //// Material:
panel.add(new JLabel(trans.get("StreamerCfg.lbl.Material"))); panel.add(new JLabel(trans.get("StreamerCfg.lbl.Material")));
JComboBox combo = new JComboBox(new MaterialModel(panel, component, JComboBox combo = new JComboBox(new MaterialModel(panel, component,
Material.Type.SURFACE)); Material.Type.SURFACE));
//// The component material affects the weight of the component. //// The component material affects the weight of the component.
combo.setToolTipText(trans.get("StreamerCfg.combo.ttip.MaterialModel")); combo.setToolTipText(trans.get("StreamerCfg.combo.ttip.MaterialModel"));
panel.add(combo,"spanx 3, growx, wrap 20lp"); panel.add(combo, "spanx 3, growx, wrap 20lp");
// CD // CD
//// <html>Drag coefficient C<sub>D</sub>: //// <html>Drag coefficient C<sub>D</sub>:
JLabel label = new HtmlLabel(trans.get("StreamerCfg.lbl.longA1")); JLabel label = new HtmlLabel(trans.get("StreamerCfg.lbl.longA1"));
//// <html>The drag coefficient relative to the total area of the streamer.<br> //// <html>The drag coefficient relative to the total area of the streamer.<br>
String tip = trans.get("StreamerCfg.lbl.longB1") + String tip = trans.get("StreamerCfg.lbl.longB1") +
//// "A larger drag coefficient yields a slowed descent rate. //// "A larger drag coefficient yields a slowed descent rate.
trans.get("StreamerCfg.lbl.longB2"); trans.get("StreamerCfg.lbl.longB2");
label.setToolTipText(tip); label.setToolTipText(tip);
panel.add(label); panel.add(label);
m = new DoubleModel(component,"CD",UnitGroup.UNITS_COEFFICIENT,0); m = new DoubleModel(component, "CD", UnitGroup.UNITS_COEFFICIENT, 0);
spin = new JSpinner(m.getSpinnerModel()); spin = new JSpinner(m.getSpinnerModel());
spin.setToolTipText(tip); spin.setToolTipText(tip);
spin.setEditor(new SpinnerEditor(spin)); spin.setEditor(new SpinnerEditor(spin));
panel.add(spin,"growx"); panel.add(spin, "growx");
JCheckBox check = new JCheckBox(m.getAutomaticAction()); JCheckBox check = new JCheckBox(m.getAutomaticAction());
//// Automatic //// Automatic
check.setText(trans.get("StreamerCfg.lbl.Automatic")); check.setText(trans.get("StreamerCfg.lbl.Automatic"));
panel.add(check,"skip, span, wrap"); panel.add(check, "skip, span, wrap");
//// The drag coefficient is relative to the area of the streamer. //// The drag coefficient is relative to the area of the streamer.
panel.add(new StyledLabel(trans.get("StreamerCfg.lbl.longC1"), panel.add(new StyledLabel(trans.get("StreamerCfg.lbl.longC1"),
-2), "span, wrap"); -2), "span, wrap");
primary.add(panel, "grow, gapright 20lp");
panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::][]",""));
primary.add(panel, "grow, gapright 20lp");
panel = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::][]", ""));
//// Position //// Position
//// Position relative to: //// Position relative to:
panel.add(new JLabel(trans.get("StreamerCfg.lbl.Posrelativeto"))); panel.add(new JLabel(trans.get("StreamerCfg.lbl.Posrelativeto")));
combo = new JComboBox( combo = new JComboBox(
new EnumModel<RocketComponent.Position>(component, "RelativePosition", new EnumModel<RocketComponent.Position>(component, "RelativePosition",
new RocketComponent.Position[] { new RocketComponent.Position[] {
RocketComponent.Position.TOP, RocketComponent.Position.TOP,
RocketComponent.Position.MIDDLE, RocketComponent.Position.MIDDLE,
RocketComponent.Position.BOTTOM, RocketComponent.Position.BOTTOM,
RocketComponent.Position.ABSOLUTE RocketComponent.Position.ABSOLUTE
})); }));
panel.add(combo,"spanx, growx, wrap"); panel.add(combo, "spanx, growx, wrap");
//// plus //// plus
panel.add(new JLabel(trans.get("StreamerCfg.lbl.plus")),"right"); panel.add(new JLabel(trans.get("StreamerCfg.lbl.plus")), "right");
m = new DoubleModel(component,"PositionValue",UnitGroup.UNITS_LENGTH); m = new DoubleModel(component, "PositionValue", UnitGroup.UNITS_LENGTH);
spin = new JSpinner(m.getSpinnerModel()); spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin)); spin.setEditor(new SpinnerEditor(spin));
panel.add(spin,"growx"); panel.add(spin, "growx");
panel.add(new UnitSelector(m),"growx"); panel.add(new UnitSelector(m), "growx");
panel.add(new BasicSlider(m.getSliderModel( panel.add(new BasicSlider(m.getSliderModel(
new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE), new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE),
new DoubleModel(component.getParent(), "Length"))), new DoubleModel(component.getParent(), "Length"))),
"w 100lp, wrap"); "w 100lp, wrap");
//// Spatial length: //// Spatial length:
panel.add(new JLabel(trans.get("StreamerCfg.lbl.Packedlength"))); panel.add(new JLabel(trans.get("StreamerCfg.lbl.Packedlength")));
m = new DoubleModel(component,"Length",UnitGroup.UNITS_LENGTH,0); m = new DoubleModel(component, "Length", UnitGroup.UNITS_LENGTH, 0);
spin = new JSpinner(m.getSpinnerModel()); spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin)); spin.setEditor(new SpinnerEditor(spin));
panel.add(spin,"growx"); panel.add(spin, "growx");
panel.add(new UnitSelector(m),"growx");
panel.add(new BasicSlider(m.getSliderModel(0, 0.1, 0.5)),"w 100lp, wrap");
panel.add(new UnitSelector(m), "growx");
panel.add(new BasicSlider(m.getSliderModel(0, 0.1, 0.5)), "w 100lp, wrap");
//// Tube diameter //// Tube diameter
//// Packed diameter: //// Packed diameter:
panel.add(new JLabel(trans.get("StreamerCfg.lbl.Packeddiam"))); panel.add(new JLabel(trans.get("StreamerCfg.lbl.Packeddiam")));
DoubleModel od = new DoubleModel(component,"Radius",2,UnitGroup.UNITS_LENGTH,0); DoubleModel od = new DoubleModel(component, "Radius", 2, UnitGroup.UNITS_LENGTH, 0);
// Diameter = 2*Radius // Diameter = 2*Radius
spin = new JSpinner(od.getSpinnerModel()); spin = new JSpinner(od.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin)); spin.setEditor(new SpinnerEditor(spin));
panel.add(spin,"growx"); panel.add(spin, "growx");
panel.add(new UnitSelector(od),"growx");
panel.add(new BasicSlider(od.getSliderModel(0, 0.04, 0.2)),"w 100lp, wrap 30lp");
panel.add(new UnitSelector(od), "growx");
panel.add(new BasicSlider(od.getSliderModel(0, 0.04, 0.2)), "w 100lp, wrap 30lp");
//// Deployment //// Deployment
//// Deploys at: //// Deploys at:
panel.add(new JLabel(trans.get("StreamerCfg.lbl.Deploysat")),""); panel.add(new JLabel(trans.get("StreamerCfg.lbl.Deploysat")), "");
combo = new JComboBox(new EnumModel<IgnitionEvent>(component, "DeployEvent")); combo = new JComboBox(new EnumModel<IgnitionEvent>(component, "DeployEvent"));
panel.add(combo,"spanx 3, growx, wrap"); panel.add(combo, "spanx 3, growx, wrap");
// ... and delay // ... and delay
//// plus //// plus
panel.add(new JLabel(trans.get("StreamerCfg.lbl.plusdelay")),"right"); panel.add(new JLabel(trans.get("StreamerCfg.lbl.plusdelay")), "right");
m = new DoubleModel(component,"DeployDelay",0); m = new DoubleModel(component, "DeployDelay", 0);
spin = new JSpinner(m.getSpinnerModel()); spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin)); spin.setEditor(new SpinnerEditor(spin));
panel.add(spin,"spanx, split"); panel.add(spin, "spanx, split");
//// seconds //// seconds
panel.add(new JLabel(trans.get("StreamerCfg.lbl.seconds")),"wrap paragraph"); panel.add(new JLabel(trans.get("StreamerCfg.lbl.seconds")), "wrap paragraph");
// Altitude: // Altitude:
label = new JLabel(trans.get("StreamerCfg.lbl.Altitude")); label = new JLabel(trans.get("StreamerCfg.lbl.Altitude"));
altitudeComponents.add(label); altitudeComponents.add(label);
panel.add(label); panel.add(label);
m = new DoubleModel(component,"DeployAltitude",UnitGroup.UNITS_DISTANCE,0); m = new DoubleModel(component, "DeployAltitude", UnitGroup.UNITS_DISTANCE, 0);
spin = new JSpinner(m.getSpinnerModel()); spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin)); spin.setEditor(new SpinnerEditor(spin));
altitudeComponents.add(spin); altitudeComponents.add(spin);
panel.add(spin,"growx"); panel.add(spin, "growx");
UnitSelector unit = new UnitSelector(m); UnitSelector unit = new UnitSelector(m);
altitudeComponents.add(unit); altitudeComponents.add(unit);
panel.add(unit,"growx"); panel.add(unit, "growx");
BasicSlider slider = new BasicSlider(m.getSliderModel(100, 1000)); BasicSlider slider = new BasicSlider(m.getSliderModel(100, 1000));
altitudeComponents.add(slider); altitudeComponents.add(slider);
panel.add(slider,"w 100lp, wrap"); panel.add(slider, "w 100lp, wrap");
primary.add(panel, "grow"); primary.add(panel, "grow");
updateFields(); updateFields();
//// General and General properties //// General and General properties
tabbedPane.insertTab(trans.get("StreamerCfg.tab.General"), null, primary, tabbedPane.insertTab(trans.get("StreamerCfg.tab.General"), null, primary,
trans.get("StreamerCfg.tab.ttip.General"), 0); trans.get("StreamerCfg.tab.ttip.General"), 0);
//// Radial position and Radial position configuration //// Radial position and Radial position configuration
tabbedPane.insertTab(trans.get("StreamerCfg.tab.Radialpos"), null, positionTab(), tabbedPane.insertTab(trans.get("StreamerCfg.tab.Radialpos"), null, positionTab(),
trans.get("StreamerCfg.tab.ttip.Radialpos"), 1); trans.get("StreamerCfg.tab.ttip.Radialpos"), 1);
tabbedPane.setSelectedIndex(0); tabbedPane.setSelectedIndex(0);
} }
protected JPanel positionTab() { protected JPanel positionTab() {
JPanel panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]","")); JPanel panel = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::]", ""));
//// Radial position //// Radial position
//// Radial distance: //// Radial distance:
panel.add(new JLabel(trans.get("StreamerCfg.lbl.Radialdistance"))); panel.add(new JLabel(trans.get("StreamerCfg.lbl.Radialdistance")));
DoubleModel m = new DoubleModel(component,"RadialPosition",UnitGroup.UNITS_LENGTH,0); DoubleModel m = new DoubleModel(component, "RadialPosition", UnitGroup.UNITS_LENGTH, 0);
JSpinner spin = new JSpinner(m.getSpinnerModel()); JSpinner spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin)); spin.setEditor(new SpinnerEditor(spin));
panel.add(spin,"growx"); panel.add(spin, "growx");
panel.add(new UnitSelector(m),"growx");
panel.add(new BasicSlider(m.getSliderModel(0, 0.1, 1.0)),"w 100lp, wrap");
panel.add(new UnitSelector(m), "growx");
panel.add(new BasicSlider(m.getSliderModel(0, 0.1, 1.0)), "w 100lp, wrap");
//// Radial direction //// Radial direction
//// Radial direction: //// Radial direction:
panel.add(new JLabel(trans.get("StreamerCfg.lbl.Radialdirection"))); panel.add(new JLabel(trans.get("StreamerCfg.lbl.Radialdirection")));
m = new DoubleModel(component,"RadialDirection",UnitGroup.UNITS_ANGLE,0); m = new DoubleModel(component, "RadialDirection", UnitGroup.UNITS_ANGLE, 0);
spin = new JSpinner(m.getSpinnerModel()); spin = new JSpinner(m.getSpinnerModel());
spin.setEditor(new SpinnerEditor(spin)); spin.setEditor(new SpinnerEditor(spin));
panel.add(spin,"growx"); panel.add(spin, "growx");
panel.add(new UnitSelector(m), "growx");
panel.add(new BasicSlider(m.getSliderModel(-Math.PI, Math.PI)), "w 100lp, wrap");
panel.add(new UnitSelector(m),"growx");
panel.add(new BasicSlider(m.getSliderModel(-Math.PI, Math.PI)),"w 100lp, wrap");
//// Reset button //// Reset button
JButton button = new JButton(trans.get("StreamerCfg.but.Reset")); JButton button = new JButton(trans.get("StreamerCfg.but.Reset"));
button.addActionListener(new ActionListener() { button.addActionListener(new ActionListener() {
@ -283,7 +283,7 @@ public class StreamerConfig extends RecoveryDeviceConfig {
((MassComponent) component).setRadialPosition(0.0); ((MassComponent) component).setRadialPosition(0.0);
} }
}); });
panel.add(button,"spanx, right"); panel.add(button, "spanx, right");
return panel; return panel;
} }

View File

@ -2,6 +2,7 @@
* OpenRocketPrintable.java * OpenRocketPrintable.java
*/ */
package net.sf.openrocket.gui.print; package net.sf.openrocket.gui.print;
import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Application;
@ -10,85 +11,86 @@ import net.sf.openrocket.startup.Application;
*/ */
public enum OpenRocketPrintable { public enum OpenRocketPrintable {
//PARTS_LIST("Parts list", true, 0), //PARTS_LIST("Parts list", true, 0),
//// Parts detail //// Parts detail
PARTS_DETAIL("OpenRocketPrintable.Partsdetail", true, 1), PARTS_DETAIL("OpenRocketPrintable.Partsdetail", true, 1),
//// ////
FIN_TEMPLATE("OpenRocketPrintable.Fintemplates", true, 2), FIN_TEMPLATE("OpenRocketPrintable.Fintemplates", true, 2),
//// Design Report //// Design Report
DESIGN_REPORT("OpenRocketPrintable.DesignReport", false, 3); DESIGN_REPORT("OpenRocketPrintable.DesignReport", false, 3);
/** private static final Translator trans = Application.getTranslator();
* The description - will be displayed in the JTree.
*/ /**
private String description; * The description - will be displayed in the JTree.
*/
/** private String description;
* Flag that indicates if the enum value is different depending upon stage.
*/ /**
private boolean stageSpecific; * Flag that indicates if the enum value is different depending upon stage.
*/
/** private boolean stageSpecific;
* The order of the item as it appears in the printed document.
*/ /**
private int order; * The order of the item as it appears in the printed document.
*/
/** private int order;
* Constructor.
* /**
* @param s the displayable description * Constructor.
* @param staged indicates if the printable is stage dependent *
* @param idx the relative print order * @param s the displayable description
*/ * @param staged indicates if the printable is stage dependent
OpenRocketPrintable (String s, boolean staged, int idx) { * @param idx the relative print order
description = s; */
stageSpecific = staged; OpenRocketPrintable(String s, boolean staged, int idx) {
order = idx; description = s;
} stageSpecific = staged;
order = idx;
/** }
* Get the description of this printable.
* /**
* @return a displayable string * Get the description of this printable.
*/ *
public String getDescription () { * @return a displayable string
final Translator trans = Application.getTranslator(); */
return trans.get(description); public String getDescription() {
} return trans.get(description);
}
/**
* Answers if this enum value has different meaning depending upon the stage. /**
* * Answers if this enum value has different meaning depending upon the stage.
* @return true if the printable is stage dependent *
*/ * @return true if the printable is stage dependent
public boolean isStageSpecific () { */
return stageSpecific; public boolean isStageSpecific() {
} return stageSpecific;
}
/**
* Answer the print order. This is relative to other enum values. No two enum values will have the same print /**
* order value. * Answer the print order. This is relative to other enum values. No two enum values will have the same print
* * order value.
* @return a 0 based order (0 being first, or highest) *
*/ * @return a 0 based order (0 being first, or highest)
public int getPrintOrder () { */
return order; public int getPrintOrder() {
} return order;
}
/**
* Look up an enum value based on the description. /**
* * Look up an enum value based on the description.
* @param target the description *
* * @param target the description
* @return an instance of this enum class or null if not found *
*/ * @return an instance of this enum class or null if not found
public static OpenRocketPrintable findByDescription (String target) { */
OpenRocketPrintable[] values = values(); public static OpenRocketPrintable findByDescription(String target) {
for (OpenRocketPrintable value : values) { OpenRocketPrintable[] values = values();
if (value.getDescription().equalsIgnoreCase(target)) { for (OpenRocketPrintable value : values) {
return value; if (value.getDescription().equalsIgnoreCase(target)) {
} return value;
} }
return null; }
} return null;
}
} }

View File

@ -1,13 +1,13 @@
package net.sf.openrocket.rocketcomponent; package net.sf.openrocket.rocketcomponent;
import java.util.List;
import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.material.Material; import net.sf.openrocket.material.Material;
import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup; import net.sf.openrocket.unit.UnitGroup;
import net.sf.openrocket.util.Prefs; import net.sf.openrocket.util.Prefs;
import java.util.List;
/** /**
* Class of components with well-defined physical appearance and which have an effect on * Class of components with well-defined physical appearance and which have an effect on
* aerodynamic simulation. They have material defined for them, and the mass of the component * aerodynamic simulation. They have material defined for them, and the mass of the component
@ -17,7 +17,7 @@ import java.util.List;
*/ */
public abstract class ExternalComponent extends RocketComponent { public abstract class ExternalComponent extends RocketComponent {
public enum Finish { public enum Finish {
//// Rough //// Rough
ROUGH("ExternalComponent.Rough", 500e-6), ROUGH("ExternalComponent.Rough", 500e-6),
@ -29,35 +29,35 @@ public abstract class ExternalComponent extends RocketComponent {
SMOOTH("ExternalComponent.Smoothpaint", 20e-6), SMOOTH("ExternalComponent.Smoothpaint", 20e-6),
//// Polished //// Polished
POLISHED("ExternalComponent.Polished", 2e-6); POLISHED("ExternalComponent.Polished", 2e-6);
private static final Translator trans = Application.getTranslator();
private final String name; private final String name;
private final double roughnessSize; private final double roughnessSize;
Finish(String name, double roughness) { Finish(String name, double roughness) {
this.name = name; this.name = name;
this.roughnessSize = roughness; this.roughnessSize = roughness;
} }
public double getRoughnessSize() { public double getRoughnessSize() {
return roughnessSize; return roughnessSize;
} }
@Override @Override
public String toString() { public String toString() {
final Translator trans = Application.getTranslator();
return trans.get(name) + " (" + UnitGroup.UNITS_ROUGHNESS.toStringUnit(roughnessSize) + ")"; return trans.get(name) + " (" + UnitGroup.UNITS_ROUGHNESS.toStringUnit(roughnessSize) + ")";
} }
} }
/** /**
* The material of the component. * The material of the component.
*/ */
protected Material material = null; protected Material material = null;
protected Finish finish = Finish.NORMAL; protected Finish finish = Finish.NORMAL;
/** /**
* Constructor that sets the relative position of the component. * Constructor that sets the relative position of the component.
@ -66,13 +66,13 @@ public abstract class ExternalComponent extends RocketComponent {
super(relativePosition); super(relativePosition);
this.material = Prefs.getDefaultComponentMaterial(this.getClass(), Material.Type.BULK); this.material = Prefs.getDefaultComponentMaterial(this.getClass(), Material.Type.BULK);
} }
/** /**
* Returns the volume of the component. This value is used in calculating the mass * Returns the volume of the component. This value is used in calculating the mass
* of the object. * of the object.
*/ */
public abstract double getComponentVolume(); public abstract double getComponentVolume();
/** /**
* Calculates the mass of the component as the product of the volume and interior density. * Calculates the mass of the component as the product of the volume and interior density.
*/ */
@ -80,7 +80,7 @@ public abstract class ExternalComponent extends RocketComponent {
public double getComponentMass() { public double getComponentMass() {
return material.getDensity() * getComponentVolume(); return material.getDensity() * getComponentVolume();
} }
/** /**
* ExternalComponent has aerodynamic effect, so return true. * ExternalComponent has aerodynamic effect, so return true.
*/ */
@ -88,7 +88,7 @@ public abstract class ExternalComponent extends RocketComponent {
public boolean isAerodynamic() { public boolean isAerodynamic() {
return true; return true;
} }
/** /**
* ExternalComponent has effect on the mass, so return true. * ExternalComponent has effect on the mass, so return true.
*/ */
@ -96,36 +96,36 @@ public abstract class ExternalComponent extends RocketComponent {
public boolean isMassive() { public boolean isMassive() {
return true; return true;
} }
public Material getMaterial() { public Material getMaterial() {
return material; return material;
} }
public void setMaterial(Material mat) { public void setMaterial(Material mat) {
if (mat.getType() != Material.Type.BULK) { if (mat.getType() != Material.Type.BULK) {
throw new IllegalArgumentException("ExternalComponent requires a bulk material" + throw new IllegalArgumentException("ExternalComponent requires a bulk material" +
" type=" + mat.getType()); " type=" + mat.getType());
} }
if (material.equals(mat)) if (material.equals(mat))
return; return;
material = mat; material = mat;
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
} }
public Finish getFinish() { public Finish getFinish() {
return finish; return finish;
} }
public void setFinish(Finish finish) { public void setFinish(Finish finish) {
if (this.finish == finish) if (this.finish == finish)
return; return;
this.finish = finish; this.finish = finish;
fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
} }
@Override @Override
protected List<RocketComponent> copyFrom(RocketComponent c) { protected List<RocketComponent> copyFrom(RocketComponent c) {
ExternalComponent src = (ExternalComponent) c; ExternalComponent src = (ExternalComponent) c;
@ -133,5 +133,5 @@ public abstract class ExternalComponent extends RocketComponent {
this.material = src.material; this.material = src.material;
return super.copyFrom(c); return super.copyFrom(c);
} }
} }

View File

@ -8,17 +8,16 @@ import net.sf.openrocket.util.ChangeSource;
import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Coordinate;
public interface MotorMount extends ChangeSource { public interface MotorMount extends ChangeSource {
static final Translator trans = Application.getTranslator();
public static enum IgnitionEvent { public static enum IgnitionEvent {
//// Automatic (launch or ejection charge) //// Automatic (launch or ejection charge)
AUTOMATIC(trans.get("MotorMount.IgnitionEvent.AUTOMATIC")) { AUTOMATIC("MotorMount.IgnitionEvent.AUTOMATIC") {
@Override @Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) { public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
int count = source.getRocket().getStageCount(); int count = source.getRocket().getStageCount();
int stage = source.getStageNumber(); int stage = source.getStageNumber();
if (stage == count-1) { if (stage == count - 1) {
return LAUNCH.isActivationEvent(e, source); return LAUNCH.isActivationEvent(e, source);
} else { } else {
return EJECTION_CHARGE.isActivationEvent(e, source); return EJECTION_CHARGE.isActivationEvent(e, source);
@ -26,38 +25,38 @@ public interface MotorMount extends ChangeSource {
} }
}, },
//// Launch //// Launch
LAUNCH(trans.get("MotorMount.IgnitionEvent.LAUNCH")) { LAUNCH("MotorMount.IgnitionEvent.LAUNCH") {
@Override @Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) { public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
return (e.getType() == FlightEvent.Type.LAUNCH); return (e.getType() == FlightEvent.Type.LAUNCH);
} }
}, },
//// First ejection charge of previous stage //// First ejection charge of previous stage
EJECTION_CHARGE(trans.get("MotorMount.IgnitionEvent.EJECTION_CHARGE")) { EJECTION_CHARGE("MotorMount.IgnitionEvent.EJECTION_CHARGE") {
@Override @Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) { public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
if (e.getType() != FlightEvent.Type.EJECTION_CHARGE) if (e.getType() != FlightEvent.Type.EJECTION_CHARGE)
return false; return false;
int charge = e.getSource().getStageNumber(); int charge = e.getSource().getStageNumber();
int mount = source.getStageNumber(); int mount = source.getStageNumber();
return (mount+1 == charge); return (mount + 1 == charge);
} }
}, },
//// First burnout of previous stage //// First burnout of previous stage
BURNOUT(trans.get("MotorMount.IgnitionEvent.BURNOUT")) { BURNOUT("MotorMount.IgnitionEvent.BURNOUT") {
@Override @Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) { public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
if (e.getType() != FlightEvent.Type.BURNOUT) if (e.getType() != FlightEvent.Type.BURNOUT)
return false; return false;
int charge = e.getSource().getStageNumber(); int charge = e.getSource().getStageNumber();
int mount = source.getStageNumber(); int mount = source.getStageNumber();
return (mount+1 == charge); return (mount + 1 == charge);
} }
}, },
//// Never //// Never
NEVER(trans.get("MotorMount.IgnitionEvent.NEVER")) { NEVER("MotorMount.IgnitionEvent.NEVER") {
@Override @Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) { public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
return false; return false;
@ -65,7 +64,8 @@ public interface MotorMount extends ChangeSource {
}, },
; ;
private static final Translator trans = Application.getTranslator();
private final String description; private final String description;
IgnitionEvent(String description) { IgnitionEvent(String description) {
@ -76,7 +76,7 @@ public interface MotorMount extends ChangeSource {
@Override @Override
public String toString() { public String toString() {
return description; return trans.get(description);
} }
}; };
@ -113,7 +113,7 @@ public interface MotorMount extends ChangeSource {
* @param motor the motor, or <code>null</code>. * @param motor the motor, or <code>null</code>.
*/ */
public void setMotor(String id, Motor motor); public void setMotor(String id, Motor motor);
/** /**
* Get the number of similar motors clustered. * Get the number of similar motors clustered.
* *
@ -125,7 +125,7 @@ public interface MotorMount extends ChangeSource {
public int getMotorCount(); public int getMotorCount();
/** /**
* Return the ejection charge delay of given motor configuration. * Return the ejection charge delay of given motor configuration.
* A "plugged" motor without an ejection charge is given by * A "plugged" motor without an ejection charge is given by
@ -192,7 +192,7 @@ public interface MotorMount extends ChangeSource {
public void setMotorOverhang(double overhang); public void setMotorOverhang(double overhang);
/** /**
* Return the inner diameter of the motor mount. * Return the inner diameter of the motor mount.
* *

View File

@ -15,29 +15,29 @@ import net.sf.openrocket.startup.Application;
public enum LineStyle { public enum LineStyle {
//// Solid //// Solid
SOLID("LineStyle.Solid",new float[] { 10f, 0f }), SOLID("LineStyle.Solid", new float[] { 10f, 0f }),
//// Dashed //// Dashed
DASHED("LineStyle.Dashed",new float[] { 6f, 4f }), DASHED("LineStyle.Dashed", new float[] { 6f, 4f }),
//// Dotted //// Dotted
DOTTED("LineStyle.Dotted",new float[] { 2f, 3f }), DOTTED("LineStyle.Dotted", new float[] { 2f, 3f }),
//// Dash-dotted //// Dash-dotted
DASHDOT("LineStyle.Dash-dotted",new float[] { 8f, 3f, 2f, 3f}) DASHDOT("LineStyle.Dash-dotted", new float[] { 8f, 3f, 2f, 3f });
;
private static final Translator trans = Application.getTranslator();
private final String name; private final String name;
private final float[] dashes; private final float[] dashes;
LineStyle(String name, float[] dashes) { LineStyle(String name, float[] dashes) {
this.name = name; this.name = name;
this.dashes = dashes; this.dashes = dashes;
} }
public float[] getDashes() { public float[] getDashes() {
return Arrays.copyOf(dashes, dashes.length); return Arrays.copyOf(dashes, dashes.length);
} }
@Override @Override
public String toString() { public String toString() {
final Translator trans = Application.getTranslator();
return trans.get(name); return trans.get(name);
} }
} }