javafx.scene.shape.Path#setStrokeLineCap ( )源码实例Demo

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

源代码1 项目: latexdraw   文件: ViewArrowableTraitPath.java
@Override
protected void clipPath(final Path path) {
	final Path clip = pathProducer.clonePath(path);
	clip.setFill(path.getFill());
	clip.setStrokeWidth(path.getStrokeWidth());

	if(!clip.getElements().isEmpty()) { // Defensive programming
		final Optional<Point> pt1 = getArrowReducedPoint(arrows.get(0).arrow);
		final Optional<Point> pt2 = getArrowReducedPoint(arrows.get(arrows.size() - 1).arrow);

		if(pt1.isPresent() && clip.getElements().get(0) instanceof MoveTo) { // Defensive programming
			// Changing the first point to the one at the beginning of the arrow.
			final MoveTo moveTo = (MoveTo) clip.getElements().get(0);
			moveTo.setX(pt1.get().getX());
			moveTo.setY(pt1.get().getY());
		}

		pt2.ifPresent(pt -> {
			if(clip.getElements().get(clip.getElements().size() - 1) instanceof LineTo) {
				final LineTo lineTo = (LineTo) clip.getElements().get(clip.getElements().size() - 1);
				lineTo.setX(pt.getX());
				lineTo.setY(pt.getY());
			}else if(clip.getElements().get(clip.getElements().size() - 1) instanceof CubicCurveTo) {
				final CubicCurveTo ccTo = (CubicCurveTo) clip.getElements().get(clip.getElements().size() - 1);
				ccTo.setX(pt.getX());
				ccTo.setY(pt.getY());
			}
		});
	}

	clip.setStrokeWidth(path.getStrokeWidth());
	clip.setStrokeLineCap(path.getStrokeLineCap());
	path.setClip(clip);
}
 
源代码2 项目: OEE-Designer   文件: SparkLineTileSkin.java
@Override protected void initGraphics() {
    super.initGraphics();

    averagingListener = o -> handleEvents("AVERAGING");

    timeFormatter = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale());

    if (tile.isAutoScale()) tile.calcAutoScale();

    niceScaleY = new NiceScale(tile.getMinValue(), tile.getMaxValue());
    niceScaleY.setMaxTicks(5);
    tickLineColor = Color.color(tile.getChartGridColor().getRed(), tile.getChartGridColor().getGreen(), tile.getChartGridColor().getBlue(), 0.5);
    horizontalTickLines = new ArrayList<>(5);
    tickLabelsY = new ArrayList<>(5);
    for (int i = 0 ; i < 5 ; i++) {
        Line hLine = new Line(0, 0, 0, 0);
        hLine.getStrokeDashArray().addAll(1.0, 2.0);
        hLine.setStroke(Color.TRANSPARENT);
        horizontalTickLines.add(hLine);
        Text tickLabelY = new Text("");
        tickLabelY.setFill(Color.TRANSPARENT);
        tickLabelsY.add(tickLabelY);
    }

    gradientLookup = new GradientLookup(tile.getGradientStops());
    low            = tile.getMaxValue();
    high           = tile.getMinValue();
    stdDeviation   = 0;
    movingAverage  = tile.getMovingAverage();
    noOfDatapoints = tile.getAveragingPeriod();
    dataList       = new LinkedList<>();

    // To get smooth lines in the chart we need at least 4 values
    if (noOfDatapoints < 4) throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3.");

    graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45);

    titleText = new Text(tile.getTitle());
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    valueText = new Text(String.format(locale, formatString, tile.getValue()));
    valueText.setFill(tile.getValueColor());
    Helper.enableNode(valueText, tile.isValueVisible());

    unitText = new Text(tile.getUnit());
    unitText.setFill(tile.getUnitColor());
    Helper.enableNode(unitText, !tile.getUnit().isEmpty());

    valueUnitFlow = new TextFlow(valueText, unitText);
    valueUnitFlow.setTextAlignment(TextAlignment.RIGHT);

    averageText = new Text(String.format(locale, formatString, tile.getAverage()));
    averageText.setFill(Tile.FOREGROUND);
    Helper.enableNode(averageText, tile.isAverageVisible());

    highText = new Text();
    highText.setTextOrigin(VPos.BOTTOM);
    highText.setFill(tile.getValueColor());

    lowText = new Text();
    lowText.setTextOrigin(VPos.TOP);
    lowText.setFill(tile.getValueColor());

    text = new Text(tile.getText());
    text.setTextOrigin(VPos.TOP);
    text.setFill(tile.getTextColor());

    timeSpanText = new Text("");
    timeSpanText.setTextOrigin(VPos.TOP);
    timeSpanText.setFill(tile.getTextColor());
    Helper.enableNode(timeSpanText, !tile.isTextVisible());

    stdDeviationArea = new Rectangle();
    Helper.enableNode(stdDeviationArea, tile.isAverageVisible());

    averageLine = new Line();
    averageLine.setStroke(Tile.FOREGROUND);
    averageLine.getStrokeDashArray().addAll(PREFERRED_WIDTH * 0.005, PREFERRED_WIDTH * 0.005);
    Helper.enableNode(averageLine, tile.isAverageVisible());

    pathElements = new ArrayList<>(noOfDatapoints);
    pathElements.add(0, new MoveTo());
    for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); }

    sparkLine = new Path();
    sparkLine.getElements().addAll(pathElements);
    sparkLine.setFill(null);
    sparkLine.setStroke(tile.getBarColor());
    sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075);
    sparkLine.setStrokeLineCap(StrokeLineCap.ROUND);
    sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND);

    dot = new Circle();
    dot.setFill(tile.getBarColor());

    getPane().getChildren().addAll(titleText, valueUnitFlow, stdDeviationArea, averageLine, sparkLine, dot, averageText, highText, lowText, timeSpanText, text);
    getPane().getChildren().addAll(horizontalTickLines);
    getPane().getChildren().addAll(tickLabelsY);
}
 
