All Packages This Package Class Hierarchy Class Search Index
java.lang.Object | +----jkp.geometry.grid.Grid
| Summary |
public class Grid
extends java.lang.Object
{
// Fields 6
private static final int NUMCOLORS;
private Vector grid;
private int gridsize;
private Image image;
private GridPoint maxs;
private GridPoint mins;
// Constructors 2
public Grid(int);
public Grid(int, Grid);
// Methods 39
public static Grid readGrid(InputStream) throws IOException;
private static void readGridData(Grid, int, String);
private static int readGridSize(String);
private static double readLatitude(String);
private static double readLongitude(String);
public void blankImage();
private void debug2(int, int, int, int, Dimension);
private void debugGridPoint(GridPoint, int, int, int, int);
public void fill();
public void fill(MandelParams);
private Image generateImage(Component, int);
public GridPoint getGridPoint(int, int);
public int getGridSize();
public GridPoint getMaxs();
public GridPoint getMins();
public final int gridI(double, Dimension);
public final int gridI(int, Dimension);
int gridIndex(int, int);
public final int gridJ(double, Dimension);
public final int gridJ(int, Dimension);
public final double gridPointScreenHeight(Dimension);
public final double gridPointScreenWidth(Dimension);
public boolean onGrid(int, int);
public void paint(Component, int);
public void resetZ();
public final double screenValueX(int, Dimension);
public final double screenValueY(int, Dimension);
public final int screenX(double, Dimension);
public final int screenX(int, Dimension);
public final int screenY(double, Dimension);
public final int screenY(int, Dimension);
protected Color selectColor(double, int);
protected Color selectColor(int);
public void setGridPoint(GridPoint, int, int);
public String toString();
public void updateExtremeZ();
private final double valueAtI(int);
private final double valueAtJ(int);
protected Color zColor(double, double, double, int);
}
A square grid of three dimensional points (GridPoints) that tracks current and original Z coordinates for each point.
See Also: GridPoint
| Cross Reference |
| Fields |
· NUMCOLORS | Summary | Top |
private static final int NUMCOLORS
Number of colors used to color the grid.
· grid | Summary | Top |
private Vector grid
Holds the list of GridPoints
See Also: GridPoint
· gridsize | Summary | Top |
private int gridsize
The size of this NxN grid.
· image | Summary | Top |
private Image image
Buffered image of this grid to save on repaints.
· maxs | Summary | Top |
private GridPoint maxs
Maximum X/Y/Z values in grid.
· mins | Summary | Top |
private GridPoint mins
Minimum X/Y/Z values in grid.
| Constructors |
· Grid | Summary | Top |
public Grid(int gridsize)
Constructs a new Grid of the given size.
Parameter Description gridsize The size for the NxN grid.
· Grid | Summary | Top |
public Grid(int gridsize,
Grid grid)
Constructs a new Grid of the given size given a preexisting Grid. If the original grid is larger, it will be truncated. If the original grid is smaller, it will be zero-filled on the right and bottom which tends to make the grid data difficult to analyse. This might be changed to sample and fill later. As it's used in jkp.Mesh00 the original will always be larger.
Parameter Description gridsize The size of the new Grid. grid The Grid to copy data from.
| Methods |
· blankImage | Summary | Top |
public void blankImage()
Forget the currently buffered Image.
· debug2 | Summary | Top |
private void debug2(int i,
int j,
int sx,
int sy,
Dimension dim)
Another one like the first.
Parameter Description i +XX+ j +XX+ sx +XX+ sy +XX+ dim +XX+
· debugGridPoint | Summary | Top |
private void debugGridPoint(GridPoint gp,
int x,
int y,
int dx,
int dy)
Top secret routine designed to take over the world.
Parameter Description gp +XX+ x +XX+ y +XX+ dx +XX+ dy +XX+
· fill | Summary | Top |
public void fill()
Fill this Grid with Mandelbrot set data.
· fill | Summary | Top |
public void fill(MandelParams mandparam)
Fill this Grid with Mandelbrot set data using the given parameters.
Parameter Description mandparam Mandelbrot set parameters.
· generateImage | Summary | Top |
private Image generateImage(Component comp,
int numcolors)
Creates buffered image for this Grid
Parameter Description comp The component this image will be painted on later. numcolors The number of colors that can be used.
- Returns:
- The generated Image.
· getGridPoint | Summary | Top |
public GridPoint getGridPoint(int i,
int j)
Returns the GridPoint at a given row and column
Parameter Description i The column index (X). j The row index (Y).
- Returns:
- The GridPoint at that location.
· getGridSize | Summary | Top |
public int getGridSize()
Returns the current grid size.
- Returns:
- The size of the Grid.
· getMaxs | Summary | Top |
public GridPoint getMaxs()
Retrieve maximum values for Grid.
- Returns:
- The maximum X/Y/Z values.
· getMins | Summary | Top |
public GridPoint getMins()
Retrieve minimum values for Grid.
- Returns:
- The minimum X/Y/Z values.
· gridI | Summary | Top |
public final int gridI(double x,
Dimension dim)
Given a grid X data value, determine the grid's column index.
Parameter Description x The grid X data value. dim The dimensions of the component this is being painted on (currently needed as implemented???).
- Returns:
- +XX+
· gridI | Summary | Top |
public final int gridI(int sx,
Dimension dim)
Given an X coordinate on a component, return the grid's column index at that point.
Parameter Description sx The components X coordinate dim The dimensions of the component
- Returns:
- The grid's column index at that point on the component.
· gridIndex | Summary | Top |
int gridIndex(int i,
int j)
Calculates the index in the grid Vector for a given point
Parameter Description i The column index (X). j The row index (Y).
- Returns:
- The Vector index = i * gridsize + j.
· gridJ | Summary | Top |
public final int gridJ(double y,
Dimension dim)
Given a grid Y data value, determine the grid's row index.
Parameter Description y The grid Y data value. dim The dimensions of the component this is being painted on (currently needed as implemented???).
- Returns:
- +XX+
· gridJ | Summary | Top |
public final int gridJ(int sy,
Dimension dim)
Given an Y coordinate on a component, return the grid's row index at that point.
Parameter Description sy The components Y coordinate dim The dimensions of the component
- Returns:
- The grid's row index at that point on the component.
· gridPointScreenHeight | Summary | Top |
public final double gridPointScreenHeight(Dimension dim)
Given the dimensions of a component, calculate the height of a point on the grid.
Parameter Description dim The dimensions of the component that will be painted on.
- Returns:
- The height of a point on that component.
· gridPointScreenWidth | Summary | Top |
public final double gridPointScreenWidth(Dimension dim)
Given the dimensions of a component, calculate the width of a point on the grid.
Parameter Description dim The dimensions of the component that will be painted on.
- Returns:
- The width of a point on that component.
· onGrid | Summary | Top |
public boolean onGrid(int i,
int j)
Tests to see if a point is on the Grid.
Parameter Description i The column index (X). j The row index (Y).
- Returns:
- true if both values are between 0 and gridsize-1 (inclusive), false otherwise
· paint | Summary | Top |
public void paint(Component c,
int numcolors)
Paints the Grid (using the buffered Image if available) on the given Component
Parameter Description c The component to paint() on. numcolors The number of colors to use.
· readGrid | Summary | Top |
public static Grid readGrid(InputStream is) throws IOException
Read 5-minute terrain data file acquired from http://www.ngdc.noaa.gov/mgg/global/seltopo.html
Parameter Description is Stream for URL/File to read from
- Returns:
- The Grid read.
· readGridData | Summary | Top |
private static void readGridData(Grid grid,
int lineno,
String line)
Parse and store the Z values.
Parameter Description grid To be filled. lineno Current line number (row) of data. line The line to parse Z values from.
· readGridSize | Summary | Top |
private static int readGridSize(String line)
Parse the line containing the size of the input data grid.
Parameter Description line The line containing the grid size from the input file.
- Returns:
- The minimum grid size if not square.
· readLatitude | Summary | Top |
private static double readLatitude(String line)
Parse a latitude line (two of them)
Parameter Description line The latitude line from the input file.
- Returns:
- The latitude (negative if South).
· readLongitude | Summary | Top |
private static double readLongitude(String line)
Parse a part of the longitude line
Parameter Description line A part of the longitude line from the input file.
- Returns:
- The longitude (negative if West).
· resetZ | Summary | Top |
public void resetZ()
Resets all Z values in the Grid to their original Z value.
See Also: GridPoint
· screenValueX | Summary | Top |
public final double screenValueX(int sx,
Dimension dim)
Calculate an grid X data value given a X coordinate on a component.
Parameter Description sx The X coordinate on the component. dim The dimensions of the component.
- Returns:
- The grid X data value for that point.
· screenValueY | Summary | Top |
public final double screenValueY(int sy,
Dimension dim)
Calculate an grid Y data value given a Y coordinate on a component.
Parameter Description sy The X coordinate on the component. dim The dimensions of the component
- Returns:
- The grid Y data value for that point.
· screenX | Summary | Top |
public final int screenX(double x,
Dimension dim)
Given an X value on the Grid and the dimensions of a component return the location (X) on the component for a point at that X value.
Parameter Description x A grid X data value dim The dimensions of the component to paint on.
- Returns:
- The component coordinate (X) for the data point.
· screenX | Summary | Top |
public final int screenX(int gi,
Dimension dim)
Given a column index for the Grid and the dimensions of a component return the location (X) on the component for a point in that column
Parameter Description gi A grid column index (X). dim The dimensions of the component to paint on.
- Returns:
- The component coordinate (X) for the grid column.
· screenY | Summary | Top |
public final int screenY(double y,
Dimension dim)
Given an Y value on the Grid and the dimensions of a component return the location (Y) on the component for a point at that Y value.
Parameter Description Y A grid Y data value dim The dimensions of the component to paint on.
- Returns:
- The component coordinate (Y) for the data point.
· screenY | Summary | Top |
public final int screenY(int gj,
Dimension dim)
Given a row index for the Grid and the dimensions of a component return the location (Y) on the component for a point in that row
Parameter Description gj A grid row index (Y). dim The dimensions of the component to paint on.
- Returns:
- The component coordinate (Y) for the grid row.
· selectColor | Summary | Top |
protected Color selectColor(double d,
int numcolors)
Select a color given an altitude value and the number of colors available
Parameter Description d The altitude value. numcolors The number of Colors.
- Returns:
- The selected Color.
· selectColor | Summary | Top |
protected Color selectColor(int i)
Select a color (no black - all brightened)
Parameter Description i This will be modulo'd w/NUMCOLORS to pick a color.
- Returns:
- The selected Color.
· setGridPoint | Summary | Top |
public void setGridPoint(GridPoint gp,
int i,
int j)
Store a GridPoint at the given row and column in the grid Vector
Parameter Description gp The GridPoint to store in the Vector. i The column index (X). j The row index (Y).
· toString | Summary | Top |
public String toString()
Converts Grid to a String - only reports size, mins and maxs
- Returns:
- Some info about the Grid.
- Overrides:
- toString in class Object
· updateExtremeZ | Summary | Top |
public void updateExtremeZ()
Update min/maxs for Grid.
· valueAtI | Summary | Top |
private final double valueAtI(int i)
Given a grid column index, calculate the grid's X data value at that point.
Parameter Description i The column index for the Grid.
- Returns:
- The grid X data value for that column
· valueAtJ | Summary | Top |
private final double valueAtJ(int j)
Given a grid row index, calculate the grid's Y data value at that point.
Parameter Description j The row index for the Grid.
- Returns:
- The grid Y data value for that column
· zColor | Summary | Top |
protected Color zColor(double zlo,
double zhi,
double z,
int numcolors)
Select a color based upon the altitude of a point.
Parameter Description zlo Lowest altitude on Grid. zhi Highest alitude on Grid. z Altitude for this point on the Grid. numcolors Number of colors availble.
- Returns:
- The selected Color.
All Packages This Package Class Hierarchy Class Search IndexFreshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7