diff options
author | Kenneth Russel <[email protected]> | 2007-10-09 07:38:25 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2007-10-09 07:38:25 +0000 |
commit | c8e0d487886dbec1e3a994ea36724bbf59f5122a (patch) | |
tree | 0b9588684708a2429b8252ca367777d0b9125bf6 /src/demos/nurbs/knotslidercomponent/KnotPolygon.java | |
parent | 2bdf0b792c0b89cde549087af1676ee558e37aa6 (diff) |
Integration of Tomas Hrasky's port of basic GLU NURBS functionality
from C++ to Java, plus example applications, done as part of his
Bachelor of Science degree at the University of Hradec Králové,
Faculty of Informatics and Management.
Current state of code is documented in
src/classes/com/sun/opengl/impl/nurbs/README.txt.
Example applications require Java 1.5 and are not currently built by
default. Specify -Djogl.nurbs=1 during jogl-demos build with a 1.5
javac on the PATH to build them. Dependent jars are copied to build
output directory.
Deleted old partially-complete GLU NURBS port.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/trunk@223 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos/nurbs/knotslidercomponent/KnotPolygon.java')
-rwxr-xr-x | src/demos/nurbs/knotslidercomponent/KnotPolygon.java | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/src/demos/nurbs/knotslidercomponent/KnotPolygon.java b/src/demos/nurbs/knotslidercomponent/KnotPolygon.java new file mode 100755 index 0000000..5665392 --- /dev/null +++ b/src/demos/nurbs/knotslidercomponent/KnotPolygon.java @@ -0,0 +1,159 @@ +package demos.nurbs.knotslidercomponent; + +import java.awt.Polygon; + +/** + * Object representing knot + * Objekt reprezentující uzel v uzlovém vektoru + * @author Tomáš Hráský + * + */ +@SuppressWarnings("serial") +class KnotPolygon extends Polygon implements Comparable { + /** + * Knot value + * Hodnota uzlu + */ + private Double value; + + /** + * Size of change when moved by one pixel + * Velikost změny při posunu o jeden pixel + */ + private double oneStep; + + /** + * Top space + * Horní mezera osy + */ + private int top; + + /** + * Side space + * Boční mezera osy + */ + private int side; + + /** + * Knot multiplicity + * Násobnost uzlu + */ + private int multi; + + /** + * Creates new instance with given values + * Vytvoří instanci se zadanými hodnotami + * @param d knot value + * @param oneStep change of one pixel movement + * @param top top space + * @param side side space + */ + public KnotPolygon(Double d, double oneStep, int top, int side) { + this.value = d; + xpoints = new int[3]; + ypoints = new int[3]; + npoints = 3; + multi=1; + makeCoords(oneStep, top, side); + } + + /** + * Computes coords of polygon representing knot + * Vypočte souřadnice polygonu reprezentujícího uzel + * @param oneStep change of one pixel movement + * @param top top space + * @param side side space + */ + private void makeCoords(double oneStep, int top, int side) { + this.oneStep = oneStep; + this.top = top; + this.side = side; + + int x = (int) (value / oneStep); + x += side; + + xpoints[0] = x; + xpoints[1] = x - 4; + xpoints[2] = x + 4; + ypoints[0] = top + 2; + ypoints[1] = top + 12; + ypoints[2] = top + 12; + + invalidate(); + } + + /** + * Computes coords from set values + * Vypočte souřadnice podle nastavených hodont + */ + private void makeCoords() { + makeCoords(oneStep, top, side); + } + + /** + * Computes coords from given values + * Vypočte souřadnice podle zadaných hodont + * @param oneStep step of one pixel movement + * @param top top space + * @param side side space + */ + public void update(double oneStep, int top, int side) { + makeCoords(oneStep, top, side); + } + + /** + * Updates coords from given coord of polygon top + * Upraví souřadnice podle nové zadané souřadnice vrcholu polygonu + * @param x nová souřadnice vrcholu + */ + public void updateByX(int x) { + value = oneStep * (x - side); + makeCoords(); + } + + /** + * Updates coords from given value of knot + * Upraví souřadnice polygonu podle nové hodnoty + * @param d nová hodnota + */ + public void updateByValue(Double d){ + value=d; + makeCoords(); + } + + public int compareTo(Object o) { + if (o instanceof KnotPolygon) { + KnotPolygon kp = (KnotPolygon) o; + return getValue().compareTo(kp.getValue()); + } else + return 0; + } + + /** + * Returns knot value + * Vrací hodnotu uzlu + * @return knot value + */ + public Double getValue() { + return value; + } + + /** + * Returns knot multiplicity + * Vrací násobnost uzlu + * @return knot multiplicity + */ + public int getMulti() { + return multi; + } + + /** + * Sets knot multiplicity + * Nastavuje násobnost uzlu + * @param multi knot multiplicity + */ + public void setMulti(int multi) { + this.multi = multi; + } + +} |