JIDE 3.5.15

com.jidesoft.scale
Class ScaleArea<T>

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.jidesoft.scale.ScaleArea<T>
Type Parameters:
T - The base unit value of the scale, for example Date or Integer.
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class ScaleArea<T>
extends JComponent

The scale area is the header of the gantt chart and can show the scale in different granularities.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int DEFAULT_PERIOD_HEIGHT
           
static int DEFAULT_PERIOD_WIDTH
           
static String PROPERTY_PERIOD_BACKGROUND_PAINTER
           
static String PROPERTY_PERIOD_CONVERTERS
           
static String PROPERTY_PERIOD_HEADER_PAINTER
           
static String PROPERTY_PERIOD_MARGIN
           
static String PROPERTY_PREFERRED_PERIOD_SIZE
           
static String PROPERTY_SCALE_END
           
static String PROPERTY_SCALE_MODEL
          Also implies a scale start, scale end and visible periods change.
static String PROPERTY_SCALE_START
           
static String PROPERTY_TABLE_CELL_RENDERER
           
static String PROPERTY_TREE_TABLE
           
static String PROPERTY_VISIBLE_PERIOD_COUNT
           
static String PROPERTY_VISIBLE_PERIODS
           
 
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
ScaleArea()
           
ScaleArea(ScaleModel<T> scaleModel, PeriodConverter<T> defaultConverter)
           
 
Method Summary
 void addPopupMenuCustomizer(ScaleAreaPopupMenuCustomizer<T> customizer)
           
 PeriodConverter<T> getDefaultPeriodConverter()
           
 T getEnd()
           
 T getInstantAt(int x)
          Note: the components left-to-right orientation is already taken into account.
 PeriodConverter<T> getPeriodConverter(Period period)
           
 PeriodHeaderPainter getPeriodHeaderPainter()
           
 int getPeriodMargin()
           
 List<ScaleAreaPopupMenuCustomizer<T>> getPopupMenuCustomizers()
           
 Dimension getPreferredPeriodSize()
           
 String getResourceString(String key)
          Gets the localized string from resource bundle.
 ScaleModel<T> getScaleModel()
           
 Period getSmallestVisiblePeriod()
           
 T getStart()
           
 TableCellRenderer getTableCellRenderer()
           
 String getToolTipText(MouseEvent event)
           
 TreeTable getTreeTable()
           
 ScaleAreaUI getUI()
           
 String getUIClassID()
           
 int getVisiblePeriodCount()
           
 List<Period> getVisiblePeriods()
           
 int getX(T instant)
          Note: the components left-to-right orientation is already taken into account.
 boolean isPreferredPeriodSizeSet()
           
 void removePopupMenuCustomizer(ScaleAreaPopupMenuCustomizer<T> customizer)
           
protected  void resizeAndRepaint()
           
 void setDefaultPeriodConverter(PeriodConverter<T> converter)
           
 void setEnd(T end)
          If the end instant is at or before than the current start instant, the start instant is moved to the smallest period end before the end.
 void setPeriodConverter(Period period, PeriodConverter<T> converter)
          Set the renderer for the specified period.
 void setPeriodHeaderPainter(PeriodHeaderPainter periodHeaderPainter)
           
 void setPeriodMargin(int periodMargin)
           
 void setPreferredPeriodSize(Dimension size)
           
 void setPreferredSize(Dimension preferredSize)
           
 void setScaleModel(ScaleModel<T> scaleModel)
          Updates the model, start instant, end instant and visible periods.
 void setStart(T start)
          If the start instant is at or after than the current end instant, the end instant is moved to the smallest period end after the start.
 void setTableCellRenderer(TableCellRenderer tableCellRenderer)
           
 void setTreeTable(TreeTable treeTable)
           
protected  void setUI(ScaleAreaUI newUI)
           
 void setVisiblePeriodCount(int visiblePeriodCount)
          Sets the preferred visible period count for the smallest visible period.
 void setVisiblePeriods(List<? extends Period> visiblePeriods)
           
 void setVisiblePeriods(List<? extends Period> visiblePeriods, boolean setPreferredTierCount)
           
 void setVisiblePeriodsToFit(T start, T end, int availableWidth)
          Adjusts the visible periods and preferred period width so the specified range is visible.
 void updateUI()
           
 void zoomPeriodWidth(double factor)
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, 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, 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, checkImage, checkImage, 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, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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
 

