I have to use a GUI Element that draws a picture at a specific screen position. If the user selects this picture there is a border drawn around the Image. Now we want to include another border that identifies pictures with a specific value for the user.
At the moment the Element looks at his internal state if it is selected and then decides how to draw itself.
graphic.drawImage(icon, x, y, null);
if (selected) {
drawBorder();
}
I don't like the idea of adding another if else to this drawing method. I thought about creating a new class that inherits the behavior of the element and overwrites the draw method but that means duplicating the whole selected code in every inherited class. Is there a nice possibility so solve this problem without creating a subclass?