Class HistoryChart

All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible

public class HistoryChart extends JPanel implements PropertyChangeListener
Chart showing either from/to or total times in given period scale.
See Also:
  • Field Details

    • days

      private Vector days
      Days whose data should be drawn.
    • taskFilter

      private AbstractTaskFilter taskFilter
      Filter for highlighting tasks.
    • chartType

      private int chartType
      Type of history chart to be drawn.
    • maxValueY

      int maxValueY
      Maximum value on Y axis.
    • minValueY

      int minValueY
      Minimum value on X axis.
    • xStep

      private double xStep
      Distance between two values on X axis.
    • yStep

      private double yStep
      Distance between two values on Y axis.
    • TYPE_TOTAL

      public static final int TYPE_TOTAL
      Chart displaying total times for days.
      See Also:
    • TYPE_FROM_TO

      public static final int TYPE_FROM_TO
      Chart displaying from/to times for days.
      See Also:
    • TYPE_TIME_USAGE

      public static final int TYPE_TIME_USAGE
      Chart displaying used/wasted time ratio.
      See Also:
    • INSET_LEFT

      private static final int INSET_LEFT
      Left space before chart e.g. distance between left edge and X axis.
      See Also:
    • INSET_RIGHT

      private static final int INSET_RIGHT
      Right space behind chart.
      See Also:
    • INSET_TOP

      private static final int INSET_TOP
      Top space above chart.
      See Also:
    • INSET_BOTTOM

      private static final int INSET_BOTTOM
      Bottom space behind chart.
      See Also:
    • LIGHT_GREEN

      private static final Color LIGHT_GREEN
      Light green color for chart axes and grid.
  • Constructor Details

    • HistoryChart

      public HistoryChart(Vector days, AbstractTaskFilter taskFilter, int chartType)
      Creates a new history chart.
      Parameters:
      days - Days that should be used to draw history chart.
      taskFilter - Filter for highlighting tasks when drawing chart.
      chartType - Type of history chart to be drawn.
  • Method Details

    • setDays

      public void setDays(Vector days)
      Sets which days should be used to draw history chart.
      Parameters:
      days - Days that should be used to draw history chart.
    • setHighlightingFilter

      public void setHighlightingFilter(AbstractTaskFilter taskFilter)
      Sets task filter for highlighting tasks when drawing chart.
      Parameters:
      taskFilter - Filter that will be used to select tasks that will be highlighted when drawing total times chart.
    • setChartType

      public void setChartType(int chartType)
      Sets type of history chart to be drawn.
      Parameters:
      chartType - Type of history chart to be drawn.
    • paint

      public void paint(Graphics graphics)
      Draws the chart of specified type from given days.
      Overrides:
      paint in class JComponent
      Parameters:
      graphics - Graphics area where the chart should be drawn.
    • computeSteps

      private void computeSteps()
      Computes both X and Y steps based on days and type of chart.
    • computeMaxMinY

      private void computeMaxMinY()
      Computes maximum and minimum values for Y axis.
    • drawAxes

      private void drawAxes(Graphics graphics, boolean drawGrid)
      Draws axes and values including chart grid if needed.
      Parameters:
      graphics - Graphics area where the axes should be drawn.
      drawGrid - Whether chart grid should be drawn or not.
    • drawHours

      private void drawHours(Graphics graphics)
      Draws actual data i.e. hour columns.
      Parameters:
      graphics - Graphics area where the axes should be drawn.
    • drawReferenceLines

      private void drawReferenceLines(Graphics graphics, boolean drawAverageHours, boolean drawGivenHours)
      Draws reference lines in chart if required.
      Parameters:
      graphics - Graphics area where the axes should be drawn.
      drawAverageHours - If true, average hours for all and working days will be drawn.
      drawGivenHours - If true, given working hours will be drawn.
    • getDayAt

      public Day getDayAt(Point point)
      Returns day represented by column at specified point.
      Parameters:
      point - Point to be checked for existency of day column.
      Returns:
      Day painted at given point or null if there is no day column at specified X position.
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Method called when some property of task was changed.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Parameters:
      evt - Event describing what was changed.