当前位置: 首页>>代码示例>>Java>>正文


Java GraphicsContext.strokeLine方法代码示例

本文整理汇总了Java中javafx.scene.canvas.GraphicsContext.strokeLine方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsContext.strokeLine方法的具体用法?Java GraphicsContext.strokeLine怎么用?Java GraphicsContext.strokeLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.canvas.GraphicsContext的用法示例。


在下文中一共展示了GraphicsContext.strokeLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawShapes

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private static void drawShapes(GraphicsContext gc) {
    gc.setFill(Color.GREEN);
    gc.setStroke(Color.BLUE);
    gc.setLineWidth(5);
    gc.strokeLine(40, 10, 10, 40);
    gc.fillOval(10, 60, 30, 30);
    gc.strokeOval(60, 60, 30, 30);
    gc.fillRoundRect(110, 60, 30, 30, 10, 10);
    gc.strokeRoundRect(160, 60, 30, 30, 10, 10);
    gc.fillArc(10, 110, 30, 30, 45, 240, ArcType.OPEN);
    gc.fillArc(60, 110, 30, 30, 45, 240, ArcType.CHORD);
    gc.fillArc(110, 110, 30, 30, 45, 240, ArcType.ROUND);
    gc.strokeArc(10, 160, 30, 30, 45, 240, ArcType.OPEN);
    gc.strokeArc(60, 160, 30, 30, 45, 240, ArcType.CHORD);
    gc.strokeArc(110, 160, 30, 30, 45, 240, ArcType.ROUND);
    gc.fillPolygon(new double[]{10, 40, 10, 40},
                   new double[]{210, 210, 240, 240}, 4);
    gc.strokePolygon(new double[]{60, 90, 60, 90},
                     new double[]{210, 210, 240, 240}, 4);
    gc.strokePolyline(new double[]{110, 140, 110, 140},
                      new double[]{210, 210, 240, 240}, 4);
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:23,代码来源:ExampleCanvas.java

示例2: drawGrid

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void drawGrid() {
    GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
    // Task: draw a grid paper with horizontal lines 20 pixels apart
    // and the vertical lines 20 pixels apart, as well
    
    double width = drawingCanvas.getWidth();
    double height = drawingCanvas.getHeight();
    
    gc.setStroke(Color.RED);
    for (int x = 0; x <= width; x += 20)
        gc.strokeLine(x, 0, x, height);
    
    for (int y = 0; y <= height; y += 20)
        gc.strokeLine(0, y, width, y);
    
    gc.setStroke(Color.BLUE);
    for (int x = 0; x <= width; x += 100)
        gc.strokeLine(x, 0, x, height);
    
    for (int y = 0; y <= height; y += 100)
        gc.strokeLine(0, y, width, y);
    
}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:24,代码来源:FXMLDocumentController.java

示例3: drawZeroLine

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Draw RSM Zero Lines
 */
public void drawZeroLine() {
    BaseYCanvas yCanvas = this.getYCanvas();
    if (yCanvas == null) {
        return;
    }
    
    GraphicsContext gc1 = getGraphicsContext2D();
    Double width = getWidth();
    Double x = 0d;
    Double y = yCanvas.getYPosByValue(0.0f);
    gc1.setLineWidth(0.618);
    //The color if I set it here to use the Color Properties that I have defined
    //It doesn work !!!! I don't know why If I set it as white color
    //It works perfectly
    gc1.setStroke(Color.WHITE);
    gc1.strokeLine(x, y, width, y);
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:21,代码来源:RSMCanvas.java

示例4: drawLines

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawLines() {
	CoordProjector projector = getProjector();

	GraphicsContext context = getGraphicsContext();

	for (int i = 1; i < 20; i++) {
		//Horizontal Lines
		DrawCoords start = projector.fromBoardCoords(getCoords(1, i));
		DrawCoords end = projector.fromBoardCoords(getCoords(19, i));

		context.strokeLine(start.getX(), start.getY(), end.getX(), end.getY());

		//Vertical Lines
		start = projector.fromBoardCoords(getCoords(i, 1));
		end = projector.fromBoardCoords(getCoords(i, 19));

		context.strokeLine(start.getX(), start.getY(), end.getX(), end.getY());
	}
	Canvas canvas = context.getCanvas();

	StoneDrawer drawer = new SimpleStoneDrawer(canvas);
	double scale = DimensionHelper.getStoneRadius(canvas);
	scale = (context.getLineWidth() * 4) / scale;

	drawer.drawStones(getHandicapStones(9), BLACK, scale);
}
 
开发者ID:GoSuji,项目名称:Suji,代码行数:28,代码来源:SimpleBoardDrawer.java

示例5: drawTextTick

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawTextTick(double x, double y, double value) {
    GraphicsContext gc = getGraphicsContext2D();
    double bigTickLength = 10; //Big Tick
    //Draw ticks and draw texts
    gc.setLineWidth(0.1);
    gc.setStroke(ChartTickColorProperty.getValue());
    gc.strokeLine(x, y, x + bigTickLength, y);
    String strValue = "";
    
    if (value >= 0 && value <= 0.01) {
        strValue = String.format("%.4f m", value);
    }
    else if (value > 0.01 && value <= 0.1) {
        strValue = String.format("%.3f m", value);
    }
    else if (value > 0.1 && value <= 1.0) {
        strValue = String.format("%.3f m", value);
    }
    else if (value > 1.0 && value <= 10.0) {
        strValue = String.format("%.2f m", value);
    }
    else {
        strValue = String.format("%.2f m", value);
    }
    
    gc.setFill(ChartTickColorProperty.getValue());
    gc.fillText(strValue, x + bigTickLength + 3, y + 5);
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:30,代码来源:VolumeYCanvas.java

示例6: drawGrid

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private void drawGrid() {
    double width = drawingCanvas.getWidth();
    double height = drawingCanvas.getHeight();
    double dx = 20;
    double dy = 20;

    GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
    gc.setLineWidth(1);
    gc.setStroke(Color.LIGHTGRAY);

    // write two for loops to draw the horizontal and vertical lines
    // vertical lines
    for (double x = 0; x <= width; x = x + dx) {
        gc.strokeLine(x, 0, x, height);
    }

    // horizontal lines
    for (double y = 0; y <= height; y = y + dy) {
        gc.strokeLine(0, y, width, y);
    }

    dx = 100;
    dy = 100;

    gc.setStroke(Color.DARKGRAY);

    // write two for loops to draw the horizontal and vertical lines
    // vertical lines
    for (double x = 0; x <= width; x = x + dx) {
        gc.strokeLine(x, 0, x, height);
    }

    // horizontal lines
    for (double y = 0; y <= height; y = y + dy) {
        gc.strokeLine(0, y, width, y);
    }
    // Hometask:
    // 2. brush up on your trigonometry and polar coordinate knowledge

}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:41,代码来源:FXMLDocumentController.java

示例7: drawNormalTick

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawNormalTick(double x, double y) {
    GraphicsContext gc = getGraphicsContext2D();
    double tickLength = 5; //Small Tick
    //Draw ticks and draw texts
    gc.setLineWidth(0.1);
    gc.setStroke(ChartTickColorProperty.getValue());
    gc.strokeLine(x, y, x + tickLength, y);
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:10,代码来源:RSMYCanvas.java

示例8: drawGrid

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void drawGrid() {
    GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
    // Task: draw a grid paper with horizontal lines 20 pixels apart
    // and the vertical lines 20 pixels apart, as well

    double width = drawingCanvas.getWidth();
    double height = drawingCanvas.getHeight();

    gc.setStroke(Color.RED);
    for (int x = 0; x <= width; x += 20) {
        gc.strokeLine(x, 0, x, height);
    }

    for (int y = 0; y <= height; y += 20) {
        gc.strokeLine(0, y, width, y);
    }

    gc.setStroke(Color.BLUE);
    for (int x = 0; x <= width; x += 100) {
        gc.strokeLine(x, 0, x, height);
    }

    for (int y = 0; y <= height; y += 100) {
        gc.strokeLine(0, y, width, y);
    }

}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:28,代码来源:FXMLDocumentController.java

示例9: handleMouseClick

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@FXML
private void handleMouseClick(MouseEvent event) {
    double x = event.getX();
    double y = event.getY();
    
    GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
    gc.strokeLine(0, 0, x, y);
    System.out.printf("User clicked at (%.2f, %.2f)\n", x, y);
}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:10,代码来源:FXMLDocumentController.java

示例10: addGrid

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Add a grid to the canvas, send it to the back
 */
public void addGrid() {
    double w = getBoundsInLocal().getWidth();
    double h = getBoundsInLocal().getHeight();

    // add grid
    Canvas grid = new Canvas(w, h);

    // don't catch mouse events
    grid.setMouseTransparent(true);

    GraphicsContext gc = grid.getGraphicsContext2D();

    gc.setStroke(Color.GRAY);
    gc.setLineWidth(1);

    // draw grid lines
    double offset = 50;
    for (double i = offset; i < w; i += offset) {
        gc.strokeLine(i, 0, i, h);
        gc.strokeLine(0, i, w, i);
    }

    getChildren().add(grid);

    grid.toBack();
}
 
开发者ID:INAETICS,项目名称:Drones-Simulator,代码行数:30,代码来源:PannableCanvas.java

示例11: drawHIndicator

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Draw mouse hover indicator
 */
public void drawHIndicator() {
    if (showMouseHoverIndicator.getValue()) {
        double width = getWidth();
        GraphicsContext gc = getGraphicsContext2D();
        gc.setLineWidth(0.1);
        gc.setStroke(CrossIndicatorLineColorProperty.getValue());
        gc.strokeLine(0, mouseY.getValue(), width, mouseY.getValue());
        gc.strokeLine(0, mouseY.getValue(), width, mouseY.getValue());
        gc.strokeLine(0, mouseY.getValue(), width, mouseY.getValue());
        gc.strokeLine(0, mouseY.getValue(), width, mouseY.getValue());
        gc.strokeLine(0, mouseY.getValue(), width, mouseY.getValue());
        gc.strokeLine(0, mouseY.getValue(), width, mouseY.getValue());
    }
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:18,代码来源:BaseCanvas.java

示例12: drawTextTick

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawTextTick(double x, double y, double value) {
    GraphicsContext gc = getGraphicsContext2D();
    double bigTickLength = 10; //Big Tick
    //Draw ticks and draw texts
    gc.setLineWidth(0.1);
    gc.setStroke(ChartTickColorProperty.getValue());
    gc.strokeLine(x, y, x + bigTickLength, y);
    String strValue = "";
    
    if (value >= 0 && value <= 0.01) {
        strValue = String.format("%.4f", value);
    }
    else if (value > 0.01 && value <= 0.1) {
        strValue = String.format("%.3f", value);
    }
    else if (value > 0.1 && value <= 1.0) {
        strValue = String.format("%.3f", value);
    }
    else if (value > 1.0 && value <= 10.0) {
        strValue = String.format("%.2f", value);
    }
    else {
        strValue = String.format("%.2f", value);
    }
    
    gc.setFill(ChartTickColorProperty.getValue());
    gc.fillText(strValue, x + bigTickLength + 3, y + 5);
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:30,代码来源:RSDYCanvas.java

示例13: drawTextTick

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Draw text tick
 * @param x POS
 * @param y POS
 * @param value - the text to be drawn
 */
@Override
public void drawTextTick(double x, double y, double value) {
    GraphicsContext gc = getGraphicsContext2D();
    double bigTickLength = 10; //Big Tick
    //Draw ticks and draw texts
    gc.setLineWidth(0.1);
    gc.setStroke(ChartTickColorProperty.getValue());
    gc.strokeLine(x, y, x + bigTickLength, y);
    String strValue = "";
    
    if (value >= 0 && value <= 0.01) {
        strValue = String.format("%.4f", value);
    }
    else if (value > 0.01 && value <= 0.1) {
        strValue = String.format("%.3f", value);
    }
    else if (value > 0.1 && value <= 1.0) {
        strValue = String.format("%.3f", value);
    }
    else if (value > 1.0 && value <= 10.0) {
        strValue = String.format("%.2f", value);
    }
    else {
        strValue = String.format("%.2f", value);
    }
    
    gc.setFill(ChartTickColorProperty.getValue());
    gc.fillText(strValue, x + bigTickLength + 3, y + 5);
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:36,代码来源:PriceYCanvas.java

示例14: paint

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
     *
     * @param g2d
     */
    @Override
    public void paint(GraphicsContext g2d) {
        super.paint(g2d);

        g2d.setStroke(Paint.valueOf("BLACK"));
        g2d.setLineWidth(0.5);

        g2d.setFill(Paint.valueOf("Red"));
//        g2d.fillText(massKey, 10, 15);

        int index = 0;
        for (double[] myOnPeakData : allMeasuredTrimMasses) {
            double[] myOnPeakNormalizedAquireTimes = allMeasuredTrimMassesTimes.get(index);

            g2d.beginPath();
            g2d.moveTo(mapX(myOnPeakNormalizedAquireTimes[0]), mapY(myOnPeakData[0]));
            for (int i = 0; i < myOnPeakData.length; i++) {
                // line tracing through points
                g2d.lineTo(mapX(myOnPeakNormalizedAquireTimes[i]), mapY(myOnPeakData[i]));

//                // every 6 scans
//                if ((i + 1) % 6 == 0) {
//                    g2d.setStroke(Paint.valueOf("Red"));
//                    g2d.setLineWidth(0.5);
//
//                    if (i < (myOnPeakData.length - 1)) {
//                        double runX = mapX((myOnPeakNormalizedAquireTimes[i] + myOnPeakNormalizedAquireTimes[i + 1]) / 2.0);
//                        g2d.strokeLine(runX, 0, runX, height);
//                    }
//
//                    g2d.setFont(Font.font("Lucida Sans", 8));
//                    g2d.fillText(String.valueOf((int) ((i + 1) / 6)), mapX(myOnPeakNormalizedAquireTimes[i - 4]), height - 2);
//                    g2d.setStroke(Paint.valueOf("BLACK"));
//                    g2d.setLineWidth(0.5);
//                }
                g2d.strokeOval(mapX(myOnPeakNormalizedAquireTimes[i]) - 1, mapY(myOnPeakData[i]) - 1, 2, 2);

            }

            g2d.stroke();
        }

        // tics
        if (tics != null) {
            for (int i = 0; i < tics.length; i++) {
                try {
                    g2d.strokeLine( //
                            mapX(minX), mapY(tics[i].doubleValue()), mapX(maxX), mapY(tics[i].doubleValue()));

                    g2d.fillText(tics[i].toPlainString(),//
                            (float) mapX(minX) - 35f,
                            (float) mapY(tics[i].doubleValue()) + 2.9f);
                } catch (Exception e) {
                }
            }
        }
    }
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:62,代码来源:SummaryRawDataViewForShrimp.java

示例15: draw

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Draws all nucleotides in strand from left to right
 * @param gc: GraphicsContext on which to draw strand
 * Add type functionality
 */
public void draw(GraphicsContext gc) {
	int x2 = x;
	int y2 = y;
	if(r!=0) {
			gc.save();
			gc.translate(x, y);
			gc.rotate(r);
			gc.translate(-x, -y);
	}
	if(type==1){
		for(int i = 0; i < bases.size(); i++) {
			if(bases.get(i) != null){
				bases.get(i).draw(gc,x2,y);
				if(i+1< bases.size()){
					if(bases.get(i+1) != null && bonds.get(i)){
						gc.strokeLine(x2+Nucleotide.getImageSize()*.81, y+Nucleotide.getImageSize()*.81, x2+Nucleotide.getImageSize()*1.10, y+Nucleotide.getImageSize()*.73);
					}
				}
			}
			x2+=Nucleotide.getImageSize();
		}
	}
	else if(type == 0){
		int lx = x2+Nucleotide.getImageSize()*2;
		y2+=Nucleotide.getImageSize();
		x2+=Nucleotide.getImageSize();
		for(int i = 0; i < bases.size(); i++) {
			if(bases.get(i) != null){
				bases.get(i).draw(gc,x2,y2,180);
				if(i+1< bases.size()){
					if(bases.get(i+1) != null && bonds.get(i)){
						//gc.strokeLine(x2,y2,x2+50,y2+50);
						gc.strokeLine(lx-Nucleotide.getImageSize()*.81, y2-Nucleotide.getImageSize()*.81, lx-Nucleotide.getImageSize()*1.10, y2-Nucleotide.getImageSize()*.73);
					}
				}
			}
			x2+=Nucleotide.getImageSize();
			lx+=Nucleotide.getImageSize();
		}
	}
	else{
		System.out.println("Type is not 0 or 1");
	}
	if(r!=0) {
		gc.restore();
	}
}
 
开发者ID:clonex10100,项目名称:Dna-replication-game,代码行数:53,代码来源:Strand.java


注:本文中的javafx.scene.canvas.GraphicsContext.strokeLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。