Javafx 2 JavaFX画布:绘制虚线
我正在使用JavaFX在一个屏幕上绘制即时模式 可以画虚线吗 谢谢Javafx 2 JavaFX画布:绘制虚线,javafx-2,Javafx 2,我正在使用JavaFX在一个屏幕上绘制即时模式 可以画虚线吗 谢谢 GC.setLineWidth(2); GC.setLineWidth(2); GC.setStroke(LASSO_COLOR); GC.beginPath(); hdashed(x0, x1, y0); hdashed(x0, x1, y1); vdashed(x0, y0, y1); vdashed(x1, y0, y1); GC.closePath(); GC.stroke(); private void hdashe
GC.setLineWidth(2);
GC.setLineWidth(2);
GC.setStroke(LASSO_COLOR);
GC.beginPath();
hdashed(x0, x1, y0);
hdashed(x0, x1, y1);
vdashed(x0, y0, y1);
vdashed(x1, y0, y1);
GC.closePath();
GC.stroke();
private void hdashed(double x0, double x1, double yy)
{
boolean on = true;
GC.moveTo(x0, yy);
for (double xx=x0; xx<=x1; xx+=DASH_LENGTH) {
if (on) GC.lineTo(xx, yy);
else GC.moveTo(xx, yy);
on = !on;
}
}
private void vdashed(double xx, double y0, double y1)
{
boolean on = true;
GC.moveTo(xx, y0);
for (double yy=y0; yy<=y1; yy+=DASH_LENGTH) {
if (on) GC.lineTo(xx, yy);
else GC.moveTo(xx, yy);
on = !on;
}
}
GC.设定行程(套索颜色);
GC.beginPath();
hdashed(x0,x1,y0);
hdashed(x0,x1,y1);
vdashed(x0,y0,y1);
vdashed(x1,y0,y1);
GC.closePath();
GC.stroke();
私有无效hdashed(双x0,双x1,双yy)
{
布尔开=真;
GC.moveTo(x0,yy);
对于(double xx=x0;xx此功能已添加到JFX 8u40中。有关详细信息,请参阅。虚线有一种方法,一切与以前一样:
...
gc.setStroke(Color.RED);
gc.setLineWidth(1);
gc.setLineDashes(2);
gc.strokeLine(x1, y1, x1, y1);