Java 类javafx.scene.paint.LinearGradient 实例源码

项目:FXGLGames    文件:BreakoutApp.java   
private void initBackground() {
    Rectangle bg0 = new Rectangle(getWidth(), getHeight(),
            new LinearGradient(getWidth() / 2, 0, getWidth() / 2, getHeight(),
                    false, CycleMethod.NO_CYCLE,
                    new Stop(0.2, Color.AQUA), new Stop(0.8, Color.BLACK)));

    Rectangle bg1 = new Rectangle(getWidth(), getHeight(), Color.color(0, 0, 0, 0.2));
    bg1.setBlendMode(BlendMode.DARKEN);

    EntityView bg = new EntityView(RenderLayer.BACKGROUND);
    bg.addNode(bg0);
    bg.addNode(bg1);

    // we add IrremovableComponent because regardless of the level
    // the background and screen bounds stay in the game world
    Entities.builder()
            .viewFromNode(bg)
            .with(new IrremovableComponent())
            .buildAndAttach(getGameWorld());

    Entity screenBounds = Entities.makeScreenBounds(40);
    screenBounds.addComponent(new IrremovableComponent());

    getGameWorld().addEntity(screenBounds);
}
项目:openjfx-8u-dev-tests    文件:CanvasEffects2App.java   
@Override
public Node drawNode() {

    Group group = new Group();
    final Canvas canvas = new Canvas(120, 120);
    GraphicsContext gc = canvas.getGraphicsContext2D();
    group.getChildren().add(canvas);

    gc.setFill(Color.GREEN);
    gc.fillRect(10,10, 70, 70);

    ColorInput effect = new ColorInput();
    effect.setPaint(new LinearGradient(0, 0, 0.5f, 0.1f, true, CycleMethod.REPEAT, new Stop[] {
                    new Stop(0, Color.RED),
                    new Stop(1, Color.GREEN),
                }));
    effect.setX(15);
    effect.setY(15);
    effect.setWidth(70);
    effect.setHeight(70);

    gc.applyEffect(effect);
    return group;

}
项目:Medusa    文件:SectionSkin.java   
private void createNeedle() {
    double needleWidth  = size * 0.04;
    double needleHeight = size * 0.4675;
    needle.getElements().clear();
    needle.getElements().add(new MoveTo(0.3125 * needleWidth, 0.015957446808510637 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.3125 * needleWidth, 0.005319148936170213 * needleHeight,
                                              0.4375 * needleWidth, 0.0,
                                              0.5 * needleWidth, 0.0));
    needle.getElements().add(new CubicCurveTo(0.5625 * needleWidth, 0.0,
                                              0.6875 * needleWidth, 0.005319148936170213 * needleHeight,
                                              0.6875 * needleWidth, 0.015957446808510637 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.6875 * needleWidth, 0.015957446808510637 * needleHeight,
                                              needleWidth, 0.9946808510638298 * needleHeight,
                                              needleWidth, 0.9946808510638298 * needleHeight));
    needle.getElements().add(new LineTo(0.0, 0.9946808510638298 * needleHeight));
    needle.getElements().add(new CubicCurveTo(0.0, 0.9946808510638298 * needleHeight,
                                              0.3125 * needleWidth, 0.015957446808510637 * needleHeight,
                                              0.3125 * needleWidth, 0.015957446808510637 * needleHeight));
    needle.getElements().add(new ClosePath());
    needle.setFill(new LinearGradient(needle.getLayoutBounds().getMinX(), 0,
                                      needle.getLayoutBounds().getMaxX(), 0,
                                      false, CycleMethod.NO_CYCLE,
                                      new Stop(0.0, gauge.getNeedleColor().darker()),
                                      new Stop(0.5, gauge.getNeedleColor()),
                                      new Stop(1.0, gauge.getNeedleColor().darker())));
}
项目:Medusa    文件:SectionSkin.java   
@Override protected void redraw() {
    sectionsVisible = gauge.getSectionsVisible();
    drawSections();
    needle.setFill(new LinearGradient(needle.getLayoutBounds().getMinX(), 0,
                                      needle.getLayoutBounds().getMaxX(), 0,
                                      false, CycleMethod.NO_CYCLE,
                                      new Stop(0.0, gauge.getNeedleColor().darker()),
                                      new Stop(0.5, gauge.getNeedleColor()),
                                      new Stop(1.0, gauge.getNeedleColor().darker())));
    titleText.setFill(gauge.getTitleColor());
    valueText.setFill(gauge.getValueColor());
    mask.setFill(gauge.getBackgroundPaint());
    knob.setFill(gauge.getKnobColor());
    titleText.setText(gauge.getTitle());
    resizeText();
}
项目:Medusa    文件:ModernSkin.java   
public void handleMouseEvent(final MouseEvent EVENT) {
    if (gauge.isDisabled()) return;
    final EventType TYPE = EVENT.getEventType();
    if (MouseEvent.MOUSE_PRESSED.equals(TYPE)) {
        gauge.fireEvent(gauge.BTN_PRESSED_EVENT);
        centerKnob.setFill(new LinearGradient(0.5 * size, 0.2708333333333333 * size,
                                              0.5 * size, 0.7291666666666666 * size,
                                              false, CycleMethod.NO_CYCLE,
                                              new Stop(0.0, Color.rgb(31, 31, 31)),
                                              new Stop(1.0, Color.rgb(69, 70, 73))));
        valueText.setTranslateY(size * 0.501);
        subTitleText.setTranslateY(size * 0.3525);
        unitText.setTranslateY(size * 0.6675);
    } else if (MouseEvent.MOUSE_RELEASED.equals(TYPE)) {
        gauge.fireEvent(gauge.BTN_RELEASED_EVENT);
        centerKnob.setFill(new LinearGradient(0.5 * size, 0.2708333333333333 * size,
                                              0.5 * size, 0.7291666666666666 * size,
                                              false, CycleMethod.NO_CYCLE,
                                              new Stop(0.0, Color.rgb(69, 70, 73)),
                                              new Stop(1.0, Color.rgb(31, 31, 31))));
        valueText.setTranslateY(size * 0.5);
        subTitleText.setTranslateY(size * 0.35);
        unitText.setTranslateY(size * 0.67);
    }
}
项目:CSS-Editor-FX    文件:CSSPaintPaser.java   
public List<Function<String, Paint>> getTasks() {
  return CacheUtil.cache(CSSPaintPaser.class, () -> Arrays.asList(
      text -> Color.web(text, 1),
      text -> LinearGradient.valueOf(text),
      text -> RadialGradient.valueOf(text),
      text -> context.lookup(text),
      text -> DeriveColorConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
      text -> LadderConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
      text -> LinearGradientConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
      text -> RadialGradientConverter.getInstance().convert(factory.apply(text), Font.getDefault())
      ));
}
项目:FXGLGames    文件:BreakoutApp.java   
private void initBackground() {
    Rectangle bg0 = new Rectangle(getWidth(), getHeight(),
            new LinearGradient(getWidth() / 2, 0, getWidth() / 2, getHeight(),
                    false, CycleMethod.NO_CYCLE,
                    new Stop(0.2, Color.AQUA), new Stop(0.8, Color.BLACK)));

    Rectangle bg1 = new Rectangle(getWidth(), getHeight(), Color.color(0, 0, 0, 0.2));
    bg1.setBlendMode(BlendMode.DARKEN);

    EntityView bg = new EntityView(RenderLayer.BACKGROUND);
    bg.addNode(bg0);
    bg.addNode(bg1);

    // we add IrremovableComponent because regardless of the level
    // the background and screen bounds stay in the game world
    Entities.builder()
            .viewFromNode(bg)
            .with(new IrremovableComponent())
            .buildAndAttach(getGameWorld());

    Entity screenBounds = Entities.makeScreenBounds(40);
    screenBounds.addComponent(new IrremovableComponent());

    getGameWorld().addEntity(screenBounds);
}
项目:examples-javafx-repos1    文件:Overlay1Controller.java   
private void createTopHighlightBorder() {
    Stop[] stops = new Stop[] {
            new Stop(0, Color.WHITE),
            new Stop(.3, Color.LIGHTGRAY),
            new Stop(1, Color.TRANSPARENT)
    };
    LinearGradient lg1 = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stops);

    topHighlightBorder =
            new Border(new BorderStroke(
                    lg1, null, null, null,
                    BorderStrokeStyle.SOLID, BorderStrokeStyle.NONE, BorderStrokeStyle.NONE, BorderStrokeStyle.NONE,
                    CornerRadii.EMPTY,
                    new BorderWidths( 8.0d ),
                    null
            ));
}
项目:org.csstudio.display.builder    文件:ThermometerRepresentation.java   
Thermo(Color color)
{
    setFill(color);

    fill.setArcHeight(6);
    fill.setArcWidth(6);
    fill.setManaged(false);
    border.setFill(new LinearGradient(.3, 0, .7, 0, true, CycleMethod.NO_CYCLE,
            new Stop(0, Color.LIGHTGRAY),
            new Stop(.3, Color.WHITESMOKE),
            new Stop(1, Color.LIGHTGRAY)));
    border.setStroke(Color.BLACK);
    arc.setLargeArcFlag(true);
    rightcorner.setY(0);

    getChildren().add(border);
    getChildren().add(fill);
    getChildren().add(ellipse);
    setBorder(new Border(
            new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
}
项目:org.csstudio.display.builder    文件:ThermoDemo.java   
Thermo(Color color)
{
    setFill(color);

    fill.setArcHeight(3);
    fill.setArcWidth(3);
    fill.setManaged(false);
    border.setFill(new LinearGradient(.3, 0, .7, 0, true, CycleMethod.NO_CYCLE,
                                    new Stop(0, Color.LIGHTGRAY),
                                    new Stop(.3, Color.WHITESMOKE),
                                    new Stop(1, Color.LIGHTGRAY)));
    border.setStroke(Color.BLACK);
    arc.setLargeArcFlag(true);

    getChildren().add(border);
    getChildren().add(fill);
    getChildren().add(ellipse);
    setBorder(new Border(
            new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
}
项目:AudioVisualizer2.0    文件:RenderTestVis2Frame.java   
private void changeGradient2Color(int index, Color color)
{
    if (index == 0)
    {
        stopsInner[index] = new Stop (0, color);
    } else if (index == 1)
    {
        stopsInner[index] = new Stop (.1, color);
    } else if (index == 2)
    {
        stopsInner[index] = new Stop (.8, color);
    } else if (index == 3)
    {
        stopsInner[index] = new Stop (1, color);
    }
    // reset the gradient containing the given color
    lg2 = new LinearGradient (0, 0, 0, .5, true, CycleMethod.REFLECT,
            stopsInner);
}
项目:AudioVisualizer2.0    文件:RenderTestVisFrame.java   
private void changeGradient2Color(int index, Color color)
{
    if (index == 0)
    {
        stopsInner[index] = new Stop (0, color);
    } else if (index == 1)
    {
        stopsInner[index] = new Stop (.1, color);
    } else if (index == 2)
    {
        stopsInner[index] = new Stop (.8, color);
    } else if (index == 3)
    {
        stopsInner[index] = new Stop (1, color);
    }
    // reset the gradient containing the given color
    lg2 = new LinearGradient (0, 0, 0, .5, true, CycleMethod.REFLECT,
            stopsInner);
}
项目:GraphCreator    文件:Themes.java   
private static void traffic(LineGraph graph){
    graph.setClose(false);

    graphPath.setStrokeWidth(4);
    graphPath.setStroke(new LinearGradient(0,0,0,1,true, CycleMethod.NO_CYCLE,
                        new Stop(0, Color.valueOf("#03A9F4")),
                        new Stop(0.7,Color.valueOf("#f47536")), new Stop(1,Color.valueOf("#d32f2f"))));

    lines.setStroke(Color.TRANSPARENT);
    dots.setFill(Color.TRANSPARENT);
}
项目:incubator-netbeans    文件:StopWatch.java   
private void configureDesign() {
    rectangleVisual.setLayoutY(0f);
    rectangleVisual.setLayoutX(-14);
    rectangleVisual.setFill(Color.TRANSPARENT);

    rectangleSmall.setLayoutX(-7);
    rectangleSmall.setLayoutY(5);
    rectangleSmall.setFill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[]{
                new Stop(0, colorWeak),
                new Stop(0.5, colorStrong),
                new Stop(1, colorWeak)}));

    rectangleBig.setLayoutX(-14);
    rectangleBig.setLayoutY(0);
    rectangleBig.setFill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[]{
                new Stop(0, colorStrong),
                new Stop(0.5, colorWeak),
                new Stop(1, colorStrong)}));

    rectangleWatch.setFill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[]{
                new Stop(0, Color.web("#4e605f")),
                new Stop(0.2, Color.web("#c3d6d5")),
                new Stop(0.5, Color.web("#f9ffff")),
                new Stop(0.8, Color.web("#c3d6d5")),
                new Stop(1, Color.web("#4e605f"))}));
    rectangleWatch.setLayoutX(-12);
    rectangleWatch.setLayoutY(12);
}
项目:marathonv5    文件:SimpleHSBColorPicker.java   
private LinearGradient buildHueBar() {
    double offset;
    Stop[] stops = new Stop[255];
    for (int y = 0; y < 255; y++) {
        offset = (double) (1.0 / 255) * y;
        int h = (int)((y / 255.0) * 360);
        stops[y] = new Stop(offset, Color.hsb(h, 1.0, 1.0));
    }
    return new LinearGradient(0f, 0f, 1f, 0f, true, CycleMethod.NO_CYCLE, stops);
}
项目:marathonv5    文件:StopWatchSample.java   
private void configureDesign() {
    rectangleVisual.setLayoutY(0f);
    rectangleVisual.setLayoutX(-14);
    rectangleVisual.setFill(Color.TRANSPARENT);

    rectangleSmall.setLayoutX(-7);
    rectangleSmall.setLayoutY(5);
    rectangleSmall.setFill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[]{
                new Stop(0, colorWeak),
                new Stop(0.5, colorStrong),
                new Stop(1, colorWeak)}));

    rectangleBig.setLayoutX(-14);
    rectangleBig.setLayoutY(0);
    rectangleBig.setFill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[]{
                new Stop(0, colorStrong),
                new Stop(0.5, colorWeak),
                new Stop(1, colorStrong)}));

    rectangleWatch.setFill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[]{
                new Stop(0, Color.web("#4e605f")),
                new Stop(0.2, Color.web("#c3d6d5")),
                new Stop(0.5, Color.web("#f9ffff")),
                new Stop(0.8, Color.web("#c3d6d5")),
                new Stop(1, Color.web("#4e605f"))}));
    rectangleWatch.setLayoutX(-12);
    rectangleWatch.setLayoutY(12);
}
项目:marathonv5    文件:LinearGradientSample.java   
public LinearGradientSample() {
    //First rectangle
    Rectangle rect1 = new Rectangle(0,0,80,80);

    //create simple linear gradient
    LinearGradient gradient1 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[] {
        new Stop(0, Color.DODGERBLUE),
        new Stop(1, Color.BLACK)
    });

    //set rectangle fill
    rect1.setFill(gradient1);

    // Second rectangle
    Rectangle rect2 = new Rectangle(0,0,80,80);

    //create complex linear gradient
    LinearGradient gradient2 = new LinearGradient(0, 0, 0, 0.5,  true, CycleMethod.REFLECT, new Stop[] {
        new Stop(0, Color.DODGERBLUE),
        new Stop(0.1, Color.BLACK),
        new Stop(1, Color.DODGERBLUE)
    });

    //set rectangle fill
    rect2.setFill(gradient2);

    // show the rectangles
    HBox hb = new HBox(10);
    hb.getChildren().addAll(rect1, rect2);
    getChildren().add(hb);
}
项目:marathonv5    文件:LinearGradientSample.java   
public static Node createIconContent() {
    Rectangle rect = new Rectangle(80,80,new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[] {
        new Stop(0, Color.rgb(156,216,255)),
        new Stop(0.5, Color.DODGERBLUE),
        new Stop(1, Color.rgb(0,70,140))
    }));
    rect.setArcWidth(20);
    rect.setArcHeight(20);
    return rect;
}
项目:marathonv5    文件:ColorSample.java   
public static Node createIconContent() {
    double offset;
    Stop[] stops = new Stop[255];
    for (int y = 0; y < 255; y++) {
        offset = (double) (1.0 / 255) * y;
        int h = (int)((y / 255.0) * 360);
        stops[y] = new Stop(offset, Color.hsb(h, 0.8, 0.9));
    }
    Rectangle rect = new Rectangle(80,80,
            new LinearGradient(0f, 0f, 1f, 1f, true, CycleMethod.NO_CYCLE, stops));
    rect.setArcWidth(20);
    rect.setArcHeight(20);
    return rect;
}
项目:marathonv5    文件:SimpleHSBColorPicker.java   
private LinearGradient buildHueBar() {
    double offset;
    Stop[] stops = new Stop[255];
    for (int y = 0; y < 255; y++) {
        offset = (double) (1.0 / 255) * y;
        int h = (int)((y / 255.0) * 360);
        stops[y] = new Stop(offset, Color.hsb(h, 1.0, 1.0));
    }
    return new LinearGradient(0f, 0f, 1f, 0f, true, CycleMethod.NO_CYCLE, stops);
}
项目:marathonv5    文件:StopWatchSample.java   
private void configureDesign() {
    rectangleVisual.setLayoutY(0f);
    rectangleVisual.setLayoutX(-14);
    rectangleVisual.setFill(Color.TRANSPARENT);

    rectangleSmall.setLayoutX(-7);
    rectangleSmall.setLayoutY(5);
    rectangleSmall.setFill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[]{
                new Stop(0, colorWeak),
                new Stop(0.5, colorStrong),
                new Stop(1, colorWeak)}));

    rectangleBig.setLayoutX(-14);
    rectangleBig.setLayoutY(0);
    rectangleBig.setFill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[]{
                new Stop(0, colorStrong),
                new Stop(0.5, colorWeak),
                new Stop(1, colorStrong)}));

    rectangleWatch.setFill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[]{
                new Stop(0, Color.web("#4e605f")),
                new Stop(0.2, Color.web("#c3d6d5")),
                new Stop(0.5, Color.web("#f9ffff")),
                new Stop(0.8, Color.web("#c3d6d5")),
                new Stop(1, Color.web("#4e605f"))}));
    rectangleWatch.setLayoutX(-12);
    rectangleWatch.setLayoutY(12);
}
项目:marathonv5    文件:LinearGradientSample.java   
public LinearGradientSample() {
    //First rectangle
    Rectangle rect1 = new Rectangle(0,0,80,80);

    //create simple linear gradient
    LinearGradient gradient1 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[] {
        new Stop(0, Color.DODGERBLUE),
        new Stop(1, Color.BLACK)
    });

    //set rectangle fill
    rect1.setFill(gradient1);

    // Second rectangle
    Rectangle rect2 = new Rectangle(0,0,80,80);

    //create complex linear gradient
    LinearGradient gradient2 = new LinearGradient(0, 0, 0, 0.5,  true, CycleMethod.REFLECT, new Stop[] {
        new Stop(0, Color.DODGERBLUE),
        new Stop(0.1, Color.BLACK),
        new Stop(1, Color.DODGERBLUE)
    });

    //set rectangle fill
    rect2.setFill(gradient2);

    // show the rectangles
    HBox hb = new HBox(10);
    hb.getChildren().addAll(rect1, rect2);
    getChildren().add(hb);
}
项目:marathonv5    文件:LinearGradientSample.java   
public static Node createIconContent() {
    Rectangle rect = new Rectangle(80,80,new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop[] {
        new Stop(0, Color.rgb(156,216,255)),
        new Stop(0.5, Color.DODGERBLUE),
        new Stop(1, Color.rgb(0,70,140))
    }));
    rect.setArcWidth(20);
    rect.setArcHeight(20);
    return rect;
}
项目:marathonv5    文件:ColorSample.java   
public static Node createIconContent() {
    double offset;
    Stop[] stops = new Stop[255];
    for (int y = 0; y < 255; y++) {
        offset = (double) (1.0 / 255) * y;
        int h = (int)((y / 255.0) * 360);
        stops[y] = new Stop(offset, Color.hsb(h, 0.8, 0.9));
    }
    Rectangle rect = new Rectangle(80,80,
            new LinearGradient(0f, 0f, 1f, 1f, true, CycleMethod.NO_CYCLE, stops));
    rect.setArcWidth(20);
    rect.setArcHeight(20);
    return rect;
}
项目:HotaruFX    文件:ColorPickerBox.java   
private static LinearGradient createHueGradient() {
    final Stop[] stops = new Stop[255];
    for (int x = 0; x < 255; x++) {
        final double offset = (1.0 / 255.0) * x;
        final int hue = (int)((x / 255.0) * 360);
        stops[x] = new Stop(offset, Color.hsb(hue, 1.0, 1.0));
    }
    return new LinearGradient(0f, 0f, 1f, 0f, true, CycleMethod.NO_CYCLE, stops);
}
项目:GazePlay    文件:Clavier.java   
public Clavier(Instru instru) {

        this.instru = instru;// l'objet de type Instru prend la valeur de l'objet passé en paramètre

        Rectangle fond_clavier = new Rectangle();
        fond_clavier.setWidth(400);
        fond_clavier.setHeight(200);
        fond_clavier.setArcWidth(30);
        fond_clavier.setArcHeight(30);
        fond_clavier.setFill( // on remplie notre rectangle avec un dégradé
                new LinearGradient(0f, 0f, 0f, 1f, true, CycleMethod.NO_CYCLE,
                        new Stop[] { new Stop(0, Color.web("#333333")), new Stop(1, Color.web("#000000")) }));
        Reflection r = new Reflection();// on applique un effet de réflection
        r.setFraction(0.25);
        r.setBottomOpacity(0);
        r.setTopOpacity(0.5);
        fond_clavier.setEffect(r);

        touches = new Touche[] { new Touche("U", 50, 20, 60, instru), new Touche("I", 128, 20, 62, instru),
                new Touche("O", 206, 20, 64, instru), new Touche("P", 284, 20, 65, instru),
                new Touche("J", 75, 98, 67, instru), new Touche("K", 153, 98, 69, instru),
                new Touche("L", 231, 98, 71, instru), new Touche("M", 309, 98, 72, instru) };

        this.setTranslateX(50);
        this.setTranslateY(250);
        this.getChildren().add(fond_clavier);

        for (Touche touche : touches) { // on insère chaque touche une par une.
            this.getChildren().add(touche);
        }

    }
