Java Code Examples for org.controlsfx.control.PopOver#setContentNode()

The following examples show how to use org.controlsfx.control.PopOver#setContentNode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Pin.java    From BlockMap with MIT License 6 votes vote down vote up
@Override
protected PopOver initInfo() {
	PopOver info = super.initInfo();
	GridPane content = new GridPane();
	content.getStyleClass().add("grid");

	content.add(new Label("Player position:"), 0, 2);

	Vector3dc position = player.getPosition();
	Button jumpButton = new Button(position.toString());
	jumpButton.setTooltip(new Tooltip("Click to go there"));
	content.add(jumpButton, 1, 2);
	jumpButton.setOnAction(e -> {
		Vector2d spawnpoint = new Vector2d(position.x(), position.z());
		AABBd frustum = viewport.frustumProperty.get();
		viewport.translationProperty.set(spawnpoint.negate().add((frustum.maxX - frustum.minX) / 2, (frustum.maxY - frustum.minY) / 2));
		info.hide();
	});

	info.setContentNode(content);
	return info;
}
 
Example 2
Source File: Pin.java    From BlockMap with MIT License 6 votes vote down vote up
@Override
protected PopOver initInfo() {
	PopOver info = super.initInfo();
	GridPane content = new GridPane();
	content.getStyleClass().add("grid");

	content.add(new Label("Position: "), 0, 2, 1, 2);
	content.add(new Label(villageObjectPin.getPosition().toString()), 1, 2, 2, 2);

	content.add(new Label("Free tickets: "), 0, 4);
	content.add(new Label(String.valueOf(villageObjectPin.getFreeTickets())), 1, 4);

	content.add(new Label(type.name), 0, 5);

	info.setContentNode(content);
	return info;
}
 
Example 3
Source File: Pin.java    From BlockMap with MIT License 6 votes vote down vote up
@Override
protected PopOver initInfo() {
	PopOver info = super.initInfo();
	GridPane popContent = new GridPane();
	popContent.getStyleClass().add("grid");

	/* Image+Text for the popover */
	StreamUtils.zipWithIndex(pinCount.entrySet().stream()).forEach(e -> {
		ImageView img = new ImageView(e.getValue().getKey().image);
		img.setSmooth(false);
		img.setPreserveRatio(true);
		Label label1 = new Label(e.getValue().getKey().toString(), img);
		img.fitHeightProperty().bind(Bindings.createDoubleBinding(() -> label1.getFont().getSize() * 1.3, label1.fontProperty()));
		popContent.add(label1, 0, (int) e.getIndex());
		Label label2 = new Label(String.format("%dx", e.getValue().getValue()));
		popContent.add(label2, 1, (int) e.getIndex());
	});

	info.setContentNode(popContent);
	return info;
}
 
Example 4
Source File: Pin.java    From BlockMap with MIT License 5 votes vote down vote up
protected PopOver initInfo() {
	PopOver info = new PopOver();
	info.setArrowLocation(ArrowLocation.BOTTOM_CENTER);
	info.setAutoHide(true);
	info.setHeaderAlwaysVisible(true);
	/* Workaround: If the PopOver it too thin, it will be placed a bit off. Bug report: https://github.com/controlsfx/controlsfx/issues/1095 */
	Label content = new Label();
	content.setPrefWidth(130);
	info.setContentNode(content);
	info.setTitle(type.name);
	return info;
}
 
Example 5
Source File: Pin.java    From BlockMap with MIT License 5 votes vote down vote up
@Override
protected PopOver initInfo() {
	PopOver info = super.initInfo();

	GridPane popContent = new GridPane();
	popContent.getStyleClass().add("grid");
	info.setContentNode(popContent);

	StreamUtils.zipWithIndex(chunkGeneration.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting())).entrySet().stream())
			.forEach(index -> {
				popContent.add(new Label(index.getValue().getKey() + ":"), 0, (int) index.getIndex());
				popContent.add(new Label(index.getValue().getValue() + " chunks"), 1, (int) index.getIndex());
			});
	return info;
}
 
