类javafx.scene.paint.Paint源码实例Demo

下面列出了怎么用javafx.scene.paint.Paint的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ikonli   文件: SVGIcon.java
@Override
public ObjectProperty<Paint> iconColorProperty() {
    if (iconColor == null) {
        iconColor = new StyleableObjectProperty<Paint>(Color.BLACK) {
            @Override
            public CssMetaData getCssMetaData() {
                return StyleableProperties.ICON_COLOR;
            }

            @Override
            public Object getBean() {
                return SVGIcon.this;
            }

            @Override
            public String getName() {
                return "iconColor";
            }
        };
        iconColor.addListener(iconColorChangeListener);
    }
    return iconColor;
}
 
源代码2 项目: ikonli   文件: FontIcon.java
@Override
public ObjectProperty<Paint> iconColorProperty() {
    if (iconColor == null) {
        iconColor = new StyleableObjectProperty<>(Color.BLACK) {
            @Override
            public CssMetaData getCssMetaData() {
                return StyleableProperties.ICON_COLOR;
            }

            @Override
            public Object getBean() {
                return FontIcon.this;
            }

            @Override
            public String getName() {
                return "iconColor";
            }
        };
        iconColor.addListener((v, o, n) -> FontIcon.this.setFill(n));
    }
    return iconColor;
}
 
源代码3 项目: gef   文件: FXPaintUtils.java
/**
 * Creates a rectangular {@link Image} to visualize the given {@link Paint}.
 *
 * @param width
 *            The width of the resulting {@link Image}.
 * @param height
 *            The height of the resulting {@link Image}.
 * @param paint
 *            The {@link Paint} to use for filling the {@link Image}.
 * @return The resulting (filled) {@link Image}.
 */
public static ImageData getPaintImageData(int width, int height, Paint paint) {
	// use JavaFX canvas to render a rectangle with the given paint
	Canvas canvas = new Canvas(width, height);
	GraphicsContext graphicsContext = canvas.getGraphicsContext2D();
	graphicsContext.setFill(paint);
	graphicsContext.fillRect(0, 0, width, height);
	graphicsContext.setStroke(Color.BLACK);
	graphicsContext.strokeRect(0, 0, width, height);
	// handle transparent color separately (we want to differentiate it from
	// transparent fill)
	if (paint instanceof Color && ((Color) paint).getOpacity() == 0) {
		// draw a red line from bottom-left to top-right to indicate a
		// transparent fill color
		graphicsContext.setStroke(Color.RED);
		graphicsContext.strokeLine(0, height - 1, width, 1);
	}
	WritableImage snapshot = canvas.snapshot(new SnapshotParameters(), null);
	return SWTFXUtils.fromFXImage(snapshot, null);
}
 
源代码4 项目: JetUML   文件: StateTransitionEdgeViewer.java
private void drawLabel(StateTransitionEdge pEdge, GraphicsContext pGraphics)
{
	adjustLabelFont(pEdge);
	Rectangle2D labelBounds = getLabelBounds(pEdge);
	double x = labelBounds.getMinX();
	double y = labelBounds.getMinY();
	
	Paint oldFill = pGraphics.getFill();
	Font oldFont = pGraphics.getFont();
	pGraphics.translate(x, y);
	pGraphics.setFill(Color.BLACK);
	pGraphics.setFont(aFont);
	pGraphics.setTextAlign(TextAlignment.CENTER);
	pGraphics.fillText(pEdge.getMiddleLabel(), labelBounds.getWidth()/2, 0);
	pGraphics.setFill(oldFill);
	pGraphics.setFont(oldFont);
	pGraphics.translate(-x, -y);        
}
 
源代码5 项目: oim-fx   文件: IconToggleButton.java
public IconToggleButton(String text, Font font, Paint paint, Image normalImage, Image hoverImage, Image selectedImage) {
	this(text);
	this.normalImage = normalImage;
	this.hoverImage = hoverImage;
	this.selectedImage = selectedImage;
	if (null != font) {
		this.setFont(font);
	}
	if (null != paint) {
		this.setTextFill(paint);
	}
	initEvent();
	updateImage();
	VBox redVBox=new VBox();
	redVBox.setAlignment(Pos.TOP_RIGHT);
	redVBox.getChildren().add(redImageView);
	
	stackPane.getChildren().add(imageView);
	stackPane.getChildren().add(redVBox);
	
	this.getStyleClass().add(DEFAULT_STYLE_CLASS);
}
 
