本文整理汇总了Java中javafx.scene.canvas.GraphicsContext.stroke方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsContext.stroke方法的具体用法?Java GraphicsContext.stroke怎么用?Java GraphicsContext.stroke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.canvas.GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext.stroke方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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(); }
}
示例2: 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);
}
示例3: 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) {
}
}
}
}
示例4: 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);
}
示例5: 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);
}
}