项目:CSS-Editor-FX    文件:CSSPaintPaser.java   
public List<Function<String, Paint>> getTasks() {
  return CacheUtil.cache(CSSPaintPaser.class, () -> Arrays.asList(
      text -> Color.web(text, 1),
      text -> LinearGradient.valueOf(text),
      text -> RadialGradient.valueOf(text),
      text -> context.lookup(text),
      text -> DeriveColorConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
      text -> LadderConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
      text -> LinearGradientConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
      text -> RadialGradientConverter.getInstance().convert(factory.apply(text), Font.getDefault())
      ));
}
项目:charts    文件:Helper.java   
public static final LinearGradient createColorVariationGradient(final Color COLOR, final int NO_OF_COLORS) {
    List<Color> colorVariations = createColorVariations(COLOR, NO_OF_COLORS);
    List<Stop>  stops = new ArrayList<>(NO_OF_COLORS);
    double step = 1.0 / NO_OF_COLORS;
    for (int i = 0 ; i < NO_OF_COLORS ; i++) {
        stops.add(new Stop(i * step, colorVariations.get(i)));
    }
    return new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);
}
项目:fx-animation-editor    文件:ColorPickerComponent.java   
private static LinearGradient createHueGradient() {
    double offset;
    Stop[] stops = new Stop[255];
    for (int x = 0; x < 255; x++) {
        offset = 1.0 / 255 * x;
        int h = (int) ((x / 255.0) * 360);
        stops[x] = new Stop(offset, Color.hsb(h, 1, 1));
    }
    return new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);
}
项目:coaster    文件:GameScreen.java   
/**
 * draws the gradient background on canvas
 *
 * @param background which
 */

