`All Packages  Class Hierarchy  This Package  Previous  Next  Index`

# Class figPac.fBezier

```java.lang.Object
|
+----figPac.fBezier
```

public class fBezier
extends Object
implements fElement, S2V, fInteractive, MouseListener, MouseMotionListener, ItemListener, ActionListener
The class fBezier plots a smooth, Bezier curve through a sequence of points. A Bezier curve is a union of Bezier intervals, with each Bezier interval connecting two successive points in the specified sequence. A Bezier interval is determined by two two-dimensional position vectors x1[], x2[] and two two-dimensional velocity vectors v1[], v2[]. The Bezier interval is the parameterized curve x[](t) that is given by the unique cubic polynomial
```x[](t) = a0[] + a1[]*t + a2[]*t**2 + a3[]*t**3
```
obeying the conditions
```x[](0) = x1[]
x'[](0) = v1[]
x[](1) = x2[]
x'[](1) = v2[]
```
Here, x'[](t) is the derivative (i.e. velocity vector) for the curve x[](t) at time t.

The simplest way to specify a Bezier curve to the class fBezier is to just pass it a sequence of position vectors. Then fBezier automatically builds a corresponding sequence of velocity vectors by the following algorithm. Consider the Bezier interval joining x1[] and x2[] and denote by x0[] and x3[] the points in the sequence immediately preceeding and following x1[] and x2[]. Also denote by d0, d1 and d2 the distances from x0[] to x1[], from x1[] to x2[] and from x2[] to x3[] respectively. Then, if none of d0, d1 and d2 are zero,

```v1[] = (d1/2)*(  (x1[]-x0[])/d0  +  (x2[]-x1[])/d1  )
v2[] = (d1/2)*(  (x2[]-x1[])/d1  +  (x3[]-x2[])/d2  )
```
If d1=0
```v1[] = 0
v2[] = 0
```
If d1!=0 but d0=0 replace v1[] by
```v1[] = x2[]-x1[]
```
If d1!=0 but d2=0 replace v2[] by
```v2[] = x2[]-x1[]
```

You can modify this choice of velocity vectors by assigning nondefault values, for example using the configure() methods, to one or more of scale[i], relScale[i], angle[i], relAngle[i]. Here i is the index (starting at i=0) of a point of the sequence. Call the point x[]. Denote by v_in[] the velocity with which the Bezier curve enters x[] (that is, the second velocity vector for the Bezier interval whose second point is x[]) and by v_out[] the velocity with which the Bezier curve leaves x[] (that is, the first velocity vector for the Bezier interval whose first point is x[]). The computeCoeff() method first uses the above algorithm to assign preliminary values to v_in[] and v_out and then

• multiplies the lengths of both v_in[] and v_out[] by scale[i] and then
• multiplies the ratio |v_out[]|/|v_in[]| of the lengths by relScale[i] and then
• rotates both v_in[] and v_out[] by angle[i] degrees and then
• increases the angle between v_in[] and v_out[] by relAngle[i] degrees
One may also choose explicit directions for v_in[] and v_out[]. To do so just change the value, for example using the configure() methods, of inAngle[i] or outAngle[i] from NaN to an angle in degrees.

