Before Width: | Height: | Size: 156 B After Width: | Height: | Size: 211 B |
Before Width: | Height: | Size: 152 B After Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 152 B After Width: | Height: | Size: 207 B |
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 199 B |
Before Width: | Height: | Size: 152 B After Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 200 B |
Before Width: | Height: | Size: 156 B After Width: | Height: | Size: 212 B |
Before Width: | Height: | Size: 152 B After Width: | Height: | Size: 204 B |
@ -1,14 +1,35 @@
@@ -1,14 +1,35 @@
|
||||
package de.srsoftware.web4rail.tiles; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.Map; |
||||
|
||||
import de.srsoftware.tools.Tag; |
||||
|
||||
public abstract class Turnout extends Tile { |
||||
public static final String STATE = "state"; |
||||
public enum State{ |
||||
LEFT,STRAIGHT,RIGHT,UNDEF; |
||||
} |
||||
private boolean straight = true; |
||||
protected State state = State.STRAIGHT; |
||||
|
||||
public State state() { |
||||
return state; |
||||
} |
||||
|
||||
public void state(State newState) throws IOException { |
||||
state = newState; |
||||
LOG.debug("Setting {} to {}",this,state); |
||||
plan.stream("place "+tag(null)); |
||||
} |
||||
|
||||
@Override |
||||
public Tag tag(Map<String, Object> replacements) throws IOException { |
||||
Tag tag = super.tag(replacements); |
||||
tag.clazz(tag.get("class")+(" "+state).toLowerCase()); |
||||
return tag; |
||||
} |
||||
|
||||
public boolean toggle() { |
||||
straight = !straight; |
||||
return straight; |
||||
public void toggle() { |
||||
state = State.STRAIGHT; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
package de.srsoftware.web4rail.tiles; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
public class TurnoutL extends Turnout { |
||||
@Override |
||||
public Object click() throws IOException { |
||||
state = (state == State.STRAIGHT) ? State.LEFT : State.STRAIGHT; |
||||
return tag(null); |
||||
} |
||||
} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
package de.srsoftware.web4rail.tiles; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
public class TurnoutR extends Turnout { |
||||
@Override |
||||
public Object click() throws IOException { |
||||
state = (state == State.STRAIGHT) ? State.RIGHT : State.STRAIGHT; |
||||
return tag(null); |
||||
} |
||||
} |