Field Detail

PROPERTY_SCALE_MODEL

public static final String PROPERTY_SCALE_MODEL
Also implies a scale start, scale end and visible periods change.

See Also:
Constant Field Values

PROPERTY_VISIBLE_PERIODS

public static final String PROPERTY_VISIBLE_PERIODS
See Also:
Constant Field Values

PROPERTY_SCALE_START

public static final String PROPERTY_SCALE_START
See Also:
Constant Field Values

PROPERTY_SCALE_END

public static final String PROPERTY_SCALE_END
See Also:
Constant Field Values

PROPERTY_PREFERRED_PERIOD_SIZE

public static final String PROPERTY_PREFERRED_PERIOD_SIZE
See Also:
Constant Field Values

PROPERTY_VISIBLE_PERIOD_COUNT

public static final String PROPERTY_VISIBLE_PERIOD_COUNT
See Also:
Constant Field Values

PROPERTY_PERIOD_MARGIN

public static final String PROPERTY_PERIOD_MARGIN
See Also:
Constant Field Values

PROPERTY_PERIOD_CONVERTERS

public static final String PROPERTY_PERIOD_CONVERTERS
See Also:
Constant Field Values

PROPERTY_PERIOD_HEADER_PAINTER

public static final String PROPERTY_PERIOD_HEADER_PAINTER
See Also:
Constant Field Values

PROPERTY_PERIOD_BACKGROUND_PAINTER

public static final String PROPERTY_PERIOD_BACKGROUND_PAINTER
See Also:
Constant Field Values

PROPERTY_TREE_TABLE

public static final String PROPERTY_TREE_TABLE
See Also:
Constant Field Values

PROPERTY_TABLE_CELL_RENDERER

public static final String PROPERTY_TABLE_CELL_RENDERER
See Also:
Constant Field Values

DEFAULT_PERIOD_WIDTH

public static final int DEFAULT_PERIOD_WIDTH
See Also:
Constant Field Values

DEFAULT_PERIOD_HEIGHT

public static final int DEFAULT_PERIOD_HEIGHT
See Also:
Constant Field Values
Constructor Detail

ScaleArea

public ScaleArea()

ScaleArea

public ScaleArea(ScaleModel<T> scaleModel,
                 PeriodConverter<T> defaultConverter)
Method Detail

setScaleModel

public void setScaleModel(ScaleModel<T> scaleModel)
Updates the model, start instant, end instant and visible periods.

Parameters:
scaleModel - The new scale model
Throws:
IllegalArgumentException - If the ScaleModel does not define at least one Period.

getScaleModel

public ScaleModel<T> getScaleModel()

setVisiblePeriods

public void setVisiblePeriods(List<? extends Period> visiblePeriods)
Parameters:
visiblePeriods - A sub set of the ScaleModels periods which should be shown.

setVisiblePeriods

public void setVisiblePeriods(List<? extends Period> visiblePeriods,
                              boolean setPreferredTierCount)
Parameters:
visiblePeriods - A sub set of the ScaleModels periods which should be shown.
setPreferredTierCount - If true, the scale area will try to keep the amount of period the same when zooming later.
Throws:
IllegalArgumentException - If visiblePeriods is null or empty or contains Periods not defined in the ScaleModel.

resizeAndRepaint

protected void resizeAndRepaint()

getVisiblePeriods

public List<Period> getVisiblePeriods()

getSmallestVisiblePeriod

public Period getSmallestVisiblePeriod()
Returns:
Returns the visible period which has the shortest duration.

getVisiblePeriodCount

public int getVisiblePeriodCount()

setVisiblePeriodCount

public void setVisiblePeriodCount(int visiblePeriodCount)
Sets the preferred visible period count for the smallest visible period. This affects the preferred scrollable view port width of the Gantt Chart.

Parameters:
visiblePeriodCount - The number of periods visible.

getPeriodMargin

public int getPeriodMargin()

setPeriodMargin

