NetCharts Pro

netcharts.pro.common.rectangular
Class NFGrid

java.lang.Object
  extended by netcharts.pro.common.NFBaseClass
      extended by netcharts.pro.common.rectangular.NFGrid
All Implemented Interfaces:
java.lang.Cloneable

public class NFGrid
extends NFBaseClass

The NFGrid class defines a single "grid". A grid consists of a line style, a background, and a mapping to an X and Y axis. Charts that support grids (any that have X and Y axes) can draw multiple grid overlays. If multiple axes are used, each set of axes can have a unique grid or grids mapped via the axisMap attribute of the grid. As grids are added to a chart, they are stored in a grid series object.

An example of grid usage is shown here:

 ...
        NFBarchart bc = new NFBarchart();
        // axis
        NFAxis left = new NFAxis();
        left.setScale(0,100,25);
        left.setTextFont(sansserif);
        left.setTextColor(Color.gray.brighter());
        left.setTicFormat(new NFFormat(NFFormat.FLOAT, "%.3f"));

        NFAxis right = new NFAxis();
        right.setTextFont(sansserif);
        right.setTextColor(Color.blue);
        right.setScale(0,20,2);

        NFGrid grid = new NFGrid(Color.white, Color.blue);
        grid.setGridLine(NFGridLine.SOLID, 1, Color.gray, NFGridLine.HORIZONTAL);
        grid.setYAxis(left); // map this grid to left axis.
        bc.addGrid(grid); // add to chart.

        NFGrid grid2 = new NFGrid();
        grid2.setGridLine(NFGridLine.SOLID, 1, Color.blue.darker(), NFGridLine.BOTH);
        grid2.setYAxis(right); // map this grid to right axis.
        bc.addGrid(grid2); // add to chart.
        
The example above creates a barchart that has two grids. The first grid has a white background with blue border and horizontal gray bars. It is mapped to the left and bottom axes. The second grid has no background or border color, but has blue lines mapped to the right and bottom axes.


Constructor Summary
NFGrid()
          Constructs a default grid
NFGrid(java.awt.Color backgroundColor, java.awt.Color borderColor)
          Constructs a grid with the given background, and border color
NFGrid(java.awt.Color lineColor, java.awt.Color backgroundColor, java.awt.Color borderColor)
          Constructs a grid with the given line, background, and border color
 
Method Summary
 java.lang.Object clone()
          Does a deep copy of this grid object
 NFAxisMap getAxisMap()
          Returns the axis map for this grid
 NFGridBackground getBackground()
          Get the grid background
 NFGridLine getGridLine()
          Get the grid line for this grid.
 void setAxisMap(NFAxisMap axisMap)
          Set the axis map for this grid
 void setBackground(java.awt.Color backgroundColor, java.awt.Color borderColor)
          Convenience method to set this grid's background object.
 void setBackground(NFGridBackground background)
          Set the grid background.
 void setGridLine(java.awt.Color lineColor)
          Convenience method to set the grid line for this grid object.
 void setGridLine(int style, int thickness, java.awt.Color lineColor, int lineLayout)
          Convenience method to set this grid's line.
 void setGridLine(NFGridLine gridLine)
          Set the grid line.
 void setXAxis(NFAxis axis)
          Sets which axis should be used to map vertical lines.
 void setYAxis(NFAxis axis)
          Sets which axis should be used to map horizontal lines.
 
Methods inherited from class netcharts.pro.common.NFBaseClass
getModified, getUserObject, setModified, setUserObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NFGrid

public NFGrid()
Constructs a default grid


NFGrid

public NFGrid(java.awt.Color backgroundColor,
              java.awt.Color borderColor)
Constructs a grid with the given background, and border color

Parameters:
backgroundColor - Color of grid background. If null, grid is transparent
borderColor - Color of grid border. If null, border not drawn.

NFGrid

public NFGrid(java.awt.Color lineColor,
              java.awt.Color backgroundColor,
              java.awt.Color borderColor)
Constructs a grid with the given line, background, and border color

Parameters:
lineColor - Color of grid lines
backgroundColor - Color of grid background. If null, grid is transparent
borderColor - Color of grid border. If null, border not drawn.
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Does a deep copy of this grid object

Overrides:
clone in class NFBaseClass
Returns:
Object
Throws:
java.lang.CloneNotSupportedException

setAxisMap

public void setAxisMap(NFAxisMap axisMap)
Set the axis map for this grid

Parameters:
axisMap - Axis map to use when drawing grid lines.

getAxisMap

public NFAxisMap getAxisMap()
Returns the axis map for this grid

Returns:
the axis map to use when drawing grid lines

setXAxis

public void setXAxis(NFAxis axis)
Sets which axis should be used to map vertical lines.

Parameters:
axis - NFAxis object to use to map vertical lines.

setYAxis

public void setYAxis(NFAxis axis)
Sets which axis should be used to map horizontal lines.

Parameters:
axis - NFAxis object to use to map horizontal lines.

setGridLine

public void setGridLine(java.awt.Color lineColor)
Convenience method to set the grid line for this grid object.

Parameters:
lineColor - Color of grid line.

setGridLine

public void setGridLine(int style,
                        int thickness,
                        java.awt.Color lineColor,
                        int lineLayout)
Convenience method to set this grid's line.

Parameters:
style - One of NONE, BAR, SOLID, DOTTED, DASHED, DOTDASH
thickness - Line pixel thickness
lineColor - Grid line color
lineLayout - One of HORIZONTAL, VERTICAL, BOTH, NONE

setGridLine

public void setGridLine(NFGridLine gridLine)
Set the grid line. Overrides other setGridLine methods.

Parameters:
gridLine - NFGridLine object to use when rendering this grid's lines.

getGridLine

public NFGridLine getGridLine()
Get the grid line for this grid.

Returns:
gridLine object.

setBackground

public void setBackground(java.awt.Color backgroundColor,
                          java.awt.Color borderColor)
Convenience method to set this grid's background object.

Parameters:
backgroundColor - Color of grid background
borderColor - Color of grid border

setBackground

public void setBackground(NFGridBackground background)
Set the grid background. Overrides other setBackground methods.

Parameters:
background - NFGridBackground object.

getBackground

public NFGridBackground getBackground()
Get the grid background

Returns:
background object

NetCharts Pro


Visual Mining, Inc.
2099 Gaither Rd.
Suite 220
Rockville, MD 20850
800.308.0731
301.947.8293 FAX

Copyright © Visual Mining, Inc. 1996 - 2011
All Rights Reserved.

NetCharts Pro TM is a registered trademark of Visual Mining, Inc. Other brands and their products are trademarks of their respective holders.

Last Modified: Jun 28, 2011