javafx.scene.paint.Color#rgb ( )源码实例Demo

下面列出了javafx.scene.paint.Color#rgb ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Enzo   文件: LedSkin.java
private void initGraphics() {
    frame = new Region();
    frame.setOpacity(getSkinnable().isFrameVisible() ? 1 : 0);

    led = new Region();
    led.setStyle("-led-color: " + Util.colorToCss((Color) getSkinnable().getLedColor()) + ";");

    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 8, 0d, 0d, 0d);

    glow = new DropShadow(BlurType.TWO_PASS_BOX, (Color) getSkinnable().getLedColor(), 20, 0d, 0d, 0d);
    glow.setInput(innerShadow);

    highlight = new Region();

    // Set the appropriate style classes
    changeStyle();

    // Add all nodes
    getChildren().setAll(frame, led, highlight);
}
 
源代码2 项目: PDF4Teachers   文件: TextListItem.java
public static TextListItem readDataAndGive(DataInputStream reader) throws IOException {

        double fontSize = reader.readFloat();
        boolean isBold = reader.readBoolean();
        boolean isItalic = reader.readBoolean();
        String fontName = reader.readUTF();
        short colorRed = (short) (reader.readByte() + 128);
        short colorGreen = (short) (reader.readByte() + 128);
        short colorBlue = (short) (reader.readByte() + 128);
        long uses = reader.readLong();
        long creationDate = reader.readLong();
        String text = reader.readUTF();

        Font font = FontUtils.getFont(fontName, isItalic, isBold, (int) fontSize);

        return new TextListItem(font, text, Color.rgb(colorRed, colorGreen, colorBlue), uses, creationDate);
    }
 
源代码3 项目: PDF4Teachers   文件: TextTreeItem.java
public static TextTreeItem readDataAndGive(DataInputStream reader, int type) throws IOException {

		double fontSize = reader.readFloat();
		boolean isBold = reader.readBoolean();
		boolean isItalic = reader.readBoolean();
		String fontName = reader.readUTF();
		short colorRed = (short) (reader.readByte() + 128);
		short colorGreen = (short) (reader.readByte() + 128);
		short colorBlue = (short) (reader.readByte() + 128);
		long uses = reader.readLong();
		long creationDate = reader.readLong();
		String text = reader.readUTF();

		Font font = FontUtils.getFont(fontName, isItalic, isBold, (int) fontSize);

		return new TextTreeItem(font, text, Color.rgb(colorRed, colorGreen, colorBlue), type, uses, creationDate);
	}
 
源代码4 项目: charts   文件: TimeAxisTest.java
@Override public void init() {
    int               noOfValues = 24 * 60;
    LocalDateTime     start      = LocalDateTime.now();
    LocalDateTime     end        = start.plusHours(24);
    List<TYChartItem> tyData1    = new ArrayList<>();

    for (int i = 0 ; i < noOfValues ; i++) {
        tyData1.add(new TYChartItem(start.plusMinutes(i), RND.nextDouble() * 12 + RND.nextDouble() * 6, "P" + i, COLORS[RND.nextInt(3)]));
    }

    tySeries1 = new XYSeries(tyData1, ChartType.LINE, Color.RED, Color.rgb(255, 0, 0, 0.5));
    tySeries1.setSymbolsVisible(false);

    // XYChart
    Converter tempConverter     = new Converter(TEMPERATURE, CELSIUS); // Type Temperature with BaseUnit Celsius
    double    tempFahrenheitMin = tempConverter.convert(0, FAHRENHEIT);
    double    tempFahrenheitMax = tempConverter.convert(20, FAHRENHEIT);

    xAxisBottom = createBottomTimeAxis(start, end, "HH:mm", true);
    yAxisLeft   = createLeftYAxis(0, 20, true);
    yAxisRight  = createRightYAxis(tempFahrenheitMin, tempFahrenheitMax, false);
    tyChart     = new XYChart<>(new XYPane(tySeries1), yAxisLeft, yAxisRight, xAxisBottom);
    tyChart.setPrefSize(400, 200);
}
 