源代码3 项目: OEE-Designer   文件: TimerControlTileSkin.java
@Override protected void initGraphics() {
    super.initGraphics();

    currentValueListener = o -> {
        if (tile.isRunning()) { return; } // Update time only if clock is not already running
        updateTime(ZonedDateTime.ofInstant(Instant.ofEpochSecond(tile.getCurrentTime()), ZoneId.of(ZoneId.systemDefault().getId())));
    };
    timeListener         = o -> updateTime(tile.getTime());

    dateFormatter = DateTimeFormatter.ofPattern("EE d", tile.getLocale());

    sectionMap   = new HashMap<>(tile.getTimeSections().size());
    for (TimeSection section : tile.getTimeSections()) { sectionMap.put(section, new Arc()); }

    minuteRotate = new Rotate();
    hourRotate   = new Rotate();
    secondRotate = new Rotate();

    sectionsPane = new Pane();
    sectionsPane.getChildren().addAll(sectionMap.values());
    Helper.enableNode(sectionsPane, tile.getSectionsVisible());

    minuteTickMarks = new Path();
    minuteTickMarks.setFillRule(FillRule.EVEN_ODD);
    minuteTickMarks.setFill(null);
    minuteTickMarks.setStroke(tile.getMinuteColor());
    minuteTickMarks.setStrokeLineCap(StrokeLineCap.ROUND);

    hourTickMarks = new Path();
    hourTickMarks.setFillRule(FillRule.EVEN_ODD);
    hourTickMarks.setFill(null);
    hourTickMarks.setStroke(tile.getHourColor());
    hourTickMarks.setStrokeLineCap(StrokeLineCap.ROUND);

    hour = new Rectangle(3, 60);
    hour.setArcHeight(3);
    hour.setArcWidth(3);
    hour.setStroke(tile.getHourColor());
    hour.getTransforms().setAll(hourRotate);

    minute = new Rectangle(3, 96);
    minute.setArcHeight(3);
    minute.setArcWidth(3);
    minute.setStroke(tile.getMinuteColor());
    minute.getTransforms().setAll(minuteRotate);

    second = new Rectangle(1, 96);
    second.setArcHeight(1);
    second.setArcWidth(1);
    second.setStroke(tile.getSecondColor());
    second.getTransforms().setAll(secondRotate);
    second.setVisible(tile.isSecondsVisible());
    second.setManaged(tile.isSecondsVisible());

    knob = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, 4.5);
    knob.setStroke(Color.web("#282a3280"));

    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);

    shadowGroupHour   = new Group(hour);
    shadowGroupMinute = new Group(minute);
    shadowGroupSecond = new Group(second, knob);

    shadowGroupHour.setEffect(tile.isShadowsEnabled() ? dropShadow : null);
    shadowGroupMinute.setEffect(tile.isShadowsEnabled() ? dropShadow : null);
    shadowGroupSecond.setEffect(tile.isShadowsEnabled() ? dropShadow : null);

    titleText = new Text("");
    titleText.setTextOrigin(VPos.TOP);
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    amPmText = new Text(tile.getTime().get(ChronoField.AMPM_OF_DAY) == 0 ? "AM" : "PM");

    dateText = new Text("");
    Helper.enableNode(dateText, tile.isDateVisible());

    text = new Text("");
    Helper.enableNode(text, tile.isTextVisible());

    getPane().getChildren().addAll(sectionsPane, hourTickMarks, minuteTickMarks, titleText, amPmText, dateText, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond);
}
 
