show distance in Ls if less 0.01
This commit is contained in:
@@ -2,10 +2,7 @@ package ru.trader.model;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.core.OFFER_TYPE;
|
||||
import ru.trader.core.Offer;
|
||||
import ru.trader.core.SERVICE_TYPE;
|
||||
import ru.trader.core.Vendor;
|
||||
import ru.trader.core.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -106,7 +103,10 @@ public class StationModel {
|
||||
}
|
||||
|
||||
public double getDistance(StationModel other){
|
||||
return station.getPlace().getDistance(other.station.getPlace());
|
||||
Place place = station.getPlace();
|
||||
Place otherPlace = other.station.getPlace();
|
||||
if (!place.equals(otherPlace)) return station.getPlace().getDistance(other.station.getPlace());
|
||||
return (station.getDistance() + other.station.getDistance() + Math.abs(station.getDistance() - other.station.getDistance())) * 0.00000003169 / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.controlsfx.glyphfont.Glyph;
|
||||
import ru.trader.core.Order;
|
||||
import ru.trader.graph.PathRoute;
|
||||
import ru.trader.model.PathRouteModel;
|
||||
import ru.trader.view.support.cells.DistanceCell;
|
||||
|
||||
public class RouteNode {
|
||||
private final static String CSS_PATH = "path";
|
||||
@@ -52,7 +53,7 @@ public class RouteNode {
|
||||
|
||||
node.getChildren().addAll(v, icons);
|
||||
|
||||
Text t = new Text(String.format("(%.2f LY)", p.getDistance()));
|
||||
Text t = new Text(DistanceCell.distanceToString(p.getDistance()));
|
||||
t.getStyleClass().add(CSS_TRACK_TEXT);
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package ru.trader.view.support.cells;
|
||||
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.util.Callback;
|
||||
import ru.trader.view.support.NaNComparator;
|
||||
|
||||
public class DistanceCell<T> implements Callback<TableColumn<T, Double>, TableCell<T, Double>> {
|
||||
public DistanceCell() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableCell<T, Double> call(TableColumn<T, Double> param) {
|
||||
param.setComparator(new NaNComparator<>());
|
||||
return new TableCell<T, Double>(){
|
||||
@Override
|
||||
protected void updateItem(Double item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
setText(distanceToString(item));
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static String distanceToString(double distance){
|
||||
if (distance < 0.01) return String.format("%.0f Ls", distance / 0.00000003169);
|
||||
return String.format("%.2f LY", distance);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
<?import ru.trader.view.support.cells.OfferCellValueImpl?>
|
||||
<?import ru.trader.view.support.cells.OfferTableCell?>
|
||||
<?import ru.trader.view.support.cells.DistanceCell?>
|
||||
<HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="ru.trader.controllers.OrdersController" styleClass="dialog"
|
||||
prefWidth="1010">
|
||||
@@ -58,7 +59,7 @@
|
||||
<cellValueFactory><PropertyValueFactory property="price"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="curDistance" minWidth="80.0" text="%market.order.distance">
|
||||
<cellFactory><DoubleCell format="\%.2f LY"/></cellFactory>
|
||||
<cellFactory><DistanceCell/></cellFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="curProfit" minWidth="80.0" text="%market.order.profit" sortType="DESCENDING">
|
||||
<cellFactory><DoubleCell/></cellFactory>
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<?import ru.trader.view.support.cells.OfferCellValueImpl?>
|
||||
<?import ru.trader.view.support.cells.OfferTableCell?>
|
||||
<?import ru.trader.view.support.cells.PathRouteCell?>
|
||||
<?import ru.trader.view.support.cells.DistanceCell?>
|
||||
<HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="ru.trader.controllers.PathsController" styleClass="dialog"
|
||||
prefWidth="1050">
|
||||
@@ -28,7 +29,7 @@
|
||||
<cellValueFactory><PropertyValueFactory property="lands"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn minWidth="80.0" text="%market.order.distance">
|
||||
<cellFactory><DoubleCell format="\%.2f LY"/></cellFactory>
|
||||
<cellFactory><DistanceCell /></cellFactory>
|
||||
<cellValueFactory><PropertyValueFactory property="distance"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn minWidth="70.0" text="%market.order.profit">
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<?import ru.trader.view.support.cells.OfferCellValueImpl?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import ru.trader.view.support.cells.DistanceCell?>
|
||||
<HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="ru.trader.controllers.RouterController">
|
||||
<fx:define><Insets fx:id="fields_group_margin" left="2" right="10"/></fx:define>
|
||||
@@ -99,7 +100,7 @@
|
||||
<cellValueFactory><OfferCellValueImpl property="buyOffer"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn minWidth="80.0" text="%market.order.distance">
|
||||
<cellFactory><DoubleCell format="\%.2f LY"/></cellFactory>
|
||||
<cellFactory><DistanceCell /></cellFactory>
|
||||
<cellValueFactory><PropertyValueFactory property="distance"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn minWidth="80.0" text="%market.order.profit">
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
<?import ru.trader.view.support.cells.OfferCellValueImpl?>
|
||||
<?import ru.trader.view.support.cells.OfferTableCell?>
|
||||
<?import ru.trader.view.support.cells.DistanceCell?>
|
||||
<HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="ru.trader.controllers.TopOrdersController" styleClass="dialog"
|
||||
prefWidth="725">
|
||||
@@ -27,7 +28,7 @@
|
||||
<cellValueFactory><OfferCellValueImpl property="buyOffer"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn minWidth="80.0" text="%market.order.distance">
|
||||
<cellFactory><DoubleCell format="\%.2f LY"/></cellFactory>
|
||||
<cellFactory><DistanceCell /></cellFactory>
|
||||
<cellValueFactory><PropertyValueFactory property="distance"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="profit" minWidth="80.0" text="%market.order.profit" sortType="DESCENDING">
|
||||
|
||||
Reference in New Issue
Block a user