private void drawGradient(LinearGradient background) {
    gc.setFill(background);
    gc.fillRect(0, 0, viewport.getResWidth(), viewport.getResHeight());
    gc.setStroke(Color.WHITE);
    gc.setFont(new Font(20));
}
项目:tilesfx    文件:SparkLineTileSkin.java   
private void setupGradient() {
    double loFactor = (low - minValue) / tile.getRange();
    double hiFactor = (high - minValue) / tile.getRange();
    Stop   loStop   = new Stop(loFactor, gradientLookup.getColorAt(loFactor));
    Stop   hiStop   = new Stop(hiFactor, gradientLookup.getColorAt(hiFactor));
    gradient = new LinearGradient(0, graphBounds.getY() + graphBounds.getHeight(), 0, graphBounds.getY(), false, CycleMethod.NO_CYCLE, loStop, hiStop);
}
项目:tilesfx    文件:GaugeSparkLineTileSkin.java   
private void setupGradient() {
    double loFactor = (low - minValue) / tile.getRange();
    double hiFactor = (high - minValue) / tile.getRange();
    Stop   loStop   = new Stop(loFactor, gradientLookup.getColorAt(loFactor));
    Stop   hiStop   = new Stop(hiFactor, gradientLookup.getColorAt(hiFactor));
    gradient = new LinearGradient(0, graphBounds.getY() + graphBounds.getHeight(), 0, graphBounds.getY(), false, CycleMethod.NO_CYCLE, loStop, hiStop);
}
项目:tilesfx    文件:RadialPercentageTileSkin.java   
@Override protected void redraw() {
    super.redraw();
    locale           = tile.getLocale();
    formatString     = new StringBuilder("%.").append(Integer.toString(tile.getDecimals())).append("f").toString();
    sectionsVisible  = tile.getSectionsVisible();

    barBackground.setStroke(tile.getBarBackgroundColor());

    LinearGradient gradient = new LinearGradient(0, 0, 1, 1, true, CycleMethod.NO_CYCLE, tile.getGradientStops());

    bar.setStroke(tile.isFillWithGradient() ? gradient : tile.getBarColor());
    proportionBar.setStroke(tile.isFillWithGradient() ? gradient : tile.getBarColor());
    percentageValueText.setFill(tile.getValueColor());
    percentageUnitText.setFill(tile.getUnitColor());
    descriptionText.setFill(tile.getDescriptionColor());
    unitText.setFill(tile.getUnitColor());
    titleText.setFill(tile.getTitleColor());
    text.setFill(tile.getTextColor());
    separator.setStroke(tile.getBackgroundColor());

    titleText.setText(tile.getTitle());
    descriptionText.setText(tile.getDescription());
    text.setText(tile.getText());
    unitText.setText(tile.getUnit());

    referenceValue = tile.getReferenceValue() < maxValue ? maxValue : tile.getReferenceValue();

    resizeStaticText();
    resizeDynamicText();
}
项目:tilesfx    文件:SmoothAreaChartTileSkin.java   
@Override protected void redraw() {
    super.redraw();

    smoothing = tile.isSmoothing();

    titleText.setText(tile.getTitle());

    valueText.setText(String.format(locale, formatString, tile.getCurrentValue()));
    unitText.setText(tile.getUnit());

    resizeDynamicText();
    resizeStaticText();

    titleText.setFill(tile.getTitleColor());
    valueText.setFill(tile.getValueColor());
    unitText.setFill(tile.getUnitColor());
    selector.setStroke(tile.getForegroundColor());
    selector.setFill(tile.getBackgroundColor());
    Color fillPathColor1 = Helper.getColorWithOpacity(tile.getBarColor(), 0.7);
    Color fillPathColor2 = Helper.getColorWithOpacity(tile.getBarColor(), 0.1);
    if (tile.isFillWithGradient() && !tile.getGradientStops().isEmpty()) {
        fillPath.setFill(new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, tile.getGradientStops()));
        strokePath.setStroke(tile.getGradientStops().get(0).getColor());
        if (dataPointsVisible) { drawDataPoints(points, tile.getGradientStops().get(0).getColor()); }
    } else {
        fillPath.setFill(new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0, fillPathColor1), new Stop(1, fillPathColor2)));
        strokePath.setStroke(tile.getBarColor());
        if (dataPointsVisible) { drawDataPoints(points, tile.getBarColor()); }
    }
    drawChart(points);
}
项目:javaone2016    文件:QualityGauge.java   
private void updateValue() {
    double value = model.getValue();
    if (value == 0) {
        currentQuality.setFill(Color.TRANSPARENT);
        currentQuality.setStroke(Color.TRANSPARENT);
        currentQualityText.setFill(Color.TRANSPARENT);
        currentQualityText.setText("");
        knob.setFill(Color.web("#cccccc"));
    } else {
        currentQualityRotate.setAngle(279 + ((int) value) * sectionAngle - sectionAngle);
        double radius      = width * 0.45;
        double sinValue    = Math.sin(Math.toRadians(currentQualityRotate.getAngle() + (-sectionAngle * ((int) value + 0.5) + model.getStartAngle() + 270 + sectionAngle)));
        double cosValue    = Math.cos(Math.toRadians(currentQualityRotate.getAngle() + (-sectionAngle * ((int) value + 0.5) + model.getStartAngle() + 270 + sectionAngle)));
        Color sectionColor = model.getSections().get((int) value - 1).getColor().deriveColor(0, 2.5, 1, 1);
        LinearGradient currentQualityFill = new LinearGradient(centerX + radius * sinValue,
                                                               centerY + radius * cosValue,
                                                               centerX, centerY,
                                                               false, CycleMethod.NO_CYCLE,
                                                               new Stop(0.0, sectionColor),
                                                               new Stop(0.22, sectionColor),
                                                               new Stop(0.22, sectionColor.deriveColor(0, 0.7, 1.1, 1)),
                                                               new Stop(1.0, sectionColor.deriveColor(0, 0.7, 1.1, 1)));

        currentQuality.setFill(currentQualityFill);
        currentQuality.setStroke(Color.WHITE);

        sinValue = Math.sin(Math.toRadians(-sectionAngle * ((int) value + 0.5) + model.getStartAngle() + 270 + sectionAngle));
        cosValue = Math.cos(Math.toRadians(-sectionAngle * ((int) value + 0.5) + model.getStartAngle() + 270 + sectionAngle));
        currentQualityText.setFont(Font.font(height * 0.14860681));
        currentQualityText.setText(model.getSections().get((int) value - 1).getText());
        currentQualityText.setFill(Color.WHITE);
        currentQualityText.setX(centerX - (currentQualityText.getLayoutBounds().getWidth() * 0.55) + radius * sinValue);
        currentQualityText.setY(centerY + radius * cosValue);

        knob.setFill(sectionColor);
    }
}
项目:particlesfx    文件:NodeBubbles.java   
private Node[] createBubble(final double SIZE) {
    final double CENTER = SIZE * 0.5;
    final Node[] NODES  = new Node[3];

    final Circle MAIN = new Circle(CENTER, CENTER, CENTER);
    final Paint MAIN_FILL = new LinearGradient(CENTER, 0.02 * SIZE,
                                               0.50 * SIZE, 0.98 * SIZE,
                                               false, CycleMethod.NO_CYCLE,
                                               new Stop(0.0, Color.TRANSPARENT),
                                               new Stop(0.85, Color.rgb(255, 255, 255, 0.2)),
                                               new Stop(1.0, Color.rgb(255, 255, 255, 0.90)));
    MAIN.setFill(MAIN_FILL);
    MAIN.setStroke(null);

    final Circle FRAME      = new Circle(CENTER, CENTER, CENTER);
    final Paint  FRAME_FILL = new RadialGradient(0, 0,
                                                 CENTER, CENTER,
                                                 0.48 * SIZE,
                                                 false, CycleMethod.NO_CYCLE,
                                                 new Stop(0.0, Color.TRANSPARENT),
                                                 new Stop(0.92, Color.TRANSPARENT),
                                                 new Stop(1.0, Color.rgb(255, 255, 255, 0.5)));
    FRAME.setFill(FRAME_FILL);
    FRAME.setStroke(null);

    final Ellipse HIGHLIGHT      = new Ellipse(CENTER, 0.27 * SIZE, 0.38 * SIZE, 0.25 * SIZE);
    final Paint   HIGHLIGHT_FILL = new LinearGradient(CENTER, 0.04 * SIZE,
                                                     CENTER, CENTER,
                                                     false, CycleMethod.NO_CYCLE,
                                                     new Stop(0.0, Color.rgb(255, 255, 255, 0.7)),
                                                     new Stop(1.0, Color.TRANSPARENT));
    HIGHLIGHT.setFill(HIGHLIGHT_FILL);
    HIGHLIGHT.setStroke(null);

    NODES[0] = FRAME;
    NODES[1] = MAIN;
    NODES[2] = HIGHLIGHT;

    return NODES;
}
项目:medusademo    文件:FuelGauge.java   
@Override public void init() {
    fuelIcon = new Region();
    fuelIcon.getStyleClass().setAll("fuel-icon");

    gauge = GaugeBuilder.create()
                        .skinType(SkinType.HORIZONTAL)
                        .prefSize(500, 250)
                        .knobColor(Color.rgb(0, 0, 0))
                        .foregroundBaseColor(Color.rgb(249, 249, 249))
                        .animated(true)
                        .shadowsEnabled(true)
                        .valueVisible(false)
                        //.title("FUEL")
                        .needleColor(Color.rgb(255, 10, 1))
                        .needleShape(NeedleShape.ROUND)
                        .needleSize(NeedleSize.THICK)
                        .minorTickMarksVisible(false)
                        .mediumTickMarksVisible(false)
                        //.majorTickMarkType(TickMarkType.TRIANGLE)
                        .sectionsVisible(true)
                        .sections(new Section(0, 0.2, Color.rgb(255, 10, 1)))
                        .minValue(0)
                        .maxValue(1)
                        .angleRange(90)
                        .customTickLabelsEnabled(true)
                        .customTickLabels("E", "", "", "", "", "1/2", "", "", "", "", "F")
                        .build();

    pane = new StackPane(fuelIcon, gauge);
    pane.setPadding(new Insets(10));
    LinearGradient gradient = new LinearGradient(0, 0, 0, pane.getLayoutBounds().getHeight(),
                                                 false, CycleMethod.NO_CYCLE,
                                                 new Stop(0.0, Color.rgb(38, 38, 38)),
                                                 new Stop(1.0, Color.rgb(15, 15, 15)));
    pane.setBackground(new Background(new BackgroundFill(gradient, CornerRadii.EMPTY, Insets.EMPTY)));
}
项目:openjfx-8u-dev-tests    文件:Effects2App.java   
@Override
        public Node drawNode() {
            Group group = new Group();
            Rectangle rect = new Rectangle(0, 0, 90, 60);
            LinearGradient lg = new LinearGradient(
                0, 0, 0.25f, 0.25f, true, CycleMethod.REFLECT,
                new Stop[] { new Stop(0, Color.RED), new Stop(1, Color.YELLOW) }
            );
            rect.setFill(lg);
            group.getChildren().add(rect);
            Text text = new Text("XYZ");
            text.setX(5);
            text.setY(50);
            text.setFill(Color.BLUE);
            setFontViaCss(text, 40);
            //text.setFont(Font.font("Arial", FontWeight.BOLD, 40));
//            text.setEffect(new Blend() {{
//                            //setMode(BlendMode.SRC_OUT); see http://javafx-jira.kenai.com/browse/RT-15041
//                            setTopInput(new ColorInput(5, 5, 80, 80, Color.GREEN) {{
//                                    setPaint(Color.GREEN);
//                                    setX(5);
//                                    setY(5);
//                                    setWidth(80); // TODO (SLOTSIZEX - 10);
//                                    setHeight(80); // (SLOTSIZEY - 10);
//                                }
//                            });
//                        }
//                    });
            text.setEffect(new Blend(BlendMode.SRC_OVER, null, new ColorInput(5, 5, 80, 80, Color.GREEN)));
            group.getChildren().add(text);
            return group;
        }
项目:openjfx-8u-dev-tests    文件:Effects2App.java   
@Override
public Node drawNode() {
    Rectangle rect = new Rectangle(10, 10, 70, 70);
    ColorInput effect = new ColorInput();
    effect.setPaint(new LinearGradient(0, 0, 0.5f, 0.1f, true, CycleMethod.REPEAT, new Stop[] {
                    new Stop(0, Color.RED),
                    new Stop(1, Color.GREEN),
                }));
    effect.setX(15);
    effect.setY(15);
    effect.setWidth(70);
    effect.setHeight(70);
    rect.setEffect(effect);
    return rect;
}
项目:openjfx-8u-dev-tests    文件:NodeSnaphot2Test.java   
/**
* test Node.snapshot with SnapshotParameters
*/
   @Test
   public void SnapshotWithParametersTest_fill() throws InterruptedException {

       SnapshotParameters param = new SnapshotParameters();
       param.setFill(new LinearGradient(0, 0, 1, 2, true, CycleMethod.REPEAT, new Stop[]{new Stop(0, Color.AQUA), new Stop(0.5f, Color.RED)}));
       testCommon(Pages.DropShadow.name(),"fill", param);
   }