源代码5 项目: metastone   文件: IconFactory.java
public static Color getRarityColor(Rarity rarity) {
	Color color = Color.BLACK;
	switch (rarity) {
	case COMMON:
		color = Color.WHITE;
		break;
	case EPIC:
		// a335ee
		color = Color.rgb(163, 53, 238);
		break;
	case LEGENDARY:
		// ff8000
		color = Color.rgb(255, 128, 0);
		break;
	case RARE:
		// 0070dd
		color = Color.rgb(0, 112, 221);
		break;
	default:
		color = Color.GRAY;
		break;
	}
	return color;

}
 
源代码6 项目: FXGLGames   文件: TileViewComponent.java
public TileViewComponent() {
    Rectangle bg = new Rectangle(getAppWidth() / 3, getAppHeight() / 3, Color.rgb(13, 222, 236));

    Rectangle bg2 = new Rectangle(getAppWidth() / 4, getAppHeight() / 4, Color.rgb(250, 250, 250, 0.25));
    bg2.setArcWidth(25);
    bg2.setArcHeight(25);

    arc.setFill(null);
    arc.setStroke(Color.BLACK);
    arc.setStrokeWidth(3);

    line1.setStrokeWidth(3);
    line2.setStrokeWidth(3);

    line1.setVisible(false);
    line2.setVisible(false);

    getViewRoot().getChildren().addAll(new StackPane(bg, bg2, arc, line1, line2));
}
 
源代码7 项目: 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.web("0xEF2F06"))
                        //.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)));
}
 
