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,16 +56,44 @@ 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);
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 icons = new VBox();
VBox.setVgrow(icons, Priority.ALWAYS);
stationNode.getStyleClass().add(CSS_SYSTEM);
icons.getStyleClass().add(CSS_ICONS); icons.getStyleClass().add(CSS_ICONS);
VBox.setVgrow(icons, Priority.ALWAYS);
stationNode.getChildren().add(buildText(entry.getStation(), entry.isTransit()));
if (entry.isBuy()){ if (entry.isBuy()){
icons.getChildren().add(Glyph.create("FontAwesome|UPLOAD")); icons.getChildren().add(Glyph.create("FontAwesome|UPLOAD"));
} }
@@ -76,37 +103,23 @@ public class Track {
if (entry.isSell()){ if (entry.isSell()){
icons.getChildren().add(Glyph.create("FontAwesome|DOWNLOAD")); icons.getChildren().add(Glyph.create("FontAwesome|DOWNLOAD"));
} }
entryNode.getChildren().addAll(stationNode, icons); return 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();
}
} }
private VBox buildText(StationModel station, boolean transit){ private VBox buildInfoNode(RouteEntryModel prevEntry, RouteEntryModel entry){
Text systemText = new Text(station.getSystem().getName()); VBox node = new VBox();
systemText.getStyleClass().add(CSS_SYSTEM_TEXT); node.getStyleClass().add(CSS_INFO);
VBox.setVgrow(node, Priority.ALWAYS);
VBox text = new VBox(2); Text timeText = new Text(ViewUtils.timeToString(entry.getTime()));
VBox.setVgrow(text, Priority.ALWAYS); Text distanceText = new Text(prevEntry != null ? ViewUtils.distanceToString(prevEntry.getStation().getSystem().getDistance(entry.getStation().getSystem())): "");
text.getStyleClass().add(CSS_TEXT); Text stationDistanceText = new Text(entry.getStation().getSystem().getName());
text.getChildren().addAll(systemText); if (entry.isTransit()) {
stationDistanceText.setText("");
if (!transit) { } else {
Text stationText = new Text(station.getName()); stationDistanceText.setText(ViewUtils.stationDistanceToString(entry.getStation().getDistance()));
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);
} }
node.getChildren().addAll(timeText, distanceText, stationDistanceText);
return text; 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;