trackeditor: show length for curve segments

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8763 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 74a06353de3f48a52ac7502254cd40715915b3e2
Former-commit-id: 9676f6835554370903854b37a772c79e1e812411
This commit is contained in:
iobyte 2023-03-07 00:11:23 +00:00
parent 845b1968b8
commit e6cec2c0f3
3 changed files with 44 additions and 27 deletions

View file

@ -794,6 +794,7 @@ public class SegmentEditorDlg extends JDialog implements SliderListener
this.getRadiusEndSlider().setEnabled(true);
this.getArcSlider().setEnabled(true);
this.getLengthSlider().setEnabled(false);
this.getLengthSlider().setValue(curve.getLength());
getGroupButton().setEnabled(true);
getGroupButton().setSelected(curve.getType());
@ -1004,7 +1005,13 @@ public class SegmentEditorDlg extends JDialog implements SliderListener
// TODO Auto-generated catch block
e.printStackTrace();
}
double length = shape.getLength();
view.redrawCircuit();
double newLength = shape.getLength();
if (length != newLength)
{
getLengthSlider().setValue(newLength);
}
editorFrame.documentIsModified = true;
dirty = true;
}

View file

@ -22,6 +22,7 @@ package gui.segment;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.text.NumberFormat;
import java.util.Vector;
import javax.swing.JCheckBox;
@ -42,24 +43,25 @@ import utils.SegmentSliderLayout;
public class SegmentSlider extends JPanel
{
private Vector<SliderListener> sliderListeners = new Vector<SliderListener>();
private JLabel sectionLabel = null;
private JTextField textField = null;
private JLabel attLabel = null;
private JSlider slider = null;
private JCheckBox checkBox = null;
private boolean enabled = true;
private boolean optional = false;
private JLabel sectionLabel = null;
private JTextField textField = null;
private JLabel attLabel = null;
private JSlider slider = null;
private JCheckBox checkBox = null;
private boolean enabled = true;
private boolean optional = false;
private String section;
private String attr;
private double min;
private double max;
private double extent;
private double tickSpacing;
private double realToTextCoeff;
private String method;
private Object parent;
private double value;
private String section;
private String attr;
private double min;
private double max;
private double extent;
private double tickSpacing;
private double realToTextCoeff;
private String method;
private Object parent;
private double value;
private NumberFormat nf;
//private Segment shape;
@ -78,6 +80,11 @@ public class SegmentSlider extends JPanel
*/
private void initialize()
{
nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(3);
nf.setMinimumFractionDigits(1);
nf.setGroupingUsed(false);
attLabel = new JLabel();
sectionLabel = new JLabel();
this.setLayout(new SegmentSliderLayout());
@ -348,12 +355,15 @@ public class SegmentSlider extends JPanel
System.out.println("Increasing slider maximum to " + newMaximum + " was " + getSlider().getMaximum());
getSlider().setMaximum(newMaximum);
}
getTextField().setText(value + "");
getTextField().setEnabled(true);
getSlider().setValue((int) value);
getSlider().setEnabled(true);
if (this.optional)
checkBox.setSelected(true);
getTextField().setText(nf.format(value));
if (isEnabled())
{
getTextField().setEnabled(true);
getSlider().setValue((int) value);
getSlider().setEnabled(true);
if (this.optional)
checkBox.setSelected(true);
}
}
}
@ -366,9 +376,9 @@ public class SegmentSlider extends JPanel
{
textValue = Double.parseDouble(getTextField().getText());
}
if (textValue != value)
if (Math.abs(textValue - value) >= 0.001)
{
getTextField().setText(value + "");
getTextField().setText(nf.format(value));
}
valueChanged();
}
@ -447,7 +457,7 @@ public class SegmentSlider extends JPanel
}
if (oldValue != value)
{
getTextField().setText(value + "");
getTextField().setText(nf.format(value));
getTextField().setEnabled(true);
getSlider().setValue((int) value);
getSlider().setEnabled(true);

View file

@ -34,7 +34,7 @@ public class Properties
private static Properties instance = new Properties();
private Vector<ActionListener> propertiesListeners = new Vector<ActionListener>();
public final String title = "sd2-trackeditor";
public final String version = "1.0.7";
public final String version = "1.0.8";
private String path;
private double imageScale = 1;