源代码6 项目: RadialFx   文件: DemoUtil.java
public void addColorControl(final String title,
    final ObjectProperty<Paint> paintProperty) {
final ColorPicker colorPicker = ColorPickerBuilder.create()
	.value((Color) paintProperty.get()).build();

paintProperty.bind(colorPicker.valueProperty());
final VBox box = new VBox();
final Text titleText = new Text(title);

titleText.textProperty().bind(new StringBinding() {
    {
	super.bind(colorPicker.valueProperty());
    }

    @Override
    protected String computeValue() {
	return title + " : " + colorPicker.getValue().toString();
    }

});
box.getChildren().addAll(titleText, colorPicker);
getChildren().add(box);
   }
 
源代码7 项目: Enzo   文件: SimpleGauge.java
public final ObjectProperty<Paint> titleTextColorProperty() {
    if (null == titleTextColor) {
        titleTextColor = new StyleableObjectProperty<Paint>(DEFAULT_TITLE_TEXT_COLOR) {
            @Override public CssMetaData getCssMetaData() { return StyleableProperties.TITLE_TEXT_COLOR; }
            @Override public Object getBean() { return this; }
            @Override public String getName() { return "titleTextColor"; }
        };
    }
    return titleTextColor;
}
 
源代码8 项目: Enzo   文件: SimpleGauge.java
public final ObjectProperty<Paint> sectionFill2Property() {
    if (null == sectionFill2) {
        sectionFill2 = new StyleableObjectProperty<Paint>(DEFAULT_SECTION_FILL_2) {
            @Override public CssMetaData getCssMetaData() { return StyleableProperties.SECTION_FILL_2; }
            @Override public Object getBean() { return this; }
            @Override public String getName() { return "sectionFill2"; }
        };
    }
    return sectionFill2;
}
 
源代码9 项目: chart-fx   文件: DashPatternStyle.java
private static ImagePattern createDefaultHatch(final Paint color, final double strokeWidth,
        final boolean isHorizontal, final double[] pattern) {
    final Integer hash = computeHash(color, strokeWidth, isHorizontal, pattern);

    return DashPatternStyle.dashHashMap.computeIfAbsent(hash, t -> {
        // need to recompute hatch pattern image
        final double dashPatternLength = getPatternLength(pattern);
        final double width = isHorizontal ? dashPatternLength : strokeWidth;
        final double height = isHorizontal ? strokeWidth : dashPatternLength;
        final double middle = (int) (strokeWidth / 2.0);

        final Pane pane = new Pane();
        pane.setPrefSize(width, height);
        final Line fw = isHorizontal ? new Line(0, middle, dashPatternLength, middle)
                : new Line(middle, 0, middle, dashPatternLength);

        fw.setSmooth(false);
        fw.setStroke(color);
        if (pattern == null) {
            fw.getStrokeDashArray().setAll(dashPatternLength);
        } else {
            fw.getStrokeDashArray().setAll(DoubleStream.of(pattern).boxed().collect(Collectors.toList()));
        }
        fw.setStrokeWidth(strokeWidth);

        pane.getChildren().addAll(fw);
        pane.setStyle("-fx-background-color: rgba(0, 0, 0, 0.0)");
        final Scene scene = new Scene(pane);
        scene.setFill(Color.TRANSPARENT);

        final Image hatch = pane.snapshot(null, null);

        return new ImagePattern(hatch, width, 0, width, height, false);

    });
}
 
源代码10 项目: chart-fx   文件: Hexagon.java
public void drawContour(GraphicsContext gc) {
    gc.save();
    gc.setStroke(getStroke());
    gc.setLineWidth(getStrokeWidth());
    gc.setFill(getFill());
    if (map == null) {
        drawHexagon(gc, Direction.values());
        gc.restore();
    }

    final List<Direction> list = new ArrayList<>();
    for (final Direction direction : Direction.values()) {
        final Hexagon neighbour = getNeighbour(direction);
        if (neighbour == null) {
            continue;
        }
        final Paint stroke = neighbour.getStroke();
        // if (stroke != null && !stroke.equals(this.getStroke())) {
        // list.add(direction);
        // }

        // TODO: find work-around for colour smoothing operation on image scaling
        if (stroke != null && !myColourCompare(stroke, getStroke(), 0.2)) {
            list.add(direction);
        }
    }

    drawHexagon(gc, list.toArray(new Direction[list.size()]));

    gc.restore();
}
 
