moebiusViewer.shape
Class Grid

java.lang.Object
  extended bymoebiusViewer.shape.AbstractShape
      extended bymoebiusViewer.shape.Grid
All Implemented Interfaces:
java.lang.Cloneable, MoebiusShape, java.io.Serializable

public class Grid
extends AbstractShape

A Grid is a 2-dimensional quadrilateral mesh. In order to handle families of closed curves, there is a flag

isClosed
to determine whether the rows are to be considered as closed curves (we saw no need for doubly periodic grids)

See Also:
Serialized Form

Field Summary
 double[][] im
           
 double[][] re
           
 
Fields inherited from class moebiusViewer.shape.AbstractShape
EPS, EPSSQR, propertyChangeSupport, toolList
 
Constructor Summary
Grid()
          Creates a Grid with 1 row, 1 colum, located at the zero
Grid(int m, int n)
          Creates a Grid with integer coordinates, lower left corner at (0,0), upper right corner at (m,n)
 
Method Summary
 void draw(MoebiusGraphics context)
          Draws the grid
 Complex[][] getCoords()
          Returns the coordinates as a freshly created Complex array
 void getCoords(Complex[][] pts, int i0, int j0)
          writes the coordinates between row
 Complex getCoords(int i, int j)
          Returns the coordinate in row
 boolean getDrawHorizontalLines()
          Returns the boolean that determines whether the horizontal lines are drawn
 boolean getDrawPoints()
          Returns the boolean that determines whether the points are drawn
 boolean getDrawVerticalLines()
          Returns the boolean that determines whether the vertical lines are drawn
 Complex[] getInterpolatedRow(double t)
           
 boolean getIsClosed()
          Returns the boolean that tells whether horizontal curves are to be treated as closed
 int getNumColums()
          Returns the number of colums
 int getNumRows()
          Returns the number of Rows
 void getProjectiveCoords(int i, int j, Complex z)
          Writes the coordinate in row
 Complex[][] getProjectiveCoords(int i0, int j0, int i1, int j1)
          Returns the coordinates in the intersection of the integer rectangle
 Complex[] getRow(int i)
           
 void makeRuled()
          Equivalent to
 void makeRuled(int startRow, int endRow)
          Does nothing unless
 void setCoords(Complex[][] pts)
          Sets the dimensions of the grid to the dimensions of pts and uses the entries of pts (as far as they are non-null) as coordinates.
 void setDrawHorizontalLines(boolean b)
          Sets the boolean that determines whether the horizontal lines are drawn
 void setDrawPoints(boolean b)
          Sets the boolean that determines whether the points are drawn
 void setDrawVerticalLines(boolean b)
          Sets the boolean that determines whether the vertical lines are drawn
 void setIsClosed(boolean v)
          Sets the boolean that tells whether horizontal curves are to be treated as closed
 void setNumColums(int newNumCols)
          Change the number of colums, by truncation if the number of colums is getting smaller, by linear extrapolation if it is getting bigger.
 void setNumRows(int newNumRows)
          Change the number of rows, by truncation if the number of rows is getting smaller, by linear extrapolation if it is getting bigger.
 void setProjectiveCoords(int i, int j, Complex p)
          Sets the coordinate in row
 void setProjectiveCoords(int i, int j, double a, double b)
          Sets the coordinate in row
 void setRow(int i, Complex[] pts)
          First sets the number of colums to the length of
 
Methods inherited from class moebiusViewer.shape.AbstractShape
addPropertyChangeListener, clone, dontFirePropertyChange, equals, firePropertyChange, firePropertyChange, getColor, getFilled, getLabel, getLineWidth, getPickable, getPointOutline, getPointRadius, getShowLabel, getString, getTools, isDoFirePropertyChange, isPickable, removePropertyChangeListener, reset, setColor, setDoFirePropertyChange, setFilled, setLabel, setLineWidth, setPickable, setPointOutline, setPointRadius, setShowLabel
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

re

public double[][] re

im

public double[][] im
Constructor Detail

Grid

public Grid()
Creates a Grid with 1 row, 1 colum, located at the zero


Grid

public Grid(int m,
            int n)
Creates a Grid with integer coordinates, lower left corner at (0,0), upper right corner at (m,n)

Method Detail

getNumRows

public int getNumRows()
Returns the number of Rows


setNumRows

