eu.beesoft.gantt.chart
Class Layer

java.lang.Object
  extended by eu.beesoft.gantt.chart.Layer
Direct Known Subclasses:
BackgroundLayer, CalendarLayer, DependencyLayer, GanttNodeLayer, GridLayer, LabelLayer, TodayLayer

public abstract class Layer
extends java.lang.Object

A layer is an object having a graphical representation that can be displayed in the gantt chart and that can interact with the user.

The Layer class is the abstract superclass of the each gantt chart layer.

Gantt ChartComponent holds a stack of user-defined layers. When the method paint() on ChartComponent is invoked, it walks through this stack (in order the layers were added) and if the layer is visible (method isVisible() return true) calls method paint() on it.


Constructor Summary
Layer()
          Default constructor
 
Method Summary
protected  JGantt getGantt()
          Returns instance of JGantt to which this Layer belongs.
protected  GanttModel getGanttModel()
          Returns GanttModel for this gantt chart.
protected  int getHeaderHeight()
          Returns height of tree-table header.
protected  ChartComponent getChartComponent()
          Returns gantt ChartComponent for this Layer.
protected  GanttNode getNodeAt(int x, int y)
          Returns the gantt node at the specified location of ChartComponent.
protected  java.util.List<GanttNode> getPaintedNodes()
          Returns list of currently on-screen visible and painted gantt nodes.
protected  int getPosition(java.util.Date date)
          Returns x-coordinate for given date.
 boolean isVisible()
          Returns value of property 'visible'.
protected  void mouseClicked(java.awt.event.MouseEvent e)
          Invoked when the mouse has been clicked on a component.
protected  void mouseDragged(java.awt.event.MouseEvent e)
          Invoked when a mouse button is pressed on a component and then dragged.
protected  void mouseEntered(java.awt.event.MouseEvent e)
          Invoked when the mouse enters a component.
protected  void mouseExited(java.awt.event.MouseEvent e)
          Invoked when the mouse exits a component.
protected  void mouseMoved(java.awt.event.MouseEvent e)
          Invoked when the mouse button has been moved on a component (with no buttons no down).
protected  void mousePressed(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been pressed on a component.
protected  void mouseReleased(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been released on a component.
protected abstract  void paint(java.awt.Graphics g)
          Paints this layer.
 void setVisible(boolean visible)
          Sets new value for property 'visible'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Layer

public Layer()
Default constructor

Method Detail

getGantt

protected JGantt getGantt()
Returns instance of JGantt to which this Layer belongs.

Returns:
instance of JGantt

getGanttModel

protected GanttModel getGanttModel()
Returns GanttModel for this gantt chart.

Returns:
instance of GanttModel

getChartComponent

protected ChartComponent getChartComponent()
Returns gantt ChartComponent for this Layer.

Returns:
instance of ChartComponent

isVisible

public boolean isVisible()
Returns value of property 'visible'.

Returns:
true if this Layer is visible (painted)

setVisible

public void setVisible(boolean visible)
Sets new value for property 'visible'. Layer is painted only if visible = true.

Parameters:
visible - - new value for property 'visible'

getHeaderHeight

protected int getHeaderHeight()
Returns height of tree-table header.

Returns:
height of header

getPaintedNodes

protected java.util.List<GanttNode> getPaintedNodes()
Returns list of currently on-screen visible and painted gantt nodes.

Returns:
list of visible nodes

getPosition

protected int getPosition(java.util.Date date)
Returns x-coordinate for given date.

Returns:
x-coordinate for given date

paint

protected abstract void paint(java.awt.Graphics g)
Paints this layer.

Method is called from JComponent.paint(Graphics) after all node parameters are set.

Subclasses must implement this method to paint layer.

Parameters:
g - - the graphics context to use for painting

mouseClicked

protected void mouseClicked(java.awt.event.MouseEvent e)
Invoked when the mouse has been clicked on a component. In this implementation does nothing.


mouseEntered

protected void mouseEntered(java.awt.event.MouseEvent e)
Invoked when the mouse enters a component. In this implementation does nothing.


mouseExited

protected void mouseExited(java.awt.event.MouseEvent e)
Invoked when the mouse exits a component. In this implementation does nothing.


mousePressed

protected void mousePressed(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed on a component. In this implementation does nothing.


mouseReleased

protected void mouseReleased(java.awt.event.MouseEvent e)
Invoked when a mouse button has been released on a component. In this implementation does nothing.


mouseMoved

protected void mouseMoved(java.awt.event.MouseEvent e)
Invoked when the mouse button has been moved on a component (with no buttons no down). In this implementation does nothing.


mouseDragged

protected void mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged. In this implementation does nothing.


getNodeAt

protected GanttNode getNodeAt(int x,
                              int y)
Returns the gantt node at the specified location of ChartComponent.

Parameters:
x - - an integer giving the number of pixels horizontally from the left edge of the ChartComponent
y - - an integer giving the number of pixels vertically from the top of the ChartComponent
Returns:
node at the given location or null