lt.monarch.chart.view
Class ViewGrid

java.lang.Object
  extended by lt.monarch.chart.AbstractView<E>
      extended by lt.monarch.chart.view.CompositeView<ChartPaintTags>
          extended by lt.monarch.chart.view.ViewGrid
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, StyleEditorEntity, View, ViewListener
Direct Known Subclasses:
ViewGridIndexed

public class ViewGrid
extends CompositeView<ChartPaintTags>

Layouts several sub-views in a grid. Using order in which views are added to the grid, they are placed one by one to toFill the first row of grid from left to right, then the second row and so on. To control where each view is inserted ViewGridIndexed subclass can be used.

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
protected  int columns
           
protected  int[] columnWeight
           
protected  int hGap
           
protected  int rows
           
protected  int[] rowWeight
           
protected  int totalColumnWeight
           
protected  int totalRowWeight
           
protected  int vGap
           
 
Fields inherited from class lt.monarch.chart.view.CompositeView
views
 
Fields inherited from class lt.monarch.chart.AbstractView
layoutInvalid, paintStyle, style
 
Constructor Summary
Constructor and Description
ViewGrid()
          Constructs a container with 1 row and 1 column.
ViewGrid(int columns, int rows)
          Constructs a container with the number of rows and columns.
 
Method Summary
Modifier and Type Method and Description
 void addView(View v)
          Adds a new view into this container.
protected  void checkBounds(int row, int col)
           
protected  void checkColumn(int column)
           
protected  void checkRow(int row)
           
 int getHgap()
          Returns the horizontal gap between grid cells in pixels.
 java.awt.Dimension getPreferredSize(AbstractGraphics g)
          Gets the preferred size of this view in the specified Graphics context.
 int getVgap()
          Returns the vertical gap between grid cells in pixels.
protected  View getView(int row, int col)
           
protected  int getViewIndex(int row, int col)
           
protected  void increaseSize(int rows, int columns)
           
protected  void layout(AbstractGraphics g)
          Prepares the view by arranging all internal views and calculates required constants.
 void setColumnWeight(int col, int weight)
          Sets the weight of a column.
 void setGridSize(int rows, int columns)
          Sets new size for this grid.
 void setHgap(int hGap)
          Sets the horizontal gap between grid cells in pixels.
 void setRowWeight(int row, int weight)
          Sets the weight of a row.
 void setVgap(int vGap)
          Sets the vertical gap between grid cells in pixels.
 void viewInvalidated(View view)
          Notifies, that view layout changed
 
Methods inherited from class lt.monarch.chart.view.CompositeView
dispose, getContainingObjects, getGraphicsType, getViewCount, getViews, paint, removeView, setContainer, setView, validate, viewActivated, viewDeactivated
 
Methods inherited from class lt.monarch.chart.AbstractView
activate, addViewListener, clone, container, deactivate, finalize, getAlignmentX, getAlignmentY, getBounds, getChartObjectBounds, getContainer, getHeight, getMaximumSize, getMinimumSize, getPaintMode, getPaintStyle, getParent, getSize, getSize, getStyle, getStyle, getWidth, getX, getY, invalidate, isLayoutValid, removeViewListener, render, repaint, repaint, setAlignmentX, setAlignmentY, setBounds, setBounds, setLocation, setMaximumSize, setMinimumSize, setPaintMode, setPreferredSize, setSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

columnWeight

protected int[] columnWeight

rowWeight

protected int[] rowWeight

totalColumnWeight

protected int totalColumnWeight

totalRowWeight

protected int totalRowWeight

columns

protected int columns

rows

protected int rows

vGap

protected int vGap

hGap

protected int hGap
Constructor Detail

ViewGrid

public ViewGrid()
Constructs a container with 1 row and 1 column.


ViewGrid

public ViewGrid(int columns,
                int rows)
Constructs a container with the number of rows and columns.

Parameters:
columns - number of columns in a grid
rows - number of rows in a grid
Method Detail

setGridSize

public void setGridSize(int rows,
                        int columns)
                 throws java.lang.IllegalArgumentException
Sets new size for this grid.

Parameters:
rows - new rows count of grid
columns - new columns count of grid
Throws:
java.lang.IllegalArgumentException

increaseSize

protected void increaseSize(int rows,
                            int columns)

getViewIndex

protected int getViewIndex(int row,
                           int col)

getView

protected View getView(int row,
                       int col)

checkRow

protected void checkRow(int row)

checkColumn

protected void checkColumn(int column)

checkBounds

protected void checkBounds(int row,
                           int col)

setRowWeight

public void setRowWeight(int row,
                         int weight)
Sets the weight of a row. A row with a bigger weight is proportionally higher. A row with weight 2 is twice as high as a row with weight 1.

Parameters:
row - row index
weight - row weight

setColumnWeight

public void setColumnWeight(int col,
                            int weight)
Sets the weight of a column. A column with a bigger weight is proportionally wider. A column with weight 2 is twice as wide as a column with weight 1.

Parameters:
col - column index
weight - column weight

addView

public void addView(View v)
Description copied from class: CompositeView
Adds a new view into this container.

Overrides:
addView in class CompositeView<ChartPaintTags>
Parameters:
v - view to be added

setVgap

public void setVgap(int vGap)
Sets the vertical gap between grid cells in pixels.

Parameters:
vGap - vertical gap in pixels

setHgap

public void setHgap(int hGap)
Sets the horizontal gap between grid cells in pixels.

Parameters:
hGap - horizontal gap in pixels

getVgap

public int getVgap()
Returns the vertical gap between grid cells in pixels.

Returns:
vertical gap in pixels

getHgap

public int getHgap()
Returns the horizontal gap between grid cells in pixels.

Returns:
horizontal gap in pixels

viewInvalidated

public void viewInvalidated(View view)
Description copied from interface: ViewListener
Notifies, that view layout changed

Specified by:
viewInvalidated in interface ViewListener
Overrides:
viewInvalidated in class CompositeView<ChartPaintTags>
Parameters:
view - view

getPreferredSize

public java.awt.Dimension getPreferredSize(AbstractGraphics g)
Description copied from class: AbstractView
Gets the preferred size of this view in the specified Graphics context.

Specified by:
getPreferredSize in interface View
Overrides:
getPreferredSize in class AbstractView<ChartPaintTags>
Parameters:
g - the Graphics context in which view will be painted
Returns:
a dimension object indicating this view's preferred size.

layout

protected void layout(AbstractGraphics g)
Description copied from class: AbstractView
Prepares the view by arranging all internal views and calculates required constants.

Overrides:
layout in class AbstractView<ChartPaintTags>
Parameters:
g - graphics context