SvgNode icon = new SvgNode("M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z", 32); icon.setColor(Color.RED);
<SvgNode path="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z" size="32" color="RED" />
<SvgNode size="32" color="RED">
<path>
<MyIcons fx:constant="HOME"/>
</path>
</SvgNode>
.svg-node { -fx-path: "M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"; -fx-size: 24; -fx-color: red; }
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class | SvgNode.
A |
| Modifier and Type | Field and Description |
|---|---|
| private StyleableObjectProperty | |
| private static final String | |
| private static final double | |
| private StyleableStringProperty | |
| private StyleableDoubleProperty | |
| private final SvgNode. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final StyleableObjectProperty | |
| protected double | computeMaxHeight(double width)
Overrides javafx. Computes the maximum height of this region. |
| protected double | computeMaxWidth(double height)
Overrides javafx. Computes the maximum width for this region. |
| protected double | computeMinHeight(double width)
Overrides javafx. Computes the minimum height of this region. |
| protected double | computeMinWidth(double height)
Overrides javafx. Computes the minimum width of this region. |
| protected double | computePrefHeight(double width)
Overrides javafx. Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy. |
| protected double | computePrefWidth(double height)
Overrides javafx. Computes the preferred width of this region for the given height. |
| public static List | Returns: theCssMetaDataHides javafx. Gets the |
| public final Paint | |
| public List | getCssMetaData()
Overrides javafx. Implements javafx. This method should delegate to |
| public final String | |
| public final double | |
| protected void | layoutChildren()
Overrides javafx. Invoked during the layout pass to layout the children in this
|
| public final StyleableStringProperty | Returns: the path propertyThe SVG path content string (e.g. |
| public final void | |
| public final void | |
| public final void | |
| public final StyleableDoubleProperty | Returns: the size propertyThe target size (width and height) the SVG should be rasterized to. |
| color | back to summary |
|---|---|
| private StyleableObjectProperty<Paint> color | |
| DEFAULT_PATH | back to summary |
|---|---|
| private static final String DEFAULT_PATH | |
| DEFAULT_SIZE | back to summary |
|---|---|
| private static final double DEFAULT_SIZE | |
| path | back to summary |
|---|---|
| private StyleableStringProperty path | |
| size | back to summary |
|---|---|
| private StyleableDoubleProperty size | |
| svgContent | back to summary |
|---|---|
| private final SvgNode. | |
| SvgNode | back to summary |
|---|---|
| public SvgNode() Creates an empty | |
| SvgNode | back to summary |
|---|---|
| public SvgNode(String path) Creates an
| |
| SvgNode | back to summary |
|---|---|
| public SvgNode(String path, double size) Creates an
| |
| colorProperty | back to summary |
|---|---|
| public final StyleableObjectProperty The fill color of the SVG shape itself. Can be set in CSS with
| |
| computeMaxHeight | back to summary |
|---|---|
| protected double computeMaxHeight(double width) Overrides javafx. Doc from javafx. Computes the maximum height of this region. Returns Double.MAX_VALUE by default. Region subclasses may override this method to return a different value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.
| |
| computeMaxWidth | back to summary |
|---|---|
| protected double computeMaxWidth(double height) Overrides javafx. Doc from javafx. Computes the maximum width for this region. Returns Double.MAX_VALUE by default. Region subclasses may override this method to return an different value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.
| |
| computeMinHeight | back to summary |
|---|---|
| protected double computeMinHeight(double width) Overrides javafx. Doc from javafx. Computes the minimum height of this region. Returns the sum of the top and bottom insets by default. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.
| |
| computeMinWidth | back to summary |
|---|---|
| protected double computeMinWidth(double height) Overrides javafx. Doc from javafx. Computes the minimum width of this region. Returns the sum of the left and right insets by default. region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.
| |
| computePrefHeight | back to summary |
|---|---|
| protected double computePrefHeight(double width) Overrides javafx. Doc from javafx. Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.
| |
| computePrefWidth | back to summary |
|---|---|
| protected double computePrefWidth(double height) Overrides javafx. Doc from javafx. Computes the preferred width of this region for the given height. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.
| |
| getClassCssMetaData | back to summary |
|---|---|
| public static List Hides javafx. Gets the
| |
| getColor | back to summary |
|---|---|
| public final Paint getColor() | |
| getCssMetaData | back to summary |
|---|---|
| public List Overrides javafx. Implements javafx. Doc from javafx. This method should delegate to
| |
| getPath | back to summary |
|---|---|
| public final String getPath() | |
| getSize | back to summary |
|---|---|
| public final double getSize() | |
| layoutChildren | back to summary |
|---|---|
| protected void layoutChildren() Overrides javafx. Doc from javafx. Invoked during the layout pass to layout the children in this
Subclasses should override this function to layout content as needed.
| |
| pathProperty | back to summary |
|---|---|
| public final StyleableStringProperty pathProperty() The SVG path content string (e.g. Can be set in CSS with
| |
| setColor | back to summary |
|---|---|
| public final void setColor(Paint value) | |
| setPath | back to summary |
|---|---|
| public final void setPath(String value) | |
| setSize | back to summary |
|---|---|
| public final void setSize(double value) | |
| sizeProperty | back to summary |
|---|---|
| public final StyleableDoubleProperty sizeProperty() The target size (width and height) the SVG should be rasterized to. The SVG path is rasterized uniformly to fit within a square of this size while preserving its original aspect ratio. Can be set in CSS with
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final List |
| Access | Constructor and Description |
|---|---|
| private |
| COLOR | back to summary |
|---|---|
| private static final CssMetaData<SvgNode, Paint> COLOR | |
| PATH | back to summary |
|---|---|
| private static final CssMetaData<SvgNode, String> PATH | |
| SIZE | back to summary |
|---|---|
| private static final CssMetaData<SvgNode, Number> SIZE | |
| STYLEABLES | back to summary |
|---|---|
| private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES | |
| StyleableProperties | back to summary |
|---|---|
| private StyleableProperties() | |
| Modifier and Type | Field and Description |
|---|---|
| private double | |
| private final SVGPath | |
| private double |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| protected double | computeMaxHeight(double width)
Overrides javafx. Computes the maximum height of this region. |
| protected double | computeMaxWidth(double height)
Overrides javafx. Computes the maximum width for this region. |
| protected double | computeMinHeight(double width)
Overrides javafx. Computes the minimum height of this region. |
| protected double | computeMinWidth(double height)
Overrides javafx. Computes the minimum width of this region. |
| protected double | computePrefHeight(double width)
Overrides javafx. Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy. |
| protected double | computePrefWidth(double height)
Overrides javafx. Computes the preferred width of this region for the given height. |
| public String | getUserAgentStylesheet()
Overrides javafx. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. |
| pack-priv void | |
| pack-priv void |
| svgHeight | back to summary |
|---|---|
| private double svgHeight | |
| svgPath | back to summary |
|---|---|
| private final SVGPath svgPath | |
| svgWidth | back to summary |
|---|---|
| private double svgWidth | |
| SvgContent | back to summary |
|---|---|
| pack-priv SvgContent() | |
| calculateSvgSize | back to summary |
|---|---|
| private void calculateSvgSize(double rasterizedSize) | |
| computeMaxHeight | back to summary |
|---|---|
| protected double computeMaxHeight(double width) Overrides javafx. Doc from javafx. Computes the maximum height of this region. Returns Double.MAX_VALUE by default. Region subclasses may override this method to return a different value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.
| |
| computeMaxWidth | back to summary |
|---|---|
| protected double computeMaxWidth(double height) Overrides javafx. Doc from javafx. Computes the maximum width for this region. Returns Double.MAX_VALUE by default. Region subclasses may override this method to return an different value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.
| |
| computeMinHeight | back to summary |
|---|---|
| protected double computeMinHeight(double width) Overrides javafx. Doc from javafx. Computes the minimum height of this region. Returns the sum of the top and bottom insets by default. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.
| |
| computeMinWidth | back to summary |
|---|---|
| protected double computeMinWidth(double height) Overrides javafx. Doc from javafx. Computes the minimum width of this region. Returns the sum of the left and right insets by default. region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.
| |
| computePrefHeight | back to summary |
|---|---|
| protected double computePrefHeight(double width) Overrides javafx. Doc from javafx. Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.
| |
| computePrefWidth | back to summary |
|---|---|
| protected double computePrefWidth(double height) Overrides javafx. Doc from javafx. Computes the preferred width of this region for the given height. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.
| |
| getUserAgentStylesheet | back to summary |
|---|---|
| public String getUserAgentStylesheet() Overrides javafx. Doc from javafx. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls. The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath. Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.
For additional information about using CSS with the scene graph,
see the CSS Reference Guide.
| |
| updatePath | back to summary |
|---|---|
| pack-priv void updatePath(String path, double rasterizedSize) | |
| updateRasterizedSize | back to summary |
|---|---|
| pack-priv void updateRasterizedSize(double rasterizedSize) | |