Archived
0

change track node

This commit is contained in:
iMoHax
2015-11-09 17:52:38 +03:00
parent d8da2b0eb0
commit d3fe01c92d
2 changed files with 66 additions and 67 deletions

View File

@@ -19,12 +19,11 @@ import java.util.List;
public class Track { public class Track {
private final static String CSS_ROUTE = "route"; private final static String CSS_ROUTE = "route";
private final static String CSS_ICONS = "route-icons"; private final static String CSS_ROUTE_MARKER = "route-marker";
private final static String CSS_TRACK = "route-track";
private final static String CSS_TRACK_TEXT = "route-track-text";
private final static String CSS_SYSTEM = "route-system"; 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_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_SYSTEM_TEXT = "route-system-text";
private final static String CSS_STATION_TEXT = "route-station-text"; private final static String CSS_STATION_TEXT = "route-station-text";
@@ -42,7 +41,7 @@ public class Track {
} }
private void build(){ private void build(){
StationModel prev = null; RouteEntryModel prev = null;
for (RouteEntryModel entry : route.getEntries()) { for (RouteEntryModel entry : route.getEntries()) {
/* if (prev != null){ /* if (prev != null){
VBox track = new VBox(); VBox track = new VBox();
@@ -57,26 +56,13 @@ public class Track {
}*/ }*/
HBox entryNode = new HBox(); HBox entryNode = new HBox();
Circle circle = new Circle(5); Circle circle = new Circle(5);
circle.getStyleClass().add(CSS_ROUTE_MARKER);
entryNode.getChildren().add(circle); entryNode.getChildren().add(circle);
VBox stationNode = new VBox(); VBox stationNode = buildStationNode(entry);
VBox icons = new VBox(); HBox.setHgrow(stationNode, Priority.ALWAYS);
VBox.setVgrow(icons, Priority.ALWAYS); VBox icons = buildIconsNode(entry);
VBox info = buildInfoNode(prev, entry);
stationNode.getStyleClass().add(CSS_SYSTEM); entryNode.getChildren().addAll(stationNode, icons, info);
icons.getStyleClass().add(CSS_ICONS);
stationNode.getChildren().add(buildText(entry.getStation(), entry.isTransit()));
if (entry.isBuy()){
icons.getChildren().add(Glyph.create("FontAwesome|UPLOAD"));
}
if (entry.getRefill() > 0){
icons.getChildren().add(Glyph.create("FontAwesome|REFRESH"));
}
if (entry.isSell()){
icons.getChildren().add(Glyph.create("FontAwesome|DOWNLOAD"));
}
entryNode.getChildren().addAll(stationNode, icons);
node.getChildren().addAll(entryNode); node.getChildren().addAll(entryNode);
final int curIndex = entryNodes.size(); final int curIndex = entryNodes.size();
entryNode.setOnMouseClicked(e -> { entryNode.setOnMouseClicked(e -> {
@@ -85,28 +71,55 @@ public class Track {
} }
}); });
entryNodes.add(entryNode); entryNodes.add(entryNode);
prev = entry.getStation(); prev = entry;
} }
} }
private VBox buildText(StationModel station, boolean transit){ private VBox buildStationNode(RouteEntryModel entry){
Text systemText = new Text(station.getSystem().getName()); 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); systemText.getStyleClass().add(CSS_SYSTEM_TEXT);
node.getChildren().addAll(systemText);
VBox text = new VBox(2); if (!entry.isTransit()) {
VBox.setVgrow(text, Priority.ALWAYS); Text stationText = new Text(entry.getStation().getName());
text.getStyleClass().add(CSS_TEXT);
text.getChildren().addAll(systemText);
if (!transit) {
Text stationText = new Text(station.getName());
stationText.getStyleClass().add(CSS_STATION_TEXT); stationText.getStyleClass().add(CSS_STATION_TEXT);
Text distanceText = new Text(String.format("%.0f Ls", station.getDistance())); node.getChildren().addAll(stationText);
distanceText.getStyleClass().add(CSS_STATION_TEXT);
text.getChildren().addAll(stationText, distanceText);
} }
return node;
}
return text; private VBox buildIconsNode(RouteEntryModel entry){
VBox icons = new VBox();
icons.getStyleClass().add(CSS_ICONS);
VBox.setVgrow(icons, Priority.ALWAYS);
if (entry.isBuy()){
icons.getChildren().add(Glyph.create("FontAwesome|UPLOAD"));
}
if (entry.getRefill() > 0){
icons.getChildren().add(Glyph.create("FontAwesome|REFRESH"));
}
if (entry.isSell()){
icons.getChildren().add(Glyph.create("FontAwesome|DOWNLOAD"));
}
return icons;
}
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()));
}
node.getChildren().addAll(timeText, distanceText, stationDistanceText);
return node;
} }
public int getActive() { public int getActive() {

View File

@@ -61,39 +61,30 @@ HBox.fields-group hbox-margin{
-fx-fill-height: true; -fx-fill-height: true;
} }
.route-system, .path-system { .route-marker {
-fx-alignment: center-left; -fx-alignment: center-left;
}
.route-system {
-fx-alignment: top-left;
-fx-text-alignment: left; -fx-text-alignment: left;
} }
.route-text, .path-text { .route-system-text {
-fx-alignment: center; -fx-font-size: 17;
} }
.route-system-text, .path-system-text { .route-station-text {
-fx-font-size: 14;
} }
.route-station-text, .path-station-text { .route-icons {
-fx-font-size: 8pt; -fx-alignment: top-right;
} }
.route-icons, .path-icons { .route-info {
-fx-alignment: center; -fx-alignment: top-right;
} -fx-font-size: 12;
.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-active { .route-active {
@@ -101,11 +92,6 @@ HBox.fields-group hbox-margin{
-fx-background-color: lightskyblue; -fx-background-color: lightskyblue;
} }
.path-pane {
-fx-padding: 10;
-fx-alignment: center-left;
}
/* EditOfferCell */ /* EditOfferCell */
#items .change { #items .change {
-fx-background-color: lightgreen; -fx-background-color: lightgreen;