Class TimeIntervalGraphics


  • public class TimeIntervalGraphics
    extends Object
    Class to draw time intervals as graphics, being able to indicate the colors to use (or default colors).

    The result graphics are like: |{background color}|time-interval{fill color}|{background color}|

    Author:
    Eduardo Ramos
    • Field Detail

      • DEFAULT_FILL

        public static final Color DEFAULT_FILL
      • DEFAULT_BORDER

        public static final Color DEFAULT_BORDER
      • min

        private double min
      • max

        private double max
      • range

        private double range
    • Constructor Detail

      • TimeIntervalGraphics

        public TimeIntervalGraphics​(double min,
                                    double max)
        Create a new TimeIntervalGraphics with the given minimum and maximum times to render intervals later.
        Parameters:
        min - Minimum time of all intervals
        max - Maximum time of all intervals
    • Method Detail

      • calculateRange

        private void calculateRange()
      • createTimeIntervalImage

        public BufferedImage createTimeIntervalImage​(double start,
                                                     double end,
                                                     int width,
                                                     int height)
        Creates a time interval graphic representation with default colors. If starts or ends are infinite, they will be normalized to the min or max values range.
        Parameters:
        start - Start of the interval (must be greater or equal than minimum time)
        end - End of the interval (must be lesser or equal than maximum time)
        width - Image width
        height - Image height
        Returns:
        Generated image for the interval
      • createTimeIntervalImage

        public BufferedImage createTimeIntervalImage​(double start,
                                                     double end,
                                                     int width,
                                                     int height,
                                                     Color fill,
                                                     Color border)
        Creates a time interval graphic representation with the indicated fill and border colors (or null to use default colors). If starts or ends are infinite, they will be normalized to the min or max values range.
        Parameters:
        start - Start of the interval (must be greater or equal than minimum time)
        end - End of the interval (must be lesser or equal than maximum time)
        width - Image width
        height - Image height
        fill - Fill color for the interval
        border - Border color for the interval
        Returns:
        Generated image for the interval
      • createTimeIntervalImage

        public BufferedImage createTimeIntervalImage​(double start,
                                                     double end,
                                                     int width,
                                                     int height,
                                                     Color fill,
                                                     Color border,
                                                     Color background)
        Creates a time interval graphic representation with the indicated fill and border colors (or null to use default colors). If starts or ends are infinite, they will be normalized to the min or max values range.
        Parameters:
        start - Start of the interval (must be greater or equal than minimum time)
        end - End of the interval (must be lesser or equal than maximum time)
        width - Image width
        height - Image height
        fill - Fill color for the interval
        border - Border color for the interval
        background - Background color
        Returns:
        Generated image for the interval
      • createTimeIntervalImage

        public BufferedImage createTimeIntervalImage​(double[] starts,
                                                     double[] ends,
                                                     int width,
                                                     int height,
                                                     Color fill,
                                                     Color border,
                                                     Color background)
        Creates a time interval graphic representation with the indicated fill, border and background colors (or null to use default colors). If starts or ends are infinite, they will be normalized to the min or max values range.
        Parameters:
        starts - Starts of the intervals (must be greater or equal than minimum time)
        ends - Ends of the intervals (must be lesser or equal than maximum time)
        width - Image width
        height - Image height
        fill - Fill color for the interval
        border - Border color for the interval
        background - Background color
        Returns:
        Generated image for the interval
      • getMax

        public double getMax()
      • setMax

        public void setMax​(double max)
      • getMin

        public double getMin()
      • setMin

        public void setMin​(double min)
      • normalize

        private double normalize​(double d)
      • normalizeToRange

        private double normalizeToRange​(double d)
      • setMinMax

        public void setMinMax​(double min,
                              double max)