本文整理汇总了Java中javafx.scene.shape.Line.setStrokeWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Line.setStrokeWidth方法的具体用法?Java Line.setStrokeWidth怎么用?Java Line.setStrokeWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Line
的用法示例。
在下文中一共展示了Line.setStrokeWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LineSample
import javafx.scene.shape.Line; //导入方法依赖的package包/类
public LineSample() {
super(180,90);
// Create line shape
Line line = new Line(5, 85, 175 , 5);
line.setFill(null);
line.setStroke(Color.RED);
line.setStrokeWidth(2);
// show the line shape;
getChildren().add(line);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Line Stroke", line.strokeProperty()),
new SimplePropertySheet.PropDesc("Line Start X", line.startXProperty(), 0d, 170d),
new SimplePropertySheet.PropDesc("Line Start Y", line.startYProperty(), 0d, 90d),
new SimplePropertySheet.PropDesc("Line End X", line.endXProperty(), 10d, 180d),
new SimplePropertySheet.PropDesc("Line End Y", line.endYProperty(), 0d, 90d)
);
// END REMOVE ME
}
示例2: drawArrowHead
import javafx.scene.shape.Line; //导入方法依赖的package包/类
/**
* Draws an ArrowHead and returns it in a group.
* Based on code from http://www.coderanch.com/t/340443/GUI/java/Draw-arrow-head-line
* @param startX
* @param startY
* @param endX
* @param endY
* @return Group.
*/
private void drawArrowHead(double startX, double startY, double endX, double endY) {
arrowHead.getChildren().clear();
double phi = Math.toRadians(30);
int barb = 15;
double dy = startY - endY;
double dx = startX - endX;
double theta = Math.atan2(dy, dx);
double x, y, rho = theta + phi;
for (int j = 0; j < 2; j++) {
x = startX - barb * Math.cos(rho);
y = startY - barb * Math.sin(rho);
Line arrowHeadLine = new Line(startX, startY, x, y);
arrowHeadLine.setStrokeWidth(super.STROKE_WIDTH);
arrowHeadLines.add(arrowHeadLine);
if(super.isSelected()){
arrowHeadLine.setStroke(Constants.selected_color);
}
arrowHead.getChildren().add(arrowHeadLine);
rho = theta - phi;
}
}
示例3: Arrow
import javafx.scene.shape.Line; //导入方法依赖的package包/类
public Arrow(Double fromX, Double fromY, Double toX, Double toY, Double radius) {
line = new Line();
line.setStartX(fromX);
line.setStartY(fromY);
line.setEndX(toX);
line.setEndY(toY);
line.setStrokeWidth(3);
line.setFill(Color.BLACK);
this.radius = radius;
indicator = createIndicator(toX, toY, radius);
indicator.setFill(Color.BLACK);
// calcolo il punto esatto in cui deve terminare la linea -- al centro del cerchio
this.calculateActualEnd();
this.getChildren().addAll(line, indicator);
}
示例4: drawArrowHead
import javafx.scene.shape.Line; //导入方法依赖的package包/类
/**
* Draws an ArrowHead and returns it in a group.
* Based on code from http://www.coderanch.com/t/340443/GUI/java/Draw-arrow-head-line
* @param startX
* @param startY
* @param endX
* @param endY
* @return Group.
*/
private Group drawArrowHead(double startX, double startY, double endX, double endY) {
Group group = new Group();
double phi = Math.toRadians(40);
int barb = 20;
double dy = startY - endY;
double dx = startX - endX;
double theta = Math.atan2(dy, dx);
double x, y, rho = theta + phi;
for (int j = 0; j < 2; j++) {
x = startX - barb * Math.cos(rho);
y = startY - barb * Math.sin(rho);
Line arrowHeadLine = new Line(startX, startY, x, y);
arrowHeadLine.setStrokeWidth(super.STROKE_WIDTH);
arrowHeadLines.add(arrowHeadLine);
if(super.isSelected()){
arrowHeadLine.setStroke(Constants.selected_color);
}
group.getChildren().add(arrowHeadLine);
rho = theta - phi;
}
return group;
}
示例5: playWinAnimation
import javafx.scene.shape.Line; //导入方法依赖的package包/类
private void playWinAnimation(TileCombo combo) {
Line line = new Line();
line.setStartX(combo.getTile1().getCenter().getX());
line.setStartY(combo.getTile1().getCenter().getY());
line.setEndX(combo.getTile1().getCenter().getX());
line.setEndY(combo.getTile1().getCenter().getY());
line.setStroke(Color.YELLOW);
line.setStrokeWidth(3);
getGameScene().addUINode(line);
Timeline timeline = new Timeline();
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(1),
new KeyValue(line.endXProperty(), combo.getTile3().getCenter().getX()),
new KeyValue(line.endYProperty(), combo.getTile3().getCenter().getY())));
timeline.setOnFinished(e -> gameOver(combo.getWinSymbol()));
timeline.play();
}
示例6: getGraphEdges
import javafx.scene.shape.Line; //导入方法依赖的package包/类
/**
* Returns a group containing the edges between all the segment coordinates.
*/
private Group getGraphEdges() {
Group res = new Group();
ArrayList<ArrayList<Integer>> links = dbm.getDbReader().getLinks(genomeIds);
ArrayList<ArrayList<Integer>> counts = dbm.getDbReader().getLinkWeights(genomeIds);
ArrayList<Integer> xcoords = dbm.getDbReader().getAllXCoord();
ArrayList<Integer> ycoords = dbm.getDbReader().getAllYCoord();
for (int fromId = 1; fromId <= links.size(); fromId++) {
for (int j = 0; j < links.get(fromId - 1).size(); j++) {
int toId = links.get(fromId - 1).get(j);
segmentIds.add(fromId);
segmentIds.add(toId);
Line line = new Line(xcoords.get(fromId - 1), ycoords.get(fromId - 1),
xcoords.get(toId - 1), ycoords.get(toId - 1));
line.setStrokeWidth(counts.get(fromId - 1).get(j));
res.getChildren().add(line);
}
}
System.out.println("Finished creating graph edges");
return res;
}
示例7: populateLineStyleOptions
import javafx.scene.shape.Line; //导入方法依赖的package包/类
/**
* Populates the combobox with linestyle options given a width
* and color.
* @param penWidth
* @param penColor
*/
private void populateLineStyleOptions(double penWidth, Color penColor) {
this.getItems().clear();
LineStyle[] styles = LineStyle.values();
for(LineStyle style : styles) {
Line line = style.getLine();
line.setStartX(-(WIDTH)/2);
line.setEndX(WIDTH/2);
line.setStrokeWidth(penWidth);
line.setStroke(penColor);
this.getItems().add(line);
}
}
示例8: positionedLine
import javafx.scene.shape.Line; //导入方法依赖的package包/类
/**
* Positions and styles the pen according to the information
* from the turtle.
*
* @param startx - starting X position
* @param starty - starting Y position
* @param endx - ending X position
* @param endy - ending Y position
* @param penColor - color of the stroke
* @param penWidth - width of the stroke
* @param penStyleIndex - style index from properties file
* @return the positioned and styled line
*/
private Line positionedLine (double startx,
double starty,
double endx,
double endy,
Color penColor,
String penWidth,
int penStyleIndex) {
Line line = new Line(startx, starty, endx, endy);
line.setTranslateX(endx - (endx - startx) / 2);
line.setTranslateY(endy - (endy - starty) / 2);
line.setStroke(penColor);
line.setStrokeWidth(Double.parseDouble(penWidth));
line.getStrokeDashArray().clear();
for(Double d : assignDashArray(penStyleIndex)) {
line.getStrokeDashArray().add(d);
}
return line;
}
示例9: createIconContent
import javafx.scene.shape.Line; //导入方法依赖的package包/类
public static Node createIconContent() {
Line line = new Line(0, 0, 70, 70);
line.setStroke(Color.web("#b9c0c5"));
line.setStrokeWidth(5);
line.getStrokeDashArray().addAll(15d,15d);
line.setFill(null);
javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
effect.setOffsetX(1);
effect.setOffsetY(1);
effect.setRadius(3);
effect.setColor(Color.rgb(0,0,0,0.6));
line.setEffect(effect);
return line;
}
示例10: start
import javafx.scene.shape.Line; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
Group root = new Group();
Line seeSaw = new Line (60,340,340,140);
seeSaw.setStroke(Color.BLACK);
seeSaw.setStrokeWidth(15);
Circle circle = new Circle(70,280,40);
circle.setStroke(Color.GREENYELLOW);
circle.setFill(Color.ORANGE);
circle.setStrokeWidth(5);
Rectangle rect = new Rectangle(240,90,80,70);
rect.setStroke(Color.MEDIUMPURPLE);
rect.setStrokeWidth(5);
rect.setFill(Color.MEDIUMPURPLE);
Line left = new Line (200,240,160,340);
left.setStrokeWidth(5);
Line right = new Line(200,240,240,340);
right.setStrokeWidth(5);
root.getChildren().addAll(seeSaw,rect,circle,left,right);
Scene scene = new Scene(root, 400, 400,Color.WHITE);
primaryStage.setTitle("SeeSaw");
primaryStage.setScene(scene);
primaryStage.show();
}
示例11: drawingArrowhead
import javafx.scene.shape.Line; //导入方法依赖的package包/类
protected void drawingArrowhead(double x1, double y1, double x2, double y2, Pane pane){
Line line = new Line(x1, y1, x2, y2);
line.setStrokeWidth(3);//设置线的宽度
line.setFill(Color.RED);
line.setStroke(Color.RED);
pane.getChildren().add(line);
// 斜率
double slope = ((((double) y1) - (double) y2)) / (((double) x1) - (((double) x2)));
double arctan = Math.atan(slope);
// This will flip the arrow 45 off of a
// perpendicular line at pt x2
double set45 = 1.57 / 2;
// 箭头永远指向i 而不是 i+1
if (x1 < x2) {
// add 90 degrees to arrow lines
set45 = -1.57 * 1.5;
}
// set length of arrows
int arrlen = 15;
Line line1 = new Line(x2, y2, (x2 + (Math.cos(arctan + set45) * arrlen)), ((y2)) + (Math.sin(arctan + set45) * arrlen));
Line line2 = new Line(x2, y2, (x2 + (Math.cos(arctan - set45) * arrlen)), ((y2)) + (Math.sin(arctan - set45) * arrlen));
line1.setStrokeWidth(3);//设置线的宽度
line1.setStrokeWidth(3);//设置线的宽度
line1.setStroke(Color.RED);//颜色
line2.setStroke(Color.RED);
// 在线上加箭头
pane.getChildren().add(line1);
pane.getChildren().add(line2);
}
示例12: drawingArrowhead
import javafx.scene.shape.Line; //导入方法依赖的package包/类
protected void drawingArrowhead(double x1, double y1, double x2, double y2, Pane pane){
Line line = new Line(x1, y1, x2, y2);
line.setStrokeWidth(3);//设置线的宽度
line.setFill(Color.RED);
line.setStroke(Color.RED);
pane.getChildren().add(line);
// 斜率
double slope = (y1 - y2) / (x1 - x2);
double arctan = Math.atan(slope);
// This will flip the arrow 45 off of a
// perpendicular line at pt x2
double set45 = 1.57 / 2;
// 箭头永远指向i 而不是 i+1
if (x1 < x2) {
// add 90 degrees to arrow lines
set45 = -1.57 * 1.5;
}
// set length of arrows
int arrlen = 15;
Line line1 = new Line(x2, y2, (x2 + (Math.cos(arctan + set45) * arrlen)), ((y2)) + (Math.sin(arctan + set45) * arrlen));
Line line2 = new Line(x2, y2, (x2 + (Math.cos(arctan - set45) * arrlen)), ((y2)) + (Math.sin(arctan - set45) * arrlen));
line1.setStrokeWidth(3);//设置线的宽度
line2.setStrokeWidth(3);//设置线的宽度
line1.setStroke(Color.RED);
line2.setStroke(Color.RED);
// 在线上加箭头
pane.getChildren().add(line1);
pane.getChildren().add(line2);
}
示例13: snapshotNode
import javafx.scene.shape.Line; //导入方法依赖的package包/类
private void snapshotNode(Scene scene, Node node) {
SnapshotParameters params = new SnapshotParameters();
Bounds layoutBounds = node.getLayoutBounds();
Bounds bounds = node.localToScene(layoutBounds);
if (!(bounds.getWidth() > 0 && bounds.getHeight() > 0)) {
return;
}
params.setViewport(new Rectangle2D(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()));
WritableImage writable = new WritableImage((int) bounds.getWidth(), (int) bounds.getHeight());
writable = scene.getRoot().snapshot(params, writable);
ImageView imageView = new ImageView(writable);
imageView.getStyleClass().add("snapshot-image");
imageView.setManaged(false);
imageView.setLayoutX(bounds.getMinX());
imageView.setLayoutY(bounds.getMinY());
imageView.setFitWidth(bounds.getWidth());
imageView.setFitHeight(bounds.getHeight());
Region rect = new Region();
rect.getStyleClass().add("snapshot-background");
rect.setLayoutX(bounds.getMinX() - 5);
rect.setLayoutY(bounds.getMinY() - 5);
rect.resize(bounds.getWidth() + 10, bounds.getHeight() + 10);
rect.setManaged(false);
Line line = new Line();
line.setStartX(bounds.getMaxX() + 4);
line.setStartY(bounds.getMaxY() + 4);
line.setEndX(bounds.getMaxX() + 200);
line.setEndY(bounds.getMaxY() + 200);
line.setStroke(imagePattern);
line.setStrokeWidth(5);
line.setManaged(false);
getChildren().addAll(rect, imageView); //, line);
}
示例14: AnimatedIcon
import javafx.scene.shape.Line; //导入方法依赖的package包/类
public AnimatedIcon() {
iconFill = new SimpleObjectProperty<>(Color.ORANGE);
line1 = new Line(4, 8, 28, 8);
line1.setStrokeWidth(3);
line1.strokeProperty().bind(iconFill);
line1.setManaged(false);
line1.setStrokeLineCap(StrokeLineCap.ROUND);
line2 = new Line(4, 16, 28, 16);
line2.setStrokeWidth(3);
line2.strokeProperty().bind(iconFill);
line2.setManaged(false);
line2.setStrokeLineCap(StrokeLineCap.ROUND);
line3 = new Line(4, 24, 28, 24);
line3.setStrokeWidth(3);
line3.strokeProperty().bind(iconFill);
line3.setManaged(false);
line3.setStrokeLineCap(StrokeLineCap.ROUND);
getChildren().addAll(line1, line2, line3);
setPrefWidth(32);
setPrefHeight(32);
setMinWidth(USE_PREF_SIZE);
setMinHeight(USE_PREF_SIZE);
setMaxWidth(USE_PREF_SIZE);
setMaxHeight(USE_PREF_SIZE);
}
示例15: EdgeController
import javafx.scene.shape.Line; //导入方法依赖的package包/类
public EdgeController(Pane pDrawPane, AbstractDiagramController diagramController) {
aDrawPane = pDrawPane;
dragLine = new Line();
dragLine.setStroke(Color.DARKGRAY);
dragLine.setStrokeWidth(2);
this.diagramController = diagramController;
}