### Linear Gradient Syntax Examples
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Examples demonstrating the syntax for creating linear gradients. This includes basic gradients from corner to corner, and more complex gradients with multiple color stops and defined start/end points.
```css
linear-gradient(to bottom right, red, black)
linear-gradient(from 0% 0% to 100% 100%, red 0%, black 100%)
linear-gradient(from 0px 0px to 0px 50px, gray, darkgray 50%, dimgray 99%, white)
```
--------------------------------
### libxml2 Meson Build Options
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/ThirdParty/libxml/src/README.md
Example Meson build options for libxml2, as listed in `meson_options.txt`. These options control aspects of the build, such as the installation prefix, enabling history support, enabling HTTP support, disabling schematron, and enabling zlib.
```bash
-Dprefix=$prefix
-Dhistory=enabled
-Dhttp=enabled
-Dschematron=disabled
-Dzlib=enabled
```
--------------------------------
### Media Query Examples with Logical Operators
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Illustrates the usage of media queries with different logical operators (not, and, or) and grouping using parentheses. These examples show how to combine media features for conditional styling in JavaFX.
```css
@media not (prefers-color-scheme: light) { ... }
```
```css
@media (prefers-color-scheme: dark) and (prefers-reduced-motion) and (prefers-reduced-transparency) { ... }
```
```css
@media (prefers-color-scheme: dark) or (prefers-reduced-motion) or (prefers-reduced-transparency) { ... }
```
```css
@media (prefers-color-scheme: dark) and ((prefers-reduced-motion) or (prefers-reduced-transparency)) { ... }
```
```css
@media (prefers-color-scheme: dark) and (not (prefers-reduced-motion)) { ... }
```
--------------------------------
### Radial Gradient Syntax Examples
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Examples illustrating the syntax for defining radial gradients. This covers gradients radiating from a center point with specified radii and includes options for focus angle, distance, and reflection.
```css
radial-gradient(radius 100%, red, darkgray, black)
radial-gradient(focus-angle 45deg, focus-distance 20%, center 25% 25%, radius 50%, reflect, gray, darkgray 75%, dimgray)
```
--------------------------------
### CMake Build Configuration for libxml2 (Windows focus)
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/ThirdParty/libxml/src/README.md
This section provides example commands for building libxml2 on Windows using CMake. It demonstrates extracting the archive, configuring the build with specific options (like disabling Python or enabling zlib), building the project, running tests, and installing.
```bash
cmake -E tar xf libxml2-xxx.tar.xz
cmake -S libxml2-xxx -B builddir [options]
cmake --build builddir
ctest --test-dir builddir
cmake --install builddir
```
--------------------------------
### Image Pattern Usage Examples
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Demonstrates how to use the `image-pattern` function to fill areas with an image. It shows variations with and without specifying the anchor rectangle and proportional scaling.
```css
image-pattern("images/Duke.png")
image-pattern("images/Duke.png", 20%, 20%, 80%, 80%)
image-pattern("images/Duke.png", 20%, 20%, 80%, 80%, true)
image-pattern("images/Duke.png", 20, 20, 80, 80, false)
```
--------------------------------
### Build with Scons
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/WTF/wtf/dtoa/README.md
Builds the static and shared libraries and installs them. The DESTDIR option can be used to specify an alternative installation directory.
```bash
scons install
scons DESTDIR=alternative_directory install
```
--------------------------------
### Repeating Image Pattern Example
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Provides an example of the `repeating-image-pattern` function, which is a shorthand for creating tiled image fills. It takes the image URI as its only parameter.
```css
repeating-image-pattern("com/mycompany/myapp/images/Duke.png")
```
--------------------------------
### JavaFX Animation Example with Transitions and Timeline
Source: https://context7.com/openjdk/jfx/llms.txt
This Java code demonstrates the use of JavaFX's animation framework. It includes examples of FadeTransition, TranslateTransition, ParallelTransition for concurrent animation execution, and Timeline with KeyFrames for defining complex animation sequences. The code requires the JavaFX SDK and application setup.
```java
import javafx.animation.*;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import javafx.util.Duration;
public class AnimationExample extends Application {
@Override
public void start(Stage stage) {
Pane root = new Pane();
root.setPadding(new Insets(20));
root.setPrefSize(600, 400);
// Circle for transition animations
Circle circle = new Circle(50, 50, 30, Color.BLUE);
// Rectangle for timeline animation
Rectangle rect = new Rectangle(50, 150, 50, 50);
rect.setFill(Color.RED);
root.getChildren().addAll(circle, rect);
// FadeTransition
FadeTransition fadeTransition = new FadeTransition(Duration.seconds(2), circle);
fadeTransition.setFromValue(1.0);
fadeTransition.setToValue(0.3);
fadeTransition.setCycleCount(Timeline.INDEFINITE);
fadeTransition.setAutoReverse(true);
// TranslateTransition
TranslateTransition translateTransition = new TranslateTransition(Duration.seconds(3), circle);
translateTransition.setFromX(0);
translateTransition.setToX(500);
translateTransition.setCycleCount(Timeline.INDEFINITE);
translateTransition.setAutoReverse(true);
translateTransition.setInterpolator(Interpolator.EASE_BOTH);
// ParallelTransition - run both animations together
ParallelTransition parallelTransition = new ParallelTransition(
fadeTransition, translateTransition
);
// Timeline with keyframes for complex animation
Timeline timeline = new Timeline(
new KeyFrame(Duration.ZERO,
new KeyValue(rect.translateXProperty(), 0),
new KeyValue(rect.rotateProperty(), 0),
new KeyValue(rect.fillProperty(), Color.RED)
),
new KeyFrame(Duration.seconds(2),
new KeyValue(rect.translateXProperty(), 300),
new KeyValue(rect.rotateProperty(), 180),
new KeyValue(rect.fillProperty(), Color.GREEN)
),
new KeyFrame(Duration.seconds(4),
new KeyValue(rect.translateXProperty(), 0),
new KeyValue(rect.rotateProperty(), 360),
new KeyValue(rect.fillProperty(), Color.BLUE)
)
);
timeline.setCycleCount(Timeline.INDEFINITE);
// Control buttons
Button startBtn = new Button("Start Animations");
startBtn.setLayoutX(20);
startBtn.setLayoutY(300);
startBtn.setOnAction(e -> {
parallelTransition.play();
timeline.play();
});
Button stopBtn = new Button("Stop Animations");
stopBtn.setLayoutX(140);
stopBtn.setLayoutY(300);
stopBtn.setOnAction(e -> {
parallelTransition.stop();
timeline.stop();
});
root.getChildren().addAll(startBtn, stopBtn);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setTitle("Animation Example");
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
```
--------------------------------
### Create Minimal JDK with jlink (Failing Example)
Source: https://github.com/openjdk/jfx/blob/master/doc-files/release-notes-11.md
This command demonstrates the failing jlink configuration for creating a minimal JDK image that includes JavaFX Swing interop. It highlights the omission of necessary modules for successful operation.
```bash
jlink --output myjdk --module-path javafx-jmods-11 \
--add-modules java.desktop,javafx.swing,javafx.controls
```
--------------------------------
### Using Custom Control in Java and FXML (Code Examples)
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.fxml/src/main/docs/javafx/fxml/doc-files/introduction_to_fxml.html
These examples show how to use the previously defined CustomControl. The Java snippet demonstrates instantiating the control, setting its text, and adding it to a layout. The FXML snippet shows how to include the CustomControl directly within another FXML file, treating it like any other JavaFX component.
```java
HBox hbox = new HBox();
CustomControl customControl = new CustomControl();
customControl.setText("Hello World!");
hbox.getChildren().add(customControl);
```
```fxml
```
--------------------------------
### Shared Library Versioning and Installation (CMake)
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/JavaScriptCore/CMakeLists.txt
This CMake code handles versioning and installation of the JavaScriptCore shared library. It checks if the platform is not 'Mac' and if the library type is 'SHARED', then populates version information and installs the target.
```cmake
if (NOT "${PORT}" STREQUAL "Mac")
if (${JavaScriptCore_LIBRARY_TYPE} STREQUAL "SHARED")
WEBKIT_POPULATE_LIBRARY_VERSION(JAVASCRIPTCORE)
set_target_properties(JavaScriptCore PROPERTIES VERSION ${JAVASCRIPTCORE_VERSION} SOVERSION ${JAVASCRIPTCORE_VERSION_MAJOR})
install(TARGETS JavaScriptCore DESTINATION "${LIB_INSTALL_DIR}")
endif ()
endif ()
```
--------------------------------
### FXML Static Property Example
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.fxml/src/main/docs/javafx/fxml/doc-files/introduction_to_fxml.html
Demonstrates the concise syntax for handling static properties in FXML. This approach is similar to static property elements and supports location, resource, and variable resolution operators.
```FXML
```
--------------------------------
### FXML Instance Property Example (Button)
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.fxml/src/main/docs/javafx/fxml/doc-files/introduction_to_fxml.html
Demonstrates setting an instance property, 'text', on a Button element in FXML. This is a straightforward way to configure the initial state of UI controls.
```fxml
```
--------------------------------
### FXML Structure for Nested Controllers
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.fxml/src/main/docs/javafx/fxml/doc-files/introduction_to_fxml.html
Example of an FXML file structure demonstrating how to include another FXML document and define a controller for the main layout.
```xml
...
```
--------------------------------
### Meson Build Configuration for libxml2
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/ThirdParty/libxml/src/README.md
Instructions for building libxml2 using Meson, a high-level build system. It includes commands for setting up the build directory, compiling the project with Ninja, running tests, and installing the library. Options can be passed using `-D` flags.
```bash
meson setup [options] builddir
ninja -C builddir
meson test -C builddir
ninja -C builddir install
```
--------------------------------
### JavaFX Region Border CSS Example
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Example of defining the border for a JavaFX Region using CSS. This demonstrates setting border color, style, width, and image properties.
```css
-fx-border-color: black;
-fx-border-style: dashed;
-fx-border-width: 2;
-fx-border-radius: 5;
```
--------------------------------
### JavaFX Region Background CSS Example
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Example of setting the background for a JavaFX Region using CSS. This includes specifying background color, image, and related properties like insets and radius.
```css
-fx-background-color: lightblue;
-fx-background-image: url("image.png");
-fx-background-insets: 5;
-fx-background-radius: 8;
```
--------------------------------
### C: Inline Allocation Fast Path Example
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/bmalloc/libpas/Documentation.md
Demonstrates an inline-only fast path for memory allocation in C. It attempts to allocate memory using an internal implementation and falls back to a casual case if the inline attempt fails. This pattern is used to avoid stack frames for frequently called allocation functions.
```c
static PAS_ALWAYS_INLINE void* bmalloc_try_allocate_inline(size_t size)
{
pas_allocation_result result;
result = bmalloc_try_allocate_impl_inline_only(size, 1);
if (PAS_LIKELY(result.did_succeed))
return (void*)result.begin;
return bmalloc_try_allocate_casual(size);
}
```
--------------------------------
### C: Inline Deallocation Fast Path Example
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/bmalloc/libpas/Documentation.md
Shows a simple inline fast path for deallocating memory in C. It directly calls the pas_deallocate function with the provided pointer and heap configuration. This implementation aims for minimal overhead for deallocation operations.
```c
static PAS_ALWAYS_INLINE void bmalloc_deallocate_inline(void* ptr)
{
pas_deallocate(ptr, BMALLOC_HEAP_CONFIG);
}
```
--------------------------------
### JavaFX Region CSS Properties Examples
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Examples of common CSS properties for JavaFX Region, including padding, shape, scaling, and pixel snapping. These properties control the visual appearance and behavior of a Region node.
```css
-fx-padding: 10;
-fx-shape: "M 0 0 L 100 0 L 100 100 L 0 100 z";
-fx-scale-shape: true;
-fx-snap-to-pixel: false;
```
--------------------------------
### Define Basic Heap Configuration (C)
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/bmalloc/libpas/Documentation.md
This C code snippet demonstrates how to define a basic heap configuration using the PAS_BASIC_HEAP_CONFIG macro. It sets various parameters for memory allocation, segregation, and logging, tailored for a specific heap type like 'iso'. Dependencies include Libpas header files.
```c
#define ISO_MINALIGN_SHIFT ((size_t)4)
#define ISO_MINALIGN_SIZE ((size_t)1 << ISO_MINALIGN_SHIFT)
#define ISO_HEAP_CONFIG PAS_BASIC_HEAP_CONFIG( \
iso, \
.activate = pas_heap_config_utils_null_activate, \
.get_type_size = pas_simple_type_as_heap_type_get_type_size, \
.get_type_alignment = pas_simple_type_as_heap_type_get_type_alignment, \
.dump_type = pas_simple_type_as_heap_type_dump, \
.check_deallocation = true, \
.small_segregated_min_align_shift = ISO_MINALIGN_SHIFT, \
.small_segregated_sharing_shift = PAS_SMALL_SHARING_SHIFT, \
.small_segregated_page_size = PAS_SMALL_PAGE_DEFAULT_SIZE, \
.small_segregated_wasteage_handicap = PAS_SMALL_PAGE_HANDICAP, \
.small_exclusive_segregated_logging_mode = pas_segregated_deallocation_size_oblivious_logging_mode, \
.small_shared_segregated_logging_mode = pas_segregated_deallocation_no_logging_mode, \
.small_exclusive_segregated_enable_empty_word_eligibility_optimization = false, \
.small_shared_segregated_enable_empty_word_eligibility_optimization = false, \
.small_segregated_use_reversed_current_word = PAS_ARM64, \
.enable_view_cache = false, \
.use_small_bitfit = true, \
.small_bitfit_min_align_shift = ISO_MINALIGN_SHIFT, \
.small_bitfit_page_size = PAS_SMALL_BITFIT_PAGE_DEFAULT_SIZE, \
.medium_page_size = PAS_MEDIUM_PAGE_DEFAULT_SIZE, \
.granule_size = PAS_GRANULE_DEFAULT_SIZE, \
.use_medium_segregated = true, \
.medium_segregated_min_align_shift = PAS_MIN_MEDIUM_ALIGN_SHIFT, \
.medium_segregated_sharing_shift = PAS_MEDIUM_SHARING_SHIFT, \
.medium_segregated_wasteage_handicap = PAS_MEDIUM_PAGE_HANDICAP, \
.medium_exclusive_segregated_logging_mode = pas_segregated_deallocation_size_aware_logging_mode, \
.medium_shared_segregated_logging_mode = pas_segregated_deallocation_no_logging_mode, \
.use_medium_bitfit = true, \
.medium_bitfit_min_align_shift = PAS_MIN_MEDIUM_ALIGN_SHIFT, \
.use_marge_bitfit = true, \
.marge_bitfit_min_align_shift = PAS_MIN_MARGE_ALIGN_SHIFT, \
.marge_bitfit_page_size = PAS_MARGE_PAGE_DEFAULT_SIZE, \
.pgm_enabled = false)
PAS_API extern const pas_heap_config iso_heap_config;
PAS_BASIC_HEAP_CONFIG_DECLARATIONS(iso, ISO);
```
--------------------------------
### Example: Button Opacity Transition on Hover (JavaFX CSS)
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
This CSS example demonstrates how to apply a transition to a button's opacity when the mouse hovers over it. It sets the initial opacity, the property to transition, and the duration for the change.
```css
.button {
-fx-opacity: 0.8;
transition-property: -fx-opacity;
transition-duration: 0.5s;
}
.button:hover {
-fx-opacity: 1;
}
```
--------------------------------
### JavaFX Application Lifecycle and Initialization
Source: https://context7.com/openjdk/jfx/llms.txt
Demonstrates how to create a JavaFX application with proper lifecycle management. This includes the init(), start(), and stop() methods, along with launching the application using the main method. It requires the JavaFX SDK to run.
```java
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class MyApplication extends Application {
// Called on launcher thread - no UI creation here
@Override
public void init() throws Exception {
super.init();
// Perform initialization (load resources, configure settings)
System.out.println("Initializing application...");
}
// Called on JavaFX Application Thread - create UI here
@Override
public void start(Stage primaryStage) throws Exception {
Button btn = new Button("Click to Exit");
btn.setOnAction(e -> Platform.exit());
StackPane root = new StackPane(btn);
Scene scene = new Scene(root, 400, 300);
primaryStage.setTitle("JavaFX Application");
primaryStage.setScene(scene);
primaryStage.show();
}
// Called on JavaFX Application Thread during shutdown
@Override
public void stop() throws Exception {
super.stop();
// Cleanup resources, save state
System.out.println("Application shutting down...");
}
public static void main(String[] args) {
// Launch the application
launch(args);
}
}
```
--------------------------------
### Define Basic Heap Configuration Implementation (C)
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/bmalloc/libpas/Documentation.md
This C code provides the implementation for a basic heap configuration, defining the 'iso_heap_config' variable. It uses the PAS_BASIC_HEAP_CONFIG_DEFINITIONS macro to set specific properties like page zeroing and intrinsic view cache capacity. This code is intended to be part of a .c file corresponding to the heap configuration header.
```c
const pas_heap_config iso_heap_config = ISO_HEAP_CONFIG;
PAS_BASIC_HEAP_CONFIG_DEFINITIONS(
iso, ISO,
.allocate_page_should_zero = false,
.intrinsic_view_cache_capacity = pas_heap_runtime_config_zero_view_cache_capacity);
```
--------------------------------
### JavaFX StackPane CSS Properties Examples
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Demonstrates the use of the -fx-alignment property in JavaFX StackPane to control the alignment of its children. This property is essential for positioning elements within a StackPane.
```css
-fx-alignment: center;
```
--------------------------------
### JavaFX VBox CSS Properties Examples
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Shows CSS properties for JavaFX VBox, focusing on spacing and alignment of children. The -fx-spacing and -fx-alignment properties are key for managing vertical layout in a VBox.
```css
-fx-spacing: 10;
-fx-alignment: center-left;
-fx-fill-width: false;
```
--------------------------------
### Compile WebKit and Media Libraries from Source (Gradle)
Source: https://github.com/openjdk/jfx/blob/master/WEBKIT-MEDIA-STUBS.md
Enables building WebKit and Media shared libraries from source using Gradle. This requires additional build tooling and can take a significant amount of time. The compiled libraries can be cached for future use.
```gradle
-PCOMPILE_WEBKIT=true -PCOMPILE_MEDIA=true
```
--------------------------------
### Mock Media Source and Player Implementations (C++)
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/WebCore/Sources.txt
Contains mock implementations for media source-related components, including media player integration and source buffer management. These mocks are essential for testing media playback and manipulation logic in isolation.
```cpp
#include "platform/mock/mediasource/MockBox.cpp"
#include "platform/mock/mediasource/MockMediaPlayerMediaSource.cpp"
#include "platform/mock/mediasource/MockMediaSourcePrivate.cpp"
#include "platform/mock/mediasource/MockSourceBufferPrivate.cpp"
// Example usage (conceptual):
// MockMediaPlayerMediaSource mediaPlayerMock;
// MockSourceBufferPrivate sourceBufferMock;
// // Inject mocks into media playback tests...
```
--------------------------------
### JavaFX TilePane CSS Properties Examples
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Illustrates CSS properties for JavaFX TilePane, including orientation, tile dimensions, gaps, and alignment. These settings define how tiles are arranged within the TilePane.
```css
-fx-orientation: vertical;
-fx-pref-rows: 3;
-fx-pref-columns: 3;
-fx-hgap: 5;
-fx-vgap: 5;
-fx-alignment: center;
-fx-tile-alignment: center;
```
--------------------------------
### Time Utility for Timer - JavaScript
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/test/resources/test/html/guimark2-vector.html
Provides a simple timer utility to get the elapsed time in milliseconds since the script started. It uses `new Date().getTime()` for precise timing.
```javascript
TimeUtil = {
startTime: new Date().getTime(),
getTimer: function(){
return new Date().getTime()-TimeUtil.startTime;
}
}
```
--------------------------------
### JavaScript WebSocket Client for Basic Communication
Source: https://github.com/openjdk/jfx/blob/master/tests/manual/web/websocket.html
This snippet demonstrates a simple WebSocket client. It establishes a connection, sends a test message upon opening, and logs received messages or errors to the console and an alert. It requires a WebSocket server to connect to.
```javascript
let socket = new WebSocket("wss://echo.websocket.org/");
let messageElement = document.getElementById("message");
socket.onopen = function(e) {
messageElement.textContent = "\[open\] Connection established";
socket.send("Test WebSocket");
alert("[open] Connection established");
};
socket.onmessage = function(event) {
messageElement.textContent = '[message] Data received from server!';
alert('[message] Data received from server!');
};
socket.onerror = function(event) {
messageElement.textContent = "ERROR!";
alert("ERROR!");
};
```
--------------------------------
### Setting Background Image with URL in JavaFX
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Demonstrates how to set a background image for a JavaFX StackPane using CSS. The URL can be relative to the classpath or a stylesheet. This example uses an image file located in an 'images' directory.
```java
@Override public void start(Stage stage) {
StackPane root = new StackPane();
root.setStyle("-fx-background-image: url(images/Duke.png);\n");
Scene scene = new Scene(root, 300, 250);
stage.setScene(scene);
stage.show();
}
```
--------------------------------
### JavaScript IntersectionObserver Setup and Callback
Source: https://github.com/openjdk/jfx/blob/master/tests/system/src/test/resources/test/javafx/scene/web/testIObserver.html
Sets up an IntersectionObserver to monitor the intersection ratio between a target element and its root. A callback function updates the displayed intersection ratio when changes occur. It requires a parent and target element in the DOM.
```javascript
function callback(entries) {
document.querySelector('#output pre').innerText = entries[0].intersectionRatio;
}
let options = {
root: document.querySelector('#parent')
};
testIO = function() {
let observer = new IntersectionObserver(callback, options);
observer.observe(document.querySelector('#target'));
}
```
--------------------------------
### Loading FXML with FXMLLoader
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.fxml/src/main/docs/javafx/fxml/doc-files/introduction_to_fxml.html
Demonstrates loading an FXML file using FXMLLoader, specifying its location, a resource bundle for localization, and retrieving the root element and controller.
```java
URL location = getClass().getResource("example.fxml");
ResourceBundle resources = ResourceBundle.getBundle("com.foo.example");
FXMLLoader fxmlLoader = new FXMLLoader(location, resources);
Pane root = (Pane)fxmlLoader.load();
MyController controller = (MyController)fxmlLoader.getController();
```
--------------------------------
### JavaFX CSS @font-face Example
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Demonstrates how to use the @font-face CSS rule in JavaFX to load a font from a URL. It showcases setting a custom font family for a Label and applying it via a stylesheet. The @font-face descriptor 'src' is used, while others are ignored.
```java
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class HelloFontFace extends Application {
@Override
public void start(Stage primaryStage) {
Label label = new Label("Hello @FontFace");
label.setStyle("-fx-font-family: sample; -fx-font-size: 80;");
Scene scene = new Scene(label);
scene.getStylesheets().add("http://font.samples/web?family=samples");
primaryStage.setTitle("Hello @FontFace");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
```
--------------------------------
### C: Macro for Intrinsic Allocation Fast Path Creation
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/bmalloc/libpas/Documentation.md
Illustrates the use of a C macro, PAS_CREATE_TRY_ALLOCATE_INTRINSIC, to generate the necessary functions for an intrinsic heap allocation fast path. This macro sets up both inline and out-of-line allocation logic, configurable with heap specifics and runtime settings.
```c
PAS_CREATE_TRY_ALLOCATE_INTRINSIC(
bmalloc_try_allocate_impl,
BMALLOC_HEAP_CONFIG,
&bmalloc_intrinsic_runtime_config.base,
&bmalloc_allocator_counts,
pas_allocation_result_identity,
&bmalloc_common_primitive_heap,
&bmalloc_common_primitive_heap_support,
pas_intrinsic_heap_is_designated);
```
--------------------------------
### JavaFX Scene Styling with CSS
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Demonstrates a basic JavaFX application setup with a scene, a rectangle, and applying styles via an external CSS file. This snippet shows how to create a scene, add a shape, assign a style class, and link a stylesheet.
```java
Scene scene = new Scene(new Group());
scene.getStylesheets().add("test.css");
Rectangle rect = new Rectangle(100,100);
rect.setLayoutX(50);
rect.setLayoutY(50);
rect.getStyleClass().add("my-rect");
((Group)scene.getRoot()).getChildren().add(rect);
```
--------------------------------
### Specify Cache Directories for SDK Libraries (Gradle)
Source: https://github.com/openjdk/jfx/blob/master/WEBKIT-MEDIA-STUBS.md
Manually places WebKit and Media shared libraries in specified cache directories. Unix systems use '.so' or '.dylib' files in 'sdk/lib', while Windows systems use '.dll' files in 'sdk/bin'. This is useful for caching compiled libraries.
```gradle
$projectDir/../caches/sdk/lib
$projectDir/../caches/sdk/bin
```
--------------------------------
### JavaFX CSS Naming Convention Example
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Illustrates the naming convention for mapping JavaFX class names to CSS style-class names and JavaFX variable names to CSS property names. This convention involves converting camelCase to kebab-case and, for properties, prefixing with '-fx-'.
```text
JavaFX Class Name: ToggleButton -> CSS Style-class: toggle-button
JavaFX Variable Name: blendMode -> CSS Property Name: -fx-blend-mode
```
--------------------------------
### RGB Color Formats in CSS
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Demonstrates various ways to define RGB colors in CSS for OpenJFX, including short hex, full hex, decimal RGB, percentage RGB, and RGBA with alpha transparency. These examples show the flexibility in specifying the same color red with different notations.
```css
.label { -fx-text-fill: #f00 } /* #rgb */
.label { -fx-text-fill: #ff0000 } /* #rrggbb */
.label { -fx-text-fill: rgb(255,0,0) }
.label { -fx-text-fill: rgb(100%, 0%, 0%) }
.label { -fx-text-fill: rgba(255,0,0,1) }
```
--------------------------------
### Real-time Media Source Settings and Constraints (C++)
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/WebCore/Sources.txt
Defines settings and supported constraints for real-time media sources, enabling configuration and validation of media capture devices like cameras and microphones. These files are crucial for managing the input parameters of media streams.
```cpp
#include "platform/mediastream/RealtimeMediaSourceSettings.h"
#include "platform/mediastream/RealtimeMediaSourceSupportedConstraints.h"
// Example usage (conceptual):
// RealtimeMediaSourceSettings settings;
// settings.setFrameRate(30.0);
//
// RealtimeMediaSourceSupportedConstraints constraints;
// if (constraints.isFrameRateSupported(30.0)) {
// // Proceed with setting the frame rate
// }
```
--------------------------------
### RGBA Color with Alpha Transparency in CSS
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Illustrates the use of RGBA color values in CSS for OpenJFX, specifying both RGB components and an alpha value for opacity. It shows examples using decimal integer ranges (0-255) and percentage ranges (0.0%-100.0%) for RGB, with alpha from 0.0 (transparent) to 1.0 (opaque).
```css
.label { -fx-text-fill: rgb(255,0,0) } /* integer range 0 — 255*/
.label { -fx-text-fill: rgba(255,0,0,1) /* the same, with explicit opacity of 1 */
.label { -fx-text-fill: rgb(100%,0%,0%) } /* float range 0.0% — 100.0% */
.label { -fx-text-fill: rgba(100%,0%,0%,1) } /* the same, with explicit opacity of 1 */
```
--------------------------------
### Mock Objects for Media and Device Testing (C++)
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/WebCore/Sources.txt
Provides mock implementations for various components used in media streaming and device interaction testing. These mocks allow for isolated unit testing of functionalities without relying on actual hardware or complex dependencies.
```cpp
#include "platform/mock/DeviceOrientationClientMock.cpp"
#include "platform/mock/GeolocationClientMock.cpp"
#include "platform/mock/MediaEngineConfigurationFactoryMock.cpp"
#include "platform/mock/MockRealtimeAudioSource.cpp"
#include "platform/mock/MockRealtimeMediaSourceCenter.cpp"
#include "platform/mock/MockRealtimeVideoSource.cpp"
#include "platform/mock/PlatformSpeechSynthesizerMock.cpp"
#include "platform/mock/RTCDataChannelHandlerMock.cpp"
#include "platform/mock/RTCNotifiersMock.cpp"
// Example usage (conceptual):
// DeviceOrientationClientMock orientationMock;
// MockRealtimeAudioSource audioMock;
// // Use mocks in test scenarios...
```
--------------------------------
### JavaFX ladder() Color Function
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
The ladder function interpolates between colors to create a gradient effect. It uses a base color and a list of color stops. The brightness of the base color determines the position on the gradient (0% brightness maps to the start, 100% to the end). This is useful for setting text colors that adapt to background brightness.
```css
ladder(base_color, color_stop1, color_stop2, ...)
```
```css
background: white;
-fx-text-fill: ladder(background, white 49%, black 50%);
```
--------------------------------
### HTML Structure for IntersectionObserver Example
Source: https://github.com/openjdk/jfx/blob/master/tests/system/src/test/resources/test/javafx/scene/web/testIObserver.html
Provides the necessary HTML structure for the IntersectionObserver example. It defines a parent container, a target element within it, and an output area to display the intersection ratio. Basic styling is included.
```html
```
--------------------------------
### libxml2 Autotools Configuration Options
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/ThirdParty/libxml/src/README.md
A list of configuration options for the Autotools build system of libxml2. These flags allow fine-grained control over which features and modules are included in the build, such as XML Catalogs, HTML parsing, Python bindings, and DTD validation.
```bash
--with-c14n
--with-catalog
--with-debug
--with-history
--with-readline[=DIR]
--with-html
--with-http
--with-iconv[=DIR]
--with-icu
--with-iso8859x
--with-lzma[=DIR]
--with-modules
--with-output
--with-pattern
--with-push
--with-python
--with-reader
--with-regexps
--with-relaxng
--with-sax1
--with-schemas
--with-schematron
--with-threads
--with-thread-alloc
--with-valid
--with-writer
--with-xinclude
--with-xpath
--with-xptr
--with-zlib[=DIR]
--with-minimum
--with-legacy
```
--------------------------------
### Media Capabilities and Configuration
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/WebCore/Sources.txt
Handles media capabilities and engine configuration, including logging and factory creation for media-related features.
```cpp
#include "platform/mediacapabilities/MediaCapabilitiesLogging.cpp"
#include "platform/mediacapabilities/MediaEngineConfigurationFactory.cpp"
```
--------------------------------
### Run All Tests with Gradle
Source: https://github.com/openjdk/jfx/blob/master/CONTRIBUTING.md
Executes the complete test suite for the OpenJFX project using Gradle. This command ensures that all tests are run to verify the integrity of the codebase.
```bash
bash ./gradlew all test
```
--------------------------------
### WebXR API Implementation (C++)
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/WebCore/Sources.txt
This snippet details C++ files for the WebXR API, enabling immersive augmented reality and virtual reality experiences. It includes classes for navigator integration, bounded reference spaces, XR frames, gamepads, hands, input sources (and their spaces and arrays), joint poses and spaces, layers (including WebGL layers), opaque framebuffers, poses, reference spaces, render states, rigid transforms, sessions, generic XR spaces, systems, views, viewer poses, viewports, composition layers, GPU bindings and sub-images, input source events, input sources change events, layer events, projection layers, reference space events, session events, WebGL bindings and sub-images. These components are fundamental for developing advanced XR applications.
```cpp
Modules/webxr/NavigatorWebXR.cpp
Modules/webxr/WebXRBoundedReferenceSpace.cpp
Modules/webxr/WebXRFrame.cpp
Modules/webxr/WebXRGamepad.cpp
Modules/webxr/WebXRHand.cpp
Modules/webxr/WebXRInputSource.cpp
Modules/webxr/WebXRInputSourceArray.cpp
Modules/webxr/WebXRInputSpace.cpp
Modules/webxr/WebXRJointPose.cpp
Modules/webxr/WebXRJointSpace.cpp
Modules/webxr/WebXRLayer.cpp
Modules/webxr/WebXROpaqueFramebuffer.cpp
Modules/webxr/WebXRPose.cpp
Modules/webxr/WebXRReferenceSpace.cpp
Modules/webxr/WebXRRenderState.cpp
Modules/webxr/WebXRRigidTransform.cpp
Modules/webxr/WebXRSession.cpp
Modules/webxr/WebXRSpace.cpp
Modules/webxr/WebXRSystem.cpp
Modules/webxr/WebXRView.cpp
Modules/webxr/WebXRViewerPose.cpp
Modules/webxr/WebXRViewport.cpp
Modules/webxr/WebXRWebGLLayer.cpp
Modules/webxr/XRCompositionLayer.cpp
Modules/webxr/XRGPUBinding.cpp
Modules/webxr/XRGPUSubImage.cpp
Modules/webxr/XRInputSourceEvent.cpp
Modules/webxr/XRInputSourcesChangeEvent.cpp
Modules/webxr/XRLayerEvent.cpp
Modules/webxr/XRProjectionLayer.cpp
Modules/webxr/XRReferenceSpaceEvent.cpp
Modules/webxr/XRSessionEvent.cpp
Modules/webxr/XRWebGLBinding.cpp
Modules/webxr/XRWebGLSubImage.cpp
```
--------------------------------
### Pseudo-classes
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Overview of CSS pseudo-classes available in JavaFX, categorized by their function.
```APIDOC
## Pseudo-classes
### Description
Available CSS Pseudo-classes for styling JavaFX applications.
### Categories
#### User Action Pseudo-classes
- **:focused**: Applies when the `focused` variable is true.
- **:focus-visible**: Applies when the `focusVisible` variable is true.
- **:focus-within**: Applies when the `focusWithin` variable is true.
- **:hover**: Applies when the `hover` variable is true.
- **:pressed**: Applies when the `pressed` variable is true.
#### Input Pseudo-classes
- **:disabled**: Applies when the `disabled` variable is true.
- **:show-mnemonic**: Applies when the mnemonic affordance should be shown.
#### Tree-Structural Pseudo-classes
- **:first-child**: Applies when the node is the first child in its `Parent` container.
- **:last-child**: Applies when the node is the last child in its `Parent` container.
- **:only-child**: Applies when the node is the only child in its `Parent` container.
- **:nth-child(even | odd)**: Applies when the node is the n-th child in its `Parent` container.
#### Root Pseudo-class
- **:root**: Applies when the `Parent` is the root node of a `Scene` or `SubScene`.
### Inheritance
All pseudo-classes of `Node` are also available to its subclasses unless explicitly overridden.
```
--------------------------------
### WebAuthn FIDO Protocol Implementation (C++)
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/WebCore/Sources.txt
This snippet details C++ files related to the WebAuthn FIDO (Fast Identity Online) protocol. It includes classes for handling authenticator responses, supported options, device request/response conversion, constants, HID messages and packets, parsing utilities, PIN management, and U2F commands/responses. These files are crucial for implementing secure authentication mechanisms.
```cpp
Modules/webauthn/fido/AuthenticatorGetInfoResponse.cpp
Modules/webauthn/fido/AuthenticatorSupportedOptions.cpp
Modules/webauthn/fido/DeviceRequestConverter.cpp
Modules/webauthn/fido/DeviceResponseConverter.cpp
Modules/webauthn/fido/FidoConstants.cpp
Modules/webauthn/fido/FidoHidMessage.cpp
Modules/webauthn/fido/FidoHidPacket.cpp
Modules/webauthn/fido/FidoParsingUtils.cpp
Modules/webauthn/fido/Pin.cpp
Modules/webauthn/fido/U2fCommandConstructor.cpp
Modules/webauthn/fido/U2fResponseConverter.cpp
```
--------------------------------
### ImageView CSS Properties
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Details on CSS properties specifically for the ImageView component in JavaFX.
```APIDOC
## POST /api/imageview/style
### Description
Applies CSS styling to an ImageView component.
### Method
POST
### Endpoint
`/api/imageview/style`
### Parameters
#### Request Body
- **styleClass** (string) - Optional - The CSS class name for the ImageView.
- **fitHeight** (number) - Optional - The height of the bounding box within which the source image is resized.
- **fitWidth** (number) - Optional - The width of the bounding box within which the source image is resized.
- **image** (uri) - Optional - The URI of the source image. Relative URLs are resolved against the URL of the stylesheet.
- **preserveRatio** (boolean) - Optional - Indicates whether to preserve the aspect ratio of the source image when scaling.
- **smooth** (boolean) - Optional - Indicates whether to use a better quality filtering algorithm when transforming or scaling the source image.
### Request Example
```json
{
"styleClass": "image-view",
"fitHeight": 100,
"fitWidth": 150,
"image": "/images/logo.png",
"preserveRatio": true,
"smooth": true
}
```
### Response
#### Success Response (200)
- **message** (string) - Confirmation of successful styling.
#### Response Example
```json
{
"message": "ImageView styled successfully."
}
```
```
--------------------------------
### Autotools Build Configuration for libxml2
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.web/src/main/native/Source/ThirdParty/libxml/src/README.md
These commands configure and build the libxml2 library on POSIX systems using Autotools. The `./configure` command accepts various options to enable or disable specific modules and features like C14N, HTML parsing, Python bindings, and zlib support.
```bash
./autogen.sh [configuration options]
./configure [configuration options]
make
make check
make install
```
--------------------------------
### -fx-border-image-repeat
Source: https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html
Specifies how the border image should be repeated. It accepts a series of repeat-style values, separated by commas.
```APIDOC
## -fx-border-image-repeat
### Description
Specifies how the border image should be repeated. It accepts a series of repeat-style values ('repeat-x', 'repeat-y', 'repeat', 'space', 'round', 'no-repeat'), separated by commas. Each value applies to the corresponding border image.
### Method
N/A (CSS Property)
### Endpoint
N/A
### Parameters
#### CSS Property Value
- **** - String - A keyword indicating the repeat style (e.g., 'repeat', 'round', 'no-repeat').
- ** [ , ]*** - String - A comma-separated series of repeat-style values.
### Request Example
```css
-fx-border-image-repeat: repeat-x, round;
```
### Response
#### Success Response (200)
N/A (CSS Property)
#### Response Example
N/A
```