private void drawSteeringWheel(Graphics g, int panelWidth, int panelHeight) { // outer circle int x = panelWidth / 2 - WheelRadius; int y = panelHeight / 2 - WheelRadius; Color defaultColor = this.getBackground(); g.setColor(Color.LIGHT_GRAY); g.fillOval(x, y, WheelRadius * 2, WheelRadius * 2); // inner circle int innerWheelRadius = (int) (WheelRadius * InnerWheelRatio); x = panelWidth / 2 - innerWheelRadius; y = panelHeight / 2 - innerWheelRadius; g.setColor(defaultColor); g.fillOval(x, y, innerWheelRadius * 2, innerWheelRadius * 2); double steeringWheelRotation = in.getSteeringWheelSignedPercentage(); // drawing the 'needle' { double needleRadius = (WheelRadius - innerWheelRadius) / 2; double needleRotation = (steeringWheelRotation * WheelMovementScaleRatio - 90); double needleLength = innerWheelRadius + needleRadius; x = (int) (panelWidth / 2 - needleRadius + Math.cos(Math.toRadians(needleRotation)) * needleLength); y = (int) (panelHeight / 2 - needleRadius + Math.sin(Math.toRadians(needleRotation)) * needleLength); g.setColor(Color.DARK_GRAY); g.fillOval(x, y, (int) needleRadius * 2, (int) needleRadius * 2); } // drawing the value in text x = panelWidth / 2 - g.getFontMetrics().stringWidth(steeringWheelRotation + "%") / 2; y = panelHeight / 2; g.setColor(Color.BLACK); g.drawString(steeringWheelRotation + "%", x, y); }