angle
CLOSED
curve
The parametrized curve whose graph is the Bezier curve.
defaultFillColor
The default color used to fill the curve on the screen.
defaultPsFillColor
The default PostScript command used to color in the curve in PostScript when the fEnv variable useColorPs is "true".
defaultPsFillGray
Controls the default density used to fill the curve in postscript.
DOT
fillColor
The color used to fill the curve on the screen.
FILLED
inAngle
OPEN
outAngle
psDotFont
In the postcsript image, when fBezier.DOT is included in the type of the fPolygon, character number psDotSymbol of the font psDotFont is printed at each vertex.
psDotSymbol
In the postcsript image, when fBezier.DOT is included in the type of the fPolygon, character number psDotSymbol of the font psDotFont is printed at each vertex.
psFillColor
The PostScript command used to color in the curve in PostScript when the fEnv variable useColorPs is "true".
psFillGray
Controls the density used to fill the curve in postscript.
relAngle
relScale
scale
tmax
The parameter limits for curve.
tmin
The parameter limits for curve.
type
The type determines whether the curve is plotted as an open or closed path, whether or not it is filled and so on.
x
y
fBezier()
fBezier(double[], double[], double[], double[], double[], double[], double[], double[], int, long)
fBezier(double[], double[], double[], double[], double[], double[], int, long)
fBezier(double[], double[], int)
fBezier(double[], double[], int, long)
fBezier(double[], double[], int, long, Color)
fBezier(double[][])
Creates the fBezier whose vertices are taken from the array list.
fBezier(double[][], int)
Creates the fBezier whose vertices are the first nopoints of the array list.
fBezier(double[][], int, long)
fBezier(double[][], int, long, Color)
fBezier(double[][], long)
Creates the fBezier whose vertices are taken from the array list and also sets its type.
fBezier(PointList)
Creates the fBezier whose vertices are listed in the PointList.
fBezier(PointList, int)
Creates the fBezier whose vertices are the first nopoints of the PointList.
fBezier(PointList, int, long)
fBezier(PointList, int, long, Color)
fBezier(PointList, long)
Creates the fBezier whose vertices are listed in the PointList and also sets its type.
fBezier(PointList, long, Color)
Creates the fBezier whose vertices are listed in the PointList and also sets its type and fillColor.
actionPerformed(ActionEvent)
append(double, double)
Appends the vertex with coordinates (x,y) to the Bezier sequence.
configure(String, double)
Sets the value of the property specified by the first argument to the second argument.
configure(String, double[])
Sets the value of the property specified by the first argument to the second argument.
configure(String, String)
delete(int)
Removes vertex number vertexNo from the Bezier sequence.
drawgfx(Figure, Hashtable, V2V)
drawps(Figure, Hashtable, V2V)
endEdit()
endEditAndDelete()
insert(double, double, int)
Inserts a vertex with coordinates (x,y) at position number vertexNo in Bezier sequence.
itemStateChanged(ItemEvent)
map(double)
On the interval [i, i+1) returns the cubic polynomial ( a0x[i+1] + a1x[i+1] (t-i) + a2x[i+1] (t-i)^2 + a3x[i+1] (t-i)^3, a0y[i+1] + a1y[i+1] (t-i) + a2y[i+1] (t-i)^2 + a3y[i+1] (t-i)^3 )
mouseClicked(MouseEvent)
mouseDragged(MouseEvent)
mouseEntered(MouseEvent)
mouseExited(MouseEvent)
mouseMoved(MouseEvent)
mousePressed(MouseEvent)
mouseReleased(MouseEvent)
startEdit(figEdit)
toString()
x
``` public double x[]
```
y
``` public double y[]
```
scale
``` public double scale[]
```
relScale
``` public double relScale[]
```
angle
``` public double angle[]
```
relAngle
``` public double relAngle[]
```
inAngle
``` public double inAngle[]
```
outAngle
``` public double outAngle[]
```
curve
``` public fCurve curve
```
The parametrized curve whose graph is the Bezier curve.

tmin
``` public double tmin
```
The parameter limits for curve. Normally tmin=0, tmax = number of Bezier intervals.

tmax
``` public double tmax
```
The parameter limits for curve. Normally tmin=0, tmax = number of Bezier intervals.

OPEN
``` public static long OPEN
```
CLOSED
``` public static long CLOSED
```
FILLED
``` public static long FILLED
```
DOT
``` public static long DOT
```
type
``` public long type
```
The type determines whether the curve is plotted as an open or closed path, whether or not it is filled and so on. To determine the value of type, start with type=0. If you wish to have the curve itself plotted add either fBezier.OPEN or fBezier.CLOSED. In the latter case, a bezier segment from the last vertex to the first vertex is plotted in addition to the curve itself. If you wish to fill the curve add fBezier.FILLED. If you wish to plot the vertices of the curve add fBezier.DOT. (On the screen, a small square will be centered on each vertex. In postscript, the character number psDotSymbol of font psDotFont will be placed as a label at each vertex.)

defaultFillColor
``` public Color defaultFillColor
```
The default color used to fill the curve on the screen.

fillColor
``` public Color fillColor
```
The color used to fill the curve on the screen.

defaultPsFillGray
``` public double defaultPsFillGray
```
Controls the default density used to fill the curve in postscript. Black=0, white=1.

psFillGray
``` public double psFillGray
```
Controls the density used to fill the curve in postscript. Black=0, white=1.

defaultPsFillColor
``` public String defaultPsFillColor
```
The default PostScript command used to color in the curve in PostScript when the fEnv variable useColorPs is "true".

psFillColor
``` public String psFillColor
```
The PostScript command used to color in the curve in PostScript when the fEnv variable useColorPs is "true".

psDotFont
``` public String psDotFont
```
In the postcsript image, when fBezier.DOT is included in the type of the fPolygon, character number psDotSymbol of the font psDotFont is printed at each vertex.

psDotSymbol
``` public int psDotSymbol
```
In the postcsript image, when fBezier.DOT is included in the type of the fPolygon, character number psDotSymbol of the font psDotFont is printed at each vertex.

fBezier
``` public fBezier(PointList p)
```
Creates the fBezier whose vertices are listed in the PointList.

fBezier
``` public fBezier(PointList p,
long type)
```
Creates the fBezier whose vertices are listed in the PointList and also sets its type.

Parameters:
type - The type determines whether the curve is plotted as an open or closed path, whether or not it is filled and so on. To determine the value of type, start with type=0. If you wish to have the curve itself plotted add either fBezier.OPEN or fBezier.CLOSED. In the latter case, a bezier segment from the last vertex to the first vertex is plotted in addition to the curve itself. If you wish to fill the curve add fBezier.FILLED. If you wish to plot the vertices of the curve add fBezier.DOT. (On the screen, a small square will be centered on each vertex. In postscript, the character number psDotSymbol of font psDotFont will be placed as a label at each vertex.)
p - The list of vertices of the curve.
fBezier
``` public fBezier(PointList p,
long type,
Color color)
```
Creates the fBezier whose vertices are listed in the PointList and also sets its type and fillColor.

