for (int i = 0; i < ITEMS.size(); i++) {
RadialMenuItem item = ITEMS.get(i);
// Create graphical representation of each menu item
final StackPane ITEM_CONTAINER = new StackPane();
ITEM_CONTAINER.setPrefSize(item.getSize(), item.getSize());
ITEM_CONTAINER.setMaxSize(item.getSize(), item.getSize());
ITEM_CONTAINER.getChildren().add(item);
if (SymbolType.NONE == item.getSymbolType() && item.getThumbnailImageName().isEmpty()) {
Text text = new Text(item.getText());
text.setFont(Font.font("Open Sans", FontWeight.BOLD, item.getSize() * 0.5));
text.setFill(item.getForegroundColor());
text.setMouseTransparent(true);
ITEM_CONTAINER.getChildren().add(text);
} else if (!item.getThumbnailImageName().isEmpty()) {
try {
ITEM_CONTAINER.getChildren().add(createThumbnail(item));
} catch (IllegalArgumentException exception) {
Text text = new Text(Integer.toString(i));
text.setFont(Font.font("Open Sans", FontWeight.BOLD, item.getSize() * 0.5));
text.setFill(item.getForegroundColor());
text.setMouseTransparent(true);
ITEM_CONTAINER.getChildren().add(text);
}
} else {
Symbol symbol = new Symbol(item.getSymbolType(), 0.65 * item.getSize(), Color.WHITE, Symbol.NOT_RESIZEABLE);
symbol.setMouseTransparent(true);
ITEM_CONTAINER.getChildren().add(symbol);
}
ITEM_CONTAINER.setPickOnBounds(false);
ITEM_CONTAINER.setOpacity(0.0);
// Add animations for each menu item
double degree = (((degrees / positions) * i) + options.getOffset()) % 360;
Point2D position = new Point2D(Math.cos(Math.toRadians(degree)), Math.sin(Math.toRadians(degree)));
double x = Math.round(position.getX() * options.getRadius());
double y = Math.round(position.getY() * options.getRadius());
double delay = (200 / ITEMS.size()) * i;
openTimeLines[i] = options.isSimpleMode() ? createSimpleItemOpenTimeLine(ITEM_CONTAINER, x, y, delay) : createItemOpenTimeLine(ITEM_CONTAINER, x, y, delay);
closeTimeLines[i] = options.isSimpleMode() ? createSimpleItemCloseTimeLine(ITEM_CONTAINER, x, y, delay) : createItemCloseTimeLine(ITEM_CONTAINER, x, y, delay);
// Add mouse event handler to each item
ITEM_CONTAINER.setOnMousePressed(mouseHandler);
ITEM_CONTAINER.setOnMouseReleased(mouseHandler);
// Add items and nodes to map
itemMap.put(ITEM_CONTAINER, item);
}
items.putAll(itemMap);