源代码11 项目: charts   文件: XYZPane.java
public void setChartBackground(final Paint PAINT) {
    if (null == chartBackground) {
        _chartBackground = PAINT;
        redraw();
    } else {
        chartBackground.set(PAINT);
    }
}
 
源代码12 项目: Medusa   文件: Clock.java
/**
 * Defines the Paint object that will be used to fill the foreground of the clock.
 * This could be used to visualize glass effects etc. and is only rarely used.
 * @param PAINT
 */
public void setForegroundPaint(final Paint PAINT) {
    if (null == foregroundPaint) {
        _foregroundPaint = PAINT;
        fireUpdateEvent(REDRAW_EVENT);
    } else {
        foregroundPaint.set(PAINT);
    }
}
 
源代码13 项目: Medusa   文件: Clock.java
public ObjectProperty<Paint> borderPaintProperty() {
    if (null == borderPaint) {
        borderPaint  = new ObjectPropertyBase<Paint>(_borderPaint) {
            @Override protected void invalidated() { fireUpdateEvent(REDRAW_EVENT); }
            @Override public Object getBean() { return Clock.this; }
            @Override public String getName() { return "borderPaint"; }
        };
        _borderPaint = null;
    }
    return borderPaint;
}
 
源代码14 项目: gef   文件: DotGraphView.java
private void addGraphBackground(Paint paint) {
	double margin = 5;
	GraphPart graphPart = (GraphPart) getContentViewer().getRootPart()
			.getContentPartChildren().get(0);
	Group group = graphPart.getVisual();
	Bounds bounds = group.getLayoutBounds();
	group.setEffect(new Blend(BlendMode.SRC_OVER,
			new ColorInput(bounds.getMinX() - margin,
					bounds.getMinY() - margin,
					bounds.getWidth() + 2 * margin,
					bounds.getHeight() + 2 * margin, paint),
			null));
}
 
源代码15 项目: charts   文件: Grid.java
public ObjectProperty<Paint> majorVGridLinePaintProperty() {
    if (null == majorVGridLinePaint) {
        majorVGridLinePaint = new ObjectPropertyBase<Paint>(_majorVGridLinePaint) {
            @Override protected void invalidated() { drawGrid(); }
            @Override public Object getBean() { return Grid.this; }
            @Override public String getName() { return "majorVGridLinePaint"; }
        };
        _majorVGridLinePaint = null;
    }
    return majorVGridLinePaint;
}
 
源代码16 项目: tilesfx   文件: TilesFXSeries.java
public TilesFXSeries(final Series<X, Y> SERIES, final Paint COLOR) {
    series = SERIES;
    stroke = COLOR;
    fill   = COLOR;
    if (null != COLOR) {
        symbolBackground = new Background(new BackgroundFill(COLOR, new CornerRadii(5), Insets.EMPTY), new BackgroundFill(Color.WHITE, new CornerRadii(5), new Insets(2)));
        legendSymbolFill = COLOR;
    }
}
 
源代码17 项目: RichTextFX   文件: JavaFXCompatibility.java
/**
 * Java 8:  javafx.scene.text.Text.impl_selectionFillProperty()
 * Java 9+: javafx.scene.text.Text.selectionFillProperty()
 */
@SuppressWarnings("unchecked")
static ObjectProperty<Paint> Text_selectionFillProperty(Text text) {
    try {
        if (mText_selectionFillProperty == null) {
            mText_selectionFillProperty = Text.class.getMethod(
                    isJava9orLater ? "selectionFillProperty" : "impl_selectionFillProperty");
        }
        return (ObjectProperty<Paint>) mText_selectionFillProperty.invoke(text);
    } catch(NoSuchMethodException | SecurityException | IllegalAccessException |
            IllegalArgumentException | InvocationTargetException e) {
        e.printStackTrace();
        throw new Error(e);
    }
}
 
源代码18 项目: bisq   文件: StaticProgressIndicatorSkin.java
IndeterminateSpinner(TxConfidenceIndicator control, StaticProgressIndicatorSkin s,
                     boolean spinEnabled, Paint fillOverride) {
    this.control = control;
    this.skin = s;
    this.fillOverride = fillOverride;

    setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
    getStyleClass().setAll("spinner");

    pathsG = new IndicatorPaths(this);
    getChildren().add(pathsG);

    rebuild();
}
 
源代码19 项目: megan-ce   文件: FXUtilities.java
/**
 * changes opacity, if paint is a color
 *
 * @param paint
 * @param opacity
 * @return paint
 */