fBezier
``` public fBezier(PointList p,
int nopoints)
```
Creates the fBezier whose vertices are the first nopoints of the PointList.

fBezier
``` public fBezier(PointList p,
int nopoints,
long type)
```
fBezier
``` public fBezier(PointList p,
int nopoints,
long type,
Color color)
```
fBezier
``` public fBezier(double list[][])
```
Creates the fBezier whose vertices are taken from the array list.

fBezier
``` public fBezier(double list[][],
long type)
```
Creates the fBezier whose vertices are taken from the array list and also sets its type.

Parameters:
type - The type determines whether the curve is plotted as an open or closed path, whether or not it is filled and so on. To determine the value of type, start with type=0. If you wish to have the curve itself plotted add either fBezier.OPEN or fBezier.CLOSED. In the latter case, a bezier segment from the last vertex to the first vertex is plotted in addition to the curve itself. If you wish to fill the curve add fBezier.FILLED. If you wish to plot the vertices of the curve add fBezier.DOT. (On the screen, a small square will be centered on each vertex. In postscript, the character number psDotSymbol of font psDotFont will be placed as a label at each vertex.)
list - The list of vertices of the curve.
fBezier
``` public fBezier(double list[][],
int nopoints)
```
Creates the fBezier whose vertices are the first nopoints of the array list.

fBezier
``` public fBezier(double list[][],
int nopoints,
long type)
```
fBezier
``` public fBezier(double list[][],
int nopoints,
long type,
Color color)
```
fBezier
``` public fBezier(double xlist[],
double ylist[],
int nopoints)
```
fBezier
``` public fBezier(double xlist[],
double ylist[],
int nopoints,
long type)
```
fBezier
``` public fBezier(double xlist[],
double ylist[],
double scale[],
double relScale[],
double angle[],
double relAngle[],
int nopoints,
long type)
```
fBezier
``` public fBezier(double xlist[],
double ylist[],
double scale[],
double relScale[],
double angle[],
double relAngle[],
double inAngle[],
double outAngle[],
int nopoints,
long type)
```
fBezier
``` public fBezier(double xlist[],
double ylist[],
int nopoints,
long type,
Color color)
```
fBezier
``` public fBezier()
```
append
``` public void append(double x,
double y)
```
Appends the vertex with coordinates (x,y) to the Bezier sequence.

insert
``` public void insert(double x,
double y,
int vertexNo)
```
Inserts a vertex with coordinates (x,y) at position number vertexNo in Bezier sequence.

delete
``` public void delete(int vertexNo)
```
Removes vertex number vertexNo from the Bezier sequence.

map
``` public double[] map(double t)
```
On the interval [i, i+1) returns the cubic polynomial ( a0x[i+1] + a1x[i+1] (t-i) + a2x[i+1] (t-i)^2 + a3x[i+1] (t-i)^3, a0y[i+1] + a1y[i+1] (t-i) + a2y[i+1] (t-i)^2 + a3y[i+1] (t-i)^3 )

drawgfx
``` public void drawgfx(Figure fig,
Hashtable env,
V2V usr2pxl)
```
drawps
``` public String drawps(Figure fig,
Hashtable env,
V2V usr2ps)
```
startEdit
``` public void startEdit(figEdit applet)
```
endEdit
``` public void endEdit()
```
endEditAndDelete
``` public void endEditAndDelete()
```
mouseClicked
``` public void mouseClicked(MouseEvent evt)
```
mousePressed
``` public void mousePressed(MouseEvent evt)
```
mouseDragged
``` public void mouseDragged(MouseEvent evt)
```
mouseReleased
``` public void mouseReleased(MouseEvent evt)
```
mouseEntered
``` public void mouseEntered(MouseEvent evt)
```
mouseExited
``` public void mouseExited(MouseEvent evt)
```
mouseMoved
``` public void mouseMoved(MouseEvent evt)
```
itemStateChanged
``` public void itemStateChanged(ItemEvent evt)
```
actionPerformed
``` public void actionPerformed(ActionEvent e)
```
configure
``` public void configure(String name,
String Value)
```
configure
``` public void configure(String name,
double Value)
```
Sets the value of the property specified by the first argument to the second argument. At the present time, the following properties are supported: type, vertexIscale, vertexIrelScale, vertexIangle, vertexIrelAngle, vertexIinAngle, vertexIoutAngle. Here I is an integer (starting at zero) specifying the vertex number. For example the property with name "vertex3angle" refers to angle[3].

configure
``` public void configure(String name,
double Value[])
```
Sets the value of the property specified by the first argument to the second argument. At the present time, the following properties are supported: vertexI. Here I is an integer (starting at zero) specifying the vertex number. For example the property with name "vertex3" refers to x[3] and y[3].

toString
``` public String toString()
```
Overrides:
toString in class Object

`All Packages  Class Hierarchy  This Package  Previous  Next  Index`