public void setPeriodMargin(int periodMargin)
Parameters:
periodMargin - The margin in pixels to the left and the right of the chart.

setVisiblePeriodsToFit

public void setVisiblePeriodsToFit(T start,
                                   T end,
                                   int availableWidth)
Adjusts the visible periods and preferred period width so the specified range is visible. If start is before or the end after the current ScaleArea start or end, they are adjusted to fit as well.

Parameters:
start - The start of the range (not null).
end - The end of the range (not null).
availableWidth - The available width in pixel (typically the GanttChart width).

zoomPeriodWidth

public void zoomPeriodWidth(double factor)

getStart

public T getStart()

setStart

public void setStart(T start)
If the start instant is at or after than the current end instant, the end instant is moved to the smallest period end after the start.

Defaults to ScaleModel.getDefaultStart().

Parameters:
start - The first instant to be shown on the scale.
Throws:
IllegalArgumentException - If start is null.

getEnd

public T getEnd()

setEnd

public void setEnd(T end)
If the end instant is at or before than the current start instant, the start instant is moved to the smallest period end before the end.

Defaults to ScaleModel.getDefaultEnd().

Parameters:
end - The last instant to be shown on the scale.
Throws:
IllegalArgumentException - If end is null.

getInstantAt

public T getInstantAt(int x)
Note: the components left-to-right orientation is already taken into account.

Parameters:
x - The x-coordinate to the get the instant for.
Returns:
Return the instant at the specified x.

getX

public int getX(T instant)
Note: the components left-to-right orientation is already taken into account.

Parameters:
instant - The instant to get the screen position for.
Returns:
Returns the x-coordinate for the specified instant.

getPreferredPeriodSize

public Dimension getPreferredPeriodSize()
Returns:
Returns the width for the smallest visible Period.

setPreferredPeriodSize

public void setPreferredPeriodSize(Dimension size)
Parameters:
size - The preferred size for the smallest visible Period.

setPreferredSize

public void setPreferredSize(Dimension preferredSize)
Overrides:
setPreferredSize in class JComponent

isPreferredPeriodSizeSet

public boolean isPreferredPeriodSizeSet()

getPeriodConverter

public PeriodConverter<T> getPeriodConverter(Period period)

setPeriodConverter

public void setPeriodConverter(Period period,
                               PeriodConverter<T> converter)
Set the renderer for the specified period.

Parameters:
period - the period
converter - the converter for the period.

getDefaultPeriodConverter

public PeriodConverter<T> getDefaultPeriodConverter()

setDefaultPeriodConverter

public void setDefaultPeriodConverter(PeriodConverter<T> converter)

getToolTipText

public String getToolTipText(MouseEvent event)
Overrides:
getToolTipText in class JComponent

setPeriodHeaderPainter

public void setPeriodHeaderPainter(PeriodHeaderPainter periodHeaderPainter)

getPeriodHeaderPainter

public PeriodHeaderPainter getPeriodHeaderPainter()

setTreeTable

public void setTreeTable(TreeTable treeTable)

getTreeTable

public TreeTable getTreeTable()

setTableCellRenderer

public void setTableCellRenderer(TableCellRenderer tableCellRenderer)

getTableCellRenderer

public TableCellRenderer getTableCellRenderer()

getPopupMenuCustomizers

public List<ScaleAreaPopupMenuCustomizer<T>> getPopupMenuCustomizers()

addPopupMenuCustomizer

public void addPopupMenuCustomizer(ScaleAreaPopupMenuCustomizer<T> customizer)

removePopupMenuCustomizer

public void removePopupMenuCustomizer(ScaleAreaPopupMenuCustomizer<T> customizer)

setUI

protected void setUI(ScaleAreaUI newUI)

getUIClassID

public String getUIClassID()
Overrides:
getUIClassID in class JComponent

getUI

public ScaleAreaUI getUI()

updateUI

public void updateUI()
Overrides:
updateUI in class JComponent

getResourceString

public String getResourceString(String key)
Gets the localized string from resource bundle. Subclass can override it to provide its own string. Available keys are defined in gantt.properties.

Parameters:
key - the resource string key
Returns:
the localized string.

JIDE 3.5.15