introduced length units
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.srsoftware</groupId>
|
<groupId>de.srsoftware</groupId>
|
||||||
<artifactId>web4rail</artifactId>
|
<artifactId>web4rail</artifactId>
|
||||||
<version>1.1.7</version>
|
<version>1.1.8</version>
|
||||||
<name>Web4Rail</name>
|
<name>Web4Rail</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>Java Model Railway Control</description>
|
<description>Java Model Railway Control</description>
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ Left port\: : Port für links
|
|||||||
Length : Länge
|
Length : Länge
|
||||||
length\: : Länge:
|
length\: : Länge:
|
||||||
length\: {} : Länge: {}
|
length\: {} : Länge: {}
|
||||||
|
Length unit : Längeneinheit
|
||||||
Locomotive manager : Lok-Verwaltung
|
Locomotive manager : Lok-Verwaltung
|
||||||
Locomotives\: : Lokomotiven:
|
Locomotives\: : Lokomotiven:
|
||||||
Manage cars : Waggons verwalten
|
Manage cars : Waggons verwalten
|
||||||
@@ -160,6 +161,7 @@ Signals : Signale
|
|||||||
Simulating movement of {}... : Simuliere Fahrt von {}...
|
Simulating movement of {}... : Simuliere Fahrt von {}...
|
||||||
Slower (10 {}) : 10 {} langsamer
|
Slower (10 {}) : 10 {} langsamer
|
||||||
SOUTH : Süden
|
SOUTH : Süden
|
||||||
|
Speed unit : Geschwindigkeits-Einheit
|
||||||
Start actions : Start-Aktionen
|
Start actions : Start-Aktionen
|
||||||
Stock ID : Inventarnummer
|
Stock ID : Inventarnummer
|
||||||
Started {} : {} gestartet
|
Started {} : {} gestartet
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public abstract class BaseClass implements Constants{
|
|||||||
protected static Plan plan; // the track layout in use
|
protected static Plan plan; // the track layout in use
|
||||||
public static final Random random = new Random();
|
public static final Random random = new Random();
|
||||||
public static String speedUnit = DEFAULT_SPEED_UNIT;
|
public static String speedUnit = DEFAULT_SPEED_UNIT;
|
||||||
|
public static String lengthUnit = DEFAULT_LENGTH_UNIT;
|
||||||
private static final char[] HEX_CHARS = "0123456789ABCDEF".toCharArray();
|
private static final char[] HEX_CHARS = "0123456789ABCDEF".toCharArray();
|
||||||
public static Button contextButton(String context,String text) {
|
public static Button contextButton(String context,String text) {
|
||||||
String[] parts = context.split(":");
|
String[] parts = context.split(":");
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public interface Constants {
|
|||||||
public static final String CONTACT = "contact";
|
public static final String CONTACT = "contact";
|
||||||
public static final String CONTEXT = "context";
|
public static final String CONTEXT = "context";
|
||||||
public static final String DEFAULT_SPEED_UNIT = "km/h";
|
public static final String DEFAULT_SPEED_UNIT = "km/h";
|
||||||
|
public static final String DEFAULT_LENGTH_UNIT = "mm";
|
||||||
public static final String DISABLED = "disabled";
|
public static final String DISABLED = "disabled";
|
||||||
public static final String GITHUB_URL = "https://github.com/srsoftware-de/Web4Rail";
|
public static final String GITHUB_URL = "https://github.com/srsoftware-de/Web4Rail";
|
||||||
public static final String ID = "id";
|
public static final String ID = "id";
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ public class Plan extends BaseClass{
|
|||||||
private static final HashMap<OutputStreamWriter,Integer> clients = new HashMap<OutputStreamWriter, Integer>();
|
private static final HashMap<OutputStreamWriter,Integer> clients = new HashMap<OutputStreamWriter, Integer>();
|
||||||
private static final String FULLSCREEN = "fullscreen";
|
private static final String FULLSCREEN = "fullscreen";
|
||||||
private static final String SPEED_UNIT = "speed_unit";
|
private static final String SPEED_UNIT = "speed_unit";
|
||||||
|
private static final String LENGTH_UNIT = "length_unit";
|
||||||
|
|
||||||
public HashMap<String,Tile> tiles = new HashMap<String,Tile>(); // The list of tiles of this plan, i.e. the Track layout
|
public HashMap<String,Tile> tiles = new HashMap<String,Tile>(); // The list of tiles of this plan, i.e. the Track layout
|
||||||
private HashSet<Block> blocks = new HashSet<Block>(); // the list of tiles, that are blocks
|
private HashSet<Block> blocks = new HashSet<Block>(); // the list of tiles, that are blocks
|
||||||
@@ -419,9 +420,9 @@ public class Plan extends BaseClass{
|
|||||||
|
|
||||||
String content = new String(Files.readAllBytes(new File(filename+".plan").toPath()),UTF8);
|
String content = new String(Files.readAllBytes(new File(filename+".plan").toPath()),UTF8);
|
||||||
JSONObject json = new JSONObject(content);
|
JSONObject json = new JSONObject(content);
|
||||||
JSONArray jTiles = json.getJSONArray(TILE);
|
if (json.has(TILE)) json.getJSONArray(TILE).forEach(object -> Tile.load(object, plan));
|
||||||
jTiles.forEach(object -> Tile.load(object, plan));
|
if (json.has(LENGTH_UNIT)) lengthUnit = json.getString(LENGTH_UNIT);
|
||||||
speedUnit = json.getString(SPEED_UNIT);
|
if (json.has(SPEED_UNIT)) speedUnit = json.getString(SPEED_UNIT);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Train.loadAll(filename+".trains",plan);
|
Train.loadAll(filename+".trains",plan);
|
||||||
@@ -603,6 +604,7 @@ public class Plan extends BaseClass{
|
|||||||
Form form = new Form("plan-properties-form");
|
Form form = new Form("plan-properties-form");
|
||||||
new Input(REALM,REALM_PLAN).hideIn(form);
|
new Input(REALM,REALM_PLAN).hideIn(form);
|
||||||
new Input(ACTION,ACTION_UPDATE).hideIn(form);
|
new Input(ACTION,ACTION_UPDATE).hideIn(form);
|
||||||
|
new Input(LENGTH_UNIT, lengthUnit).addTo(new Label(t("Length unit")+":"+NBSP)).addTo(form);
|
||||||
new Input(SPEED_UNIT, speedUnit).addTo(new Label(t("Speed unit")+":"+NBSP)).addTo(form);
|
new Input(SPEED_UNIT, speedUnit).addTo(new Label(t("Speed unit")+":"+NBSP)).addTo(form);
|
||||||
new Button(t("Save"), form).addTo(form);
|
new Button(t("Save"), form).addTo(form);
|
||||||
form.addTo(win);
|
form.addTo(win);
|
||||||
@@ -708,7 +710,8 @@ public class Plan extends BaseClass{
|
|||||||
|
|
||||||
return new JSONObject()
|
return new JSONObject()
|
||||||
.put(TILE, jTiles)
|
.put(TILE, jTiles)
|
||||||
.put(SPEED_UNIT, speedUnit);
|
.put(SPEED_UNIT, speedUnit)
|
||||||
|
.put(LENGTH_UNIT, lengthUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -894,6 +897,7 @@ public class Plan extends BaseClass{
|
|||||||
Tile tile = get(params.get(ID),true);
|
Tile tile = get(params.get(ID),true);
|
||||||
if (isSet(tile)) return tile.update(params);
|
if (isSet(tile)) return tile.update(params);
|
||||||
|
|
||||||
|
if (params.containsKey(LENGTH_UNIT)) lengthUnit = params.get(LENGTH_UNIT);
|
||||||
if (params.containsKey(SPEED_UNIT)) speedUnit = params.get(SPEED_UNIT);
|
if (params.containsKey(SPEED_UNIT)) speedUnit = params.get(SPEED_UNIT);
|
||||||
|
|
||||||
return t("Plan updated.");
|
return t("Plan updated.");
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
|||||||
car.stockId,
|
car.stockId,
|
||||||
car.link(),
|
car.link(),
|
||||||
car.maxSpeed == 0 ? "–":(car.maxSpeed+NBSP+speedUnit),
|
car.maxSpeed == 0 ? "–":(car.maxSpeed+NBSP+speedUnit),
|
||||||
car.length,
|
car.length+NBSP+lengthUnit,
|
||||||
String.join(", ", car.tags()),
|
String.join(", ", car.tags()),
|
||||||
car.cloneButton()
|
car.cloneButton()
|
||||||
));
|
));
|
||||||
@@ -221,7 +221,7 @@ public class Car extends BaseClass implements Comparable<Car>{
|
|||||||
Fieldset fieldset = new Fieldset("Basic properties");
|
Fieldset fieldset = new Fieldset("Basic properties");
|
||||||
new Input(NAME,name).addTo(new Label(t("Name")+NBSP)).addTo(fieldset);
|
new Input(NAME,name).addTo(new Label(t("Name")+NBSP)).addTo(fieldset);
|
||||||
new Input(STOCK_ID,stockId).addTo(new Label(t("Stock ID")+NBSP)).addTo(fieldset);
|
new Input(STOCK_ID,stockId).addTo(new Label(t("Stock ID")+NBSP)).addTo(fieldset);
|
||||||
new Input(LENGTH,length).attr("type", "number").addTo(new Label(t("Length")+NBSP)).addTo(fieldset);
|
new Input(LENGTH,length).attr("type", "number").addTo(new Label(t("Length")+NBSP)).content(NBSP+lengthUnit).addTo(fieldset);
|
||||||
new Input(TAGS,String.join(", ", tags)).addTo(new Label(t("Tags")+NBSP)).addTo(fieldset);
|
new Input(TAGS,String.join(", ", tags)).addTo(new Label(t("Tags")+NBSP)).addTo(fieldset);
|
||||||
new Input(MAX_SPEED, maxSpeed).numeric().addTo(new Label(t("Maximum speed")+":"+NBSP)).content(NBSP+speedUnit).addTo(fieldset);
|
new Input(MAX_SPEED, maxSpeed).numeric().addTo(new Label(t("Maximum speed")+":"+NBSP)).content(NBSP+speedUnit).addTo(fieldset);
|
||||||
fieldset.addTo(form);
|
fieldset.addTo(form);
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ public class Locomotive extends Car implements Constants,Device{
|
|||||||
.map(car -> (Locomotive)car)
|
.map(car -> (Locomotive)car)
|
||||||
.sorted(Comparator.comparing(loco -> loco.address))
|
.sorted(Comparator.comparing(loco -> loco.address))
|
||||||
.sorted(Comparator.comparing(loco -> loco.stockId))
|
.sorted(Comparator.comparing(loco -> loco.stockId))
|
||||||
.forEach(loco -> table.addRow(loco.stockId,loco.link(),loco.maxSpeed == 0 ? "–":loco.maxSpeed+NBSP+speedUnit,loco.proto,loco.address,loco.length,String.join(", ", loco.tags())));
|
.forEach(loco -> table.addRow(loco.stockId,loco.link(),loco.maxSpeed == 0 ? "–":loco.maxSpeed+NBSP+speedUnit,loco.proto,loco.address,loco.length+NBSP+lengthUnit,String.join(", ", loco.tags())));
|
||||||
table.addTo(win);
|
table.addTo(win);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -458,7 +458,7 @@ public class Train extends BaseClass implements Comparable<Train> {
|
|||||||
int ms = train.maxSpeed();
|
int ms = train.maxSpeed();
|
||||||
table.addRow(
|
table.addRow(
|
||||||
train.link(),
|
train.link(),
|
||||||
train.length(),
|
train.length()+NBSP+lengthUnit,
|
||||||
ms == Integer.MAX_VALUE ? "–" : ms+NBSP+speedUnit,
|
ms == Integer.MAX_VALUE ? "–" : ms+NBSP+speedUnit,
|
||||||
String.join(", ", train.tags()),
|
String.join(", ", train.tags()),
|
||||||
train.route,
|
train.route,
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ public abstract class Tile extends BaseClass{
|
|||||||
Form form = propForm("tile-properties-"+id());
|
Form form = propForm("tile-properties-"+id());
|
||||||
if (isTrack) {
|
if (isTrack) {
|
||||||
new Tag("h4").content(t("Length")).addTo(form);
|
new Tag("h4").content(t("Length")).addTo(form);
|
||||||
new Input(LENGTH,length).numeric().addTo(new Label(t("Length")+":"+NBSP)).addTo(form);
|
new Input(LENGTH,length).numeric().addTo(new Label(t("Length")+":"+NBSP)).content(NBSP+lengthUnit).addTo(form);
|
||||||
new Tag("h4").content(t("Availability")).addTo(form);
|
new Tag("h4").content(t("Availability")).addTo(form);
|
||||||
Checkbox cb = new Checkbox(DISABLED, t("disabled"), disabled);
|
Checkbox cb = new Checkbox(DISABLED, t("disabled"), disabled);
|
||||||
if (disabled) cb.clazz("disabled");
|
if (disabled) cb.clazz("disabled");
|
||||||
|
|||||||
Reference in New Issue
Block a user