JavaFX canvas: Atrybut obwiedni ‘dash offset’
Atrybut: dash offset
Typ: double
Wartość domyślna: 0.0
Getter: double getLineDashOffset()
Setter: void setLineDashOffset(double ...)
Save/restore: true
Opis: Przesunięcie początku rysowania linii przerywanej w tablicy dashes
.
Atrybut obwiedni ‘dash offset’
Klasa Listing25_47
Ściągnij klasę Listing25_47
package rozdzial25c; import javafx.application.Application; import javafx.application.Platform; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; import javafx.scene.shape.StrokeLineCap; import javafx.stage.Stage; public class Listing25_47 extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { try { Group root = new Group(); Canvas cv = new Canvas(550, 250); GraphicsContext gc = cv.getGraphicsContext2D(); //- gc.beginPath(); gc.setStroke(Color.GRAY); gc.setLineWidth(1); gc.strokeLine(50, 40, 50, 110); //- gc.setStroke(Color.BLUE); gc.setLineWidth(10); gc.setLineCap(StrokeLineCap.BUTT); //- gc.setLineDashOffset(15); gc.setLineDashes(10, 20, 10, 20); gc.beginPath(); gc.moveTo(50, 50); gc.lineTo(500, 50); gc.stroke(); //- gc.setLineDashOffset(25); gc.setLineDashes(15, 30, 15, 30); gc.beginPath(); gc.moveTo(50, 100); gc.lineTo(500, 100); gc.stroke(); //- double d = gc.getLineDashOffset(); System.out.print(d); //- root.getChildren().add(cv); Scene scene = new Scene(root); stage.setScene(scene); stage.setTitle("Atrybut obwiedni 'dash offset'"); stage.setOnCloseRequest(e -> Platform.exit()); stage.show(); } catch (Exception e) { e.printStackTrace(); } } }
25.0