trackeditor: add pit speed units
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8886 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 7c514a820efe153147fdd09f32141c390c8177dd Former-commit-id: 9b6ebea1739794ecaa02a020458b406a69f6b49f
This commit is contained in:
parent
166b3adad4
commit
e19e4823f0
8 changed files with 261 additions and 46 deletions
|
@ -73,6 +73,7 @@ IF(Java_Development_FOUND AND Java_FOUND)
|
|||
plugin/torcs/XmlReader.java
|
||||
plugin/torcs/XmlWriter.java
|
||||
utils/CustomFileFilter.java
|
||||
utils/DoubleValue.java
|
||||
utils/Editor.java
|
||||
utils/EditorPoint.java
|
||||
utils/GroupButtonLayout.java
|
||||
|
|
|
@ -80,6 +80,7 @@ import utils.circuit.Curve;
|
|||
import utils.circuit.MainTrack;
|
||||
import utils.circuit.ObjShapeObject;
|
||||
import utils.circuit.ObjectMap;
|
||||
import utils.circuit.Pits;
|
||||
import utils.circuit.Reliefs;
|
||||
import utils.circuit.Segment;
|
||||
import utils.circuit.Straight;
|
||||
|
@ -3150,4 +3151,9 @@ public class EditorFrame extends JFrame
|
|||
{
|
||||
return trackData.getReliefs();
|
||||
}
|
||||
|
||||
public Pits getPits()
|
||||
{
|
||||
return trackData.getMainTrack().getPits();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import javax.swing.JTabbedPane;
|
|||
import javax.swing.JTextField;
|
||||
|
||||
import gui.EditorFrame;
|
||||
import utils.DoubleValue;
|
||||
import utils.SegmentVector;
|
||||
import utils.SurfaceComboBox;
|
||||
import utils.circuit.Pits;
|
||||
|
@ -92,6 +93,8 @@ public class PitProperties extends PropertyPanel
|
|||
private JComboBox<String> indicatorComboBox = null;
|
||||
private JLabel speedLimitLabel = new JLabel();
|
||||
private JTextField speedLimitTextField = new JTextField();
|
||||
private JLabel speedLimitUnitsLabel = new JLabel();
|
||||
private JComboBox<String> speedLimitUnitsComboBox = null;
|
||||
private JCheckBox generatePitsCheckBox = null;
|
||||
private JLabel generatePitsLabel = new JLabel();
|
||||
private JTabbedPane tabbedPane = null;
|
||||
|
@ -150,7 +153,7 @@ public class PitProperties extends PropertyPanel
|
|||
add(getStyleComboBox(), null);
|
||||
add(getSideComboBox(), null);
|
||||
|
||||
Pits pits = getEditorFrame().getTrackData().getMainTrack().getPits();
|
||||
Pits pits = getEditorFrame().getPits();
|
||||
|
||||
addTextField(this, 2, entryTextField, pits.getEntry(), 120, 125);
|
||||
addTextField(this, 3, startTextField, pits.getStart(), 120, 125);
|
||||
|
@ -164,7 +167,9 @@ public class PitProperties extends PropertyPanel
|
|||
|
||||
add(getIndicatorComboBox(), null);
|
||||
|
||||
addTextField(this, 12, speedLimitTextField, pits.getSpeedLimit(), 120, 125);
|
||||
addTextField(this, 12, speedLimitTextField, pits.getSpeedLimitValue(), 120, 125);
|
||||
add(getSpeedLimitUnitsLabel(), null);
|
||||
add(getSpeedLimitUnitsComboBox(), null);
|
||||
|
||||
add(getGeneratePitsCheckBox(), null);
|
||||
add(getTabbedPane(), null);
|
||||
|
@ -208,7 +213,7 @@ public class PitProperties extends PropertyPanel
|
|||
String[] items = {"none", "no pits", "on track side", "on separate path", "no building"};
|
||||
styleComboBox = new JComboBox<String>(items);
|
||||
styleComboBox.setBounds(120, 10, 125, 23);
|
||||
int style = getEditorFrame().getTrackData().getMainTrack().getPits().getStyle();
|
||||
int style = getEditorFrame().getPits().getStyle();
|
||||
if (style == Integer.MAX_VALUE)
|
||||
style = 0;
|
||||
else
|
||||
|
@ -230,7 +235,7 @@ public class PitProperties extends PropertyPanel
|
|||
String[] items = {"none", "right", "left"};
|
||||
sideComboBox = new JComboBox<String>(items);
|
||||
sideComboBox.setBounds(120, 37, 125, 23);
|
||||
String side = getEditorFrame().getTrackData().getMainTrack().getPits().getSide();
|
||||
String side = getEditorFrame().getPits().getSide();
|
||||
if (side == null || side.isEmpty())
|
||||
side = "none";
|
||||
sideComboBox.setSelectedItem(side);
|
||||
|
@ -250,7 +255,7 @@ public class PitProperties extends PropertyPanel
|
|||
String[] items = {"none", "0 normal_pit_indicator.ac", "1 pit_indicator.ac"};
|
||||
indicatorComboBox = new JComboBox<String>(items);
|
||||
indicatorComboBox.setBounds(120, 307, 175, 23);
|
||||
int indicator = getEditorFrame().getTrackData().getMainTrack().getPits().getIndicator();
|
||||
int indicator = getEditorFrame().getPits().getIndicator();
|
||||
if (indicator == Integer.MAX_VALUE)
|
||||
indicator = 0;
|
||||
else
|
||||
|
@ -260,6 +265,54 @@ public class PitProperties extends PropertyPanel
|
|||
return indicatorComboBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes speedLimitUnitsComboBox
|
||||
*
|
||||
* @return javax.swing.JComboBox
|
||||
*/
|
||||
private JLabel getSpeedLimitUnitsLabel()
|
||||
{
|
||||
speedLimitUnitsLabel.setText("Units");;
|
||||
speedLimitUnitsLabel.setBounds(260, 334, 40, 23);
|
||||
|
||||
return speedLimitUnitsLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes speedLimitUnitsComboBox
|
||||
*
|
||||
* @return javax.swing.JComboBox
|
||||
*/
|
||||
private JComboBox<String> getSpeedLimitUnitsComboBox()
|
||||
{
|
||||
if (speedLimitUnitsComboBox == null)
|
||||
{
|
||||
String[] items = {"none", "meters per second", "kilometers per hour", "miles per hour"};
|
||||
speedLimitUnitsComboBox = new JComboBox<String>(items);
|
||||
speedLimitUnitsComboBox.setBounds(300, 334, 140, 23);
|
||||
DoubleValue speedLimit = getEditorFrame().getPits().getSpeedLimit();
|
||||
int indicator = -1;
|
||||
|
||||
if (speedLimit == null || speedLimit.units == null || speedLimit.value == Double.NaN)
|
||||
indicator = 0;
|
||||
else if (speedLimit.units.equals("m") || speedLimit.units.equalsIgnoreCase("mps"))
|
||||
indicator = 1;
|
||||
else if (speedLimit.units.equalsIgnoreCase("kph"))
|
||||
indicator = 2;
|
||||
else if (speedLimit.units.equalsIgnoreCase("mph"))
|
||||
indicator = 3;
|
||||
speedLimitUnitsComboBox.setSelectedIndex(indicator);
|
||||
speedLimitUnitsComboBox.addActionListener(new java.awt.event.ActionListener()
|
||||
{
|
||||
public void actionPerformed(java.awt.event.ActionEvent e)
|
||||
{
|
||||
// Should we convert the speed limit to the new units?
|
||||
}
|
||||
});
|
||||
}
|
||||
return speedLimitUnitsComboBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes generatePitsCheckBox
|
||||
*
|
||||
|
@ -286,7 +339,7 @@ public class PitProperties extends PropertyPanel
|
|||
{
|
||||
if (generatePitsCheckBox.isSelected())
|
||||
{
|
||||
Pits pits = getEditorFrame().getTrackData().getMainTrack().getPits();
|
||||
Pits pits = getEditorFrame().getPits();
|
||||
SegmentVector data = getEditorFrame().getTrackData().getSegments();
|
||||
Segment pitEntry = null;
|
||||
Segment pitStart = null;
|
||||
|
@ -638,18 +691,18 @@ public class PitProperties extends PropertyPanel
|
|||
public void exit()
|
||||
{
|
||||
int index = getStyleComboBox().getSelectedIndex();
|
||||
int style = getEditorFrame().getTrackData().getMainTrack().getPits().getStyle();
|
||||
int style = getEditorFrame().getPits().getStyle();
|
||||
if (index == 0)
|
||||
{
|
||||
if (style != Integer.MAX_VALUE)
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setStyle(Integer.MAX_VALUE);
|
||||
getEditorFrame().getPits().setStyle(Integer.MAX_VALUE);
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
}
|
||||
else if (style == Integer.MAX_VALUE || style != index - 1)
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setStyle(index - 1);
|
||||
getEditorFrame().getPits().setStyle(index - 1);
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
|
@ -658,95 +711,112 @@ public class PitProperties extends PropertyPanel
|
|||
MutableInteger integerResult = new MutableInteger();
|
||||
|
||||
if (isDifferent((String) getSideComboBox().getSelectedItem(),
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().getSide(), stringResult))
|
||||
getEditorFrame().getPits().getSide(), stringResult))
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setSide(stringResult.getValue());
|
||||
getEditorFrame().getPits().setSide(stringResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent(entryTextField.getText(),
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().getEntry(), stringResult))
|
||||
getEditorFrame().getPits().getEntry(), stringResult))
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setEntry(stringResult.getValue());
|
||||
getEditorFrame().getPits().setEntry(stringResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent(startTextField.getText(),
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().getStart(), stringResult))
|
||||
getEditorFrame().getPits().getStart(), stringResult))
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setStart(stringResult.getValue());
|
||||
getEditorFrame().getPits().setStart(stringResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent(startBuildingsTextField.getText(),
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().getStartBuildings(), stringResult))
|
||||
getEditorFrame().getPits().getStartBuildings(), stringResult))
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setStartBuildings(stringResult.getValue());
|
||||
getEditorFrame().getPits().setStartBuildings(stringResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent(stopBuildingsTextField.getText(),
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().getStopBuildings(), stringResult))
|
||||
getEditorFrame().getPits().getStopBuildings(), stringResult))
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setStopBuildings(stringResult.getValue());
|
||||
getEditorFrame().getPits().setStopBuildings(stringResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent(maxPitsTextField.getText(),
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().getMaxPits(), integerResult))
|
||||
getEditorFrame().getPits().getMaxPits(), integerResult))
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setMaxPits(integerResult.getValue());
|
||||
getEditorFrame().getPits().setMaxPits(integerResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent(endTextField.getText(),
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().getEnd(), stringResult))
|
||||
getEditorFrame().getPits().getEnd(), stringResult))
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setEnd(stringResult.getValue());
|
||||
getEditorFrame().getPits().setEnd(stringResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent(exitTextField.getText(),
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().getExit(), stringResult))
|
||||
getEditorFrame().getPits().getExit(), stringResult))
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setExit(stringResult.getValue());
|
||||
getEditorFrame().getPits().setExit(stringResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent(widthTextField.getText(),
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().getWidth(), doubleResult))
|
||||
getEditorFrame().getPits().getWidth(), doubleResult))
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setWidth(doubleResult.getValue());
|
||||
getEditorFrame().getPits().setWidth(doubleResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent(lengthTextField.getText(),
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().getLength(), doubleResult))
|
||||
getEditorFrame().getPits().getLength(), doubleResult))
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setLength(doubleResult.getValue());
|
||||
getEditorFrame().getPits().setLength(doubleResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
index = getIndicatorComboBox().getSelectedIndex();
|
||||
int indicator = getEditorFrame().getTrackData().getMainTrack().getPits().getIndicator();
|
||||
int indicator = getEditorFrame().getPits().getIndicator();
|
||||
if (index == 0)
|
||||
{
|
||||
if (indicator != Integer.MAX_VALUE)
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setIndicator(Integer.MAX_VALUE);
|
||||
getEditorFrame().getPits().setIndicator(Integer.MAX_VALUE);
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
}
|
||||
else if (indicator == Integer.MAX_VALUE || indicator != index - 1)
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setIndicator(index - 1);
|
||||
getEditorFrame().getPits().setIndicator(index - 1);
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
if (isDifferent(speedLimitTextField.getText(),
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().getSpeedLimit(), doubleResult))
|
||||
getEditorFrame().getPits().getSpeedLimitValue(), doubleResult))
|
||||
{
|
||||
getEditorFrame().getTrackData().getMainTrack().getPits().setSpeedLimit(doubleResult.getValue());
|
||||
getEditorFrame().getPits().setSpeedLimitValue(doubleResult.getValue());
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
index = getSpeedLimitUnitsComboBox().getSelectedIndex();
|
||||
String units = getEditorFrame().getPits().getSpeedLimitUnits();
|
||||
String[] items = {null, "m", "kph", "mph"};
|
||||
if (index == 0)
|
||||
{
|
||||
if (units != null)
|
||||
{
|
||||
getEditorFrame().getPits().setSpeedLimitUnits(null);
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
}
|
||||
else if (index != -1 && !items[index].equalsIgnoreCase(units))
|
||||
{
|
||||
getEditorFrame().getPits().setSpeedLimitUnits(items[index]);
|
||||
getEditorFrame().documentIsModified = true;
|
||||
}
|
||||
|
||||
|
@ -762,7 +832,7 @@ public class PitProperties extends PropertyPanel
|
|||
*/
|
||||
private void createPits()
|
||||
{
|
||||
Pits pits = getEditorFrame().getTrackData().getMainTrack().getPits();
|
||||
Pits pits = getEditorFrame().getPits();
|
||||
SegmentVector data = getEditorFrame().getTrackData().getSegments();
|
||||
Segment pitEntry = null;
|
||||
Segment pitStart = null;
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.jdom.input.SAXHandler;
|
|||
import org.xml.sax.InputSource;
|
||||
|
||||
import gui.EditorFrame;
|
||||
import utils.DoubleValue;
|
||||
import utils.Editor;
|
||||
import utils.SegmentVector;
|
||||
import utils.ac3d.Ac3dException;
|
||||
|
@ -729,7 +730,7 @@ public class XmlReader
|
|||
editorFrame.getTrackData().getMainTrack().getPits().setLength(getAttrNumValue(pits, "length", "m"));
|
||||
editorFrame.getTrackData().getMainTrack().getPits().setWidth(getAttrNumValue(pits, "width", "m"));
|
||||
editorFrame.getTrackData().getMainTrack().getPits().setIndicator(getAttrIntValue(pits, "pit indicator"));
|
||||
editorFrame.getTrackData().getMainTrack().getPits().setSpeedLimit(getAttrNumValue(pits, "speed limit"));
|
||||
editorFrame.getTrackData().getMainTrack().getPits().setSpeedLimit(getAttrNumUnitsValue(pits, "speed limit"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -764,7 +765,7 @@ public class XmlReader
|
|||
editorFrame.getTrackData().getMainTrack().getPits().setExit(getAttrStrValue(mainTrack, "pit exit"));
|
||||
editorFrame.getTrackData().getMainTrack().getPits().setLength(getAttrNumValue(mainTrack, "pit length", "m"));
|
||||
editorFrame.getTrackData().getMainTrack().getPits().setWidth(getAttrNumValue(mainTrack, "pit width", "m"));
|
||||
editorFrame.getTrackData().getMainTrack().getPits().setSpeedLimit(getAttrNumValue(mainTrack, "speed limit"));
|
||||
editorFrame.getTrackData().getMainTrack().getPits().setSpeedLimit(getAttrNumUnitsValue(mainTrack, "speed limit"));
|
||||
}
|
||||
|
||||
private void setSideV3(Element seg, SegmentSide part, String sPart)
|
||||
|
@ -1094,6 +1095,34 @@ public class XmlReader
|
|||
return out;
|
||||
}
|
||||
|
||||
public synchronized DoubleValue getAttrNumUnitsValue(Element element, String name)
|
||||
{
|
||||
double out = Double.NaN;
|
||||
Element e = getChildWithName(element, name);
|
||||
if (e != null)
|
||||
{
|
||||
if (e.getName().equals("attnum"))
|
||||
{
|
||||
try
|
||||
{
|
||||
out = Double.parseDouble(e.getAttributeValue("val"));
|
||||
}
|
||||
catch (NumberFormatException exception)
|
||||
{
|
||||
String msg = filename + " : " + ((MyElement)e).getLineNumber() + " : " + e.getAttribute("name").getValue() + " : " + e.getAttributeValue("val");
|
||||
JOptionPane.showMessageDialog(editorFrame, msg, "Invalid number", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
if (!Double.isNaN(out))
|
||||
{
|
||||
return new DoubleValue(out, e.getAttributeValue("unit"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public synchronized double getAttrNumValue(Element element, String name, String expectedUnit)
|
||||
{
|
||||
double out = Double.NaN;
|
||||
|
@ -1144,6 +1173,22 @@ public class XmlReader
|
|||
{
|
||||
out = out * 3600.0;
|
||||
}
|
||||
else if (expectedUnit.equalsIgnoreCase("mph") && actualUnit.equals("m"))
|
||||
{
|
||||
out = out * 0.44704;
|
||||
}
|
||||
else if (expectedUnit.equalsIgnoreCase("mph") && actualUnit.equalsIgnoreCase("kph"))
|
||||
{
|
||||
out = out * 1.60934;
|
||||
}
|
||||
else if (expectedUnit.equalsIgnoreCase("kph") && actualUnit.equals("m"))
|
||||
{
|
||||
out = out * 0.277778;
|
||||
}
|
||||
else if (expectedUnit.equalsIgnoreCase("kph") && actualUnit.equalsIgnoreCase("mph"))
|
||||
{
|
||||
out = out * 0.621371;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("can't convert " + expectedUnit +" to " + actualUnit);
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.jdom.Element;
|
|||
import org.jdom.output.Format;
|
||||
|
||||
import gui.EditorFrame;
|
||||
import utils.DoubleValue;
|
||||
import utils.Editor;
|
||||
import utils.SegmentVector;
|
||||
import utils.circuit.Camera;
|
||||
|
@ -200,7 +201,7 @@ public class XmlWriter
|
|||
addContent(pits, "length", "m", editorFrame.getTrackData().getMainTrack().getPits().getLength());
|
||||
addContent(pits, "width", "m", editorFrame.getTrackData().getMainTrack().getPits().getWidth());
|
||||
addContent(pits, "pit indicator", null, editorFrame.getTrackData().getMainTrack().getPits().getIndicator());
|
||||
addContent(pits, "speed limit", "m", editorFrame.getTrackData().getMainTrack().getPits().getSpeedLimit());
|
||||
addContent(pits, "speed limit", editorFrame.getTrackData().getMainTrack().getPits().getSpeedLimit());
|
||||
|
||||
return pits;
|
||||
}
|
||||
|
@ -232,7 +233,7 @@ public class XmlWriter
|
|||
addContent(pits, "pit exit", editorFrame.getTrackData().getMainTrack().getPits().getExit());
|
||||
addContent(pits, "pit length", "m", editorFrame.getTrackData().getMainTrack().getPits().getLength());
|
||||
addContent(pits, "pit width", "m", editorFrame.getTrackData().getMainTrack().getPits().getWidth());
|
||||
addContent(pits, "speed limit", "m", editorFrame.getTrackData().getMainTrack().getPits().getSpeedLimit());
|
||||
addContent(pits, "speed limit", editorFrame.getTrackData().getMainTrack().getPits().getSpeedLimit());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -997,6 +998,14 @@ public class XmlWriter
|
|||
}
|
||||
}
|
||||
|
||||
private synchronized void addContent(Element section, String attribute, DoubleValue value)
|
||||
{
|
||||
if (value != null && !Double.isNaN(value.value))
|
||||
{
|
||||
section.addContent(attnumElement(attribute, value.units, value.value + ""));
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void addContent(Element section, String attribute, String units, int value)
|
||||
{
|
||||
if (value != Integer.MAX_VALUE)
|
||||
|
|
36
src/tools/trackeditor/utils/DoubleValue.java
Normal file
36
src/tools/trackeditor/utils/DoubleValue.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package utils;
|
||||
|
||||
public class DoubleValue
|
||||
{
|
||||
public double value = Double.NaN;
|
||||
public String units = null;
|
||||
|
||||
public DoubleValue()
|
||||
{
|
||||
}
|
||||
public DoubleValue(double value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
public DoubleValue(double value, String units)
|
||||
{
|
||||
this.value = value;
|
||||
this.units = units;
|
||||
}
|
||||
public double getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
public void setValue(double value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
public String getUnits()
|
||||
{
|
||||
return units;
|
||||
}
|
||||
public void setUnits(String units)
|
||||
{
|
||||
this.units = units;
|
||||
}
|
||||
}
|
|
@ -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.2.5";
|
||||
public final String version = "1.2.6";
|
||||
private String path;
|
||||
|
||||
private double imageScale = 1;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package utils.circuit;
|
||||
|
||||
import utils.DoubleValue;
|
||||
|
||||
public class Pits {
|
||||
private String side = null;
|
||||
private String entry = null;
|
||||
|
@ -12,9 +14,9 @@ public class Pits {
|
|||
private double width = Double.NaN;
|
||||
private double length = Double.NaN;
|
||||
private int style = Integer.MAX_VALUE;
|
||||
private int indicator = Integer.MAX_VALUE;
|
||||
private double speedLimit = Double.NaN;
|
||||
|
||||
private int indicator = Integer.MAX_VALUE;
|
||||
private DoubleValue speedLimit = null;
|
||||
|
||||
/**
|
||||
* @return Returns the side.
|
||||
*/
|
||||
|
@ -210,19 +212,65 @@ public class Pits {
|
|||
/**
|
||||
* @return Returns the speedLimit.
|
||||
*/
|
||||
public double getSpeedLimit()
|
||||
public DoubleValue getSpeedLimit()
|
||||
{
|
||||
return speedLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param speedLimit
|
||||
* The speedLimit to set.
|
||||
*/
|
||||
public void setSpeedLimit(double speedLimit)
|
||||
public void setSpeedLimit(DoubleValue speedLimit)
|
||||
{
|
||||
this.speedLimit = speedLimit;
|
||||
}
|
||||
|
||||
public double getSpeedLimitValue()
|
||||
{
|
||||
if (speedLimit == null)
|
||||
{
|
||||
return Double.NaN;
|
||||
}
|
||||
return speedLimit.value;
|
||||
}
|
||||
|
||||
public void setSpeedLimitValue(double speedLimit)
|
||||
{
|
||||
if (this.speedLimit == null)
|
||||
{
|
||||
if (Double.isNaN(speedLimit))
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.speedLimit = new DoubleValue();
|
||||
}
|
||||
this.speedLimit.value = speedLimit;
|
||||
}
|
||||
|
||||
public String getSpeedLimitUnits()
|
||||
{
|
||||
if (speedLimit == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return speedLimit.units;
|
||||
}
|
||||
|
||||
public void setSpeedLimitUnits(String units)
|
||||
{
|
||||
if (this.speedLimit == null)
|
||||
{
|
||||
if (units == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.speedLimit = new DoubleValue();
|
||||
}
|
||||
this.speedLimit.units = units;
|
||||
}
|
||||
|
||||
public void dump(String indent)
|
||||
{
|
||||
System.out.println(indent + "Pits");
|
||||
|
@ -238,6 +286,6 @@ public class Pits {
|
|||
System.out.println(indent + " length : " + length);
|
||||
System.out.println(indent + " style : " + style);
|
||||
System.out.println(indent + " indicator : " + indicator);
|
||||
System.out.println(indent + " speedLimit : " + speedLimit);
|
||||
System.out.println(indent + " speedLimit : " + speedLimit == null ? "null" : speedLimit.value + " " + (speedLimit.units != null ? speedLimit.units : ""));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue