private int getLeftBorder() {
    int numPixelsToReserve = selectedYAxis.getNumPixelsReserved();

    if (!selectedYAxis.isDisplayed) numPixelsToReserve = 0;

    return numPixelsToReserve;
  }
  private void drawYAxisAndHorizontalLines(Graphics g, Font fontForAxisLabels) {
    Color oldColor = g.getColor();
    g.setColor(Color.BLACK);

    float ySize = getHeight() - getNumPixelsReservedOnBottom();

    if (selectedYAxis.isDisplayed())
      g.drawLine(
          selectedYAxis.getNumPixelsReserved(),
          0,
          selectedYAxis.getNumPixelsReserved(),
          (int) ySize);

    if (selectedYAxis.getNumberTicks() < 1) return;

    g.setFont(fontForAxisLabels);
    int leftBorder = getLeftBorder();

    if (selectedYAxis.isDisplayed()) {
      g.setColor(Color.RED);
      g.drawString(selectedYAxis.getAxisName(), selectedYAxis.numPixelsReserved, 10);
      g.setColor(Color.BLACK);
    }

    float yInterval = ySize / selectedYAxis.getNumberTicks();
    FontMetrics fm = g.getFontMetrics(fontForAxisLabels);
    int stringAscent = fm.getAscent();

    for (int x = 1; x < selectedYAxis.getNumberTicks(); x++) {
      int yVal = (int) (yInterval * x);
      g.setColor(Color.GRAY);

      g.drawLine(leftBorder, yVal, getWidth(), yVal);

      float axisValue =
          selectedYAxis.getHighVal()
              - (x / ((float) selectedYAxis.getNumberTicks()))
                  * (selectedYAxis.getHighVal() - selectedYAxis.getLowVal());
      String axisString = getYAxisTickLabel(axisValue);
      int tickLabelPos = selectedYAxis.getNumPixelsReserved() - fm.stringWidth(axisString) - 2;
      g.setColor(Color.BLACK);

      if (selectedYAxis.isDisplayed())
        g.drawString(axisString, tickLabelPos, yVal + stringAscent / 2);
    }
    g.setColor(oldColor);
  }
  private int getNumPixelsReservedOnBottom() {
    int numPixelsReserved = 0;

    if (showGeneAnnotations) numPixelsReserved += numPixelsReservedForGeneAnnotations;

    if (xAxis.isDisplayed) numPixelsReserved += xAxis.getNumPixelsReserved();

    return numPixelsReserved;
  }
  public void drawGenbankAnnotations(Graphics g) {
    this.colorIndex = 0;
    int yOffset = 3;

    g.setFont(new Font("SansSerif", Font.BOLD, 12));

    if (genbankAnnotationList == null || !showGeneAnnotations) return;

    int leftBorder = selectedYAxis.isDisplayed() ? selectedYAxis.getNumPixelsReserved() : 0;
    int xSize = getWidth();

    Color oldColor = g.getColor();
    int offSetSize = numPixelsReservedForGeneAnnotations / 5;

    for (GenbankAnnotations ga : genbankAnnotationList) {
      this.colorIndex++;
      yOffset += offSetSize;
      if (yOffset > numPixelsReservedForGeneAnnotations) yOffset = 3;

      if (colorIndex >= colors.length) colorIndex = 0;

      g.setColor(colors[colorIndex]);

      int x1 = getXValue(ga.getBeginPos(), xSize);
      int x2 = getXValue(ga.getEndPos(), xSize);

      // dummy values of 1 and 100 as the y axis is always ok for annotations
      if (lineIsInFrame(x1, x2, 1, xSize, 100)) {
        int yValue = getHeight() - yOffset;

        drawSomeLines(g, x1, x2, yValue, leftBorder, xSize);
        ga.setXPixelStart(x1);
        ga.setXPixelEnd(x2);

        if (showGeneLabels) {
          g.setColor(Color.BLACK);
          g.drawString(ga.getProduct(), x1, yValue);
        }

      } else {
        ga.setXPixelStart(-1);
        ga.setXPixelEnd(-1);
      }
    }

    g.setColor(oldColor);
  }