本文整理汇总了Java中javafx.scene.canvas.GraphicsContext.strokeOval方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsContext.strokeOval方法的具体用法?Java GraphicsContext.strokeOval怎么用?Java GraphicsContext.strokeOval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.canvas.GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext.strokeOval方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: drawShapes
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private void drawShapes() {
GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
gc.setStroke(Color.RED);
gc.setFill(Color.YELLOW);
gc.setLineWidth(5);
double w = 100;
double h = 100;
double width = drawingCanvas.getWidth();
double height = drawingCanvas.getHeight();
gc.fillRect(width / 2 - w / 2, height / 2 - h / 2, w, h);
gc.strokeRect(width / 2 - w / 2, height / 2 - h / 2, w, h);
double initialX = 100;
double initialY = 200;
double dr = -20;
for (double radius = 100; radius >= 20; radius += dr, initialX -= dr, initialY -= dr) {
gc.strokeOval(initialX, initialY, 2 * radius, 2 * radius);
}
// Hometasks:
// 1. draw a sun!
// 2. draw regular ngons (fix the function that I wrote)
}
示例3: draw
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void draw() {
drawGrid();
GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
gc.setStroke(Color.BLACK);
gc.setLineWidth(5);
gc.setFill(Color.YELLOW);
gc.fillRect(300 - 50, 200 - 50, 100, 100);
gc.strokeRect(300 - 50, 200 - 50, 100, 100);
gc.setFill(Color.GREEN);
gc.fillOval(100, 100, 200, 100);
gc.strokeOval(100, 100, 200, 100);
// Hometasks:
// 1. Draw a circle right at the center with radius of 150 pixels
// 2. Draw 20 concentric circles in the top left box
// 3. Draw a sun (circle + rays)
// 4. Draw a regular n-gon (like pentagon)
}
示例4: draw
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void draw(int type,GraphicsContext gc){
if(type == 0) {
gc.strokeOval(pos[0]-RANGE/2,pos[1]-RANGE/2,RANGE,RANGE);
}
else if(type > 0 && type < 5) {
gc.setFill(Color.BROWN);
gc.fillOval(pos[0]-RANGE/2,pos[1]-RANGE/2,RANGE/2,RANGE/2);
}
}
示例5: task1
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void task1() {
GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
double radius = 150;
gc.setFill(new Color(9 / 255.0, 59 / 255.0, 220 / 255.0, 0.75));
gc.fillOval(drawingCanvas.getWidth() / 2 - radius, drawingCanvas.getHeight() / 2 - radius, radius * 2, radius * 2);
gc.setStroke(Color.BLACK);
gc.strokeOval(drawingCanvas.getWidth() / 2 - radius, drawingCanvas.getHeight() / 2 - radius, radius * 2, radius * 2);
}
示例6: task2
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void task2() {
GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
for (double radius = 50; radius > 0; radius -= 2.5) {
gc.strokeOval(50 - radius, 50 - radius, radius * 2, radius * 2);
}
}
示例7: 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) {
}
}
}
}