Arc类是JavaxFX的一部分。圆弧类在指定的某些给定值上创建圆弧,例如圆弧的中心,起始角度,圆弧的长度(长度)和半径。弧形类扩展了形状类。

该类的构造函数是

Arc():创建弧类的空实例

Arc(double centerX, double centerY, double radiusX, double radiusY, double startAngle, double length):创建具有给定坐标和值的弧

常用方法

方法

说明

getCenterX()

返回圆弧中心的x坐标

getCenterY()

返回圆弧中心的y坐标

getRadiusX()

返回圆弧半径的x坐标

getRadiusY()

返回圆弧半径的y坐标

getStartAngle()

返回弧的起始角度

getType()

获取属性类型的值。

setCenterX(double v)

设置圆弧中心的x坐标

setCenterY(double v)

设置圆弧中心的y坐标

setLength(double v)

设置圆弧的长度

setRadiusX(double v)

设置圆弧的X半径

setRadiusY(double v)

设置圆弧的y半径

setStartAngle(double v)

设置圆弧的起始角度

setType(ArcType v)

设置圆弧的圆弧类型

以下程序将说明Arc类的用法

Java程序创建弧

该程序将创建一个名为arc的圆弧(将中心,半径,起始角度和圆弧长度作为参数传递)。弧将在场景内创建,而场景又将在场景内托管。函数setTitle()用于为舞台提供标题。然后创建一个组,并将弧附加到该组上。最后,调用show()方法以显示最终结果。

// Java program to create a arc

import javafx.application.Application;

import javafx.scene.Scene;

import javafx.scene.shape.DrawMode;

import javafx.scene.layout.*;

import javafx.event.ActionEvent;

import javafx.scene.shape.Arc;

import javafx.scene.control.*;

import javafx.stage.Stage;

import javafx.scene.Group;

public class arc_0 extends Application {

// launch the application

public void start(Stage stage)

{

// set title for the stage

stage.setTitle("creating arc");

// create a arc

Arc arc = new Arc(100.0f, 100.0f, 100.0f, 100.0f, 0.0f, 100.0f);

// create a Group

Group group = new Group(arc);

// translate the arc to a position

arc.setTranslateX(100);

arc.setTranslateY(100);

// create a scene

Scene scene = new Scene(group, 500, 300);

// set the scene

stage.setScene(scene);

stage.show();

}

public static void main(String args[])

{

// launch the application

launch(args);

}

}

输出:

Java程序创建弧并为弧设置填充

该程序创建一个以名称arc表示的弧(使用setCenterX(),setCenterY(),setRadiusX(),setRadiusY(),setLength()设置中心,半径,起始角度和弧长)。弧将在场景内创建,而场景又将在场景内托管。函数setTitle()用于为舞台提供标题。然后创建一个组,并将弧附加到该组上。最后,调用show()方法以显示最终结果。功能setFill()用于设置圆弧的填充。

// Java program to create a arc

// and set fill for the arc

import javafx.application.Application;

import javafx.scene.Scene;

import javafx.scene.shape.DrawMode;

import javafx.scene.layout.*;

import javafx.event.ActionEvent;

import javafx.scene.shape.Arc;

import javafx.scene.control.*;

import javafx.stage.Stage;

import javafx.scene.Group;

import javafx.scene.shape.ArcType;

import javafx.scene.paint.Color;

public class arc_1 extends Application {

// launch the application

public void start(Stage stage)

{

// set title for the stage

stage.setTitle("creating arc");

// create a arc

Arc arc = new Arc();

// set center

arc.setCenterX(100.0f);

arc.setCenterY(100.0f);

// set radius

arc.setRadiusX(100.0f);

arc.setRadiusY(100.0f);

// set start angle and length

arc.setStartAngle(0.0f);

arc.setLength(270.0f);

// create a Group

Group group = new Group(arc);

// translate the arc to a position

arc.setTranslateX(100);

arc.setTranslateY(100);

// set fill for the arc

arc.setFill(Color.BLUE);

// create a scene

Scene scene = new Scene(group, 500, 300);

// set the scene

stage.setScene(scene);

stage.show();

}

public static void main(String args[])

{

// launch the application

launch(args);

}

}

输出:

Java程序创建圆弧并指定其填充和圆弧类型

该程序创建一个以名称arc表示的弧(使用setCenterX(),setCenterY(),setRadiusX(),setRadiusY(),setLength()设置中心,半径,起始角度和弧长)。弧将在场景内创建,而场景又将在场景内托管。函数setTitle()用于为舞台提供标题。然后创建一个组,并将弧附加到该组上。最后,调用show()方法以显示最终结果。功能setFill()用于设置圆弧的填充,功能setArcType()用于设置圆弧的ArcType。

// Java Program to create a arc and specify its fill and arc type

import javafx.application.Application;

import javafx.scene.Scene;

import javafx.scene.shape.DrawMode;

import javafx.scene.layout.*;

import javafx.event.ActionEvent;

import javafx.scene.shape.Arc;

import javafx.scene.control.*;

import javafx.stage.Stage;

import javafx.scene.Group;

import javafx.scene.shape.ArcType;

import javafx.scene.paint.Color;

