From 594f0ee2f39ada0cfc0ddac86add6ead81d45ce6 Mon Sep 17 00:00:00 2001 From: hneemann Date: Mon, 11 Nov 2019 11:14:55 +0100 Subject: [PATCH] minor modification on the "Button with LED" shape --- .../digital/draw/shapes/ButtonLEDShape.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/neemann/digital/draw/shapes/ButtonLEDShape.java b/src/main/java/de/neemann/digital/draw/shapes/ButtonLEDShape.java index 2d0b2fd72..91aa6cc47 100644 --- a/src/main/java/de/neemann/digital/draw/shapes/ButtonLEDShape.java +++ b/src/main/java/de/neemann/digital/draw/shapes/ButtonLEDShape.java @@ -72,17 +72,17 @@ public class ButtonLEDShape extends ButtonShape { public void drawTo(Graphic graphic, Style heighLight) { super.drawTo(graphic, heighLight); - if (ledValue == null || ledValue.getBool()) { - Vector center; - if (button != null && button.isPressed()) { - center = new Vector(-OUT_SIZE - 1, 0); - } else - center = new Vector(-OUT_SIZE - 1 - ButtonShape.HEIGHT, -ButtonShape.HEIGHT); + boolean ledOn = ledValue == null || ledValue.getBool(); + boolean pressed = button != null && button.isPressed(); + + Vector center; + if (pressed) { + center = new Vector(-OUT_SIZE - 1, 0); + } else + center = new Vector(-OUT_SIZE - 1 - ButtonShape.HEIGHT, -ButtonShape.HEIGHT); + + if (ledOn) graphic.drawCircle(center.add(-SIZE2, -SIZE2), center.add(SIZE2, SIZE2), color); - graphic.drawCircle(center.add(-SIZE2, -SIZE2), center.add(SIZE2, SIZE2), Style.THIN); - } else { - Vector center = new Vector(-OUT_SIZE - 1 - ButtonShape.HEIGHT, -ButtonShape.HEIGHT); - graphic.drawCircle(center.add(-SIZE2, -SIZE2), center.add(SIZE2, SIZE2), Style.THIN); - } + graphic.drawCircle(center.add(-SIZE2, -SIZE2), center.add(SIZE2, SIZE2), Style.THIN); } }