本文整理匯總了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);
}
示例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;
}
示例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())));
}
示例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();
}
示例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);
}
}
示例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())
));
}
示例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
));
}
示例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)));
}
示例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)));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}