Java源码示例:eu.hansolo.tilesfx.tools.Country
示例1
@Override protected void handleEvents(final String EVENT_TYPE) {
super.handleEvents(EVENT_TYPE);
if ("VISIBILITY".equals(EVENT_TYPE)) {
Helper.enableNode(titleText, !tile.getTitle().isEmpty());
Helper.enableNode(text, tile.isTextVisible());
Helper.enableNode(valueText, tile.isValueVisible());
Helper.enableNode(unitFlow, !tile.getUnit().isEmpty());
countryContainer.setMaxSize(size * 0.9, tile.isTextVisible() ? size * 0.68 : size * 0.795);
countryContainer.setPrefSize(size * 0.9, tile.isTextVisible() ? size * 0.68 : size * 0.795);
} else if ("RECALC".equals(EVENT_TYPE)) {
country = tile.getCountry();
if (null == country) { country = Country.DE; }
countryPaths = Helper.getHiresCountryPaths().get(country.name());
countryPaths.forEach(path -> path.setFill(tile.getBarColor()));
countryGroup.getChildren().setAll(countryPaths);
text.setText(country.getDisplayName());
resize();
redraw();
}
}
示例2
@Override protected void registerListeners() {
super.registerListeners();
countryPaths.forEach((name , pathList) -> {
Country country = Country.valueOf(name);
EventHandler<MouseEvent> clickHandler = e -> tile.fireTileEvent(new TileEvent(EventType.SELECTED_CHART_DATA, new ChartData(country.getName(), country.getValue(), country.getColor())));
pathList.forEach(path -> {
handlerMap.put(path, clickHandler);
path.addEventHandler(MouseEvent.MOUSE_PRESSED, clickHandler);
});
});
tile.getPoiList().addListener(poiListener);
tile.getChartData().addListener(chartDataListener);
}
示例3
private void setCountryFillAndStroke(final Country COUNTRY, final Color FILL, final Color STROKE) {
List<CountryPath> paths = countryPaths.get(COUNTRY.getName());
for (CountryPath path : paths) {
path.setFill(FILL);
path.setStroke(STROKE);
}
}
示例4
private void refresh() {
Color fill = tile.getForegroundColor();
Color stroke = tile.getBackgroundColor();
countryPaths.forEach((name, pathList) -> {
Country country = Country.valueOf(name);
pathList.forEach(path -> {
path.setFill(null == country.getColor() ? fill : country.getColor());
path.setStroke(stroke);
path.setStrokeWidth(0.2);
});
});
}
示例5
@Override protected void initGraphics() {
super.initGraphics();
//poiLocations = FXCollections.observableHashMap();
//chartDataLocations = FXCollections.observableHashMap();
//circleHandlerMap = new HashMap<>();
country = tile.getCountry();
if (null == country) { country = Country.DE; }
clickHandler = event -> tile.fireTileEvent(new TileEvent(EventType.SELECTED_CHART_DATA, new ChartData(country.getName(), country.getValue(), country.getColor())));
countryPaths = Helper.getHiresCountryPaths().get(country.name());
countryMinX = Helper.MAP_WIDTH;
countryMinY = Helper.MAP_HEIGHT;
countryMaxX = 0;
countryMaxY = 0;
countryPaths.forEach(path -> {
path.setFill(tile.getBarColor());
countryMinX = Math.min(countryMinX, path.getBoundsInParent().getMinX());
countryMinY = Math.min(countryMinY, path.getBoundsInParent().getMinY());
countryMaxX = Math.max(countryMaxX, path.getBoundsInParent().getMaxX());
countryMaxY = Math.max(countryMaxY, path.getBoundsInParent().getMaxY());
});
/*
tile.getPoiList()
.forEach(poi -> {
String tooltipText = new StringBuilder(poi.getName()).append("\n")
.append(poi.getInfo())
.toString();
Circle circle = new Circle(3, poi.getColor());
circle.setOnMousePressed(e -> poi.fireLocationEvent(new LocationEvent(poi)));
Tooltip.install(circle, new Tooltip(tooltipText));
poiLocations.put(poi, circle);
});
*/
titleText = new Text();
titleText.setFill(tile.getTitleColor());
Helper.enableNode(titleText, !tile.getTitle().isEmpty());
text = new Text(tile.getCountry().getDisplayName());
text.setFill(tile.getTextColor());
Helper.enableNode(text, tile.isTextVisible());
countryGroup = new Group();
countryGroup.getChildren().setAll(countryPaths);
countryContainer = new StackPane();
countryContainer.setMinSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795);
countryContainer.setMaxSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795);
countryContainer.setPrefSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795);
countryContainer.getChildren().setAll(countryGroup);
valueText = new Text(String.format(locale, formatString, ((tile.getValue() - minValue) / range * 100)));
valueText.setFill(tile.getValueColor());
valueText.setTextOrigin(VPos.BASELINE);
Helper.enableNode(valueText, tile.isValueVisible());
upperUnitText = new Text("");
upperUnitText.setFill(tile.getUnitColor());
Helper.enableNode(upperUnitText, !tile.getUnit().isEmpty());
fractionLine = new Line();
unitText = new Text(tile.getUnit());
unitText.setFill(tile.getUnitColor());
Helper.enableNode(unitText, !tile.getUnit().isEmpty());
unitFlow = new VBox(upperUnitText, unitText);
unitFlow.setAlignment(Pos.CENTER_RIGHT);
valueUnitFlow = new HBox(valueText, unitFlow);
valueUnitFlow.setAlignment(Pos.BOTTOM_RIGHT);
valueUnitFlow.setMouseTransparent(true);
valueUnitFlow.setMouseTransparent(true);
getPane().getChildren().addAll(titleText, countryContainer, valueUnitFlow, fractionLine, text);
//getPane().getChildren().addAll(poiLocations.values());
}
示例6
private void setFillAndStroke() {
countryPaths.keySet().forEach(name -> {
Country country = Country.valueOf(name);
setCountryFillAndStroke(country, null == country.getColor() ? tile.getForegroundColor() : country.getColor(), tile.getBackgroundColor());
});
}
示例7
public final B country(final Country COUNTRY) {
properties.put("country", new SimpleObjectProperty(COUNTRY));
return (B)this;
}