public static Paint changeOpacity(Paint paint, double opacity) {
    if (paint instanceof Color) {
        Color color = (Color) paint;
        return new Color(color.getRed(), color.getGreen(), color.getBlue(), opacity);
    } else
        return paint;
}
 
源代码20 项目: Enzo   文件: SimpleLineChart.java
@Override public StyleableProperty<Paint> getStyleableProperty(SimpleLineChart chart) {
    return (StyleableProperty) chart.sectionFill3Property();
}
 
源代码21 项目: Enzo   文件: Gauge.java
public final void setSectionFill8(Paint value) {
    sectionFill8Property().set(value);
}
 
源代码22 项目: Enzo   文件: RadialBargraph.java
public final void setSectionFill2(Paint value) {
    sectionFill2Property().set(value);
}
 
源代码23 项目: Enzo   文件: OnOffSwitch.java
public final void setThumbColor(Paint value) {
    thumbColorProperty().set(value);
}
 
源代码24 项目: Enzo   文件: Gauge.java
public final Paint getMarkerFill4() {
    return null == markerFill4 ? DEFAULT_MARKER_FILL_4 : markerFill4.get();
}
 
源代码25 项目: cssfx   文件: BasicUITest.java
@Test
@DisabledOnMac
public void checkCSSFXCanChangeTheLabelFontColor(FxRobot robot) throws Exception {
    // The CSS used by the UI
    URI basicCSS = BasicUI.class.getResource("basic.css").toURI();
    String basicCSSUrl = basicCSS.toURL().toExternalForm();

    // Resources containing the color changes we want to apply to the CSS 
    URI changedBasicCSSBlue = BasicUI.class.getResource("basic-cssfx-blue.css").toURI();
    URI changedBasicCSSRed = BasicUI.class.getResource("basic-cssfx-red.css").toURI();

    // The file we will tell CSSFX to map the CSS to
    Path mappedSourceFile = Files.createTempFile("tmp", ".css");
    mappedSourceFile.toFile().deleteOnExit();
    
    // Let's start with the normal content first 
    Files.copy(Paths.get(changedBasicCSSBlue), mappedSourceFile, StandardCopyOption.REPLACE_EXISTING);
    
    // start CSSFX
    Runnable stopper = CSSFX.onlyFor(basicUI.getRootNode())
            .noDefaultConverters()
            .addConverter((uri) -> {
                if (basicCSSUrl.equals(uri)) {
                    return mappedSourceFile;
                }
                return null;
            }).start();
    try {
        // We need to let CSSFX some time to detect the file change
        Thread.sleep(1000);
        
        // Let's check that initial launch has used the mapped
        Label cssfxLabel = robot.lookup("#cssfx").queryAs(Label.class);
        Paint textColor = cssfxLabel.getTextFill();
        assertThat("retrieved color is not one of expected", getExpectedTextColor(), hasItem(textColor));
        assertThat(textColor, is(Color.BLUE));

        // Copy the modified version in to the "source" file
        try {
            Files.copy(Paths.get(changedBasicCSSRed), mappedSourceFile, StandardCopyOption.REPLACE_EXISTING);
        } catch (IOException e) {
            e.printStackTrace();
        }

        // We TestMemoryLeaksneed to let CSSFX some time to detect the file change
        Thread.sleep(1000);

        textColor = cssfxLabel.getTextFill();
        assertThat("retrieved color is not one of expected", getExpectedTextColor(), hasItem(textColor));
        assertThat(textColor, is(Color.RED));
    } finally {
        stopper.run();
    }
}
 
源代码26 项目: RadialFx   文件: RadialMenuItem.java
public ObjectProperty<Paint> backgroundMouseOnFillProperty() {
return backgroundMouseOnFill;
   }
 
源代码27 项目: RadialFx   文件: RadialMenuItem.java
public ObjectProperty<Paint> strokeFillProperty() {
return strokeFill;
   }
 
源代码28 项目: JFX8CustomControls   文件: Led.java
public final Paint getLedColor() {
    return null == ledColor ? DEFAULT_LED_COLOR : ledColor.get();
}
 
源代码29 项目: LogFX   文件: LogLineColors.java
public Paint getFill() {
    return fill;
}
 
源代码30 项目: chart-fx   文件: AbstractAxisParameter.java
public ObjectProperty<Paint> tickLabelFillProperty() {
    return tickLabelFill;
}
 
 类所在包
 类方法
 同包方法