當前位置: 首頁>>代碼示例>>Java>>正文


Java LinearGradient類代碼示例

本文整理匯總了Java中javafx.scene.paint.LinearGradient的典型用法代碼示例。如果您正苦於以下問題:Java LinearGradient類的具體用法?Java LinearGradient怎麽用?Java LinearGradient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LinearGradient類屬於javafx.scene.paint包,在下文中一共展示了LinearGradient類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initBackground

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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);
}
 
開發者ID:AlmasB,項目名稱:FXGLGames,代碼行數:26,代碼來源:BreakoutApp.java

示例2: drawNode

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
@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;

}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:26,代碼來源:CanvasEffects2App.java

示例3: createNeedle

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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())));
}
 
開發者ID:HanSolo,項目名稱:Medusa,代碼行數:27,代碼來源:SectionSkin.java

示例4: redraw

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
@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();
}
 
開發者ID:HanSolo,項目名稱:Medusa,代碼行數:17,代碼來源:SectionSkin.java

示例5: handleMouseEvent

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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);
    }
}
 
開發者ID:HanSolo,項目名稱:Medusa,代碼行數:26,代碼來源:ModernSkin.java

示例6: getTasks

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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())
      ));
}
 
開發者ID:XDean,項目名稱:CSS-Editor-FX,代碼行數:13,代碼來源:CSSPaintPaser.java

示例7: createTopHighlightBorder

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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
            ));
}
 
開發者ID:bekwam,項目名稱:examples-javafx-repos1,代碼行數:18,代碼來源:Overlay1Controller.java

示例8: Thermo

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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)));
}
 
開發者ID:kasemir,項目名稱:org.csstudio.display.builder,代碼行數:22,代碼來源:ThermometerRepresentation.java

示例9: Thermo

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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)));
}
 
開發者ID:kasemir,項目名稱:org.csstudio.display.builder,代碼行數:21,代碼來源:ThermoDemo.java

示例10: changeGradient2Color

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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);
}
 
開發者ID:entitycs,項目名稱:AudioVisualizer2.0,代碼行數:20,代碼來源:RenderTestVis2Frame.java

示例11: traffic

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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);
}
 
開發者ID:DrMerfy,項目名稱:GraphCreator,代碼行數:12,代碼來源:Themes.java

示例12: configureDesign

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:StopWatch.java

示例13: buildHueBar

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:SimpleHSBColorPicker.java

示例14: LinearGradientSample

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:32,代碼來源:LinearGradientSample.java

示例15: createIconContent

import javafx.scene.paint.LinearGradient; //導入依賴的package包/類
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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:LinearGradientSample.java


注:本文中的javafx.scene.paint.LinearGradient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。