com.dlsc.flexgantt.model.dateline

## Class AbstractDatelineModel<T extends IGranularity>

- java.lang.Object
- - com.dlsc.flexgantt.model.dateline.AbstractDatelineModel<T>

- Type Parameters:
    `T` - the granularity type
  All Implemented Interfaces:
    IDatelineModel<T>
  Direct Known Subclasses:
    SimpleGranularityDatelineModel, TimeGranularityDatelineModel

      public abstract class AbstractDatelineModel<T extends IGranularity>
      extends Object
      implements IDatelineModel<T>

  An abstract implementation of `IDatelineModel` that contains the most basic functionality shared by most dateline models.
  Since:
    1.0
  Version:
    $Revision: 1.17 $
  Author:
    Dirk Lemmermann

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected double` | `datelineWidth` The width of the dateline based on the current granularity and the time span (the horizon).
    `protected T` | `granularity` Stores the currently used time granularity (e.g. hours, minutes, seconds, ...).
    `protected ITimeSpan` | `selectedTimeSpan` Stores the currently selected time span (is NULL is no selection exists).
    `int` | `spreadsheetCellWidth` The width used for the cells when the Gantt chart shows a spreadsheet.
    `protected ITimeSpan` | `timeSpan` The total time span covered by the dateline model.
    `protected TimeZone` | `timeZone` The time zone represented by the dateline model.
    `protected double` | `zoom` The zoom factor that gets used for smooth zoom operations.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractDatelineModel(ITimeSpan timeSpan, TimeZone timeZone)` Constructs a new dateline model.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDatelineModelListener(IDatelineModelListener l)` Adds a listener to the dateline model.
    `protected abstract void` | `calculateDatelineWidth()` Calculates the required width of the dateline based on the total time span and some additional information that needs to be provided by the subclasses.
    `protected void` | `fireDatelineModelChangeEvent(DatelineModelEvent evt)` Sends dateline model events to all currently registered listeners.
    `protected void` | `fireDatelineModelWillChangeEvent(DatelineModelEvent evt)` Sends dateline model events to all currently registered listeners.
    `int` | `getDatelineWidth()` Returns the width of the dateline that is required based on the current settings of the dateline model.
    `T` | `getGranularity()` Returns the currently shown granularity.
    `ITimeSpan` | `getSelectedTimeSpan()` Returns the currently selected time span.
    `int` | `getSpreadsheetCellWidth()` Returns the width used for spreadsheet cells.
    `ITimeSpan` | `getTimeSpan()` Returns the total time span covered by the model / dateline.
    `TimeZone` | `getTimeZone()` Returns the time zone represented by the dateline.
    `double` | `getZoom()` Returns the zoom factor of the model / dateline.
    `void` | `removeDatelineModelListener(IDatelineModelListener l)` Removes a listener from the dateline model.
    `void` | `setGranularity(T granularity)` Sets the granularity for the minor times, which will cause a recalculation of the dateline width.
    `void` | `setSelectedTimeSpan(ITimeSpan newSpan)` Sets a time span selection.
    `void` | `setSpreadsheetCellWidth(int width)` Sets the width used for spreadsheet cells.
    `void` | `setTimeSpan(ITimeSpan timeSpan)` Sets the total time span covered by the model / dateline.
    `void` | `setTimeZone(TimeZone zone)` Sets the time zone represented by the dateline.
    `void` | `setZoom(double zoom)` Sets a zoom factor on the model / dateline.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.dlsc.flexgantt.model.dateline.IDatelineModel

      `getGrid, getTimeAt, getTimeLocation, getTimeSpanAt, getTimeString, requestVisibleTimeSpan`

- - ### Field Detail

    - #### selectedTimeSpan

          protected ITimeSpan selectedTimeSpan

      Stores the currently selected time span (is NULL is no selection exists).
      Since:
        1.0

    - #### timeZone

          protected TimeZone timeZone

      The time zone represented by the dateline model. The time zone is required to calculate the offset between the time locations returned by the model and the data returned by the Gantt chart nodes (each node can be associated with its own time zone, e.g. a plant might be located in India, another one in the US, a third one in Europe).
      Since:
        1.0

    - #### timeSpan

          protected ITimeSpan timeSpan

      The total time span covered by the dateline model. The time span in combination with model specific attributes is important for calculating the width of the dateline. The user will not be able to scroll to a time point before the start time of the time span and also not to a time point after the end time of the time span.
      Since:
        1.0

    - #### granularity

          protected T extends IGranularity granularity

      Stores the currently used time granularity (e.g. hours, minutes, seconds, ...).
      Since:
        1.0

    - #### zoom

          protected double zoom

      The zoom factor that gets used for smooth zoom operations.
      Since:
        1.0

    - #### datelineWidth

          protected double datelineWidth

      The width of the dateline based on the current granularity and the time span (the horizon).
      Since:
        1.0

    - #### spreadsheetCellWidth

          public int spreadsheetCellWidth

      The width used for the cells when the Gantt chart shows a spreadsheet.
      Since:
        2.1

  - ### Constructor Detail

    - #### AbstractDatelineModel

          protected AbstractDatelineModel(ITimeSpan timeSpan,
                                          TimeZone timeZone)

      Constructs a new dateline model.
      Parameters:
        `timeSpan` - the total time span covered by the model (span in which the user can scroll)
        `timeZone` - the time zone represented by the model (used for offset calculations)
      Since:
        1.0

  - ### Method Detail

    - #### setSpreadsheetCellWidth

          public void setSpreadsheetCellWidth(int width)
                                       throws DatelineModelException

      Sets the width used for spreadsheet cells.
      Specified by:
        `setSpreadsheetCellWidth` in interface `IDatelineModel<T extends IGranularity>`
      Parameters:
        `width` - spreadsheet cell width
      Throws:
        `DatelineModelException` - when the cell width violates model constraints
      Since:
        2.1

    - #### getSpreadsheetCellWidth

          public int getSpreadsheetCellWidth()

      Returns the width used for spreadsheet cells.
      Specified by:
        `getSpreadsheetCellWidth` in interface `IDatelineModel<T extends IGranularity>`
      Returns:
        the spreadsheet cell width
      Since:
        2.1

    - #### getTimeSpan

          public ITimeSpan getTimeSpan()

      Description copied from interface: `IDatelineModel`
      Returns the total time span covered by the model / dateline. The width of the dateline gets calculated based on the time span plus some additional information. The additional information can vary depending on the dateline model implementation. The `TimeGranularityDatelineModel` for example uses the currently used `TimeGranularity` while the `SimpleGranularityDatelineModel` uses the currently active `SimpleGranularity`.
      Specified by:
        `getTimeSpan` in interface `IDatelineModel<T extends IGranularity>`
      Returns:
        the total time span covered by the dateline
      See Also:
        `IDatelineModel.setTimeSpan(ITimeSpan)`

    - #### setTimeSpan

          public void setTimeSpan(ITimeSpan timeSpan)
                           throws DatelineModelException

      Description copied from interface: `IDatelineModel`
      Sets the total time span covered by the model / dateline. The width of the dateline gets calculated based on the time span plus some additional information. The additional information can vary depending on the dateline model implementation. The `TimeGranularityDatelineModel` for example uses the currently used `TimeGranularity` while the `SimpleGranularityDatelineModel` uses the currently active `SimpleGranularity`.
      Specified by:
        `setTimeSpan` in interface `IDatelineModel<T extends IGranularity>`
      Parameters:
        `timeSpan` - the total time span covered by the dateline
      Throws:
        `DatelineModelException`
      See Also:
        `IDatelineModel.getTimeSpan()`

    - #### setTimeZone

          public void setTimeZone(TimeZone zone)
                           throws DatelineModelException

      Description copied from interface: `IDatelineModel`
      Sets the time zone represented by the dateline. The time zone is required for calculating the offset of the data provided by the Gantt chart model. Each tree node in the Gantt chart can represent its own time zone and the data stored on the node needs to be translated to the dateline's coordinate system via the time zone offsets.
      Specified by:
        `setTimeZone` in interface `IDatelineModel<T extends IGranularity>`
      Parameters:
        `zone` - the time zone represented by the dateline (model)
      Throws:
        `DatelineModelException`
      See Also:
        `IDatelineModel.getTimeZone()`

    - #### setZoom

          public void setZoom(double zoom)
                       throws DatelineModelException

      Description copied from interface: `IDatelineModel`
      Sets a zoom factor on the model / dateline. This way the currently used granularity can be shown with a larger width than the default.
      Specified by:
        `setZoom` in interface `IDatelineModel<T extends IGranularity>`
      Parameters:
        `zoom` - the zoom factor
      Throws:
        `DatelineModelException` - if the requested zoom factor can not be applied
      See Also:
        `IDatelineModel.getZoom()`

    - #### getZoom

          public double getZoom()

      Description copied from interface: `IDatelineModel`
      Returns the zoom factor of the model / dateline.
      Specified by:
        `getZoom` in interface `IDatelineModel<T extends IGranularity>`
      Returns:
        the zoom factor
      See Also:
        `IDatelineModel.setZoom(double)`

    - #### getTimeZone

          public TimeZone getTimeZone()

      Description copied from interface: `IDatelineModel`
      Returns the time zone represented by the dateline. The time zone is required for calculating the offset of the data provided by the Gantt chart model. Each tree node in the Gantt chart can represent its own time zone and the data stored on the node needs to be translated to the dateline's coordinate system via the time zone offsets.
      Specified by:
        `getTimeZone` in interface `IDatelineModel<T extends IGranularity>`
      Returns:
        the time zone represented by the dateline
      See Also:
        `IDatelineModel.setTimeZone(TimeZone)`

    - #### setSelectedTimeSpan

          public void setSelectedTimeSpan(ITimeSpan newSpan)

      Description copied from interface: `IDatelineModel`
      Sets a time span selection.
      Specified by:
        `setSelectedTimeSpan` in interface `IDatelineModel<T extends IGranularity>`
      Parameters:
        `newSpan` - the selected time span
      See Also:
        `IDatelineModel.getSelectedTimeSpan()`

    - #### getGranularity

          public T getGranularity()

      Returns the currently shown granularity.
      Specified by:
        `getGranularity` in interface `IDatelineModel<T extends IGranularity>`
      Returns:
        the current granularity
      Since:
        1.0

    - #### setGranularity

          public void setGranularity(T granularity)
                              throws DatelineModelException

      Sets the granularity for the minor times, which will cause a recalculation of the dateline width.
      Specified by:
        `setGranularity` in interface `IDatelineModel<T extends IGranularity>`
      Parameters:
        `granularity` - the granularity to use for the minor times
      Throws:
        `DatelineModelException` - if the requested granularity can not be shown by the dateline
      Since:
        1.0

    - #### getSelectedTimeSpan

          public ITimeSpan getSelectedTimeSpan()

      Description copied from interface: `IDatelineModel`
      Returns the currently selected time span. The dateline model incorporates selection model behaviour.
      Specified by:
        `getSelectedTimeSpan` in interface `IDatelineModel<T extends IGranularity>`
      Returns:
        the time span selection
      See Also:
        `IDatelineModel.setSelectedTimeSpan(ITimeSpan)`

    - #### addDatelineModelListener

          public void addDatelineModelListener(IDatelineModelListener l)

      Description copied from interface: `IDatelineModel`
      Adds a listener to the dateline model.
      Specified by:
        `addDatelineModelListener` in interface `IDatelineModel<T extends IGranularity>`
      Parameters:
        `l` - the listener to add
      See Also:
        `IDatelineModel.removeDatelineModelListener(IDatelineModelListener)`

    - #### removeDatelineModelListener

          public void removeDatelineModelListener(IDatelineModelListener l)

      Description copied from interface: `IDatelineModel`
      Removes a listener from the dateline model.
      Specified by:
        `removeDatelineModelListener` in interface `IDatelineModel<T extends IGranularity>`
      Parameters:
        `l` - the listener to remove
      See Also:
        `IDatelineModel.addDatelineModelListener(IDatelineModelListener)`

    - #### fireDatelineModelWillChangeEvent

          protected void fireDatelineModelWillChangeEvent(DatelineModelEvent evt)
                                                   throws DatelineModelVetoException

      Sends dateline model events to all currently registered listeners.
      Parameters:
        `evt` - the event to propagate
      Throws:
        `DatelineModelVetoException` - if a listener rejects the requested change
      Since:
        1.0
      See Also:
        `IDatelineModelListener`, `addDatelineModelListener(IDatelineModelListener)`

    - #### fireDatelineModelChangeEvent

          protected void fireDatelineModelChangeEvent(DatelineModelEvent evt)

      Sends dateline model events to all currently registered listeners.
      Parameters:
        `evt` - the event to propagate
      Since:
        1.0
      See Also:
        `IDatelineModelListener`, `addDatelineModelListener(IDatelineModelListener)`

    - #### getDatelineWidth

          public int getDatelineWidth()

      Description copied from interface: `IDatelineModel`
      Returns the width of the dateline that is required based on the current settings of the dateline model. The width gets calculated based on the total time span covered by the model and some additional information provided by the individual dateline implementations.
      Specified by:
        `getDatelineWidth` in interface `IDatelineModel<T extends IGranularity>`
      Returns:
        the width of the dateline

    - #### calculateDatelineWidth

          protected abstract void calculateDatelineWidth()
                                                  throws DatelineModelException

      Calculates the required width of the dateline based on the total time span and some additional information that needs to be provided by the subclasses.
      Throws:
        `DatelineModelException` - if the calculated width exceeds the maximum width that is equal to `Integer.MAX_VALUE`
      Since:
        1.0

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.