From 4d477cfa5d9bcf35bbfd4724e10d2f3c5a0c6af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Wed, 20 May 2020 13:31:03 +0200 Subject: [PATCH] Make inputs enter from the top of a block, outputs go to the bottom. --- .../minicards/parts/buttons/RoundButton.java | 4 ++-- .../minicards/parts/logic/Ticker.java | 7 ++++--- .../minicards/parts/logic/Toggle.java | 14 +++++++------ .../minicards/parts/samples/ColorBox.java | 7 ++++--- .../parts/strings/ConvertToString.java | 20 ++++++++++--------- .../types/connectors/Wiring/Wire.java | 8 ++++---- app/src/main/res/layout/activity_main.xml | 2 +- 7 files changed, 34 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/com/codigoparallevar/minicards/parts/buttons/RoundButton.java b/app/src/main/java/com/codigoparallevar/minicards/parts/buttons/RoundButton.java index d6f9b38..c421613 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/parts/buttons/RoundButton.java +++ b/app/src/main/java/com/codigoparallevar/minicards/parts/buttons/RoundButton.java @@ -115,11 +115,11 @@ public class RoundButton implements Part { } private int getOutputConnectorCenterX() { - return _xCenter + _outerRadius; + return _xCenter; } private int getOutputConnectorCenterY() { - return _yCenter; + return _yCenter + _outerRadius; } private int getOutputConnectRadius() { diff --git a/app/src/main/java/com/codigoparallevar/minicards/parts/logic/Ticker.java b/app/src/main/java/com/codigoparallevar/minicards/parts/logic/Ticker.java index 4629bc3..c99db56 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/parts/logic/Ticker.java +++ b/app/src/main/java/com/codigoparallevar/minicards/parts/logic/Ticker.java @@ -147,7 +147,8 @@ public class Ticker implements Part { Paint connectorPaint = new Paint(Paint.ANTI_ALIAS_FLAG); connectorPaint.setColor(Color.RED); - canvas.drawCircle(_right, getOutputConnectorCenterY(), + canvas.drawCircle(getOutputConnectorCenterX(), + getOutputConnectorCenterY(), getOutputConnectRadius(), connectorPaint); } @@ -289,11 +290,11 @@ public class Ticker implements Part { private int getOutputConnectorCenterX() { - return _right; + return (_left + _right) / 2; } private int getOutputConnectorCenterY() { - return (_top + _bottom) / 2; + return _bottom; } private int getOutputConnectRadius() { diff --git a/app/src/main/java/com/codigoparallevar/minicards/parts/logic/Toggle.java b/app/src/main/java/com/codigoparallevar/minicards/parts/logic/Toggle.java index 4d7132f..f7b6dd7 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/parts/logic/Toggle.java +++ b/app/src/main/java/com/codigoparallevar/minicards/parts/logic/Toggle.java @@ -132,14 +132,16 @@ public class Toggle implements Part { inputConnectorPaint.setColor(Color.YELLOW); canvas.drawCircle( - getInputConnectorCenterX(), getInputConnectorCenterY(), + getInputConnectorCenterX(), + getInputConnectorCenterY(), getInputConnectRadius(), inputConnectorPaint); Paint outputConnectorPaint = new Paint(Paint.ANTI_ALIAS_FLAG); outputConnectorPaint.setColor(Color.RED); - canvas.drawCircle(_right, getOutputConnectorCenterY(), + canvas.drawCircle(getOutputConnectorCenterX(), + getOutputConnectorCenterY(), getOutputConnectRadius(), outputConnectorPaint); } @@ -306,7 +308,7 @@ public class Toggle implements Part { } public int getInputConnectorCenterX() { - return get_left(); + return (get_left() + get_right()) / 2; } private int getInputConnectRadius() { @@ -314,15 +316,15 @@ public class Toggle implements Part { } public int getInputConnectorCenterY() { - return (get_top() + get_bottom()) / 2; + return get_top(); } private int getOutputConnectorCenterX() { - return _right; + return (get_left() + get_right()) / 2; } private int getOutputConnectorCenterY() { - return (_top + _bottom) / 2; + return get_bottom(); } private int getOutputConnectRadius() { diff --git a/app/src/main/java/com/codigoparallevar/minicards/parts/samples/ColorBox.java b/app/src/main/java/com/codigoparallevar/minicards/parts/samples/ColorBox.java index 57613f6..0b16e36 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/parts/samples/ColorBox.java +++ b/app/src/main/java/com/codigoparallevar/minicards/parts/samples/ColorBox.java @@ -109,7 +109,8 @@ public class ColorBox implements Part { connectorPaint.setColor(Color.YELLOW); canvas.drawCircle( - getInputConnectorCenterX(), getInputConnectorCenterY(), + getInputConnectorCenterX(), + getInputConnectorCenterY(), getInputConnectRadius(), connectorPaint); } @@ -238,7 +239,7 @@ public class ColorBox implements Part { } public int getInputConnectorCenterX() { - return get_left(); + return (get_left() + get_right()) / 2; } private int getInputConnectRadius() { @@ -246,7 +247,7 @@ public class ColorBox implements Part { } public int getInputConnectorCenterY() { - return (get_top() + get_bottom()) / 2; + return get_top(); } public static PartInstantiator getInstantiator() { diff --git a/app/src/main/java/com/codigoparallevar/minicards/parts/strings/ConvertToString.java b/app/src/main/java/com/codigoparallevar/minicards/parts/strings/ConvertToString.java index 19535b4..09491d2 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/parts/strings/ConvertToString.java +++ b/app/src/main/java/com/codigoparallevar/minicards/parts/strings/ConvertToString.java @@ -110,7 +110,7 @@ public class ConvertToString implements Part { drawWires(canvas, devMode); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); - paint.setColor(Color.WHITE); + paint.setColor(Color.BLACK); canvas.drawRect( new Rect(_left, _top, _right, _bottom), @@ -120,8 +120,8 @@ public class ConvertToString implements Part { textPaint.setColor(Color.GREEN); textPaint.setTextSize(100); canvas.drawText(_lastValue, - _left, - _top - 5, + _left + 10, + _bottom - 10, textPaint); } } @@ -131,14 +131,16 @@ public class ConvertToString implements Part { inputConnectorPaint.setColor(Color.YELLOW); canvas.drawCircle( - getInputConnectorCenterX(), getInputConnectorCenterY(), + getInputConnectorCenterX(), + getInputConnectorCenterY(), getInputConnectRadius(), inputConnectorPaint); Paint outputConnectorPaint = new Paint(Paint.ANTI_ALIAS_FLAG); outputConnectorPaint.setColor(Color.RED); - canvas.drawCircle(_right, getOutputConnectorCenterY(), + canvas.drawCircle(getOutputConnectorCenterX(), + getOutputConnectorCenterY(), getOutputConnectRadius(), outputConnectorPaint); } @@ -315,7 +317,7 @@ public class ConvertToString implements Part { } public int getInputConnectorCenterX() { - return get_left(); + return (get_left() + get_right()) / 2; } private int getInputConnectRadius() { @@ -323,15 +325,15 @@ public class ConvertToString implements Part { } public int getInputConnectorCenterY() { - return (get_top() + get_bottom()) / 2; + return get_top(); } private int getOutputConnectorCenterX() { - return _right; + return (get_left() + get_right()) / 2; } private int getOutputConnectorCenterY() { - return (_top + _bottom) / 2; + return get_bottom(); } private int getOutputConnectRadius() { diff --git a/app/src/main/java/com/codigoparallevar/minicards/types/connectors/Wiring/Wire.java b/app/src/main/java/com/codigoparallevar/minicards/types/connectors/Wiring/Wire.java index 10cf453..d292ad0 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/types/connectors/Wiring/Wire.java +++ b/app/src/main/java/com/codigoparallevar/minicards/types/connectors/Wiring/Wire.java @@ -53,13 +53,13 @@ public class Wire