Class AxisTimeStyle

java.lang.Object
com.amalgamasimulation.charts.axes.ticks.AxisTimeStyle

public class AxisTimeStyle extends Object
Class that represents parameters for formatting and ranging time-relative axes. Used to calculate and customize the visual display of ticks and gridlines.
Author:
Aleksey Kirillov
  • Constructor Details

    • AxisTimeStyle

      public AxisTimeStyle(LocalDateTime beginDate, ChronoUnit timeUnit)
      Constructs a AxisTimeStyle with given begin date and time unit. Other parameters are set to default: major tick length is equal to 10pcx, minor tick length is equals to 5pcx.
      Parameters:
      beginDate - the starting date from which all ticks are counted. Cannot be null
      timeUnit - the axis ticks time units. HOURS by default. Cannot be null
    • AxisTimeStyle

      public AxisTimeStyle(int majorTickLength, int minorTickLength, LocalDateTime beginDate, ChronoUnit timeUnit)
      Constructs a AxisTimeStyle with manually setting of all initialization parameters.
      Parameters:
      majorTickLength - visual length of major ticks, in pixels
      minorTickLength - visual length of minor ticks, in pixels
      beginDate - the starting date from which all ticks are counted. Cannot be null
      timeUnit - the axis ticks time units. HOURS by default. Cannot be null
  • Method Details

    • addParameters

      public AxisTimeStyle addParameters(double minWindowSize, double maxWindowSize, TimeTicksParameters majorTicksParameters, TimeTicksParameters minorTicksParameters, Function<LocalDateTime,String> majorTickLabelsProvider)
      Used to set different policies for splitting the displayed range into major/minor ticks depending on displayed range size. For example, it makes sense to make a daily displayed range for hourly and minute ticks, a weekly displayed range for daily and hourly ticks, and a yearly displayed range for monthly and weekly ticks. The given set of displayed ranges must not contains self-intersections.
      Parameters:
      minWindowSize - displayed range minimum size
      maxWindowSize - displayed range maximum size
      majorTicksParameters - TimeTicksParameters for major ticks
      minorTicksParameters - TimeTicksParameters for minor ticks
      majorTickLabelsProvider - the formatter to tick labels, i.e. the function that takes a LocalDateTime value and produces a String that should be drawn to represent this value
      Returns:
      reference to this object
    • getMajorTickLength

      public int getMajorTickLength()
      Returns the visual length of major ticks, in pixels.
      Returns:
      the visual length of major ticks, in pixels
    • getMinorTickLength

      public int getMinorTickLength()
      Returns the visual length of minor ticks, in pixels.
      Returns:
      the visual length of minor ticks, in pixels
    • getBeginDate

      public LocalDateTime getBeginDate()
      Returns the starting date from which all ticks are counted.
      Returns:
      the starting date from which all ticks are counted
    • getTimeUnit

      public ChronoUnit getTimeUnit()
      Returns the axis ticks time units.
      Returns:
      the axis ticks time units
    • getTimeLabelsAndTicksDescriptors

      public List<TimeLabelsAndTicksDescriptor> getTimeLabelsAndTicksDescriptors()
      Returns the list of splitting the displayed range policies.
      Returns:
      the list of splitting the displayed range policies
    • getTimeLabelsAndTicksDescriptor

      public TimeLabelsAndTicksDescriptor getTimeLabelsAndTicksDescriptor(double duration)
      Return splitting the displayed range policy by given duration or null if the policies are not set.
      Parameters:
      duration - displayed range duration
      Returns:
      splitting the displayed range policy by given duration
    • timeToDate

      public LocalDateTime timeToDate(double time)
      Converts the specified time to corresponding date of calendar.
      Parameters:
      time - converting time
      Returns:
      the specified time to corresponding date of calendar
    • dateToTime

      public double dateToTime(LocalDateTime date)
      Converts the specified date of calendar to the corresponding time.
      Parameters:
      date - converting date
      Returns:
      the specified date of calendar to the corresponding time
    • getDefault

      public static AxisTimeStyle getDefault(LocalDateTime beginDate, ChronoUnit chronoUnit)
      Creates a default set of policies for splitting the displayed range into major/minor ticks depending on displayed range size.
      Parameters:
      beginDate - the starting date from which all ticks are counted. Cannot be null
      chronoUnit - the axis ticks time units. HOURS by default. Cannot be null
      Returns:
      a default set of policies for splitting the displayed range into major/minor ticks depending on displayed range size