源代码8 项目: tilesfx   文件: TileSkin.java
protected void initGraphics() {
    // Set initial size
    if (Double.compare(tile.getPrefWidth(), 0.0) <= 0 || Double.compare(tile.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(tile.getWidth(), 0.0) <= 0 || Double.compare(tile.getHeight(), 0.0) <= 0) {
        if (tile.getPrefWidth() > 0 && tile.getPrefHeight() > 0) {
            tile.setPrefSize(tile.getPrefWidth(), tile.getPrefHeight());
        } else {
            tile.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    shadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 3, 0, 0, 0);

    backgroundImageView = new ImageView();
    backgroundImageView.setPreserveRatio(true);
    backgroundImageView.setMouseTransparent(true);
    if (null == tile.getBackgroundImage()) {
        enableNode(backgroundImageView, false);
    } else {
        backgroundImageView.setImage(tile.getBackgroundImage());
        enableNode(backgroundImageView, true);
    }

    notifyRegion = new NotifyRegion();
    enableNode(notifyRegion, false);

    infoRegion = new InfoRegion();
    infoRegion.setPickOnBounds(false);
    enableNode(infoRegion, false);

    lowerRightRegion = new LowerRightRegion();
    enableNode(lowerRightRegion, false);

    pane = new Pane(backgroundImageView, notifyRegion, infoRegion, lowerRightRegion);
    pane.getStyleClass().add("tile");
    pane.setBorder(new Border(new BorderStroke(tile.getBorderColor(), BorderStrokeStyle.SOLID, new CornerRadii(PREFERRED_WIDTH * 0.025), new BorderWidths(tile.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(tile.getBackgroundColor(), new CornerRadii(PREFERRED_WIDTH * 0.025), Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
源代码9 项目: charts   文件: ComparisonRingChart.java
public ComparisonRingChart(final ChartItemSeries SERIES_1, final ChartItemSeries SERIES_2) {
    series1             = SERIES_1;
    series2             = SERIES_2;
    _barBackgroundFill = Color.rgb(230, 230, 230);
    _sorted             = true;
    _order              = Order.DESCENDING;
    _numberFormat       = NumberFormat.NUMBER;
    listeners           = new CopyOnWriteArrayList<>();
    popup               = new InfoPopup();
    itemEventListener   = e -> {
        final EventType TYPE = e.getEventType();
        switch(TYPE) {
            case UPDATE  : drawChart(); break;
            case FINISHED: drawChart(); break;
        }
    };
    chartItemListener   = c -> {
        while (c.next()) {
            if (c.wasAdded()) {
                c.getAddedSubList().forEach(addedItem -> addedItem.addItemEventListener(itemEventListener));
            } else if (c.wasRemoved()) {
                c.getRemoved().forEach(removedItem -> removedItem.removeItemEventListener(itemEventListener));
            }
        }
        drawChart();
    };
    mouseHandler        = e -> handleMouseEvents(e);
    prepareSeries(series1);
    prepareSeries(series2);
    initGraphics();
    registerListeners();
}
 
源代码10 项目: Augendiagnose   文件: ImageUtil.java
/**
 * Convert a temperature into a color value representing the color of this temperature.
 *
 * @param temperature The temperature value (in the range -1..1).
 * @return The color value.
 */
private static Color convertTemperatureToColor(final double temperature) {
	if (temperature >= 0) {
		return Color.rgb((int) (BYTE - 150 * temperature), (int) (BYTE - 105 * temperature), BYTE); // MAGIC_NUMBER
	}
	else {
		return Color.rgb(BYTE, (int) (BYTE + 80 * temperature), (int) (BYTE + 145 * temperature)); // MAGIC_NUMBER
	}
}
 
源代码11 项目: charts   文件: ChartItem.java
public ChartItem(final String NAME, final double VALUE) {
    this(NAME, VALUE, Color.rgb(233, 30, 99), Color.TRANSPARENT, Color.BLACK, Instant.now(), false, 800);
}
 
源代码12 项目: JFoenix   文件: JFXPasswordField.java
@Override
public Paint getUnFocusColor() {
    return unFocusColor == null ? Color.rgb(77, 77, 77) : unFocusColor.get();
}
 
源代码13 项目: charts   文件: SingleChartTest.java
@Override public void init() {
    List<XYChartItem> xyItem1 = new ArrayList<>(NO_OF_X_VALUES);
    List<XYChartItem> xyItem2 = new ArrayList<>(NO_OF_X_VALUES);
    List<XYChartItem> xyItem3 = new ArrayList<>(NO_OF_X_VALUES);
    List<XYChartItem> xyItem4 = new ArrayList<>(NO_OF_X_VALUES);

    for (int i = 0 ; i < NO_OF_X_VALUES ; i++) {
        xyItem1.add(new XYChartItem(i, RND.nextDouble() * 12 + RND.nextDouble() * 6, "P" + i, COLORS[RND.nextInt(3)]));
        xyItem2.add(new XYChartItem(i, RND.nextDouble() * 7 + RND.nextDouble() * 3, "P" + i, COLORS[RND.nextInt(3)]));
        xyItem3.add(new XYChartItem(i, RND.nextDouble() * 3 + RND.nextDouble() * 4, "P" + i, COLORS[RND.nextInt(3)]));
        xyItem4.add(new XYChartItem(i, RND.nextDouble() * 4, "P" + i, COLORS[RND.nextInt(3)]));
    }

    xySeries1 = new XYSeries(xyItem1, ChartType.LINE, Color.rgb(255, 0, 0, 0.5), Color.RED);
    xySeries2 = new XYSeries(xyItem2, ChartType.LINE, Color.rgb(0, 255, 0, 0.5), Color.LIME);
    xySeries3 = new XYSeries(xyItem3, ChartType.LINE, Color.rgb(0, 0, 255, 0.5), Color.BLUE);
    xySeries4 = new XYSeries(xyItem4, ChartType.LINE, Color.rgb(255, 0, 255, 0.5), Color.MAGENTA);

    xySeries1.setSymbolsVisible(false);
    xySeries2.setSymbolsVisible(false);
    xySeries3.setSymbolsVisible(false);
    xySeries4.setSymbolsVisible(false);

    // XYChart
    Converter tempConverter     = new Converter(TEMPERATURE, CELSIUS); // Type Temperature with BaseUnit Celsius
    double    tempFahrenheitMin = tempConverter.convert(0, FAHRENHEIT);
    double    tempFahrenheitMax = tempConverter.convert(20, FAHRENHEIT);

    lineChartXAxisBottom = createBottomXAxis(0, NO_OF_X_VALUES, true);
    lineChartYAxisLeft   = createLeftYAxis(0, 20, true);
    lineChartYAxisRight  = createRightYAxis(tempFahrenheitMin, tempFahrenheitMax, false);
    xyChart = new XYChart<>(new XYPane(xySeries1, xySeries2, xySeries3, xySeries4),
                            lineChartYAxisLeft, lineChartYAxisRight, lineChartXAxisBottom);

    // YChart
    List<YChartItem> yItem1 = new ArrayList<>(20);
    List<YChartItem> yItem2 = new ArrayList<>(20);
    List<YChartItem> yItem3 = new ArrayList<>(20);
    for (int i = 0 ; i < 20 ; i++) {
        yItem1.add(new YChartItem(RND.nextDouble() * 100, "P" + i, COLORS[RND.nextInt(3)]));
        yItem2.add(new YChartItem(RND.nextDouble() * 100, "P" + i, COLORS[RND.nextInt(3)]));
        yItem3.add(new YChartItem(RND.nextDouble() * 100, "P" + i, COLORS[RND.nextInt(3)]));
    }

    ySeries1 = new YSeries(yItem1, ChartType.RADAR_SECTOR, new RadialGradient(0, 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(255, 0, 0, 0.5)), new Stop(0.5, Color.rgb(255, 255, 0, 0.5)), new Stop(1.0, Color.rgb(0, 200, 0, 0.8))), Color.TRANSPARENT);
    ySeries2 = new YSeries(yItem2, ChartType.SMOOTH_RADAR_POLYGON, new RadialGradient(0, 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(0, 255, 255, 0.5)), new Stop(1.0, Color.rgb(0, 0, 255, 0.5))), Color.TRANSPARENT);
    ySeries3 = new YSeries(yItem3, ChartType.SMOOTH_RADAR_POLYGON, new RadialGradient(0, 0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0.0, Color.rgb(255, 255, 0, 0.5)), new Stop(1.0, Color.rgb(255, 0, 255, 0.5))), Color.TRANSPARENT);
    yChart   = new YChart(new YPane(ySeries1, ySeries2, ySeries3));

    lastTimerCall = System.nanoTime();
    timer = new AnimationTimer() {
        @Override public void handle(final long now) {
            if (now > lastTimerCall + UPDATE_INTERVAL) {
                ObservableList<XYChartItem> xyItems = xySeries1.getItems();
                xyItems.forEach(item -> item.setY(RND.nextDouble() * 8 + RND.nextDouble() * 10));

                xyItems = xySeries2.getItems();
                xyItems.forEach(item -> item.setY(RND.nextDouble() * 4 + RND.nextDouble() * 10));

                xyItems = xySeries3.getItems();
                xyItems.forEach(item -> item.setY(RND.nextDouble() * 3 + RND.nextDouble() * 4));

                xyItems = xySeries4.getItems();
                xyItems.forEach(item -> item.setY(RND.nextDouble() * 4));

                ObservableList<YChartItem> yItems = ySeries1.getItems();
                yItems.forEach(item -> item.setY(RND.nextDouble() * 100));

                yItems = ySeries2.getItems();
                yItems.forEach(item -> item.setY(RND.nextDouble() * 100));

                yItems = ySeries3.getItems();
                yItems.forEach(item -> item.setY(RND.nextDouble() * 100));

                // Can be used to update charts but if more than one series is in one xyPane
                // it's easier to use the refresh() method of XYChart
                //xySeries1.refresh();
                //xySeries2.refresh();
                //xySeries3.refresh();
                //xySeries4.refresh();

                // Useful to refresh the chart if it contains more than one series to avoid
                // multiple redraws
                xyChart.refresh();

                //ySeries1.refresh();
                //ySeries2.refresh();

                yChart.refresh();

                lastTimerCall = now;
            }
        }
    };
}
 
源代码14 项目: regulators   文件: Regulator.java
private void initGraphics() {
    dropShadow  = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), PREFERRED_WIDTH * 0.016, 0.0, 0, PREFERRED_WIDTH * 0.028);
    highlight   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.2), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.2), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    highlight.setInput(innerShadow);
    dropShadow.setInput(highlight);

    barArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE, 0);
    barArc.setType(ArcType.OPEN);
    barArc.setStrokeLineCap(StrokeLineCap.ROUND);
    barArc.setFill(null);
    barArc.setStroke(barColor.get());

    double center = PREFERRED_WIDTH * 0.5;
    ring = Shape.subtract(new Circle(center, center, PREFERRED_WIDTH * 0.42),
                          new Circle(center, center, PREFERRED_WIDTH * 0.3));
    ring.setFill(color.get());
    ring.setEffect(dropShadow);

    mainCircle = new Circle();
    mainCircle.setFill(color.get().darker().darker());

    text = new Text(String.format(Locale.US, formatString, getTargetValue()));
    text.setFill(Color.WHITE);
    text.setTextOrigin(VPos.CENTER);

    indicatorRotate = new Rotate(-ANGLE_RANGE *  0.5, center, center);

    indicatorGlow        = new DropShadow(BlurType.TWO_PASS_BOX, getIndicatorColor(), PREFERRED_WIDTH * 0.02, 0.0, 0, 0);
    indicatorInnerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.5), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    indicatorHighlight   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.35), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    indicatorHighlight.setInput(indicatorInnerShadow);

    indicator = new Circle();
    indicator.setFill(color.get().darker());
    indicator.setStroke(color.get().darker().darker());
    indicator.setMouseTransparent(true);
    indicator.getTransforms().add(indicatorRotate);

    Group indicatorGroup = new Group(indicator);
    indicatorGroup.setEffect(indicatorHighlight);

    symbol = new Region();
    symbol.getStyleClass().setAll("symbol");
    symbol.setCacheHint(CacheHint.SPEED);

    icon = new FontIcon();
    icon.setTextOrigin(VPos.CENTER);

    iconPane = new StackPane(symbol, icon);

    pane = new Pane(barArc, ring, mainCircle, text, indicatorGroup, iconPane);
    pane.setPrefSize(PREFERRED_HEIGHT, PREFERRED_HEIGHT);
    pane.setBackground(new Background(new BackgroundFill(color.get().darker(), new CornerRadii(1024), Insets.EMPTY)));
    pane.setEffect(highlight);

    getChildren().setAll(pane);
}
 
