public void draw(Graphics g, int max) { if (enterable) { float hue = ((float) cost / (float) max); if (solution || (moveable != null && moveable.solution)) { g.setColor(new Color(Color.HSBtoRGB(1.0f - hue, 1f, 1f))); } else { g.setColor(new Color(Color.HSBtoRGB(hue, 0.5f, 0.8f))); } g.fillRect(x * size, y * size, size, size); } else { g.setColor(Color.BLACK); g.fillRect(x * size, y * size, size, size); } g.setColor(Color.BLACK); g.drawRect(x * size, y * size, size, size); if (enterable) { g.setColor(Color.RED); g.drawString(cost + "", (x * size) + (size / 2), (y * size) + (size / 2)); } if (moveable != null) { moveable.draw(g, cost); } }