|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
eu.beesoft.gantt.chart.ChartComponent
public class ChartComponent
A ChartComponent is one of the most meaningful sub-components of
JGantt
.
It is painted on the right side of JGantt (there is an instance of
JTreeTable
on the left).
It co-ordinates painting with registered instances of the Layer
class
and dispatches events to them.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
ChartComponent(JGantt ganttComponent)
Create and initializes a new instance of ChartComponent. |
Method Summary | |
---|---|
void |
addLayer(Layer layer)
Adds given layer to the end of registered layers. |
void |
addLayer(Layer layer,
int index)
Inserts given layer at the specified index in
the registered layers list. |
JGantt |
getGantt()
Return instance of JGantt which created this ChartComponent. |
java.util.List<Layer> |
getLayers()
Returns list of all registered layers. |
java.awt.Dimension |
getMinimumSize()
Returns preferred size of chart component. |
protected java.util.List<GanttNode> |
getPaintedNodes()
Returns list of GanttNode s to paint. |
protected int |
getPosition(java.util.Date date)
Returns x-coordinate for given date . |
java.awt.Dimension |
getPreferredSize()
Returns preferred size of chart component. |
java.awt.Dimension |
getSize()
Returns preferred size of chart component. |
protected TimeSpan |
getTimeSpan(java.util.Date date)
Returns TimeSpan for given date or null, if no such
TimeSpan exists. |
java.util.List<TimeSpan> |
getTimeSpans()
Returns list of all TimeSpan instances in this chart. |
TimeUnit |
getTimeSpanUnit()
Returns TimeUnit used for TimeSpan instances. |
int |
getTimeSpanWidth()
Returns width (in pixels) of TimeSpan instances. |
int |
getZoomIndex()
Returns current step (index) in ZoomPolicy . |
ZoomPolicy |
getZoomPolicy()
Returns current instance of ZoomPolicy . |
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. |
void |
paintComponent(java.awt.Graphics g)
Paints chart component. |
void |
removeLayer(Layer layer)
Removes given layer from the registered layers list. |
void |
setTimeSpanUnit(TimeUnit timeSpanUnit)
Sets TimeUnit for use with TimeSpan instances. |
void |
setZoomIndex(int zoomIndex)
Sets new value for step (index) in ZoomPolicy . |
void |
setZoomPolicy(ZoomPolicy zoomPolicy)
Sets new instance of ZoomPolicy for zooming control. |
void |
updateChart()
The key method of ChartComponent, responsible for chart updating. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printComponent, printChildren, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, checkImage, checkImage, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ChartComponent(JGantt ganttComponent)
ganttComponent
- - instance of JGantt which creates this ChartComponentMethod Detail |
---|
public JGantt getGantt()
public void updateChart()
protected TimeSpan getTimeSpan(java.util.Date date)
TimeSpan
for given date
or null, if no such
TimeSpan exists.
public java.util.List<TimeSpan> getTimeSpans()
TimeSpan
instances in this chart.
public TimeUnit getTimeSpanUnit()
TimeUnit
used for TimeSpan
instances.
public void setTimeSpanUnit(TimeUnit timeSpanUnit)
TimeUnit
for use with TimeSpan
instances. This
TimeUnit should be equal or less than TimeUnit for minor step (see
ZoomPolicy
).
timeSpanUnit
- - a constant of TimeUnit for TimeSpan instances to setpublic int getTimeSpanWidth()
TimeSpan
instances. In this
implementation simply redirects to the ZoomPolicy
method.
public void addLayer(Layer layer)
layer
to the end of registered layers.
layer
- - layer to addpublic void addLayer(Layer layer, int index)
layer
at the specified index
in
the registered layers list.
layer
- - layer to addindex
- - position in layers list where to insertpublic void removeLayer(Layer layer)
layer
from the registered layers list.
layer
- - layer to removepublic java.util.List<Layer> getLayers()
public void paintComponent(java.awt.Graphics g)
In the first step it finds all gantt nodes that should be painted
(visible on the screen). These nodes can be later obtained via
getPaintedNodes()
method.
Then it iterates over registered layers and if layer is visible (e.g.
method Layer.isVisible()
returns true) it calls method
Layer.paint(Graphics)
on it.
paintComponent
in class javax.swing.JComponent
g
- - the graphics context to use for paintingprotected java.util.List<GanttNode> getPaintedNodes()
GanttNode
s to paint.
protected int getPosition(java.util.Date date)
date
. This method obtains the
coordinate from an appropriate TimeSpan instance. If no such is found,
returns 0.
public java.awt.Dimension getSize()
getSize
in class java.awt.Component
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public java.awt.Dimension getPreferredSize()
TimeSpan
width * number of TimeSpan instances in
chart componentJTreeTable
row height * number of rows in tree table
getPreferredSize
in class javax.swing.JComponent
public ZoomPolicy getZoomPolicy()
ZoomPolicy
.
public void setZoomPolicy(ZoomPolicy zoomPolicy)
ZoomPolicy
for zooming control.
zoomPolicy
- - instance of ZoomPolicy to setpublic int getZoomIndex()
ZoomPolicy
.
public void setZoomIndex(int zoomIndex)
ZoomPolicy
.
zoomIndex
- - a new ZoomPolicy step to setprotected void mouseClicked(java.awt.event.MouseEvent e)
Layer.mouseClicked(MouseEvent)
on each visible
Layer instance.
e
- - mouse eventprotected void mouseEntered(java.awt.event.MouseEvent e)
Layer.mouseEntered(MouseEvent)
on each visible Layer instance.
e
- - mouse eventprotected void mouseExited(java.awt.event.MouseEvent e)
Layer.mouseExited(MouseEvent)
on each visible Layer instance.
e
- - mouse eventprotected void mousePressed(java.awt.event.MouseEvent e)
Layer.mousePressed(MouseEvent)
on each visible
Layer instance.
e
- - mouse eventprotected void mouseReleased(java.awt.event.MouseEvent e)
Layer.mouseReleased(MouseEvent)
on each visible
Layer instance.
e
- - mouse eventprotected void mouseDragged(java.awt.event.MouseEvent e)
Layer.mouseDragged(MouseEvent)
on each
visible Layer instance.
e
- - mouse eventprotected void mouseMoved(java.awt.event.MouseEvent e)
Layer.mouseMoved(MouseEvent)
on each visible Layer instance.
e
- - mouse event
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |