AWT CubicCurve2D類


CubicCurve2D類規定的三次引數曲線段(X,Y)坐標空間。

類的宣告

以下是的宣告類java.awt.geom.CubicCurve2D:

public abstract class CubicCurve2D
   extends Object
      implements Shape, Cloneable

類別建構函式

S.N. 建構函式與說明
1 protected CubicCurve2D() 
這是一個抽象類,不能直接範例化。

類方法

S.N. 方法和說明
1 Object clone() 
Creates a new object of the same class as this object.
2 boolean contains(double x, double y) 
Tests if the specified coordinates are inside the boundary of the Shape.
3 boolean contains(double x, double y, double w, double h) 
Tests if the interior of the Shape entirely contains the specified rectangular area.
4 boolean contains(Point2D p) 
Tests if a specified Point2D is inside the boundary of the Shape.
5 boolean contains(Rectangle2D r) 
Tests if the interior of the Shape entirely contains the specified Rectangle2D.
6 Rectangle getBounds() 
Returns an integer Rectangle that completely encloses the Shape.
7 abstract Point2D getCtrlP1() 
Returns the first control point.
8 abstract Point2D getCtrlP2() 
Returns the second control point.
9 abstract double getCtrlX1() 
Returns the X coordinate of the first control point in double precision.
10 abstract double getCtrlX2() 
Returns the X coordinate of the second control point in double precision.
11 abstract double getCtrlY1() 
Returns the Y coordinate of the first control point in double precision.
12 abstract double getCtrlY2() 
Returns the Y coordinate of the second control point in double precision.
13 double getFlatness() 
Returns the flatness of this curve.
14 static double getFlatness(double[] coords, int offset) 
Returns the flatness of the cubic curve specified by the control points stored in the indicated array at the indicated index.
15 static double getFlatness(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) 
Returns the flatness of the cubic curve specified by the indicated control points.
16 double getFlatnessSq() 
Returns the square of the flatness of this curve.
17 static double getFlatnessSq(double[] coords, int offset) 
Returns the square of the flatness of the cubic curve specified by the control points stored in the indicated array at the indicated index.
18 static double getFlatnessSq(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) 
Returns the square of the flatness of the cubic curve specified by the indicated control points.
19 abstract Point2D getP1() 
Returns the start point.
20 abstract Point2D getP2() 
Returns the end point.
21 PathIterator getPathIterator(AffineTransform at) 
Returns an iteration object that defines the boundary of the shape.
22 PathIterator getPathIterator(AffineTransform at, double flatness) 
Return an iteration object that defines the boundary of the flattened shape.
23 abstract double getX1() 
Returns the X coordinate of the start point in double precision.
24 abstract double getX2() 
Returns the X coordinate of the end point in double precision.
25 abstract double getY1() 
Returns the Y coordinate of the start point in double precision.
26 abstract double getY2() 
Returns the Y coordinate of the end point in double precision.
27 boolean intersects(double x, double y, double w, double h) 
Tests if the interior of the Shape intersects the interior of a specified rectangular area.
28 boolean intersects(Rectangle2D r) 
Tests if the interior of the Shape intersects the interior of a specified Rectangle2D.
29 void setCurve(CubicCurve2D c) 
Sets the location of the end points and control points of this curve to the same as those in the specified CubicCurve2D.
30 void setCurve(double[] coords, int offset) 
Sets the location of the end points and control points of this curve to the double coordinates at the specified offset in the specified array.
31 abstract void setCurve(double x1, double y1, double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) 
Sets the location of the end points and control points of this curve to the specified double coordinates.
32 void setCurve(Point2D[] pts, int offset) 
Sets the location of the end points and control points of this curve to the coordinates of the Point2D objects at the specified offset in the specified array.
33 void setCurve(Point2D p1, Point2D cp1, Point2D cp2, Point2D p2) 
Sets the location of the end points and control points of this curve to the specified Point2D coordinates.
34 static int solveCubic(double[] eqn) 
Solves the cubic whose coefficients are in the eqn array and places the non-complex roots back into the same array, returning the number of roots.
35 static int solveCubic(double[] eqn, double[] res) 
Solve the cubic whose coefficients are in the eqn array and place the non-complex roots into the res array, returning the number of roots.
36 void subdivide(CubicCurve2D left, CubicCurve2D right) 
Subdivides this cubic curve and stores the resulting two subdivided curves into the left and right curve parameters.
37 static void subdivide(CubicCurve2D src, CubicCurve2D left, CubicCurve2D right)
Subdivides the cubic curve specified by the src parameter and stores the resulting two subdivided curves into the left and right curve parameters.
38 static void subdivide(double[] src, int srcoff, double[] left, int leftoff, double[] right, int rightoff) 
Subdivides the cubic curve specified by the coordinates stored in the src array at indices srcoff through (srcoff + 7) and stores the resulting two subdivided curves into the two result arrays at the corresponding indices.

繼承的方法

這個類繼承的方法從以下類:

  • java.lang.Object

CubicCurve2D 範例

選擇使用任何編輯器建立以下java程式 D:/ > AWT > com > yiibai > gui >

AWTGraphicsDemo.java
package com.yiibai.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);
   }
}

編譯程式,使用命令提示字元。進入到D:/> AWT,然後鍵入以下命令。

D:AWT>javac comyiibaiguiAWTGraphicsDemo.java

如果沒有錯誤出現,這意味著編譯成功。使用下面的命令來執行程式。

D:AWT>java com.yiibai.gui.AWTGraphicsDemo

驗證下面的輸出

AWT CubicCurve2D