That's the idea, except you wouldn't have to create and add your own Region.

On 8/7/14, 2:30 PM, Scott Palmer wrote:
So this is something like doing this:

import javafx.application.Application;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.control.Label;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class TestSVGLabel extends Application {

public void start(Stage stage) {
Region img = new Region();
img.getStyleClass().add("graphic");
Label label = new Label("Text 123456789", img);

VBox root = new VBox();
root.getChildren().add(label);
Scene scene = new Scene(root);
scene.getStylesheets().add("svgLabel.css");
stage.setScene(scene);
stage.show();
}
}


.label > .graphic {
-fx-scale-shape: true;
-fx-position-shape: true;
-fx-min-width: 32;
-fx-min-height:32;
-fx-border-color: black;
-fx-background-color: green;
-fx-shape: "M 100 100 L 300 100 L 200 300 z";
}


Note that there is a layout issue using JRE 8u20 and the above code.  It
seems the size of the Region is not considered properly and it causes the
Text to be truncated.

Scott



On Thu, Aug 7, 2014 at 4:54 AM, Tom Schindl <tom.schi...@bestsolution.at>
wrote:

Hi,

To me this looks like a none breaking change or do I miss something?

Still why not getting more generic and provide FXML as the graphic
syntax, the URI could be able to detect this as well, the FXMLLoader
naturally should never ever be load a controller when it is used from
inside an CSS.

Now on the syntax would it be better instead of defining svg-path to
work with protocols like browsers are doing it today (see data-urls).

We'd have then:
* file:
* http:
* ...
* data:scenegraph/svg-path;....
* data:scenegraph/fxml;....

Tom

On 07.08.14 00:59, David Grieve wrote:
In as much as CSS styles can be considered API, I propose the following
CSS API change for Labeled's -fx-graphic property. This will allow an
SVG path to be used as the value on Labeled's -fx-graphic property. See
https://javafx-jira.kenai.com/browse/RT-38192

Proposed CSS API for Labeled:

Allow -fx-graphic to be either a uri or an svg-path

      -fx-graphic: [ <uri> | <svg-path> ]

If -fx-graphic is a svg-path, a Region will be set as the Labeled's
graphicProperty. This Region will be given the style-class 'graphic'.

Example:

     .button { -fx-graphic: "M2,0 L5,4 L8,0 L10,0 L10,2 L6,5 L10,8 L10,10
L8,10 L5,6 L2,10 L0,10 L0,8 L4,5 L0,2 L0,0 Z"; }
     .button > .graphic { -fx-background-fill: red; -fx-min-width: 10;
-fx-min-height: 10; }


Reply via email to