AWT CubicCurve2D 类

简介

CubicCurve2D 类表示 (x,y) 坐标空间中的三次参数曲线段。

类声明

以下是 java.awt.geom.CubicCurve2D 类的声明:

public abstract class CubicCurve2D
    extends Object
        implements Shape, Cloneable

类构造函数

S.N.构造函数 &描述
1protected CubicCurve2D()

这是一个抽象类,不能直接实例化。

类方法

S.N.方法 &描述
1

Object clone()

创建与此对象属于同一类的新对象。

2

boolean contains(double x, double y)

测试指定的坐标是否位于 Shape 的边界内。

3

boolean contains(double x, double y, double w, double h)

测试 Shape 的内部是否完全包含指定的矩形区域。

4

boolean contains(Point2D p)

测试指定的 Point2D 是否位于Shape。

5

boolean contains(Rectangle2D r)

测试 Shape 内部是否完全包含指定的 Rectangle2D。

6

Rectangle getBounds()

返回完全包围 Shape 的整数 Rectangle。

7

abstract Point2D getCtrlP1()

返回第一个控制点。

8

abstract Point2D getCtrlP2()

返回第二个控制点点。

9

abstract double getCtrlX1()

以双精度返回第一个控制点的 X 坐标。

10

abstract double getCtrlX2()

以双精度返回第二个控制点的 X 坐标。

11

abstract double getCtrlY1()

以双精度返回第一个控制点的 Y 坐标。

12

abstract double getCtrlY2()

以双精度返回第二个控制点的 Y 坐标。双精度。

13

double getFlatness()

返回此曲线的平坦度。

14

static double getFlatness(double[] coords, int offset)

返回由指示数组中指示索引处存储的控制点指定的三次曲线的平坦度。

15

static double getFlatness(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2)

返回由指定的三次曲线的平坦度指示的控制点。

16

double getFlatnessSq()

返回此曲线的平坦度的平方。

17

static double getFlatnessSq(double[] coords, int offset)

返回由指示数组中指示索引处存储的控制点指定的三次曲线的平坦度的平方。

18

static double getFlatnessSq(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2)

返回由指示的控制点指定的三次曲线的平坦度的平方。

19

abstract Point2D getP1()

返回起点。

20

abstract Point2D getP2()

返回终点。

21

PathIterator getPathIterator(AffineTransform at)

返回定义形状边界的迭代对象。

22

PathIterator getPathIterator(AffineTransform at, double flatness)

返回定义扁平形状边界的迭代对象。

23

abstract double getX1()

以双精度返回起点的 X 坐标。

24

abstract double getX2()

以双精度返回终点的 X 坐标。

25

abstract double getY1()

以双精度返回起点的 Y 坐标。

26

abstract double getY2()

以双精度返回终点的 Y 坐标。

27

boolean intersects(double x, double y, double w, double h)

测试 Shape 的内部是否与指定的矩形区域的内部相交。

28

boolean intersects(Rectangle2D r)

测试 Shape 的内部是否与指定的 Rectangle2D 的内部相交。

29

void setCurve(CubicCurve2D c)

将此曲线的端点和控制点的位置设置为与指定的 CubicCurve2D 中的位置相同。

30

void setCurve(double[] coords, int offset)

将此曲线的端点和控制点的位置设置为指定数组中指定偏移量的双精度坐标。

31abstract void setCurve(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2)

将此曲线的端点和控制点的位置设置为指定的双精度坐标。

32

void setCurve(Point2D[] pts, int offset)

将此曲线的端点和控制点的位置设置为指定数组中指定偏移量的 Point2D 对象的坐标数组。

33

void setCurve(Point2D p1, Point2D cp1, Point2D cp2, Point2D p2)

将此曲线的端点和控制点的位置设置为指定的 Point2D 坐标。

34

static int resolveCubic(double[] eqn)

求解系数在 eqn 数组中的三次方程,并将非复数根放回同一数组中,返回根的数量。

35

static int resolveCubic(double[] eqn, double[] res)

求解三次方程,其系数在 eqn 数组中,并将非复根放入 res 数组中,返回根的数量。

36

void subdivide(CubicCurve2D left, CubicCurve2D right)

细分此三次曲线,并将得到的两条细分曲线存储到左曲线和右曲线参数中。

37

static void subdivide(CubicCurve2D src, CubicCurve2D left, CubicCurve2D right)

细分 src 参数指定的三次曲线,并将得到的两条细分曲线存储到左曲线和右曲线中参数。

38

static void subdivide(double[] src, int srcoff, double[] left, int leftoff, double[] right, int rightoff)

将存储在 src 数组中索引 srcoff 到 (srcoff + 7) 处的坐标指定的三次曲线细分,并将得到的两个细分曲线存储到相应索引处的两个结果数组中。

继承的方法

此类从以下类继承方法:

  • java.lang.Object

CubicCurve2D 示例

使用您选择的任何编辑器在 D:/ > AWT > com > tutorialspoint > gui > 中创建以下 Java 程序

AWTGraphicsDemo.java
package com.tutorialspoint.gui;

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;

public class AWTGraphicsDemo extends Frame {
       
   public AWTGraphicsDemo(){
      super("Java AWT Examples");
      prepareGUI();
   }

   public static void main(String[] args){
      AWTGraphicsDemo  awtGraphicsDemo = new AWTGraphicsDemo();  
      awtGraphicsDemo.setVisible(true);
   }

   private void prepareGUI(){
      setSize(400,400);
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent windowEvent){
            System.exit(0);
         }        
      }); 
   }    

   @Override
   public void paint(Graphics g) {
      CubicCurve2D shape = new CubicCurve2D.Float();
      shape.setCurve(250F,250F,20F,90F,140F,100F,350F,330F);       
      Graphics2D g2 = (Graphics2D) g; 
      g2.draw (shape);
      Font font = new Font("Serif", Font.PLAIN, 24);
      g2.setFont(font);
      g.drawString("Welcome to TutorialsPoint", 50, 70);
      g2.drawString("CubicCurve2D.Curve", 100, 120);
   }
}

Compile the program using command prompt. Go to D:/ > AWT

and type the following command.

D:\AWT>javac com	utorialspoint\gui\AWTGraphicsDemo.java

如果没有错误,则表示编译成功。使用以下命令运行程序。

D:\AWT>java com.tutorialspoint.gui.AWTGraphicsDemo

验证以下输出

AWT CubicCurve2D

awt_graphics.html