源代码15 项目: Medusa   文件: BarSkin.java
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    Color barColor = gauge.getBarColor();
    gauge.setGradientBarStops(new Stop(0.0, barColor),
                                       new Stop(0.01, barColor),
                                       new Stop(0.75, barColor.deriveColor(-10, 1, 1, 1)),
                                       new Stop(1.0, barColor.deriveColor(-20, 1, 1, 1)));

    shadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.45), 0.01 * PREFERRED_WIDTH, 0, 0.01 * PREFERRED_WIDTH, 0);

    circle = new Circle();
    circle.setFill(null);

    arc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.96, PREFERRED_WIDTH * 0.48, 90, 0);
    arc.setStrokeWidth(PREFERRED_WIDTH * 0.008);
    arc.setStrokeType(StrokeType.CENTERED);
    arc.setStrokeLineCap(StrokeLineCap.ROUND);
    arc.setFill(null);

    fakeDot = new Circle();
    fakeDot.setStroke(null);

    dot = new Circle();
    dot.setStroke(null);
    dot.setVisible(false);
    dot.setEffect(shadow);

    titleText = new Text(gauge.getTitle());
    titleText.setFont(Fonts.robotoLight(PREFERRED_WIDTH * 0.5));
    titleText.setFill(gauge.getTitleColor());
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue()));
    valueText.setFont(Fonts.robotoRegular(PREFERRED_WIDTH * 0.27333));
    valueText.setFill(gauge.getValueColor());
    Helper.enableNode(valueText, gauge.isValueVisible());

    unitText = new Text(gauge.getUnit());
    unitText.setFont(Fonts.robotoLight(PREFERRED_WIDTH * 0.08));
    unitText.setFill(gauge.getUnitColor());
    Helper.enableNode(unitText, !gauge.getUnit().isEmpty());

    pane = new Pane(circle, arc, fakeDot, dot, titleText, valueText, unitText);

    getChildren().setAll(pane);
}
 
