change track node
This commit is contained in:
@@ -19,12 +19,11 @@ import java.util.List;
|
||||
|
||||
public class Track {
|
||||
private final static String CSS_ROUTE = "route";
|
||||
private final static String CSS_ICONS = "route-icons";
|
||||
private final static String CSS_TRACK = "route-track";
|
||||
private final static String CSS_TRACK_TEXT = "route-track-text";
|
||||
private final static String CSS_ROUTE_MARKER = "route-marker";
|
||||
private final static String CSS_SYSTEM = "route-system";
|
||||
private final static String CSS_ICONS = "route-icons";
|
||||
private final static String CSS_INFO = "route-info";
|
||||
private final static String CSS_ACTIVE_SYSTEM = "route-active";
|
||||
private final static String CSS_TEXT = "route-text";
|
||||
private final static String CSS_SYSTEM_TEXT = "route-system-text";
|
||||
private final static String CSS_STATION_TEXT = "route-station-text";
|
||||
|
||||
@@ -42,7 +41,7 @@ public class Track {
|
||||
}
|
||||
|
||||
private void build(){
|
||||
StationModel prev = null;
|
||||
RouteEntryModel prev = null;
|
||||
for (RouteEntryModel entry : route.getEntries()) {
|
||||
/* if (prev != null){
|
||||
VBox track = new VBox();
|
||||
@@ -57,16 +56,44 @@ public class Track {
|
||||
}*/
|
||||
HBox entryNode = new HBox();
|
||||
Circle circle = new Circle(5);
|
||||
circle.getStyleClass().add(CSS_ROUTE_MARKER);
|
||||
entryNode.getChildren().add(circle);
|
||||
VBox stationNode = new VBox();
|
||||
VBox stationNode = buildStationNode(entry);
|
||||
HBox.setHgrow(stationNode, Priority.ALWAYS);
|
||||
VBox icons = buildIconsNode(entry);
|
||||
VBox info = buildInfoNode(prev, entry);
|
||||
entryNode.getChildren().addAll(stationNode, icons, info);
|
||||
node.getChildren().addAll(entryNode);
|
||||
final int curIndex = entryNodes.size();
|
||||
entryNode.setOnMouseClicked(e -> {
|
||||
if (e.getButton() == MouseButton.PRIMARY){
|
||||
setActive(curIndex);
|
||||
}
|
||||
});
|
||||
entryNodes.add(entryNode);
|
||||
prev = entry;
|
||||
}
|
||||
}
|
||||
|
||||
private VBox buildStationNode(RouteEntryModel entry){
|
||||
VBox node = new VBox();
|
||||
node.getStyleClass().add(CSS_SYSTEM);
|
||||
VBox.setVgrow(node, Priority.ALWAYS);
|
||||
Text systemText = new Text(entry.getStation().getSystem().getName());
|
||||
systemText.getStyleClass().add(CSS_SYSTEM_TEXT);
|
||||
node.getChildren().addAll(systemText);
|
||||
if (!entry.isTransit()) {
|
||||
Text stationText = new Text(entry.getStation().getName());
|
||||
stationText.getStyleClass().add(CSS_STATION_TEXT);
|
||||
node.getChildren().addAll(stationText);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private VBox buildIconsNode(RouteEntryModel entry){
|
||||
VBox icons = new VBox();
|
||||
VBox.setVgrow(icons, Priority.ALWAYS);
|
||||
|
||||
stationNode.getStyleClass().add(CSS_SYSTEM);
|
||||
icons.getStyleClass().add(CSS_ICONS);
|
||||
|
||||
stationNode.getChildren().add(buildText(entry.getStation(), entry.isTransit()));
|
||||
|
||||
VBox.setVgrow(icons, Priority.ALWAYS);
|
||||
if (entry.isBuy()){
|
||||
icons.getChildren().add(Glyph.create("FontAwesome|UPLOAD"));
|
||||
}
|
||||
@@ -76,37 +103,23 @@ public class Track {
|
||||
if (entry.isSell()){
|
||||
icons.getChildren().add(Glyph.create("FontAwesome|DOWNLOAD"));
|
||||
}
|
||||
entryNode.getChildren().addAll(stationNode, icons);
|
||||
node.getChildren().addAll(entryNode);
|
||||
final int curIndex = entryNodes.size();
|
||||
entryNode.setOnMouseClicked(e -> {
|
||||
if (e.getButton() == MouseButton.PRIMARY){
|
||||
setActive(curIndex);
|
||||
}
|
||||
});
|
||||
entryNodes.add(entryNode);
|
||||
prev = entry.getStation();
|
||||
}
|
||||
return icons;
|
||||
}
|
||||
|
||||
private VBox buildText(StationModel station, boolean transit){
|
||||
Text systemText = new Text(station.getSystem().getName());
|
||||
systemText.getStyleClass().add(CSS_SYSTEM_TEXT);
|
||||
|
||||
VBox text = new VBox(2);
|
||||
VBox.setVgrow(text, Priority.ALWAYS);
|
||||
text.getStyleClass().add(CSS_TEXT);
|
||||
text.getChildren().addAll(systemText);
|
||||
|
||||
if (!transit) {
|
||||
Text stationText = new Text(station.getName());
|
||||
stationText.getStyleClass().add(CSS_STATION_TEXT);
|
||||
Text distanceText = new Text(String.format("%.0f Ls", station.getDistance()));
|
||||
distanceText.getStyleClass().add(CSS_STATION_TEXT);
|
||||
text.getChildren().addAll(stationText, distanceText);
|
||||
private VBox buildInfoNode(RouteEntryModel prevEntry, RouteEntryModel entry){
|
||||
VBox node = new VBox();
|
||||
node.getStyleClass().add(CSS_INFO);
|
||||
VBox.setVgrow(node, Priority.ALWAYS);
|
||||
Text timeText = new Text(ViewUtils.timeToString(entry.getTime()));
|
||||
Text distanceText = new Text(prevEntry != null ? ViewUtils.distanceToString(prevEntry.getStation().getSystem().getDistance(entry.getStation().getSystem())): "");
|
||||
Text stationDistanceText = new Text(entry.getStation().getSystem().getName());
|
||||
if (entry.isTransit()) {
|
||||
stationDistanceText.setText("");
|
||||
} else {
|
||||
stationDistanceText.setText(ViewUtils.stationDistanceToString(entry.getStation().getDistance()));
|
||||
}
|
||||
|
||||
return text;
|
||||
node.getChildren().addAll(timeText, distanceText, stationDistanceText);
|
||||
return node;
|
||||
}
|
||||
|
||||
public int getActive() {
|
||||
|
||||
@@ -61,39 +61,30 @@ HBox.fields-group hbox-margin{
|
||||
-fx-fill-height: true;
|
||||
}
|
||||
|
||||
.route-system, .path-system {
|
||||
.route-marker {
|
||||
-fx-alignment: center-left;
|
||||
}
|
||||
|
||||
.route-system {
|
||||
-fx-alignment: top-left;
|
||||
-fx-text-alignment: left;
|
||||
}
|
||||
|
||||
.route-text, .path-text {
|
||||
-fx-alignment: center;
|
||||
.route-system-text {
|
||||
-fx-font-size: 17;
|
||||
}
|
||||
|
||||
.route-system-text, .path-system-text {
|
||||
.route-station-text {
|
||||
-fx-font-size: 14;
|
||||
}
|
||||
|
||||
.route-station-text, .path-station-text {
|
||||
-fx-font-size: 8pt;
|
||||
.route-icons {
|
||||
-fx-alignment: top-right;
|
||||
}
|
||||
|
||||
.route-icons, .path-icons {
|
||||
-fx-alignment: center;
|
||||
}
|
||||
|
||||
.route-track, .path-track {
|
||||
-fx-padding: 0 8;
|
||||
-fx-alignment: center;
|
||||
}
|
||||
|
||||
.route-track .glyph-font, .path-track .glyph-font {
|
||||
-fx-font-family: FontAwesome;
|
||||
-fx-font-size: 16pt;
|
||||
}
|
||||
|
||||
|
||||
.route-track-text, .path-track-text {
|
||||
-fx-font-size: 7pt;
|
||||
.route-info {
|
||||
-fx-alignment: top-right;
|
||||
-fx-font-size: 12;
|
||||
}
|
||||
|
||||
.route-active {
|
||||
@@ -101,11 +92,6 @@ HBox.fields-group hbox-margin{
|
||||
-fx-background-color: lightskyblue;
|
||||
}
|
||||
|
||||
.path-pane {
|
||||
-fx-padding: 10;
|
||||
-fx-alignment: center-left;
|
||||
}
|
||||
|
||||
/* EditOfferCell */
|
||||
#items .change {
|
||||
-fx-background-color: lightgreen;
|
||||
|
||||
Reference in New Issue
Block a user