源代码4 项目: OEE-Designer   文件: StockTileSkin.java
@Override protected void initGraphics() {
    super.initGraphics();

    averagingListener = o -> handleEvents("AVERAGING_PERIOD");

    timeFormatter = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale());

    state = State.CONSTANT;

    if (tile.isAutoScale()) tile.calcAutoScale();

    low            = tile.getMaxValue();
    high           = tile.getMinValue();
    movingAverage  = tile.getMovingAverage();
    noOfDatapoints = tile.getAveragingPeriod();
    dataList       = new LinkedList<>();

    // To get smooth lines in the chart we need at least 4 values
    if (noOfDatapoints < 4) throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3.");

    graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45);

    titleText = new Text(tile.getTitle());
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    valueText = new Text(String.format(locale, formatString, tile.getValue()));
    valueText.setBoundsType(TextBoundsType.VISUAL);
    valueText.setFill(tile.getValueColor());
    Helper.enableNode(valueText, tile.isValueVisible());

    valueUnitFlow = new TextFlow(valueText);
    valueUnitFlow.setTextAlignment(TextAlignment.RIGHT);

    highText = new Text();
    highText.setTextOrigin(VPos.BOTTOM);
    highText.setFill(tile.getValueColor());

    lowText = new Text();
    lowText.setTextOrigin(VPos.TOP);
    lowText.setFill(tile.getValueColor());

    text = new Text(tile.getText());
    text.setTextOrigin(VPos.TOP);
    text.setFill(tile.getTextColor());

    timeSpanText = new Text("");
    timeSpanText.setTextOrigin(VPos.TOP);
    timeSpanText.setFill(tile.getTextColor());
    Helper.enableNode(timeSpanText, !tile.isTextVisible());

    referenceLine = new Line();
    referenceLine.getStrokeDashArray().addAll(3d, 3d);
    referenceLine.setVisible(false);

    pathElements = new ArrayList<>(noOfDatapoints);
    pathElements.add(0, new MoveTo());
    for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); }

    sparkLine = new Path();
    sparkLine.getElements().addAll(pathElements);
    sparkLine.setFill(null);
    sparkLine.setStroke(tile.getBarColor());
    sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075);
    sparkLine.setStrokeLineCap(StrokeLineCap.ROUND);
    sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND);

    dot = new Circle();
    dot.setFill(tile.getBarColor());
    dot.setVisible(false);

    triangle = new Path();
    triangle.setStroke(null);
    triangle.setFill(state.color);
    indicatorPane = new StackPane(triangle);

    changeText = new Label(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (tile.getCurrentValue() - tile.getReferenceValue())));
    changeText.setTextFill(state.color);
    changeText.setAlignment(Pos.CENTER_RIGHT);

    changePercentageText = new Text(new StringBuilder().append(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (tile.getCurrentValue() / tile.getReferenceValue() * 100.0) - 100.0)).append("\u0025").toString());
    changePercentageText.setFill(state.color);

    changePercentageFlow = new TextFlow(indicatorPane, changePercentageText);
    changePercentageFlow.setTextAlignment(TextAlignment.RIGHT);

    getPane().getChildren().addAll(titleText, valueUnitFlow, sparkLine, dot, referenceLine, highText, lowText, timeSpanText, text, changeText, changePercentageFlow);
}
 