public class arc_2 extends Application {

// launch the application

public void start(Stage stage)

{

// set title for the stage

stage.setTitle("creating arc");

// create a arc

Arc arc = new Arc();

// set center

arc.setCenterX(100.0f);

arc.setCenterY(100.0f);

// set radius

arc.setRadiusX(100.0f);

arc.setRadiusY(100.0f);

// set start angle and length

arc.setStartAngle(0.0f);

arc.setLength(270.0f);

// create a Group

Group group = new Group(arc);

// translate the arc to a position

arc.setTranslateX(100);

arc.setTranslateY(100);

// set fill for the arc

arc.setFill(Color.BLUE);

// set Type of Arc

arc.setType(ArcType.ROUND);

// create a scene

Scene scene = new Scene(group, 500, 300);

// set the scene

stage.setScene(scene);

stage.show();

}

public static void main(String args[])

{

// launch the application

launch(args);

}

}

arc lint java,JavaFX 类 Arc用法及代码示例相关推荐

  1. java中skip的用法,Java PushbackReader skip(long)用法及代码示例

    Java中的PushbackReader类的skip(long)方法用于跳过流中指定数量的字符.此字符数被指定为参数.如果通过跳过到达流的末尾,它将阻塞流,直到它获得一些字符或抛出IOExceptio ...

  2. java linkedblockingqueue_Java LinkedBlockingQueue take()用法及代码示例

    LinkedBlockingQueue的take()方法用于检索和删除此队列的头.如果队列为空,则它将等待直到元素可用.如果在线程上工作并在该过程中使用LinkedBlockingQueue,则此方法 ...

  3. java isnan_Java Double isNaN()用法及代码示例

    Java Double类的isNaN()方法是Java中的内置方法,如果此Double值或指定的double值为Not-a-Number(NaN),则返回true,否则返回false. 用法: pub ...

  4. java cause_Java Throwable getCause()用法及代码示例

    Throwable类的getCause()方法是一种内置方法,用于返回此throwable的原因,如果无法确定发生异常的原因,则返回null.此方法有助于获取由构造函数之一提供的原因,或者由initC ...

  5. compareto java date_Java Date compareTo()用法及代码示例

    Java Date类的compareTo()方法比较两个日期并将它们排序. 用法: public int compareTo(Date anotherDate) 参数:该函数接受单个参数another ...

  6. java throwable_Java Throwable getLocalizedMessage()用法及代码示例

    Throwable类的getLocalizedMessage()方法用于在发生异常时获取Throwable对象的locale-specific描述.它有助于我们根据本地特定消息修改Throwable对 ...

  7. java doublebuffer_Java DoubleBuffer clear()用法及代码示例

    java.nio.CharBuffer类的clear()方法用于清除此缓冲区.在清除此缓冲区时,需要进行以下更改: 位置设置为零 限制设置为容量 商标被丢弃. 用法: public final Dou ...

  8. java filesystem_Java FileSystem isReadOnly()用法及代码示例

    FileSystem类的isReadOnly()方法用于检查此文件系统是否仅允许对其文件存储区进行只读访问.如果文件系统仅允许对其文件存储进行读取访问,则此方法将返回true,否则返回false. 用 ...

  9. java bidi_Java Bidi createLineBidi()用法及代码示例

    java.text.Bidi类的createLineBidi()方法用于创建具有相同基本方向并表示该范围内当前bidi的每个属性的新的bidi对象. 用法: public Bidi createLin ...

最新文章

  1. 我看过的Java方面的好文章
  2. windows下Graphviz安装及入门教程
  3. 阿里云 centos 6.9 安装 mysql 5.7
  4. 编程爱好者学vb还是python-Python语言为什么被称为高级程序设计语言?
  5. 【字节码插桩】AOP 技术 ( “字节码插桩“ 技术简介 | AspectJ 插桩工具 | ASM 插桩工具 )
  6. 消息队列软件产品大比拼
  7. 在dos下用csc命令编译,提示“csc不是内部或外部命令,也不是可运行的程序... ”
  8. vsphere虚拟克隆虚拟服务器,vSphere实战攻略2:虚拟机模板与克隆
  9. Git SSH key配置
  10. Qt文档阅读笔记-Image QML官方解析与实例
  11. 技术文档的撰写_如何撰写出色的技术博客文章
  12. python lxml模块解析html_用lxml解析HTML
  13. linux 中用vi编辑器替换字符
  14. 小tips:JS之浅拷贝与深拷贝
  15. K-Means原理及代码实现
  16. Android 极光推送集成
  17. android音频杂音问题_如何消除音频中的噪声?用这个简单好用的音频剪辑软件就够了...
  18. pt和px区别 pt是逻辑像素,px是物理像素
  19. 常用数据库URL地址的写法
  20. python内置数值运算函数有哪几个_Python这68个内置函数,建议你吃透!

热门文章

  1. 【Python】打印输出200以内的所有素数,并输出素数的个数
  2. html手机和电脑端网页效果相同,关于手机网页和电脑网页相同内容会不会重复收录的问题...
  3. VLC多媒体播放器将字幕srt等 内嵌在视频中且能合并到视频,保存为带字幕的新视频 自媒作首选工具
  4. DLNA」的介紹與應用
  5. 计算机视频分析,暴雨/夜间/人群密集难倒视频分析?三篇CVPR2021论文攻克这些难题...
  6. 用了这么久的PageHelper,你知道原生的分页查询原理和步骤吗
  7. 工作日志:海康IPC SDK实时播放项目建立
  8. 物联网工程专业的迷茫与抉择
  9. 学计算机老了会怎么办,旧电脑我们怎么处理
  10. 动易的默认数据库、用户和密码、认证码大全还有找后台方法