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


Java GraphicsContext.closePath方法代码示例

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


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

示例1: drawRoundedRect

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public static final void drawRoundedRect(final GraphicsContext CTX, final CtxBounds BOUNDS, final CtxCornerRadii RADII) {
    double x           = BOUNDS.getX();
    double y           = BOUNDS.getY();
    double width       = BOUNDS.getWidth();
    double height      = BOUNDS.getHeight();
    double xPlusWidth  = x + width;
    double yPlusHeight = y + height;

    CTX.beginPath();
    CTX.moveTo(x + RADII.getTopLeft(), y);
    CTX.lineTo(xPlusWidth - RADII.getTopRight(), y);
    CTX.quadraticCurveTo(xPlusWidth, y, xPlusWidth, y + RADII.getTopRight());
    CTX.lineTo(xPlusWidth, yPlusHeight - RADII.getBottomRight());
    CTX.quadraticCurveTo(xPlusWidth, yPlusHeight, xPlusWidth - RADII.getBottomRight(), yPlusHeight);
    CTX.lineTo(x + RADII.getBottomLeft(), yPlusHeight);
    CTX.quadraticCurveTo(x, yPlusHeight, x, yPlusHeight - RADII.getBottomLeft());
    CTX.lineTo(x, y + RADII.getTopLeft());
    CTX.quadraticCurveTo(x, y, x + RADII.getTopLeft(), y);
    CTX.closePath();
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:21,代码来源:Helper.java

示例2: drawRoundedRect

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private static void drawRoundedRect(final GraphicsContext CTX, final CtxBounds BOUNDS, final CtxCornerRadii RADII) {
    double x           = BOUNDS.getX();
    double y           = BOUNDS.getY();
    double width       = BOUNDS.getWidth();
    double height      = BOUNDS.getHeight();
    double xPlusWidth  = x + width;
    double yPlusHeight = y + height;

    CTX.beginPath();
    CTX.moveTo(x + RADII.getTopRight(), y);
    CTX.lineTo(xPlusWidth - RADII.getTopRight(), y);
    CTX.quadraticCurveTo(xPlusWidth, y, xPlusWidth, y + RADII.getTopRight());
    CTX.lineTo(xPlusWidth, yPlusHeight - RADII.getBottomRight());
    CTX.quadraticCurveTo(xPlusWidth, yPlusHeight, xPlusWidth - RADII.getBottomRight(), yPlusHeight);
    CTX.lineTo(x + RADII.getBottomLeft(), yPlusHeight);
    CTX.quadraticCurveTo(x, yPlusHeight, x, yPlusHeight - RADII.getBottomLeft());
    CTX.lineTo(x, y + RADII.getTopRight());
    CTX.quadraticCurveTo(x, y, x + RADII.getTopRight(), y);
    CTX.closePath();
}
 
开发者ID:HanSolo,项目名称:dotmatrix,代码行数:21,代码来源:DotMatrix.java

示例3: draw

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void draw(final GraphicsContext CTX, final boolean FILL, final boolean STROKE) {
    PathIterator pi = getPathIterator(new Affine());

    CTX.setFillRule(WindingRule.WIND_EVEN_ODD == pi.getWindingRule() ? FillRule.EVEN_ODD : FillRule.NON_ZERO);
    CTX.beginPath();

    double[] seg = new double[6];
    int      segType;

    while(!pi.isDone()) {
        segType = pi.currentSegment(seg);
        switch (segType) {
            case PathIterator.MOVE_TO  : CTX.moveTo(seg[0], seg[1]); break;
            case PathIterator.LINE_TO  : CTX.lineTo(seg[0], seg[1]); break;
            case PathIterator.QUAD_TO  : CTX.quadraticCurveTo(seg[0], seg[1], seg[2], seg[3]);break;
            case PathIterator.BEZIER_TO: CTX.bezierCurveTo(seg[0], seg[1], seg[2], seg[3], seg[4], seg[5]);break;
            case PathIterator.CLOSE    : CTX.closePath();break;
            default                    : break;
        }
        pi.next();
    }

    if (FILL)   { CTX.setFill(fill); CTX.fill(); }
    if (STROKE) { CTX.setStroke(stroke); CTX.stroke(); }
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:26,代码来源:Path.java

示例4: render

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void render(Bullet bullet, GraphicsContext gc) {
    gc.save();
    gc.translate(bullet.getX(), bullet.getY());
    gc.transform(new Affine(new Rotate(bullet.getAngle()))); //Rotate the gc to the angle of the bullet's path

    //TODO increase bullet size in general

    if (this == STANDARD) {
        gc.translate(-2, -3); //Move SVG to center of Bullet
        gc.setFill(Color.GRAY);
        gc.beginPath();
        gc.appendSVGPath("M 0 3 Q 0 1 2 0 Q 4 1 4 3 L 4 7 L 0 7 Z"); //SVG PATH OF BULLET
        gc.fill();
        gc.closePath();
    } else if (this == ROCKET) {
        //TODO create rocket SVG
        gc.setFill(Color.GRAY);
        gc.beginPath();
        gc.appendSVGPath("M 0 3 Q 0 1 2 0 Q 4 1 4 3 L 4 7 L 0 7 Z"); //SVG PATH OF BULLET
        gc.fill();
        gc.closePath();
    } else if (this == BOUNCY) {
        gc.setFill(Color.GRAY);
        gc.fillOval(bullet.getX() - bullet.getRadius(), bullet.getY() - bullet.getRadius(), bullet.getRadius() * 2, bullet.getRadius() * 2);
    }

    gc.restore();
}
 
开发者ID:TheBromo,项目名称:netTanks,代码行数:29,代码来源:Bullet.java

示例5: drawRSD

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Draw RS Line
 */
public void drawRSD() {
    BaseTimeCanvas timeCanvas = this.getTimeCanvas();
    if (timeCanvas == null) {
        return;
    }
    
    BaseYCanvas yCanvas = this.getYCanvas();
    if (yCanvas == null) {
        return;
    }
    
    if (denominatorDaily == null || denominatorDaily.isEmpty() ||
        denominatorWeekly == null || denominatorWeekly.isEmpty() ||
        denominatorMonthly == null || denominatorMonthly.isEmpty() ||
        denominatorYearly == null || denominatorYearly.isEmpty()) {
        return;
    }
    
    GraphicsContext gc = getGraphicsContext2D();
    gc.setLineWidth(RSLineWidthProperty.getValue());
    gc.setLineDashes(RSLineDashOffsetProperty.getValue());
    Color curColor = RSLineColorProperty.getValue();
    gc.setStroke(curColor);
    
    if (this.ChartTypeProperty.getValue() == ChartType.DAY.ordinal()){
        rs.doCalculation(dailyData, FXCollections.observableArrayList(denominatorDaily));
    }
    else if (this.ChartTypeProperty.getValue() == ChartType.WEEK.ordinal()) {
        rs.doCalculation(weeklyData, FXCollections.observableArrayList(denominatorWeekly));
    }
    else if (this.ChartTypeProperty.getValue() == ChartType.MONTH.ordinal()) {
        rs.doCalculation(monthlyData, FXCollections.observableArrayList(denominatorMonthly));
    }
    else if (this.ChartTypeProperty.getValue() == ChartType.YEAR.ordinal()) {
        rs.doCalculation(yearlyData, FXCollections.observableArrayList(denominatorYearly));
    }
    //Drawing is to be done here but not now
    Iterator<Calendar> itr = rs.getRSData().keySet().iterator();
    int i = 0;
    while (itr.hasNext()){
        //Get Date
        Calendar date = itr.next();
        //Get RSDValue
        Float rsdValue = rs.getRSDValue(date);
        float value = rsdValue.floatValue();
        Double x = timeCanvas.getXPosByDay(date);
        if (x == null){
            return;
        }
        Double y = yCanvas.getYPosByValue(value);
        if (y == null){
            System.out.println("RSD value is not found at value: " + value + " Date should be : " + date.getTime().toString());
            continue;   
        }
        
        if (i == 0){
            gc.beginPath();
            gc.moveTo(x, y);
        } else {
            gc.lineTo(x, y);
        }    
        i ++;
    }
    
    gc.stroke();
    gc.closePath();
    gc.setLineDashes(0.0d);
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:72,代码来源:RSDCanvas.java

示例6: drawOBV

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Draw OBV Line
 */
public void drawOBV() {
    BaseTimeCanvas timeCanvas = this.getTimeCanvas();
    if (timeCanvas == null) {
        return;
    }
    
    BaseYCanvas yCanvas = this.getYCanvas();
    if (yCanvas == null) {
        return;
    }
    
    GraphicsContext gc = getGraphicsContext2D();
    gc.setLineWidth(OBVLineWidthProperty.getValue());
    gc.setLineDashes(OBVLineDashOffsetProperty.getValue());
    Color curColor = OBVLineColorProperty.getValue();
    gc.setStroke(curColor);
    if (this.ChartTypeProperty.getValue() == ChartType.DAY.ordinal()){
        obv.doCalculation(dailyData);
    }
    else if (this.ChartTypeProperty.getValue() == ChartType.WEEK.ordinal()) {
        obv.doCalculation(weeklyData);
    }
    else if (this.ChartTypeProperty.getValue() == ChartType.MONTH.ordinal()) {
        obv.doCalculation(monthlyData);
    }
    else if (this.ChartTypeProperty.getValue() == ChartType.YEAR.ordinal()) {
        obv.doCalculation(yearlyData);
    }

    Iterator<Calendar> itr = obv.getOBVData().keySet().iterator();
    int i = 0;
    while (itr.hasNext()){
        //Get Date
        Calendar date = itr.next();
        //Get obvVolume
        Double obvVolume = obv.getOBVData().get(date).doubleValue();
        //Since we have shift the OBV to be: the lowest OBV is zero
        //We need to do some transfer here
        Double minObvVolume = obv.getLowestOBV().doubleValue();
        if (minObvVolume < 0) {
            obvVolume += ( -1 * minObvVolume);
        }
        float value = obvVolume.floatValue();
        value/=1000000;
        value *= 10000;
        value = (float)Math.round(value);
        value /= 10000;
        Double x = timeCanvas.getXPosByDay(date);
        if (x == null){
            return;
        }
        Double y = yCanvas.getYPosByValue(value);
        if (y == null){
            System.out.println("obv Volume is not found at value: " + value + " Date should be : " + date.getTime().toString());
            continue;   
        }
        
        if (i == 0){
            gc.beginPath();
            gc.moveTo(x, y);
        } else {
            gc.lineTo(x, y);
        }    
        i ++;
    }
    
    gc.stroke();
    gc.closePath();
    gc.setLineDashes(0.0d);
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:74,代码来源:OBVCanvas.java

示例7: drawLineChart

import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
 * Draw line chart
 */
public void drawLineChart() {
    BaseTimeCanvas timeCanvas = this.getTimeCanvas();
    if (timeCanvas == null) {
        return;
    }
    
    BaseYCanvas priceCanvas = this.getYCanvas();
    if (priceCanvas == null) {
        return;
    }
    
    GraphicsContext gc = getGraphicsContext2D();
    gc.setLineWidth(LineChartWidthProperty.getValue());
    Color curColor = LineChartColorProperty.getValue();
    gc.setStroke(curColor);   
    ObservableList<OHLC> data = FXCollections.observableArrayList();
    if (this.ChartTypeProperty.getValue() == ChartType.DAY.ordinal()){
        data.setAll(dailyData);
    }
    else if (this.ChartTypeProperty.getValue() == ChartType.WEEK.ordinal()) {
        data.setAll(weeklyData);
    }
    else if (this.ChartTypeProperty.getValue() == ChartType.MONTH.ordinal()) {
        data.setAll(monthlyData);
    }
    else if (this.ChartTypeProperty.getValue() == ChartType.YEAR.ordinal()) {
        data.setAll(yearlyData);
    }
    //Can not draw line if only one point
    if (data.size() == 1){
        return;
    }
    for (int i = 0; i<data.size(); i++) {
        int j = i + 1;
        if (j == data.size()){
            //Last point reached
            gc.stroke();
            gc.closePath();
            break;
        }
        OHLC cur = data.get(i);
        OHLC next = data.get(j);

        Calendar calendar = cur.getDate();
        Calendar nextCalendar = next.getDate();
        Double xCenter = timeCanvas.getXPosByDay(calendar);
        Double xCenter_next = timeCanvas.getXPosByDay(nextCalendar);
        if (xCenter == null || xCenter_next == null){
            continue;
        }
        Double xClose = xCenter + new Double((xIntervalProperty.getValue()/2)).intValue() - 1;
        Double xClose_next = xCenter_next + new Double((xIntervalProperty.getValue()/2)).intValue() - 1;
        Double yClose = priceCanvas.getYPosByValue(cur.getClose());
        Double yClose_next = priceCanvas.getYPosByValue(next.getClose());
        if (yClose == null || yClose_next == null) {
            continue;
        }
   
        //Draw line
        if (i == 0){
            gc.beginPath();
            gc.moveTo(xClose, yClose);
        }
        gc.lineTo(xClose_next, yClose_next); 
    }
}
 
开发者ID:ztan5,项目名称:TechnicalAnalysisTool,代码行数:70,代码来源:MainChartCanvas.java


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