源代码5 项目: tilesfx   文件: TimerControlTileSkin.java
@Override protected void initGraphics() {
    super.initGraphics();

    currentValueListener = o -> {
        if (tile.isRunning()) { return; } // Update time only if clock is not already running
        updateTime(ZonedDateTime.ofInstant(Instant.ofEpochSecond(tile.getCurrentTime()), ZoneId.of(ZoneId.systemDefault().getId())));
    };
    timeListener         = o -> updateTime(tile.getTime());

    dateFormatter = DateTimeFormatter.ofPattern("EE d", tile.getLocale());

    sectionMap   = new HashMap<>(tile.getTimeSections().size());
    for (TimeSection section : tile.getTimeSections()) { sectionMap.put(section, new Arc()); }

    minuteRotate = new Rotate();
    hourRotate   = new Rotate();
    secondRotate = new Rotate();

    sectionsPane = new Pane();
    sectionsPane.getChildren().addAll(sectionMap.values());
    Helper.enableNode(sectionsPane, tile.getSectionsVisible());

    minuteTickMarks = new Path();
    minuteTickMarks.setFillRule(FillRule.EVEN_ODD);
    minuteTickMarks.setFill(null);
    minuteTickMarks.setStroke(tile.getMinuteColor());
    minuteTickMarks.setStrokeLineCap(StrokeLineCap.ROUND);

    hourTickMarks = new Path();
    hourTickMarks.setFillRule(FillRule.EVEN_ODD);
    hourTickMarks.setFill(null);
    hourTickMarks.setStroke(tile.getHourColor());
    hourTickMarks.setStrokeLineCap(StrokeLineCap.ROUND);

    hour = new Rectangle(3, 60);
    hour.setArcHeight(3);
    hour.setArcWidth(3);
    hour.setStroke(tile.getHourColor());
    hour.getTransforms().setAll(hourRotate);

    minute = new Rectangle(3, 96);
    minute.setArcHeight(3);
    minute.setArcWidth(3);
    minute.setStroke(tile.getMinuteColor());
    minute.getTransforms().setAll(minuteRotate);

    second = new Rectangle(1, 96);
    second.setArcHeight(1);
    second.setArcWidth(1);
    second.setStroke(tile.getSecondColor());
    second.getTransforms().setAll(secondRotate);
    second.setVisible(tile.isSecondsVisible());
    second.setManaged(tile.isSecondsVisible());

    knob = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, 4.5);
    knob.setStroke(Color.web("#282a3280"));

    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);

    shadowGroupHour   = new Group(hour);
    shadowGroupMinute = new Group(minute);
    shadowGroupSecond = new Group(second, knob);

    shadowGroupHour.setEffect(tile.isShadowsEnabled() ? dropShadow : null);
    shadowGroupMinute.setEffect(tile.isShadowsEnabled() ? dropShadow : null);
    shadowGroupSecond.setEffect(tile.isShadowsEnabled() ? dropShadow : null);

    titleText = new Text("");
    titleText.setTextOrigin(VPos.TOP);
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    amPmText = new Text(tile.getTime().get(ChronoField.AMPM_OF_DAY) == 0 ? "AM" : "PM");

    dateText = new Text("");
    Helper.enableNode(dateText, tile.isDateVisible());

    text = new Text("");
    Helper.enableNode(text, tile.isTextVisible());

    getPane().getChildren().addAll(sectionsPane, hourTickMarks, minuteTickMarks, titleText, amPmText, dateText, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond);
}
 
