class RangeSelectionComponent extends AnimatedComponent {

  @Override
  protected void draw(Graphics2D g, Dimension dim) {
    // Draws if the selection range is fully visible or partially visible; and hide if it is empty or not visible.
    Range selectionRange = myModel.getSelectionRange();
    if (selectionRange.isEmpty() || selectionRange.getMin() > myViewRange.getMax() || selectionRange.getMax() < myViewRange.getMin()) {
      return;
    }
    float startXPos = rangeToX(selectionRange.getMin(), dim);
    float endXPos = rangeToX(selectionRange.getMax(), dim);
    float handleDistance = endXPos - startXPos - HANDLE_WIDTH * 2;
    if (handleDistance < MIN_HANDLE_DISTANCE) {
      // When handles are too close to each other, keep a minimum distance and adjust handle position from the mid-point.
      // |h|<-min->|h|
      // s           e
      //
      // s: start
      // e: end
      // h: handle length
      // min: min distance between handles
      handleDistance = MIN_HANDLE_DISTANCE;
      startXPos = (startXPos + endXPos) / 2 - HANDLE_WIDTH - MIN_HANDLE_DISTANCE / 2;
      endXPos = startXPos + HANDLE_WIDTH * 2 + MIN_HANDLE_DISTANCE;
    }

    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // Draw selection area.
    g.setColor(StudioColorsKt.getContentSelectionBackground());
    Rectangle2D.Float rect = new Rectangle2D.Float(startXPos + HANDLE_WIDTH, 0, handleDistance, dim.height);
    g.fill(rect);

    if (myMouseMovedX > startXPos && myMouseMovedX < endXPos && myIsMouseOverComponent) {
      g.setColor(DRAG_BAR_COLOR);
      g.fill(new Rectangle2D.Float(startXPos + HANDLE_WIDTH, 0, handleDistance, myDragBarHeight));
    }

    // Draw handles.
    g.setColor(StudioColorsKt.getSelectionBackground());
    g.fill(new Rectangle2D.Float(startXPos, 0, HANDLE_WIDTH, dim.height));
    g.fill(new Rectangle2D.Float(endXPos - HANDLE_WIDTH, 0, HANDLE_WIDTH, dim.height));
  }

  public  RangeSelectionComponent(@NotNull RangeSelectionModel model, @NotNull Range viewRange);
  public  RangeSelectionComponent(@NotNull RangeSelectionModel model, @NotNull Range viewRange, boolean isPointSelectionReplaced);

}