working on Java-Implementation
This commit is contained in:
25
.classpath
25
.classpath
@@ -1,10 +1,27 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src/main/java"/>
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="module" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
/Debug/
|
/Debug/
|
||||||
*.pyc
|
*.pyc
|
||||||
/bin/
|
/bin/
|
||||||
|
/target/
|
||||||
|
|||||||
6
.project
6
.project
@@ -10,8 +10,14 @@
|
|||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
|||||||
8
.settings/org.eclipse.jdt.core.prefs
Normal file
8
.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=11
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=11
|
||||||
4
.settings/org.eclipse.m2e.core.prefs
Normal file
4
.settings/org.eclipse.m2e.core.prefs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
||||||
17
css/style.css
Normal file
17
css/style.css
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
.tile{
|
||||||
|
border: 1px solid black;
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
svg polygon,
|
||||||
|
svg rect{
|
||||||
|
fill:rgb(0,0,255);
|
||||||
|
stroke-width:3;
|
||||||
|
stroke:rgb(0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
svg text{
|
||||||
|
font-size: 50px;
|
||||||
|
}
|
||||||
93
src/main/java/de/srsoftware/web4rail/Application.java
Normal file
93
src/main/java/de/srsoftware/web4rail/Application.java
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
package de.srsoftware.web4rail;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
|
import com.sun.net.httpserver.HttpServer;
|
||||||
|
|
||||||
|
import de.keawe.localconfig.Configuration;
|
||||||
|
import de.keawe.tools.translations.Translation;
|
||||||
|
import de.srsoftware.web4rail.tiles.DiagNE;
|
||||||
|
import de.srsoftware.web4rail.tiles.DiagSW;
|
||||||
|
import de.srsoftware.web4rail.tiles.DiagWN;
|
||||||
|
import de.srsoftware.web4rail.tiles.EndE;
|
||||||
|
import de.srsoftware.web4rail.tiles.StraightH;
|
||||||
|
import de.srsoftware.web4rail.tiles.StraightV;
|
||||||
|
import de.srsoftware.web4rail.tiles.TurnoutSE;
|
||||||
|
import de.srsoftware.web4rail.tiles.TurnoutSW;
|
||||||
|
import de.srsoftware.web4rail.tiles.TurnoutWS;
|
||||||
|
|
||||||
|
public class Application {
|
||||||
|
private static Plan plan;
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(Application.class);
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
Configuration config = new Configuration(Configuration.dir("Web4Rail")+"/app.config");
|
||||||
|
plan = new Plan();
|
||||||
|
plan.set(0, 0, new StraightH());
|
||||||
|
plan.set(1, 0, new DiagSW());
|
||||||
|
plan.set(1, 1, new StraightV());
|
||||||
|
plan.set(1, 2, new DiagNE());
|
||||||
|
plan.set(2, 2, new TurnoutWS());
|
||||||
|
plan.set(3, 2, new DiagWN());
|
||||||
|
plan.set(3, 1, new TurnoutSE());
|
||||||
|
plan.set(3, 0, new TurnoutSW());
|
||||||
|
plan.set(2, 0, new EndE());
|
||||||
|
InetSocketAddress addr = new InetSocketAddress(config.getOrAdd("port", 8080));
|
||||||
|
HttpServer server = HttpServer.create(addr, 0);
|
||||||
|
server.createContext("/plan", client -> sendPlan(client));
|
||||||
|
server.createContext("/css" , client -> sendFile(client));
|
||||||
|
server.createContext("/svg" , client -> sendFile(client));
|
||||||
|
server.setExecutor(java.util.concurrent.Executors.newCachedThreadPool());
|
||||||
|
server.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendFile(HttpExchange client) throws IOException {
|
||||||
|
URI uri = client.getRequestURI();
|
||||||
|
File file = new File(System.getProperty("user.dir")+uri);
|
||||||
|
if (file.exists()) {
|
||||||
|
client.sendResponseHeaders(200, file.length());
|
||||||
|
OutputStream out = client.getResponseBody();
|
||||||
|
FileInputStream in = new FileInputStream(file);
|
||||||
|
in.transferTo(out);
|
||||||
|
in.close();
|
||||||
|
out.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendError(client,404,t("Could not find \"{}\"",uri));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendError(HttpExchange client, int code, String msg) throws IOException {
|
||||||
|
client.sendResponseHeaders(code, msg.length());
|
||||||
|
OutputStream out = client.getResponseBody();
|
||||||
|
out.write(msg.getBytes(StandardCharsets.UTF_8));
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String t(String text, Object...fills) {
|
||||||
|
return Translation.get(Application.class, text, fills);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendPlan(HttpExchange client) throws IOException {
|
||||||
|
send(client,plan.html().style("css/style.css"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void send(HttpExchange client, Page response) throws IOException {
|
||||||
|
client.getResponseHeaders().set("content-type", "text/plain");
|
||||||
|
StringBuffer html = response.html();
|
||||||
|
client.getResponseHeaders().add("content-type", "text/html");
|
||||||
|
client.sendResponseHeaders(200, html.length());
|
||||||
|
OutputStream os = client.getResponseBody();
|
||||||
|
os.write(html.toString().getBytes(StandardCharsets.UTF_8));
|
||||||
|
os.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
53
src/main/java/de/srsoftware/web4rail/Page.java
Normal file
53
src/main/java/de/srsoftware/web4rail/Page.java
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package de.srsoftware.web4rail;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import de.srsoftware.tools.Tag;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class Page {
|
||||||
|
private StringBuffer buf;
|
||||||
|
private Vector<String> cssFiles = new Vector<String>();
|
||||||
|
|
||||||
|
public Page() {
|
||||||
|
buf = new StringBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return head().append(body(buf)).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringBuffer head() {
|
||||||
|
StringBuffer sb = new StringBuffer()
|
||||||
|
.append("<html>\n")
|
||||||
|
.append("\t<head>\n");
|
||||||
|
for (String cssFile : cssFiles) {
|
||||||
|
sb.append("\t\t"+new Tag("link").attr("rel", "stylesheet").attr("type", "text/css").attr("href", cssFile)+"\n");
|
||||||
|
}
|
||||||
|
return sb.append("\t</head>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringBuffer body(StringBuffer content) {
|
||||||
|
return new StringBuffer()
|
||||||
|
.append("\t<body>\n")
|
||||||
|
.append(content)
|
||||||
|
.append("\t</body>\n")
|
||||||
|
.append("</html>\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringBuffer html() {
|
||||||
|
return head().append(body(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page append(Object code) {
|
||||||
|
buf.append(code);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page style(String cssPath) {
|
||||||
|
cssFiles.add(cssPath);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package de.srsoftware.web4rail;
|
package de.srsoftware.web4rail;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import de.srsoftware.web4rail.tiles.Tile;
|
import de.srsoftware.web4rail.tiles.Tile;
|
||||||
|
|
||||||
@@ -15,12 +16,25 @@ public class Plan {
|
|||||||
tiles.put(x, column);
|
tiles.put(x, column);
|
||||||
}
|
}
|
||||||
old = column.get(y);
|
old = column.get(y);
|
||||||
column.put(y,tile);
|
column.put(y,tile.position(x, y));
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tile get(int x, int y) {
|
public Tile get(int x, int y) {
|
||||||
HashMap<Integer, Tile> column = tiles.get(x);
|
HashMap<Integer, Tile> column = tiles.get(x);
|
||||||
return column == null ? null : column.get(y).position(x,y);
|
return column == null ? null : column.get(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page html() {
|
||||||
|
Page page = new Page();
|
||||||
|
for (Entry<Integer, HashMap<Integer, Tile>> column : tiles.entrySet()) {
|
||||||
|
int x = column.getKey();
|
||||||
|
for (Entry<Integer, Tile> row : column.getValue().entrySet()) {
|
||||||
|
int y = row.getKey();
|
||||||
|
Tile tile = row.getValue().position(x, y);
|
||||||
|
page.append("\t\t"+tile.html()+"\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return page;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,5 @@ package de.srsoftware.web4rail.tiles;
|
|||||||
|
|
||||||
public class DiagES extends Tile{
|
public class DiagES extends Tile{
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasConnector(Direction direction) {
|
|
||||||
switch (direction) {
|
|
||||||
case SOUTH:
|
|
||||||
case EAST:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
package de.srsoftware.web4rail.tiles;
|
package de.srsoftware.web4rail.tiles;
|
||||||
|
|
||||||
|
import de.srsoftware.tools.Tag;
|
||||||
|
|
||||||
public class DiagNE extends Tile{
|
public class DiagNE extends Tile{
|
||||||
|
public String html() {
|
||||||
|
Tag svg = new Tag("svg")
|
||||||
|
.id("tile-"+x+"-"+y)
|
||||||
|
.clazz(classes)
|
||||||
|
.size(100,100)
|
||||||
|
.attr("viewbox", "0 0 100 100")
|
||||||
|
.style("left: "+(30*x)+"px; top: "+(30*y)+"px");
|
||||||
|
|
||||||
@Override
|
new Tag("polygon")
|
||||||
public boolean hasConnector(Direction direction) {
|
.attr("points","35,0 65,0 100,35 100,65")
|
||||||
switch (direction) {
|
.addTo(svg);
|
||||||
case NORTH:
|
|
||||||
case EAST:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return svg.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
package de.srsoftware.web4rail.tiles;
|
package de.srsoftware.web4rail.tiles;
|
||||||
|
|
||||||
|
import de.srsoftware.tools.Tag;
|
||||||
|
|
||||||
public class DiagSW extends Tile{
|
public class DiagSW extends Tile{
|
||||||
|
public String html() {
|
||||||
|
Tag svg = new Tag("svg")
|
||||||
|
.id("tile-"+x+"-"+y)
|
||||||
|
.clazz(classes)
|
||||||
|
.size(100,100)
|
||||||
|
.attr("viewbox", "0 0 100 100")
|
||||||
|
.style("left: "+(30*x)+"px; top: "+(30*y)+"px");
|
||||||
|
|
||||||
@Override
|
new Tag("polygon")
|
||||||
public boolean hasConnector(Direction direction) {
|
.attr("points","0,35 65,100 35,100 0,65")
|
||||||
switch (direction) {
|
.addTo(svg);
|
||||||
case SOUTH:
|
|
||||||
case WEST:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return svg.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
package de.srsoftware.web4rail.tiles;
|
package de.srsoftware.web4rail.tiles;
|
||||||
|
|
||||||
|
import de.srsoftware.tools.Tag;
|
||||||
|
|
||||||
public class DiagWN extends Tile{
|
public class DiagWN extends Tile{
|
||||||
|
public String html() {
|
||||||
|
Tag svg = new Tag("svg")
|
||||||
|
.id("tile-"+x+"-"+y)
|
||||||
|
.clazz(classes)
|
||||||
|
.size(100,100)
|
||||||
|
.attr("viewbox", "0 0 100 100")
|
||||||
|
.style("left: "+(30*x)+"px; top: "+(30*y)+"px");
|
||||||
|
|
||||||
@Override
|
new Tag("polygon")
|
||||||
public boolean hasConnector(Direction direction) {
|
.attr("points","35,0 65,0 0,65 0,35")
|
||||||
switch (direction) {
|
.addTo(svg);
|
||||||
case NORTH:
|
|
||||||
case WEST:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return svg.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
22
src/main/java/de/srsoftware/web4rail/tiles/EndE.java
Normal file
22
src/main/java/de/srsoftware/web4rail/tiles/EndE.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package de.srsoftware.web4rail.tiles;
|
||||||
|
|
||||||
|
import de.srsoftware.tools.Tag;
|
||||||
|
|
||||||
|
public class EndE extends Tile{
|
||||||
|
public String html() {
|
||||||
|
Tag svg = new Tag("svg")
|
||||||
|
.id("tile-"+x+"-"+y)
|
||||||
|
.clazz(classes)
|
||||||
|
.size(100,100)
|
||||||
|
.attr("viewbox", "0 0 100 100")
|
||||||
|
.style("left: "+(30*x)+"px; top: "+(30*y)+"px");
|
||||||
|
|
||||||
|
new Tag("rect")
|
||||||
|
.size(60,30)
|
||||||
|
.pos(40,35)
|
||||||
|
.addTo(svg);
|
||||||
|
|
||||||
|
return svg.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,14 +1,21 @@
|
|||||||
package de.srsoftware.web4rail.tiles;
|
package de.srsoftware.web4rail.tiles;
|
||||||
|
|
||||||
|
import de.srsoftware.tools.Tag;
|
||||||
|
|
||||||
public class StraightH extends StretchableTile{
|
public class StraightH extends StretchableTile{
|
||||||
@Override
|
public String html() {
|
||||||
public boolean hasConnector(Direction direction) {
|
Tag svg = new Tag("svg")
|
||||||
switch (direction) {
|
.id("tile-"+x+"-"+y)
|
||||||
case EAST:
|
.clazz(classes)
|
||||||
case WEST:
|
.size(100,100)
|
||||||
return true;
|
.attr("viewbox", "0 0 100 100")
|
||||||
default:
|
.style("left: "+(30*x)+"px; top: "+(30*y)+"px");
|
||||||
return false;
|
|
||||||
}
|
new Tag("rect")
|
||||||
|
.size(100,30)
|
||||||
|
.pos(0,35)
|
||||||
|
.addTo(svg);
|
||||||
|
|
||||||
|
return svg.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
package de.srsoftware.web4rail.tiles;
|
package de.srsoftware.web4rail.tiles;
|
||||||
|
|
||||||
public class StraightV extends StretchableTile{
|
import de.srsoftware.tools.Tag;
|
||||||
|
|
||||||
@Override
|
public class StraightV extends StretchableTile{
|
||||||
public boolean hasConnector(Direction direction) {
|
public String html() {
|
||||||
switch (direction) {
|
Tag svg = new Tag("svg")
|
||||||
case NORTH:
|
.id("tile-"+x+"-"+y)
|
||||||
case SOUTH:
|
.clazz(classes)
|
||||||
return true;
|
.size(100,100)
|
||||||
default:
|
.attr("viewbox", "0 0 100 100")
|
||||||
return false;
|
.style("left: "+(30*x)+"px; top: "+(30*y)+"px");
|
||||||
}
|
|
||||||
|
new Tag("rect")
|
||||||
|
.size(30,100)
|
||||||
|
.pos(35,0)
|
||||||
|
.addTo(svg);
|
||||||
|
|
||||||
|
return svg.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +1,46 @@
|
|||||||
package de.srsoftware.web4rail.tiles;
|
package de.srsoftware.web4rail.tiles;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import de.keawe.tools.translations.Translation;
|
||||||
|
import de.srsoftware.tools.Tag;
|
||||||
|
import de.srsoftware.web4rail.Application;
|
||||||
|
|
||||||
public abstract class Tile {
|
public abstract class Tile {
|
||||||
|
|
||||||
public enum Direction{
|
protected int x,y;
|
||||||
NORTH,SOUTH,EAST,WEST;
|
protected HashSet<String> classes = new HashSet<String>();
|
||||||
}
|
|
||||||
private class Position {
|
|
||||||
int x,y;
|
|
||||||
}
|
|
||||||
|
|
||||||
Position position;
|
public Tile() {
|
||||||
private HashMap<Direction,Tile> neighbours = new HashMap();
|
classes.add("tile");
|
||||||
|
|
||||||
public abstract boolean hasConnector(Direction direction);
|
|
||||||
|
|
||||||
public boolean connect(Direction direction, Tile neighbour) {
|
|
||||||
if (hasConnector(direction)) {
|
|
||||||
switch (direction) {
|
|
||||||
case NORTH:
|
|
||||||
neighbour.neighbours.put(Direction.SOUTH, this);
|
|
||||||
neighbour.position.x = position.x;
|
|
||||||
neighbour.position.y = position.y-1;
|
|
||||||
case SOUTH:
|
|
||||||
neighbour.neighbours.put(Direction.NORTH, this);
|
|
||||||
neighbour.position.x = position.x;
|
|
||||||
neighbour.position.y = position.y+1;
|
|
||||||
case EAST:
|
|
||||||
neighbour.neighbours.put(Direction.WEST, this);
|
|
||||||
neighbour.position.x = position.x+1;
|
|
||||||
neighbour.position.y = position.y;
|
|
||||||
case WEST:
|
|
||||||
neighbour.neighbours.put(Direction.EAST, this);
|
|
||||||
neighbour.position.x = position.x-1;
|
|
||||||
neighbour.position.y = position.y;
|
|
||||||
}
|
|
||||||
neighbours.put(direction, neighbour);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tile neighbour(Direction direction) {
|
|
||||||
return neighbours.get(direction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tile position(int x, int y) {
|
public Tile position(int x, int y) {
|
||||||
position.x = x;
|
this.x = x;
|
||||||
position.y = y;
|
this.y = y;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String html() {
|
||||||
|
Tag svg = new Tag("svg")
|
||||||
|
.id("tile-"+x+"-"+y)
|
||||||
|
.clazz(classes)
|
||||||
|
.size(100,100)
|
||||||
|
.attr("viewbox", "0 0 100 100")
|
||||||
|
.style("left: "+(30*x)+"px; top: "+(30*y)+"px");
|
||||||
|
new Tag("title").content(t("No display defined for this tile ({})",getClass().getSimpleName())).addTo(svg);
|
||||||
|
|
||||||
|
new Tag("text")
|
||||||
|
.pos(35,70)
|
||||||
|
.content("?")
|
||||||
|
.addTo(svg);
|
||||||
|
|
||||||
|
|
||||||
|
return svg.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String t(String txt, Object...fills) {
|
||||||
|
return Translation.get(Application.class, txt, fills);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,5 @@ package de.srsoftware.web4rail.tiles;
|
|||||||
|
|
||||||
public class TurnoutEN extends Turnout{
|
public class TurnoutEN extends Turnout{
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasConnector(Direction direction) {
|
|
||||||
return direction != Direction.SOUTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,4 @@ package de.srsoftware.web4rail.tiles;
|
|||||||
|
|
||||||
public class TurnoutES extends Turnout{
|
public class TurnoutES extends Turnout{
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasConnector(Direction direction) {
|
|
||||||
return direction != Direction.NORTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,5 @@ package de.srsoftware.web4rail.tiles;
|
|||||||
|
|
||||||
public class TurnoutNE extends Turnout{
|
public class TurnoutNE extends Turnout{
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasConnector(Direction direction) {
|
|
||||||
return direction != Direction.WEST;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,5 @@ package de.srsoftware.web4rail.tiles;
|
|||||||
|
|
||||||
public class TurnoutNW extends Turnout{
|
public class TurnoutNW extends Turnout{
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasConnector(Direction direction) {
|
|
||||||
return direction != Direction.EAST;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,25 @@
|
|||||||
package de.srsoftware.web4rail.tiles;
|
package de.srsoftware.web4rail.tiles;
|
||||||
|
|
||||||
|
import de.srsoftware.tools.Tag;
|
||||||
|
|
||||||
public class TurnoutSE extends Turnout{
|
public class TurnoutSE extends Turnout{
|
||||||
|
public String html() {
|
||||||
|
Tag svg = new Tag("svg")
|
||||||
|
.id("tile-"+x+"-"+y)
|
||||||
|
.clazz(classes)
|
||||||
|
.size(100,100)
|
||||||
|
.attr("viewbox", "0 0 100 100")
|
||||||
|
.style("left: "+(30*x)+"px; top: "+(30*y)+"px");
|
||||||
|
|
||||||
@Override
|
new Tag("rect")
|
||||||
public boolean hasConnector(Direction direction) {
|
.size(30,100)
|
||||||
return direction != Direction.WEST;
|
.pos(35,0)
|
||||||
}
|
.addTo(svg);
|
||||||
|
|
||||||
|
new Tag("polygon")
|
||||||
|
.attr("points","35,100 100,35 100,65 65,100")
|
||||||
|
.addTo(svg);
|
||||||
|
|
||||||
|
return svg.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,25 @@
|
|||||||
package de.srsoftware.web4rail.tiles;
|
package de.srsoftware.web4rail.tiles;
|
||||||
|
|
||||||
|
import de.srsoftware.tools.Tag;
|
||||||
|
|
||||||
public class TurnoutSW extends Turnout{
|
public class TurnoutSW extends Turnout{
|
||||||
|
public String html() {
|
||||||
|
Tag svg = new Tag("svg")
|
||||||
|
.id("tile-"+x+"-"+y)
|
||||||
|
.clazz(classes)
|
||||||
|
.size(100,100)
|
||||||
|
.attr("viewbox", "0 0 100 100")
|
||||||
|
.style("left: "+(30*x)+"px; top: "+(30*y)+"px");
|
||||||
|
|
||||||
@Override
|
new Tag("rect")
|
||||||
public boolean hasConnector(Direction direction) {
|
.size(30,100)
|
||||||
return direction != Direction.EAST;
|
.pos(35,0)
|
||||||
}
|
.addTo(svg);
|
||||||
|
|
||||||
|
new Tag("polygon")
|
||||||
|
.attr("points","0,35 65,100 35,100 0,65")
|
||||||
|
.addTo(svg);
|
||||||
|
|
||||||
|
return svg.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,6 @@ package de.srsoftware.web4rail.tiles;
|
|||||||
|
|
||||||
public class TurnoutWN extends Turnout{
|
public class TurnoutWN extends Turnout{
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasConnector(Direction direction) {
|
|
||||||
return direction != Direction.SOUTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,25 @@
|
|||||||
package de.srsoftware.web4rail.tiles;
|
package de.srsoftware.web4rail.tiles;
|
||||||
|
|
||||||
|
import de.srsoftware.tools.Tag;
|
||||||
|
|
||||||
public class TurnoutWS extends Turnout{
|
public class TurnoutWS extends Turnout{
|
||||||
|
public String html() {
|
||||||
|
Tag svg = new Tag("svg")
|
||||||
|
.id("tile-"+x+"-"+y)
|
||||||
|
.clazz(classes)
|
||||||
|
.size(100,100)
|
||||||
|
.attr("viewbox", "0 0 100 100")
|
||||||
|
.style("left: "+(30*x)+"px; top: "+(30*y)+"px");
|
||||||
|
|
||||||
@Override
|
new Tag("rect")
|
||||||
public boolean hasConnector(Direction direction) {
|
.size(100,30)
|
||||||
return direction != Direction.NORTH;
|
.pos(0,35)
|
||||||
}
|
.addTo(svg);
|
||||||
|
|
||||||
|
new Tag("polygon")
|
||||||
|
.attr("points","0,35 65,100 35,100 0,65")
|
||||||
|
.addTo(svg);
|
||||||
|
|
||||||
|
return svg.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
72004
src/socket,sys,os
Normal file
72004
src/socket,sys,os
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user