源代码6 项目: tilesfx   文件: StockTileSkin.java
@Override protected void initGraphics() {
    super.initGraphics();

    averagingListener = o -> handleEvents("AVERAGING_PERIOD");

    timeFormatter = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale());

    state = State.CONSTANT;

    if (tile.isAutoScale()) tile.calcAutoScale();

    low            = tile.getMaxValue();
    high           = tile.getMinValue();
    movingAverage  = tile.getMovingAverage();
    noOfDatapoints = tile.getAveragingPeriod();
    dataList       = new LinkedList<>();

    // To get smooth lines in the chart we need at least 4 values
    if (noOfDatapoints < 4) throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3.");

    graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45);

    titleText = new Text(tile.getTitle());
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    valueText = new Text(String.format(locale, formatString, tile.getValue()));
    valueText.setBoundsType(TextBoundsType.VISUAL);
    valueText.setFill(tile.getValueColor());
    Helper.enableNode(valueText, tile.isValueVisible());

    valueUnitFlow = new TextFlow(valueText);
    valueUnitFlow.setTextAlignment(TextAlignment.RIGHT);

    highText = new Text();
    highText.setTextOrigin(VPos.BOTTOM);
    highText.setFill(tile.getValueColor());

    lowText = new Text();
    lowText.setTextOrigin(VPos.TOP);
    lowText.setFill(tile.getValueColor());

    text = new Text(tile.getText());
    text.setTextOrigin(VPos.TOP);
    text.setFill(tile.getTextColor());

    timeSpanText = new Text("");
    timeSpanText.setTextOrigin(VPos.TOP);
    timeSpanText.setFill(tile.getTextColor());
    Helper.enableNode(timeSpanText, !tile.isTextVisible());

    referenceLine = new Line();
    referenceLine.getStrokeDashArray().addAll(3d, 3d);
    referenceLine.setVisible(false);

    pathElements = new ArrayList<>(noOfDatapoints);
    pathElements.add(0, new MoveTo());
    for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); }

    sparkLine = new Path();
    sparkLine.getElements().addAll(pathElements);
    sparkLine.setFill(null);
    sparkLine.setStroke(tile.getBarColor());
    sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075);
    sparkLine.setStrokeLineCap(StrokeLineCap.ROUND);
    sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND);

    dot = new Circle();
    dot.setFill(tile.getBarColor());
    dot.setVisible(false);

    triangle = new Path();
    triangle.setStroke(null);
    triangle.setFill(state.color);
    indicatorPane = new StackPane(triangle);

    changeText = new Label(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (tile.getCurrentValue() - tile.getReferenceValue())));
    changeText.setTextFill(state.color);
    changeText.setAlignment(Pos.CENTER_RIGHT);

    changePercentageText = new Text(new StringBuilder().append(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (tile.getCurrentValue() / tile.getReferenceValue() * 100.0) - 100.0)).append(Helper.PERCENTAGE).toString());
    changePercentageText.setFill(state.color);

    changePercentageFlow = new TextFlow(indicatorPane, changePercentageText);
    changePercentageFlow.setTextAlignment(TextAlignment.RIGHT);

    getPane().getChildren().addAll(titleText, valueUnitFlow, sparkLine, dot, referenceLine, highText, lowText, timeSpanText, text, changeText, changePercentageFlow);
}
 
