From 38c5e494adae77914bdcb3870210db5d6081d4fa Mon Sep 17 00:00:00 2001 From: iMoHax Date: Thu, 14 Apr 2016 13:14:33 +0300 Subject: [PATCH] show current entry on track screen --- .../src/main/java/ru/trader/view/support/Track.java | 13 +++++++++++++ client/src/main/resources/view/style.css | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/client/src/main/java/ru/trader/view/support/Track.java b/client/src/main/java/ru/trader/view/support/Track.java index b842a87..eb6d006 100644 --- a/client/src/main/java/ru/trader/view/support/Track.java +++ b/client/src/main/java/ru/trader/view/support/Track.java @@ -2,6 +2,7 @@ package ru.trader.view.support; import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.value.ChangeListener; import javafx.scene.Node; import javafx.scene.input.MouseButton; import javafx.scene.layout.HBox; @@ -19,6 +20,7 @@ import java.util.List; public class Track { private final static String CSS_ROUTE = "route"; private final static String CSS_ROUTE_ENTRY = "route-entry"; + private final static String CSS_ROUTE_CURRENT_ENTRY = "route-current-entry"; 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"; @@ -38,6 +40,7 @@ public class Track { active = new SimpleIntegerProperty(-1); node.getStyleClass().add(CSS_ROUTE); build(); + route.currentEntryProperty().addListener((ov , o, n) -> updateCurrentEntry(o.intValue(), n.intValue())); } private void build(){ @@ -62,6 +65,7 @@ public class Track { }); entryNodes.add(entryNode); } + updateCurrentEntry(-1, route.getCurrentEntry()); } private VBox buildStationNode(RouteEntryModel entry){ @@ -130,4 +134,13 @@ public class Track { public Node getNode() { return node; } + + private void updateCurrentEntry(int oldIndex, int newIndex){ + if (oldIndex != -1){ + entryNodes.get(oldIndex).getStyleClass().remove(CSS_ROUTE_CURRENT_ENTRY); + } + if (newIndex != -1){ + entryNodes.get(newIndex).getStyleClass().add(CSS_ROUTE_CURRENT_ENTRY); + } + } } diff --git a/client/src/main/resources/view/style.css b/client/src/main/resources/view/style.css index a0515ee..38b2e1b 100644 --- a/client/src/main/resources/view/style.css +++ b/client/src/main/resources/view/style.css @@ -154,6 +154,10 @@ HBox.fields-group hbox-margin{ -fx-max-width: 60px; } +.route-current-entry { + -fx-background-color: orange; +} + .route-active { -fx-background-color: lightskyblue; }