Java Code Examples for javafx.scene.Node#getClass()

The following examples show how to use javafx.scene.Node#getClass() . 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: JavaFXElementPropertyAccessor.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Class<?> findJavaClass(Node n) {
    Class<?> c = n.getClass();
    if (this instanceof IPseudoElement) {
        c = ((IPseudoElement) this).getPseudoComponent().getClass();
    }
    while (c.getPackage() == null || !c.getPackage().getName().startsWith("javafx.scene")) {
        c = c.getSuperclass();
    }
    return c;
}
 
Example 2
Source File: SysInfoPane.java    From Recaf with MIT License 4 votes vote down vote up
/**
 * Converts the UI to markdown text.
 * Section headers are declared with {@link SubLabeled}.
 * Section Key/Value pairs are declared with two consecutive {@link Label}.
 *
 * @return Markdown string containing all UI elements.
 */
public String buildClipboard() {
	// Data collection
	Map<String, Map<String, String>> data = new LinkedHashMap<>();
	// Current section title/map
	String currentSection = null;
	Map<String, String> currentMap = null;
	// Current section key
	boolean labelIsKey = true;
	String currentKey = null;
	for(Node node : getChildren()) {
		// header
		if(node.getClass() == SubLabeled.class) {
			if(currentMap != null) {
				data.put(currentSection, currentMap);
			}
			SubLabeled header = (SubLabeled) node;
			currentSection = header.getPrimaryText();
			currentMap = new LinkedHashMap<>();
		}
		// items (key:value), one follows the other
		else if(node.getClass() == Label.class) {
			String text = ((Label) node).getText();
			if(labelIsKey) {
				currentKey = text;
			} else {
				currentMap.put(currentKey, text);
			}
			// Swap since we do KEY -> VALUE, KEY -> VALUE
			labelIsKey = !labelIsKey;
		}
	}
	// Put to string
	StringBuilder sb = new StringBuilder();
	data.forEach((section, map) -> {
		sb.append("**").append(section).append("**\n")
		  .append("| ").append(String.join(" | ", map.keySet())).append(" |\n")
		  .append("| ").append(map.keySet().stream()
				.map(s -> "--------").collect(Collectors.joining(" | "))).append(" |\n")
		  .append("| `").append(String.join("` | `", map.values())).append("` |\n\n");
	});
	return sb.toString();
}