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

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.


Variable Index

 o angle
 o CLOSED
 o curve
The parametrized curve whose graph is the Bezier curve.
 o defaultFillColor
The default color used to fill the curve on the screen.
 o defaultPsFillColor
The default PostScript command used to color in the curve in PostScript when the fEnv variable useColorPs is "true".
 o defaultPsFillGray
Controls the default density used to fill the curve in postscript.
 o DOT
 o fillColor
The color used to fill the curve on the screen.
 o FILLED
 o inAngle
 o OPEN
 o outAngle
 o 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.
 o 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.
 o psFillColor
The PostScript command used to color in the curve in PostScript when the fEnv variable useColorPs is "true".
 o psFillGray
Controls the density used to fill the curve in postscript.
 o relAngle
 o relScale
 o scale
 o tmax
The parameter limits for curve.
 o tmin
The parameter limits for curve.
 o type
The type determines whether the curve is plotted as an open or closed path, whether or not it is filled and so on.
 o x
 o y

Constructor Index

 o fBezier()
 o fBezier(double[], double[], double[], double[], double[], double[], double[], double[], int, long)
 o fBezier(double[], double[], double[], double[], double[], double[], int, long)
 o fBezier(double[], double[], int)
 o fBezier(double[], double[], int, long)
 o fBezier(double[], double[], int, long, Color)
 o fBezier(double[][])
Creates the fBezier whose vertices are taken from the array list.
 o fBezier(double[][], int)
Creates the fBezier whose vertices are the first nopoints of the array list.
 o fBezier(double[][], int, long)
 o fBezier(double[][], int, long, Color)
 o fBezier(double[][], long)
Creates the fBezier whose vertices are taken from the array list and also sets its type.
 o fBezier(PointList)
Creates the fBezier whose vertices are listed in the PointList.
 o fBezier(PointList, int)
Creates the fBezier whose vertices are the first nopoints of the PointList.
 o fBezier(PointList, int, long)
 o fBezier(PointList, int, long, Color)
 o fBezier(PointList, long)
Creates the fBezier whose vertices are listed in the PointList and also sets its type.
 o fBezier(PointList, long, Color)
Creates the fBezier whose vertices are listed in the PointList and also sets its type and fillColor.

Method Index

 o actionPerformed(ActionEvent)
 o append(double, double)
Appends the vertex with coordinates (x,y) to the Bezier sequence.
 o configure(String, double)
Sets the value of the property specified by the first argument to the second argument.
 o configure(String, double[])
Sets the value of the property specified by the first argument to the second argument.
 o configure(String, String)
 o delete(int)
Removes vertex number vertexNo from the Bezier sequence.
 o drawgfx(Figure, Hashtable, V2V)
 o drawps(Figure, Hashtable, V2V)
 o endEdit()
 o endEditAndDelete()
 o insert(double, double, int)
Inserts a vertex with coordinates (x,y) at position number vertexNo in Bezier sequence.
 o itemStateChanged(ItemEvent)
 o 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 )
 o mouseClicked(MouseEvent)
 o mouseDragged(MouseEvent)
 o mouseEntered(MouseEvent)
 o mouseExited(MouseEvent)
 o mouseMoved(MouseEvent)
 o mousePressed(MouseEvent)
 o mouseReleased(MouseEvent)
 o startEdit(figEdit)
 o toString()

Variables

 o x
 public double x[]
 o y
 public double y[]
 o scale
 public double scale[]
 o relScale
 public double relScale[]
 o angle
 public double angle[]
 o relAngle
 public double relAngle[]
 o inAngle
 public double inAngle[]
 o outAngle
 public double outAngle[]
 o curve
 public fCurve curve
The parametrized curve whose graph is the Bezier curve.

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

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

 o OPEN
 public static long OPEN
 o CLOSED
 public static long CLOSED
 o FILLED
 public static long FILLED
 o DOT
 public static long DOT
 o 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.)

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

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

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

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

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

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

 o 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.

 o 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.

Constructors

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

 o 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.
 o 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.

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

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

 o 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.
 o fBezier
 public fBezier(double list[][],
                int nopoints)
Creates the fBezier whose vertices are the first nopoints of the array list.

 o fBezier
 public fBezier(double list[][],
                int nopoints,
                long type)
 o fBezier
 public fBezier(double list[][],
                int nopoints,
                long type,
                Color color)
 o fBezier
 public fBezier(double xlist[],
                double ylist[],
                int nopoints)
 o fBezier
 public fBezier(double xlist[],
                double ylist[],
                int nopoints,
                long type)
 o fBezier
 public fBezier(double xlist[],
                double ylist[],
                double scale[],
                double relScale[],
                double angle[],
                double relAngle[],
                int nopoints,
                long type)
 o fBezier
 public fBezier(double xlist[],
                double ylist[],
                double scale[],
                double relScale[],
                double angle[],
                double relAngle[],
                double inAngle[],
                double outAngle[],
                int nopoints,
                long type)
 o fBezier
 public fBezier(double xlist[],
                double ylist[],
                int nopoints,
                long type,
                Color color)
 o fBezier
 public fBezier()

Methods

 o append
 public void append(double x,
                    double y)
Appends the vertex with coordinates (x,y) to the Bezier sequence.

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

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

 o 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 )

 o drawgfx
 public void drawgfx(Figure fig,
                     Hashtable env,
                     V2V usr2pxl)
 o drawps
 public String drawps(Figure fig,
                      Hashtable env,
                      V2V usr2ps)
 o startEdit
 public void startEdit(figEdit applet)
 o endEdit
 public void endEdit()
 o endEditAndDelete
 public void endEditAndDelete()
 o mouseClicked
 public void mouseClicked(MouseEvent evt)
 o mousePressed
 public void mousePressed(MouseEvent evt)
 o mouseDragged
 public void mouseDragged(MouseEvent evt)
 o mouseReleased
 public void mouseReleased(MouseEvent evt)
 o mouseEntered
 public void mouseEntered(MouseEvent evt)
 o mouseExited
 public void mouseExited(MouseEvent evt)
 o mouseMoved
 public void mouseMoved(MouseEvent evt)
 o itemStateChanged
 public void itemStateChanged(ItemEvent evt)
 o actionPerformed
 public void actionPerformed(ActionEvent e)
 o configure
 public void configure(String name,
                       String Value)
 o 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].

 o 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].

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

All Packages  Class Hierarchy  This Package  Previous  Next  Index