Example 6
Source File: Pin.java    From BlockMap with MIT License 5 votes vote down vote up
@Override
protected PopOver initInfo() {
	PopOver info = super.initInfo();

	GridPane popContent = new GridPane();
	popContent.getStyleClass().add("grid");
	info.setContentNode(popContent);

	popContent.add(new Label("Found version(s):"), 0, 0);
	popContent.add(new Label(
			chunks.stream().map(c -> c.version).distinct().sorted().map(String::valueOf).collect(Collectors.joining(", ", "{", "}"))), 1, 0);
	popContent.add(new Label("Unsupported for reason(s):"), 0, 1);
	popContent.add(new Label(
			chunks.stream().map(c -> c.message).distinct().sorted().map(String::valueOf).collect(Collectors.joining(", ", "{", "}"))), 1, 1);
	popContent.add(new Separator(), 0, 2, 2, 1);
	popContent.add(new Label("Supported versions:"), 0, 3);
	popContent.add(new Label("Name:"), 1, 3);
	int row = 4;
	for (MinecraftVersion supported : MinecraftVersion.values()) {
		if (supported.maxVersion == Integer.MAX_VALUE)
			popContent.add(new Label(supported.minVersion + "+"), 0, row);
		else
			popContent.add(new Label(supported.minVersion + "-" + supported.maxVersion), 0, row);

		popContent.add(new Label(supported.versionName), 1, row++);
	}
	return info;
}
 
Example 7
Source File: Pin.java    From BlockMap with MIT License 5 votes vote down vote up
@Override
protected PopOver initInfo() {
	PopOver info = super.initInfo();
	GridPane content = new GridPane();
	content.getStyleClass().add("grid");

	int rowCount = 0;

	if (maps.size() > 1) {
		content.add(new Label("Map count:"), 0, rowCount);
		content.add(new Label(Integer.toString(maps.size())), 1, rowCount++);
	}

	for (de.piegames.blockmap.world.LevelMetadata.MapPin map : maps) {
		BorderPane mapPane = new BorderPane();
		mapPane.setLeft(new Label("Scale:"));
		mapPane.setRight(new Label("1:" + (1 << map.getScale())));

		if (map.getColors().isPresent()) {
			byte[] data = map.getColors().get();
			WritableImage image = new WritableImage(128, 128);
			for (int x = 0; x < 128; x++)
				for (int y = 0; y < 128; y++)
					image.getPixelWriter().setColor(x, y, COLOR_IDS[0xFF & data[y << 7 | x]]);
			mapPane.setBottom(new ImageView(image));
		}
		content.add(mapPane, 0, rowCount++, 1, 2);
	}
	info.setContentNode(content);
	return info;
}
 
Example 8
Source File: Pin.java    From BlockMap with MIT License 5 votes vote down vote up
@Override
protected PopOver initInfo() {
	PopOver info = super.initInfo();
	GridPane content = new GridPane();
	content.getStyleClass().add("grid");

	content.add(new Label("Name:"), 0, 2);
	Label playerName = new Label("loading...");
	playerName.textProperty().bind(this.playerName);
	content.add(playerName, 1, 2);

	player.getSpawnpoint().ifPresent(spawn -> {
		content.add(new Label("Spawnpoint: "), 0, 3);
		Button jumpButton = new Button(spawn.toString());
		jumpButton.setTooltip(new Tooltip("Click to go there"));
		content.add(jumpButton, 1, 3);
		jumpButton.setOnAction(e -> {
			Vector2d spawnpoint = new Vector2d(spawn.x(), spawn.z());
			AABBd frustum = viewport.frustumProperty.get();
			viewport.translationProperty.set(spawnpoint.negate().add((frustum.maxX - frustum.minX) / 2, (frustum.maxY - frustum.minY) / 2));
			info.hide();
		});
	});

	info.setContentNode(content);
	return info;
}
 
Example 9
Source File: Pin.java    From BlockMap with MIT License 5 votes vote down vote up
@Override
protected PopOver initInfo() {
	PopOver info = super.initInfo();
	GridPane content = new GridPane();
	content.getStyleClass().add("grid");

	content.add(new Label("Position:"), 0, 2);
	content.add(new Label(spawn.toString()), 1, 2);

	info.setContentNode(content);
	return info;
}