源代码7 项目: Medusa   文件: TileSparklineSkin.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);
        }
    }

    graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45);

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

    valueText = new Text(String.format(locale, formatString, gauge.getValue()));
    valueText.setFill(gauge.getValueColor());
    Helper.enableNode(valueText, gauge.isValueVisible());

    unitText = new Text(gauge.getUnit());
    unitText.setFill(gauge.getUnitColor());
    Helper.enableNode(unitText, !gauge.getUnit().isEmpty());

    averageText = new Text(String.format(locale, formatString, gauge.getAverage()));
    averageText.setFill(gauge.getAverageColor());
    Helper.enableNode(averageText, gauge.isAverageVisible());

    highText = new Text();
    highText.setTextOrigin(VPos.BOTTOM);
    highText.setFill(gauge.getValueColor());

    lowText = new Text();
    lowText.setTextOrigin(VPos.TOP);
    lowText.setFill(gauge.getValueColor());

    subTitleText = new Text(gauge.getSubTitle());
    subTitleText.setTextOrigin(VPos.TOP);
    subTitleText.setFill(gauge.getSubTitleColor());

    stdDeviationArea = new Rectangle();
    Helper.enableNode(stdDeviationArea, gauge.isAverageVisible());

    averageLine = new Line();
    averageLine.setStroke(gauge.getAverageColor());
    averageLine.getStrokeDashArray().addAll(PREFERRED_WIDTH * 0.005, PREFERRED_WIDTH * 0.005);
    Helper.enableNode(averageLine, gauge.isAverageVisible());

    pathElements = new ArrayList<>(noOfDatapoints);
    pathElements.add(0, new MoveTo());
    for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); }

    sparkLine = new Path();
    sparkLine.getElements().addAll(pathElements);
    sparkLine.setFill(null);
    sparkLine.setStroke(gauge.getBarColor());
    sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075);
    sparkLine.setStrokeLineCap(StrokeLineCap.ROUND);
    sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND);

    dot = new Circle();
    dot.setFill(gauge.getBarColor());

    pane = new Pane(titleText, valueText, unitText, stdDeviationArea, averageLine, sparkLine, dot, averageText, highText, lowText, subTitleText);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(PREFERRED_WIDTH * 0.025), new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(PREFERRED_WIDTH * 0.025), Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
