private void drawXAxis(Graphics g, Font font) {
    if (!xAxis.isDisplayed()) return;

    Color oldColor = g.getColor();
    g.setColor(Color.BLACK);

    float leftBorder = getLeftBorder();
    int yVal = getHeight() - getNumPixelsReservedOnBottom();

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

    float xInterval = (getWidth() - leftBorder) / xAxis.getNumberTicks();
    FontMetrics fm = g.getFontMetrics(font);

    for (int x = 1; x < xAxis.getNumberTicks(); x++) {
      float xPos = leftBorder + (xInterval * x);
      g.setColor(Color.GRAY);

      g.drawLine((int) xPos, yVal, (int) (xPos), yVal + 5);

      float axisValue =
          xAxis.getLowVal()
              + (x / ((float) xAxis.getNumberTicks())) * (xAxis.getHighVal() - xAxis.getLowVal());
      String axisString = new String("" + (int) (axisValue + 0.5));
      float tickLabelPos = xPos - fm.stringWidth(axisString) / 2;
      g.setColor(Color.BLACK);
      g.drawString(axisString, (int) tickLabelPos, yVal + 18);
    }

    g.setColor(oldColor);
  }
  private int getYValue(HitScores hs, int ySize) {
    float val = selectedYAxis.getVal(hs);

    if (val > selectedYAxis.getHighVal()) return 0;

    if (val < selectedYAxis.getLowVal()) return ySize;

    float yVal =
        ySize
            - ySize
                * (val - selectedYAxis.getLowVal())
                / (selectedYAxis.getHighVal() - selectedYAxis.getLowVal());
    return (int) yVal;
  }
  private int getXValue(int xPos, int xSize) {
    if (xPos < xAxis.getLowVal()) return 0;

    if (xPos > xAxis.getHighVal()) return xSize;

    int numPixelsToReserve = getLeftBorder();

    float xVal =
        numPixelsToReserve
            + (xSize - numPixelsToReserve)
                * (xPos - xAxis.getLowVal())
                / (xAxis.getHighVal() - xAxis.getLowVal());
    return (int) xVal;
  }
  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);
  }
 public int getLowX() {
   return (int) xAxis.getLowVal();
 }