Class ColorRange


public class ColorRange extends Figure
This class may be used to draw a set of colors at a given bar location. Each color is defined by a region. The region consists of a color plus top and bottom values. The width of the color range will be the bar width of the graph. A background color may be specified to fill areas where no color has been defined.
  • Constructor Details

    • ColorRange

      public ColorRange(long time)
      Creates a color range at the given bar time.
      time - milliseconds since 1970
  • Method Details

    • layout

      public void layout(DrawContext ctx)
      Converts the color regions to displayable areas on the graph.
      layout in class Figure
      ctx - draw context
    • draw

      public void draw(Graphics2D gc, DrawContext ctx)
      This method draws the figure on the graph (using the given Graphics2D). This method is called by the study framework to display the figure on the graph.
      draw in class Figure
      gc - graphics context
      ctx - draw context
    • addRegion

      public void addRegion(Color color, double bottom, double top)
      Adds a color region to this range. The top and bottom values are 'real' values and will be converted to graph values in the 'layout' method.
      color - Color for the region
      bottom - 'real' bottom value
      top - 'real' top value
    • clearRegions

      public void clearRegions()
      Removes all of the regions defined for this color range.
    • setBackgroundColor

      public void setBackgroundColor(Color bg)
      Sets the background color for the color range. this is the color that is shown for undefined regions.
      bg - background color
    • getBackgroundColor

      public Color getBackgroundColor()
      Gets the background color for the color range. this is the color that is shown for undefined regions.
      background color for the color range.
    • getTime

      public long getTime()
      Gets the time (in milliseconds since 1970) where this bar is displayed.
      time where this bar is displayed