本文整理汇总了Java中javafx.scene.shape.Path.setStrokeLineCap方法的典型用法代码示例。如果您正苦于以下问题:Java Path.setStrokeLineCap方法的具体用法?Java Path.setStrokeLineCap怎么用?Java Path.setStrokeLineCap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Path
的用法示例。
在下文中一共展示了Path.setStrokeLineCap方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateOutline
import javafx.scene.shape.Path; //导入方法依赖的package包/类
/**
* Once we have drawn the path, we call this method to generate two paths
* (outer and inner paths) and get a SVGPath with them that can be exported
* @param drawPath The original path
* @param svg
* @return the content string of the SVGPath with two paths
*/
public boolean generateOutline(Path drawPath, SVGPath svg) {
Pane pane = (Pane) drawPath.getParent();
final double width = pane.getWidth() * WIDTH_FACTOR;
Path outterPath = new Path(drawPath.getElements());
outterPath.setStroke(drawPath.getStroke());
outterPath.setStrokeLineJoin(drawPath.getStrokeLineJoin());
outterPath.setStrokeLineCap(drawPath.getStrokeLineCap());
outterPath.setStrokeWidth(width);
Path s1 = (Path) Shape.subtract(outterPath, new Rectangle(0, 0));
Path innerPath = new Path(drawPath.getElements());
innerPath.setStrokeWidth(0);
innerPath.setStroke(drawPath.getStroke());
innerPath.setStrokeLineJoin(drawPath.getStrokeLineJoin());
innerPath.setStrokeLineCap(drawPath.getStrokeLineCap());
Path s2 = (Path) Shape.subtract(innerPath, new Rectangle(0, 0));
Path result = (Path) Shape.subtract(s1, s2);
clearSmallPolygons(result);
svg.setContent(pathsToSVGPath());
return validPaths.size() == 2;
}
示例2: initGraphics
import javafx.scene.shape.Path; //导入方法依赖的package包/类
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);
}
示例3: StrokeCell
import javafx.scene.shape.Path; //导入方法依赖的package包/类
public StrokeCell() {
super(new Path());
Path path = (Path) this.node;
path.setId("line");
path.getElements().add(new MoveTo(0, 5));
path.getElements().add(new LineTo(15, 5));
path.setStroke(Color.BLACK);
path.setStrokeLineCap(StrokeLineCap.ROUND);
}
示例4: createSteps
import javafx.scene.shape.Path; //导入方法依赖的package包/类
private NumberExpression createSteps(Step<?> step, int depth, int currentStateIndex, int selectedStateIndex, int firstStateIndex, int lastStateIndex,
List<Path> accumulator, Object[] stepTargets) {
final int stepStartingIndex = traceExtractor.getStateIndex(step.getStartingState());
final boolean endedStep = step.getEndingState() != null;
final int startingIndex = stepStartingIndex - currentStateIndex;
final int endingIndex = (endedStep ? traceExtractor.getStateIndex(step.getEndingState())
: nbStates.intValue()) - currentStateIndex;
final Path path = new Path();
path.setStrokeWidth(2);
final double x1 = startingIndex * UNIT + UNIT / 2;
final double x4 = endingIndex * UNIT + UNIT / 2;
final double x2 = x1 + UNIT / 4;
final double x3 = x4 - UNIT / 4;
final double baseLineY = DIAMETER / 2 + V_MARGIN;
final MoveTo moveTo = new MoveTo(x1, baseLineY);
final LineTo lineTo = new LineTo(x2, baseLineY);
final HLineTo hLineTo = new HLineTo(x3);
path.getElements().addAll(moveTo, lineTo, hLineTo);
if (endedStep) {
final LineTo lastLineTo = new LineTo(x4, baseLineY);
path.getElements().add(lastLineTo);
}
accumulator.add(path);
final List<? extends Step<?>> subSteps = traceExtractor.getSubSteps(step);
NumberExpression yOffset = new SimpleDoubleProperty(0);
if (subSteps != null && !subSteps.isEmpty()) {
for (Step<?> subStep : subSteps) {
if (subStep.getStartingState() != subStep.getEndingState()
// && ((traceExtractor.getStateIndex(subStep.getEndingState()) < firstStateIndex) || traceExtractor.getStateIndex(subStep.getStartingState()) > lastStateIndex)
) {
yOffset = Bindings.max(yOffset, createSteps(subStep, depth + 1, currentStateIndex, selectedStateIndex, firstStateIndex, lastStateIndex, accumulator, stepTargets));
}
}
}
lineTo.yProperty().bind(yOffset.add(DIAMETER / 2 + V_MARGIN));
if (stepTargets[CURRENT_FORWARD_STEP] == step) {
path.setStroke(Color.DARKORANGE);
} else if (stepTargets[CURRENT_BACKWARD_STEP] == step) {
path.setStroke(Color.DARKGREEN);
} else if (stepTargets[CURRENT_BIGSTEP] == step) {
path.setStroke(Color.DARKRED);
} else {
path.setStroke(Color.DARKBLUE);
if (!traceExplorer.getCallStack().contains(step) && (stepStartingIndex > selectedStateIndex
|| (stepStartingIndex == selectedStateIndex && endedStep))) {
path.getStrokeDashArray().addAll(5., 5.);
path.setStrokeLineCap(StrokeLineCap.ROUND);
}
}
return lineTo.yProperty();
}
示例5: initGraphics
import javafx.scene.shape.Path; //导入方法依赖的package包/类
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);
}
示例6: initGraphics
import javafx.scene.shape.Path; //导入方法依赖的package包/类
@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);
}