源代码8 项目: Medusa   文件: SimpleSkin.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);
        }
    }

    sectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    sectionsCtx    = sectionsCanvas.getGraphicsContext2D();

    needleRotate   = new Rotate(180 - START_ANGLE);

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

    needleMoveTo1       = new MoveTo();
    needleCubicCurveTo2 = new CubicCurveTo();
    needleCubicCurveTo3 = new CubicCurveTo();
    needleCubicCurveTo4 = new CubicCurveTo();
    needleLineTo5       = new LineTo();
    needleLineTo6       = new LineTo();
    needleCubicCurveTo7 = new CubicCurveTo();
    needleClosePath8    = new ClosePath();
    needle              = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleLineTo5, needleLineTo6, needleCubicCurveTo7, needleClosePath8);
    needle.setFillRule(FillRule.EVEN_ODD);

    needle.getTransforms().setAll(needleRotate);
    needle.setFill(gauge.getNeedleColor());
    needle.setStroke(gauge.getBorderPaint());
    needle.setStrokeLineCap(StrokeLineCap.ROUND);
    needle.setStrokeLineJoin(StrokeLineJoin.BEVEL);

    valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getMinValue()) + gauge.getUnit());
    valueText.setMouseTransparent(true);
    valueText.setTextOrigin(VPos.CENTER);
    valueText.setFill(gauge.getValueColor());
    enableNode(valueText, gauge.isValueVisible());

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

    subTitleText = new Text(gauge.getSubTitle());
    subTitleText.setTextOrigin(VPos.CENTER);
    subTitleText.setFill(gauge.getSubTitleColor());
    enableNode(subTitleText, !gauge.getSubTitle().isEmpty());

    // Add all nodes
    pane = new Pane(sectionsCanvas, needle, valueText, titleText, subTitleText);

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

    minuteTickMarks = new Path();
    minuteTickMarks.setFillRule(FillRule.EVEN_ODD);
    minuteTickMarks.setFill(null);
    minuteTickMarks.setStroke(clock.getMinuteColor());
    minuteTickMarks.setStrokeLineCap(StrokeLineCap.ROUND);

    hourTickMarks = new Path();
    hourTickMarks.setFillRule(FillRule.EVEN_ODD);
    hourTickMarks.setFill(null);
    hourTickMarks.setStroke(clock.getHourColor());
    hourTickMarks.setStrokeLineCap(StrokeLineCap.ROUND);

    hour = new Rectangle(3, 60);
    hour.setArcHeight(3);
    hour.setArcWidth(3);
    hour.setStroke(clock.getHourColor());
    hour.getTransforms().setAll(hourRotate);

    minute = new Rectangle(3, 96);
    minute.setArcHeight(3);
    minute.setArcWidth(3);
    minute.setStroke(clock.getMinuteColor());
    minute.getTransforms().setAll(minuteRotate);

    second = new Rectangle(1, 96);
    second.setArcHeight(1);
    second.setArcWidth(1);
    second.setStroke(clock.getSecondColor());
    second.getTransforms().setAll(secondRotate);
    second.setVisible(clock.isSecondsVisible());
    second.setManaged(clock.isSecondsVisible());

    knob = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, 4.5);
    knob.setStroke(Color.web("#282a3280"));

    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);

    shadowGroupHour   = new Group(hour);
    shadowGroupMinute = new Group(minute);
    shadowGroupSecond = new Group(second, knob);

    shadowGroupHour.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupMinute.setEffect(clock.getShadowsEnabled() ? dropShadow : null);
    shadowGroupSecond.setEffect(clock.getShadowsEnabled() ? dropShadow : null);

    title = new Text("");
    title.setTextOrigin(VPos.TOP);
    Helper.enableNode(title, clock.isTitleVisible());

    amPmText = new Text(clock.getTime().get(ChronoField.AMPM_OF_DAY) == 0 ? "AM" : "PM");

    dateText = new Text("");
    Helper.enableNode(dateText, clock.isDateVisible());

    text = new Text("");
    Helper.enableNode(text, clock.isTextVisible());

    pane = new Pane(hourTickMarks, minuteTickMarks, title, amPmText, dateText, text, shadowGroupHour, shadowGroupMinute, shadowGroupSecond);
    pane.setBorder(new Border(new BorderStroke(clock.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(PREFERRED_WIDTH * 0.025), new BorderWidths(clock.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(clock.getBackgroundPaint(), new CornerRadii(PREFERRED_WIDTH * 0.025), Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
源代码10 项目: latexdraw   文件: ViewGrid.java
/**
 * Creates the view.
 * @param sh The model.
 */
ViewGrid(final Grid sh, final PathElementProducer pathProducer) {
	super(sh, pathProducer);
	maingrid = new Path();
	subgrid = new Path();
	mainGridLineCapUpdate = (o, formerv, newv) -> {
		maingrid.setStrokeLineCap(newv.doubleValue() > 0d ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
		updatePath(true, false, false);
	};
	subGridLineCapUpdate = (o, formerv, newv) -> {
		subgrid.setStrokeLineCap(newv.doubleValue() > 0d ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
		updatePath(false, true, false);
	};
	gridUpdate = (o, formerv, newv) -> updatePath(true, true, true);
	labelUpdate = (o, formerv, newv) -> updatePath(false, false, true);
	gridWidthUpdate = (o, formerv, newv) -> {
		maingrid.setStrokeWidth(model.getGridWidth());
		updatePath(false, false, true);
	};
	subGridUpdate = (o, formerv, newv) -> updatePath(false, true, false);

	getChildren().add(subgrid);
	getChildren().add(maingrid);

	maingrid.strokeProperty().bind(Bindings.createObjectBinding(() -> model.getLineColour().toJFX(), model.lineColourProperty()));
	model.gridDotsProperty().addListener(mainGridLineCapUpdate);
	subgrid.strokeProperty().bind(Bindings.createObjectBinding(() -> model.getSubGridColour().toJFX(), model.subGridColourProperty()));
	model.subGridDotsProperty().addListener(subGridLineCapUpdate);
	model.gridEndXProperty().addListener(gridUpdate);
	model.gridEndYProperty().addListener(gridUpdate);
	model.gridStartXProperty().addListener(gridUpdate);
	model.gridStartYProperty().addListener(gridUpdate);
	model.originXProperty().addListener(labelUpdate);
	model.originYProperty().addListener(labelUpdate);
	model.labelsSizeProperty().addListener(labelUpdate);
	model.yLabelWestProperty().addListener(labelUpdate);
	model.xLabelSouthProperty().addListener(labelUpdate);
	model.subGridDivProperty().addListener(subGridUpdate);
	model.gridWidthProperty().addListener(gridWidthUpdate);
	model.subGridWidthProperty().addListener(subGridUpdate);
	subgrid.strokeWidthProperty().bind(model.subGridWidthProperty());
	model.unitProperty().addListener(gridUpdate);

	updatePath(true, true, true);
}