源代码16 项目: regulators   文件: ColorRegulator.java
private void initGraphics() {
    dropShadow  = new DropShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), PREFERRED_WIDTH * 0.016, 0.0, 0, PREFERRED_WIDTH * 0.028);
    highlight   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.2), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    innerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.2), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    highlight.setInput(innerShadow);
    dropShadow.setInput(highlight);

    Stop[] stops = { new Stop(0.0, Color.rgb(255,255,0)),
                     new Stop(0.125, Color.rgb(255,0,0)),
                     new Stop(0.375, Color.rgb(255,0,255)),
                     new Stop(0.5, Color.rgb(0,0,255)),
                     new Stop(0.625, Color.rgb(0,255,255)),
                     new Stop(0.875, Color.rgb(0,255,0)),
                     new Stop(1.0, Color.rgb(255,255,0)) };

    List<Stop> reorderedStops = reorderStops(stops);

    gradientLookup = new GradientLookup(stops);

    barGradient = new ConicalGradient(reorderedStops);
    barArc = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, BAR_START_ANGLE, 0);
    barArc.setType(ArcType.OPEN);
    barArc.setStrokeLineCap(StrokeLineCap.ROUND);
    barArc.setFill(null);
    barArc.setStroke(barGradient.getImagePattern(new Rectangle(0, 0, PREFERRED_WIDTH, PREFERRED_HEIGHT)));

    buttonOn = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, -125, 34.75);
    buttonOn.setFill(null);
    buttonOn.setStroke(color.get());
    buttonOn.setStrokeLineCap(StrokeLineCap.BUTT);
    buttonOn.setStrokeWidth(PREFERRED_WIDTH * 0.072);
    buttonOn.setEffect(dropShadow);

    buttonOff = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.46, PREFERRED_HEIGHT * 0.46, -89.75, 34.75);
    buttonOff.setFill(null);
    buttonOff.setStroke(color.get());
    buttonOff.setStrokeLineCap(StrokeLineCap.BUTT);
    buttonOff.setStrokeWidth(PREFERRED_WIDTH * 0.072);
    buttonOff.setEffect(dropShadow);

    double center = PREFERRED_WIDTH * 0.5;
    ring = Shape.subtract(new Circle(center, center, PREFERRED_WIDTH * 0.42),
                          new Circle(center, center, PREFERRED_WIDTH * 0.3));
    ring.setFill(color.get());
    ring.setEffect(highlight);

    mainCircle = new Circle();
    mainCircle.setFill(color.get().darker().darker());

    textOn = new Text("ON");
    textOn.setFill(textColor.get());
    textOn.setTextOrigin(VPos.CENTER);
    textOn.setMouseTransparent(true);
    textOn.setRotate(17);

    textOff = new Text("OFF");
    textOff.setFill(textColor.get());
    textOff.setTextOrigin(VPos.CENTER);
    textOff.setMouseTransparent(true);
    textOff.setRotate(-17);

    indicatorRotate = new Rotate(-ANGLE_RANGE *  0.5, center, center);

    indicatorGlow        = new DropShadow(BlurType.TWO_PASS_BOX, getIndicatorColor(), PREFERRED_WIDTH * 0.02, 0.0, 0, 0);
    indicatorInnerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.5), PREFERRED_WIDTH * 0.008, 0.0, 0, PREFERRED_WIDTH * 0.008);
    indicatorHighlight   = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.35), PREFERRED_WIDTH * 0.008, 0.0, 0, -PREFERRED_WIDTH * 0.008);
    indicatorHighlight.setInput(indicatorInnerShadow);

    indicator = new Circle();
    indicator.setFill(color.get().darker());
    indicator.setStroke(color.get().darker().darker());
    indicator.setMouseTransparent(true);
    indicator.getTransforms().add(indicatorRotate);

    Group indicatorGroup = new Group(indicator);
    indicatorGroup.setEffect(indicatorHighlight);

    innerRing = Shape.subtract(new Circle(center, center, PREFERRED_WIDTH * 0.24),
                               new Circle(center, center, PREFERRED_WIDTH * 0.2));
    innerRing.setFill(color.get());

    currentColorCircle = new Circle();
    currentColorCircle.setFill(targetColor.get());
    currentColorCircle.setVisible(isOn());

    pane = new Pane(barArc, ring, mainCircle, currentColorCircle, innerRing, indicatorGroup, buttonOn, textOn, buttonOff, textOff);
    pane.setPrefSize(PREFERRED_HEIGHT, PREFERRED_HEIGHT);
    pane.setBackground(new Background(new BackgroundFill(color.get().darker(), new CornerRadii(1024), Insets.EMPTY)));
    pane.setEffect(highlight);

    getChildren().setAll(pane);
}
 
