Merge branch 'unstable' into issue-1189
This commit is contained in:
commit
901d7b5332
@ -826,6 +826,7 @@ AppearanceCfg.but.edit = Edit
|
||||
AppearanceCfg.but.savedefault = Save as default appearance
|
||||
AppearanceCfg.lbl.Texture = Texture:
|
||||
AppearanceCfg.lbl.shine = Shine:
|
||||
AppearanceCfg.lbl.opacity = Opacity:
|
||||
AppearanceCfg.lbl.color.Color = Color:
|
||||
AppearanceCfg.lbl.color.diffuse = Diffuse Color:
|
||||
AppearanceCfg.lbl.color.ambient = Ambient Color:
|
||||
|
@ -161,6 +161,34 @@ public class AppearanceBuilder extends AbstractChangeSource {
|
||||
this.shine = shine;
|
||||
fireChangeEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the opacity of the paint color, expressed in percentages, where 0 is fully transparent and 1 is fully opaque
|
||||
* @return opacity value of the pain color, expressed in a percentage
|
||||
*/
|
||||
public double getOpacity() {
|
||||
if (this.paint == null) {
|
||||
return 100;
|
||||
}
|
||||
return (double) this.paint.getAlpha() / 255;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the opacity/alpha of the paint color.
|
||||
*
|
||||
* @param opacity new opacity value expressed in a percentage, where 0 is fully transparent and 1 is fully opaque
|
||||
*/
|
||||
public void setOpacity(double opacity) {
|
||||
if (this.paint == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clamp opacity between 0 and 1
|
||||
opacity = Math.max(0, Math.min(1, opacity));
|
||||
|
||||
this.paint.setAlpha((int) (opacity * 255));
|
||||
fireChangeEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the current offset axis U used
|
||||
|
@ -111,7 +111,9 @@ public class RocketComponentSaver {
|
||||
if (c instanceof FinSet || c instanceof TubeFinSet) {
|
||||
elements.add("<rotation>" + angleOffset + "</rotation>");
|
||||
}
|
||||
else if (!(c instanceof RailButton) && !(c instanceof PodSet)) {
|
||||
else if (!(c instanceof ParallelStage) &&
|
||||
!(c instanceof PodSet) &&
|
||||
!(c instanceof RailButton)) {
|
||||
elements.add("<radialdirection>" + angleOffset + "</radialdirection>");
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class RocketSaver extends RocketComponentSaver {
|
||||
}
|
||||
|
||||
if (flightConfig.isNameOverridden()){
|
||||
str += "><name>" + net.sf.openrocket.util.TextUtil.escapeXML(flightConfig.getName())
|
||||
str += "><name>" + net.sf.openrocket.util.TextUtil.escapeXML(flightConfig.getNameRaw())
|
||||
+ "</name></motorconfiguration>";
|
||||
} else {
|
||||
str += "/>";
|
||||
|
@ -34,7 +34,8 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
private static final Logger log = LoggerFactory.getLogger(FlightConfiguration.class);
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
private String configurationName=null;
|
||||
private String configurationName;
|
||||
public static String DEFAULT_CONFIG_NAME = "[{motors}]";
|
||||
|
||||
protected final Rocket rocket;
|
||||
protected final FlightConfigurationId fcid;
|
||||
@ -94,7 +95,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
this.fcid = _fcid;
|
||||
}
|
||||
this.rocket = rocket;
|
||||
this.configurationName = null;
|
||||
this.configurationName = DEFAULT_CONFIG_NAME;
|
||||
this.configurationInstanceId = configurationInstanceCount++;
|
||||
|
||||
updateStages();
|
||||
@ -414,15 +415,31 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
}
|
||||
|
||||
public boolean isNameOverridden(){
|
||||
return (null != this.configurationName );
|
||||
return (!DEFAULT_CONFIG_NAME.equals(this.configurationName));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of this configuration, with DEFAULT_CONFIG_NAME replaced by a one line motor description.
|
||||
* If configurationName is null, the one line motor description is returned.
|
||||
* @return the flight configuration name
|
||||
*/
|
||||
public String getName() {
|
||||
if( null == configurationName){
|
||||
return this.getOneLineMotorDescription();
|
||||
}else{
|
||||
return configurationName;
|
||||
if (configurationName == null) {
|
||||
return getOneLineMotorDescription();
|
||||
}
|
||||
return configurationName.replace(DEFAULT_CONFIG_NAME, getOneLineMotorDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the raw configuration name, without replacing DEFAULT_CONFIG_NAME.
|
||||
* If the configurationName is null, DEFAULT_CONFIG_NAME is returned.
|
||||
* @return raw flight configuration name
|
||||
*/
|
||||
public String getNameRaw() {
|
||||
if (configurationName == null) {
|
||||
return DEFAULT_CONFIG_NAME;
|
||||
}
|
||||
return configurationName;
|
||||
}
|
||||
|
||||
private String getOneLineMotorDescription(){
|
||||
@ -699,6 +716,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
copy.modID = this.modID;
|
||||
copy.boundsModID = -1;
|
||||
copy.refLengthModID = -1;
|
||||
copy.configurationName = configurationName;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@ -713,9 +731,9 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setName( final String newName) {
|
||||
if(( null == newName ) ||( "".equals(newName))){
|
||||
this.configurationName = null;
|
||||
public void setName(final String newName) {
|
||||
if ((newName == null) || ("".equals(newName))) {
|
||||
this.configurationName = DEFAULT_CONFIG_NAME;
|
||||
return;
|
||||
}else if( ! this.getId().isValid()){
|
||||
return;
|
||||
|
@ -861,7 +861,7 @@ public class Rocket extends ComponentAssembly {
|
||||
if( this.selectedConfiguration.equals( config)){
|
||||
shortKey = "=>" + shortKey;
|
||||
}
|
||||
buf.append(String.format(fmt, shortKey, config.getName() ));
|
||||
buf.append(String.format(fmt, shortKey, config.getNameRaw() ));
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
@ -580,15 +580,22 @@ public class AppearancePanel extends JPanel {
|
||||
mDefault.addEnableComponent(offsetV, false);
|
||||
panel.add(offsetV, "wrap, w 40");
|
||||
|
||||
// Repeat
|
||||
panel.add(new JLabel(trans.get("AppearanceCfg.lbl.texture.repeat")));
|
||||
EdgeMode[] list = new EdgeMode[EdgeMode.values().length];
|
||||
System.arraycopy(EdgeMode.values(), 0, list, 0,
|
||||
EdgeMode.values().length);
|
||||
JComboBox<EdgeMode> combo = new JComboBox<EdgeMode>(new EnumModel<EdgeMode>(builder,
|
||||
"EdgeMode", list));
|
||||
mDefault.addEnableComponent(combo, false);
|
||||
panel.add(combo);
|
||||
// Opacity
|
||||
panel.add(new JLabel(trans.get("AppearanceCfg.lbl.opacity")));
|
||||
DoubleModel opacityModel = new DoubleModel(builder, "Opacity",
|
||||
UnitGroup.UNITS_RELATIVE);
|
||||
JSpinner spinOpacity = new JSpinner(opacityModel.getSpinnerModel());
|
||||
spinOpacity.setEditor(new SpinnerEditor(spinOpacity));
|
||||
JSlider slideOpacity = new JSlider(opacityModel.getSliderModel(0, 1));
|
||||
UnitSelector unitOpacity = new UnitSelector(opacityModel);
|
||||
|
||||
mDefault.addEnableComponent(slideOpacity, false);
|
||||
mDefault.addEnableComponent(spinOpacity, false);
|
||||
mDefault.addEnableComponent(unitOpacity, false);
|
||||
|
||||
panel.add(spinOpacity, "split 3, w 50");
|
||||
panel.add(unitOpacity);
|
||||
panel.add(slideOpacity, "w 50");
|
||||
|
||||
// Rotation
|
||||
panel.add(new JLabel(trans.get("AppearanceCfg.lbl.texture.rotation")));
|
||||
@ -603,5 +610,15 @@ public class AppearancePanel extends JPanel {
|
||||
-Math.PI, Math.PI));
|
||||
mDefault.addEnableComponent(bs, false);
|
||||
panel.add(bs, "w 50, wrap");
|
||||
|
||||
// Repeat
|
||||
panel.add(new JLabel(trans.get("AppearanceCfg.lbl.texture.repeat")), "skip 2");
|
||||
EdgeMode[] list = new EdgeMode[EdgeMode.values().length];
|
||||
System.arraycopy(EdgeMode.values(), 0, list, 0,
|
||||
EdgeMode.values().length);
|
||||
JComboBox<EdgeMode> combo = new JComboBox<EdgeMode>(new EnumModel<EdgeMode>(builder,
|
||||
"EdgeMode", list));
|
||||
mDefault.addEnableComponent(combo, false);
|
||||
panel.add(combo, "wrap");
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class RocketComponentConfig extends JPanel {
|
||||
|
||||
updateFields();
|
||||
|
||||
this.add(buttonPanel, "newline, spanx, growx, height 32!");
|
||||
this.add(buttonPanel, "newline, spanx, growx");
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class RenameConfigDialog extends JDialog {
|
||||
|
||||
panel.add(new JLabel(trans.get("RenameConfigDialog.lbl.name")), "span, wrap rel");
|
||||
|
||||
final JTextField textbox = new JTextField(rocket.getFlightConfiguration(fcid).getName());
|
||||
final JTextField textbox = new JTextField(rocket.getFlightConfiguration(fcid).getNameRaw());
|
||||
panel.add(textbox, "span, w 200lp, growx, wrap para");
|
||||
|
||||
panel.add(new JPanel(), "growx");
|
||||
|
@ -6,6 +6,8 @@ import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
@ -73,7 +75,13 @@ public class MotorChooserDialog extends JDialog implements CloseableDialog {
|
||||
this.setModal(true);
|
||||
this.pack();
|
||||
this.setLocationByPlatform(true);
|
||||
GUIUtil.installEscapeCloseOperation(this);
|
||||
Action closeAction = new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
close(false);
|
||||
}
|
||||
};
|
||||
GUIUtil.installEscapeCloseOperation(this, closeAction);
|
||||
|
||||
JComponent focus = selectionPanel.getDefaultFocus();
|
||||
if (focus != null) {
|
||||
@ -107,9 +115,13 @@ public class MotorChooserDialog extends JDialog implements CloseableDialog {
|
||||
public double getSelectedDelay() {
|
||||
return selectionPanel.getSelectedDelay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void open() {
|
||||
// Update the motor selection based on the motor table value that was already selected in a previous session.
|
||||
selectionPanel.selectMotorFromTable();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(boolean ok) {
|
||||
okClicked = ok;
|
||||
|
@ -112,14 +112,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
|
||||
setMotorMountAndConfig( fcid, mount );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sole constructor.
|
||||
*
|
||||
* @param current the currently selected ThrustCurveMotor, or <code>null</code> for none.
|
||||
* @param delay the currently selected ejection charge delay.
|
||||
* @param diameter the diameter of the motor mount.
|
||||
*/
|
||||
|
||||
public ThrustCurveMotorSelectionPanel() {
|
||||
super(new MigLayout("fill", "[grow][]"));
|
||||
|
||||
@ -264,17 +257,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
|
||||
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
int row = table.getSelectedRow();
|
||||
if (row >= 0) {
|
||||
row = table.convertRowIndexToModel(row);
|
||||
ThrustCurveMotorSet motorSet = model.getMotorSet(row);
|
||||
log.info(Markers.USER_MARKER, "Selected table row " + row + ": " + motorSet);
|
||||
if (motorSet != selectedMotorSet) {
|
||||
select(selectMotor(motorSet));
|
||||
}
|
||||
} else {
|
||||
log.info(Markers.USER_MARKER, "Selected table row " + row + ", nothing selected");
|
||||
}
|
||||
selectMotorFromTable();
|
||||
}
|
||||
});
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
@ -608,6 +591,23 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects a new motor based on the selection in the motor table
|
||||
*/
|
||||
public void selectMotorFromTable() {
|
||||
int row = table.getSelectedRow();
|
||||
if (row >= 0) {
|
||||
row = table.convertRowIndexToModel(row);
|
||||
ThrustCurveMotorSet motorSet = model.getMotorSet(row);
|
||||
log.info(Markers.USER_MARKER, "Selected table row " + row + ": " + motorSet);
|
||||
if (motorSet != selectedMotorSet) {
|
||||
select(selectMotor(motorSet));
|
||||
}
|
||||
} else {
|
||||
log.info(Markers.USER_MARKER, "Selected table row " + row + ", nothing selected");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the values in the delay combo box. If <code>reset</code> is <code>true</code>
|
||||
|
@ -220,7 +220,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
||||
if (fcIds == null) return;
|
||||
FlightConfigurationId initFcId = fcIds.get(0);
|
||||
new RenameConfigDialog(SwingUtilities.getWindowAncestor(this), rocket, initFcId).setVisible(true);
|
||||
String newName = rocket.getFlightConfiguration(initFcId).getName();
|
||||
String newName = rocket.getFlightConfiguration(initFcId).getNameRaw();
|
||||
for (int i = 1; i < fcIds.size(); i++) {
|
||||
rocket.getFlightConfiguration(fcIds.get(i)).setName(newName);
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
||||
double initDelay = initMount.getMotorConfig(initFcId).getEjectionDelay();
|
||||
|
||||
motorChooserDialog.setMotorMountAndConfig(initFcId, initMount);
|
||||
motorChooserDialog.setVisible(true);
|
||||
motorChooserDialog.open();
|
||||
|
||||
Motor mtr = motorChooserDialog.getSelectedMotor();
|
||||
double d = motorChooserDialog.getSelectedDelay();
|
||||
|
@ -157,9 +157,22 @@ public class GUIUtil {
|
||||
* @param dialog the dialog for which to install the action.
|
||||
*/
|
||||
public static void installEscapeCloseOperation(final JDialog dialog) {
|
||||
installEscapeCloseOperation(dialog, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct action to close a JDialog when the ESC key is pressed.
|
||||
* The dialog is closed by sending it a WINDOW_CLOSING event.
|
||||
*
|
||||
* An additional action can be passed which will be executed upon the close action key.
|
||||
*
|
||||
* @param dialog the dialog for which to install the action.
|
||||
* @param action action to execute upon the close action
|
||||
*/
|
||||
public static void installEscapeCloseOperation(final JDialog dialog, Action action) {
|
||||
Action dispatchClosing = new AbstractAction() {
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 9196153713666242274L;
|
||||
|
||||
@ -172,6 +185,9 @@ public class GUIUtil {
|
||||
JRootPane root = dialog.getRootPane();
|
||||
root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ESCAPE, CLOSE_ACTION_KEY);
|
||||
root.getActionMap().put(CLOSE_ACTION_KEY, dispatchClosing);
|
||||
if (action != null) {
|
||||
root.getActionMap().put(CLOSE_ACTION_KEY, action);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user