public void setNumRows(int newNumRows)
Change the number of rows, by truncation if the number of rows is getting smaller, by linear extrapolation if it is getting bigger.
setNumRows(n)
is equivalent to
setNumRows(1)
if n is less than 1.


getNumColums

public int getNumColums()
Returns the number of colums


setNumColums

public void setNumColums(int newNumCols)
Change the number of colums, by truncation if the number of colums is getting smaller, by linear extrapolation if it is getting bigger.
setNumColums(n)
is equivalent to
setNumRows(1)
if n is less than 1.


getRow

public Complex[] getRow(int i)

getInterpolatedRow

public Complex[] getInterpolatedRow(double t)

setRow

public void setRow(int i,
                   Complex[] pts)
First sets the number of colums to the length of
pts
. If
i
is the index of an existing row, pts is copied to the coordinates of the i'th row. Otherwise, the number of rows is first set to
i+1
. If
i
is larger than
numRows+1
, the in-between rows are filled by linear interpolation.
setRow(i,pts)
does nothing for negative i or arrays pts of length 0.


makeRuled

public void makeRuled(int startRow,
                      int endRow)
Does nothing unless
pts
are existing rows. The in-between rows are set by linear interpolation, so the vertical curves are ruled (straight) in this region.


makeRuled

public void makeRuled()
Equivalent to
makeRuled(0, numRows - 1)
. Makes the whole grid ruled


getIsClosed

public boolean getIsClosed()
Returns the boolean that tells whether horizontal curves are to be treated as closed


setIsClosed

public void setIsClosed(boolean v)
Sets the boolean that tells whether horizontal curves are to be treated as closed


getProjectiveCoords

public Complex[][] getProjectiveCoords(int i0,
                                       int j0,
                                       int i1,
                                       int j1)
Returns the coordinates in the intersection of the integer rectangle
[i0,i1] x [j0,j1]
 with the grids own index rectangle
        as a freshly created Complex array


getCoords

public Complex[][] getCoords()
Returns the coordinates as a freshly created Complex array


getCoords

public void getCoords(Complex[][] pts,
                      int i0,
                      int j0)
writes the coordinates between row
i0
 and
        row 
i0+pts.length
and between colum
j0
and
j0+pts[0].length
into the array
pts
. Produces index out of bound exceptions if some of these indices are invalid


getCoords

public Complex getCoords(int i,
                         int j)
Returns the coordinate in row
i
, colum
j
as a freshly created Complex


getProjectiveCoords

public void getProjectiveCoords(int i,
                                int j,
                                Complex z)
Writes the coordinate in row
i
, colum
j
into the Complex number z. Will produce index out of bound exceptions if either
i
does not refer to an existing row or if the grid is not closed and
j
points to a non-existing colum


setProjectiveCoords

public void setProjectiveCoords(int i,
                                int j,
                                double a,
                                double b)
Sets the coordinate in row
i
, colum
j
Will produce index out of bound exceptions if either
i
does not refer to an existing row or if the grid is not closed and
j
points to a non-existing colum


setProjectiveCoords

public void setProjectiveCoords(int i,
                                int j,
                                Complex p)
Sets the coordinate in row
i
, colum
j
Will produce index out of bound exceptions if either
i
does not refer to an existing row or if the grid is not closed and
j
points to a non-existing colum


setCoords

public void setCoords(Complex[][] pts)
Sets the dimensions of the grid to the dimensions of pts and uses the entries of pts (as far as they are non-null) as coordinates.


draw

public void draw(MoebiusGraphics context)
Draws the grid

Specified by:
draw in interface MoebiusShape
Overrides:
draw in class AbstractShape

getDrawHorizontalLines

public boolean getDrawHorizontalLines()
Returns the boolean that determines whether the horizontal lines are drawn


setDrawHorizontalLines

public void setDrawHorizontalLines(boolean b)
Sets the boolean that determines whether the horizontal lines are drawn


getDrawVerticalLines

public boolean getDrawVerticalLines()
Returns the boolean that determines whether the vertical lines are drawn


setDrawVerticalLines

public void setDrawVerticalLines(boolean b)
Sets the boolean that determines whether the vertical lines are drawn


getDrawPoints

public boolean getDrawPoints()
Returns the boolean that determines whether the points are drawn


setDrawPoints

public void setDrawPoints(boolean b)
Sets the boolean that determines whether the points are drawn