源代码17 项目: charts   文件: ChartItem.java
public ChartItem(final double VALUE, final Instant TIMESTAMP) {
    this("", VALUE, Color.rgb(233, 30, 99), Color.TRANSPARENT, Color.BLACK, TIMESTAMP, false, 800);
}
 
源代码18 项目: mars-sim   文件: DotMatrix.java
public static Color convertToColor(final int COLOR_VALUE) {
    return Color.rgb((COLOR_VALUE & RED_MASK) >> 16, (COLOR_VALUE & GREEN_MASK) >> 8, (COLOR_VALUE & BLUE_MASK), ALPHA_FACTOR * ((COLOR_VALUE & ALPHA_MASK) >>> 24));
}
 
源代码19 项目: Medusa   文件: AmpSkin.java
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    ticksAndSectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ticksAndSections       = ticksAndSectionsCanvas.getGraphicsContext2D();

    ledCanvas = new Canvas();
    led       = ledCanvas.getGraphicsContext2D();

    thresholdTooltip = new Tooltip("Threshold\n(" + String.format(locale, formatString, gauge.getThreshold()) + ")");
    thresholdTooltip.setTextAlignment(TextAlignment.CENTER);

    threshold = new Path();
    Helper.enableNode(threshold, gauge.isThresholdVisible());
    Tooltip.install(threshold, thresholdTooltip);

    average = new Path();
    Helper.enableNode(average, gauge.isAverageVisible());

    markerPane = new Pane();

    needleRotate = new Rotate(180 - START_ANGLE);
    needleRotate.setAngle(needleRotate.getAngle() + (gauge.getValue() - oldValue - gauge.getMinValue()) * angleStep);

    needleMoveTo1       = new MoveTo();
    needleCubicCurveTo2 = new CubicCurveTo();
    needleCubicCurveTo3 = new CubicCurveTo();
    needleCubicCurveTo4 = new CubicCurveTo();
    needleLineTo5       = new LineTo();
    needleCubicCurveTo6 = new CubicCurveTo();
    needleClosePath7    = new ClosePath();
    needle              = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleLineTo5, needleCubicCurveTo6, needleClosePath7);
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getTransforms().setAll(needleRotate);

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroup = new Group(needle);
    shadowGroup.setEffect(gauge.isShadowsEnabled() ? dropShadow : null);

    titleText = new Text(gauge.getTitle());
    titleText.setTextOrigin(VPos.CENTER);
    titleText.setFill(gauge.getTitleColor());
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    unitText = new Text(gauge.getUnit());
    unitText.setMouseTransparent(true);
    unitText.setTextOrigin(VPos.CENTER);

    lcd = new Rectangle(0.3 * PREFERRED_WIDTH, 0.1 * PREFERRED_HEIGHT);
    lcd.setArcWidth(0.0125 * PREFERRED_HEIGHT);
    lcd.setArcHeight(0.0125 * PREFERRED_HEIGHT);
    lcd.relocate((PREFERRED_WIDTH - lcd.getWidth()) * 0.5, 0.44 * PREFERRED_HEIGHT);
    Helper.enableNode(lcd, gauge.isLcdVisible() && gauge.isValueVisible());

    lcdText = new Label(String.format(locale, "%." + gauge.getDecimals() + "f", gauge.getValue()));
    lcdText.setAlignment(Pos.CENTER_RIGHT);
    lcdText.setVisible(gauge.isValueVisible());

    // Set initial value
    angleStep          = ANGLE_RANGE / gauge.getRange();
    double targetAngle = 180 - START_ANGLE + (gauge.getValue() - gauge.getMinValue()) * angleStep;
    targetAngle        = clamp(180 - START_ANGLE, 180 - START_ANGLE + ANGLE_RANGE, targetAngle);
    needleRotate.setAngle(targetAngle);

    lightEffect = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.65), 2, 0.0, 0.0, 2.0);

    foreground = new SVGPath();
    foreground.setContent("M 26 26.5 C 26 20.2432 26.2432 20 32.5 20 L 277.5 20 C 283.7568 20 284 20.2432 284 26.5 L 284 143.5 C 284 149.7568 283.7568 150 277.5 150 L 32.5 150 C 26.2432 150 26 149.7568 26 143.5 L 26 26.5 ZM 0 6.7241 L 0 253.2758 C 0 260 0 260 6.75 260 L 303.25 260 C 310 260 310 260 310 253.2758 L 310 6.7241 C 310 0 310 0 303.25 0 L 6.75 0 C 0 0 0 0 0 6.7241 Z");
    foreground.setEffect(lightEffect);

    // Add all nodes
    pane = new Pane();
    pane.getChildren().setAll(ticksAndSectionsCanvas,
                              markerPane,
                              ledCanvas,
                              unitText,
                              lcd,
                              lcdText,
                              shadowGroup,
                              foreground,
                              titleText);

    getChildren().setAll(pane);
}
 
源代码20 项目: medusademo   文件: InteractiveGaugeSkin.java
private void resize() {
    double width  = getSkinnable().getWidth() - getSkinnable().getInsets().getLeft() - getSkinnable().getInsets().getRight();
    double height = getSkinnable().getHeight() - getSkinnable().getInsets().getTop() - getSkinnable().getInsets().getBottom();
    size          = width < height ? width : height;

    if (size > 0) {
        double center = size * 0.5;

        pane.setMaxSize(size, size);
        pane.relocate((getSkinnable().getWidth() - size) * 0.5, (getSkinnable().getHeight() - size) * 0.5);

        dropShadow.setRadius(0.008 * size);
        dropShadow.setOffsetY(0.008 * size);

        backgroundInnerShadow.setOffsetX(0);
        backgroundInnerShadow.setOffsetY(size * 0.03);
        backgroundInnerShadow.setRadius(size * 0.04);

        pane.setEffect(getSkinnable().isInnerShadowEnabled() ? backgroundInnerShadow : null);

        sectionsAndAreasCanvas.setWidth(size);
        sectionsAndAreasCanvas.setHeight(size);

        tickMarkCanvas.setWidth(size);
        tickMarkCanvas.setHeight(size);

        markerPane.setPrefSize(size, size);

        boolean isFlatLed = LedType.FLAT == getSkinnable().getLedType();
        ledSize = isFlatLed ? 0.05 * size : 0.06 * size;
        ledCanvas.setWidth(ledSize);
        ledCanvas.setHeight(ledSize);
        ledCanvas.relocate(0.65 * size, 0.47 * size);
        ledOffShadow = isFlatLed ? null : new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 0.07 * ledSize, 0, 0, 0);
        ledOnShadow  = isFlatLed ? null : new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(0, 0, 0, 0.65), 0.07 * ledSize, 0, 0, 0);
        if (!isFlatLed) ledOnShadow.setInput(new DropShadow(BlurType.TWO_PASS_BOX, getSkinnable().getLedColor(), 0.36 * ledSize, 0, 0, 0));

        resizeText();

        if (getSkinnable().isLcdVisible()) {
            lcd.setWidth(0.4 * size);
            lcd.setHeight(0.114 * size);
            lcd.setArcWidth(0.0125 * size);
            lcd.setArcHeight(0.0125 * size);
            lcd.relocate((size - lcd.getWidth()) * 0.5, 0.583 * size);

            switch(getSkinnable().getLcdFont()) {
                case LCD:
                    valueText.setFont(Fonts.digital(0.108 * size));
                    valueText.setTranslateY(0.64 * size);
                    break;
                case DIGITAL:
                    valueText.setFont(Fonts.digitalReadout(0.105 * size));
                    valueText.setTranslateY(0.65 * size);
                    break;
                case DIGITAL_BOLD:
                    valueText.setFont(Fonts.digitalReadoutBold(0.105 * size));
                    valueText.setTranslateY(0.65 * size);
                    break;
                case ELEKTRA:
                    valueText.setFont(Fonts.elektra(0.1116 * size));
                    valueText.setTranslateY(0.645 * size);
                    break;
                case STANDARD:
                default:
                    valueText.setFont(Fonts.robotoMedium(0.09 * size));
                    valueText.setTranslateY(0.64 * size);
                    break;
            }
            valueText.setTranslateX((0.691 * size - valueText.getLayoutBounds().getWidth()));
        } else {
            valueText.setFont(Fonts.robotoMedium(size * 0.1));
            valueText.setTranslateX((size - valueText.getLayoutBounds().getWidth()) * 0.5);
            valueText.setTranslateY(size * 0.65);
        }

        drawNeedle();

        knobCanvas.setWidth(size * 0.1);
        knobCanvas.setHeight(size * 0.1);
        knobCanvas.relocate(center - size * 0.05, center - size * 0.05);

        buttonTooltip.setText(getSkinnable().getButtonTooltipText());
    }
}