Make inputs enter from the top of a block, outputs go to the bottom.

This commit is contained in:
Sergio Martínez Portela 2020-05-20 13:31:03 +02:00
parent b6c712860d
commit 4d477cfa5d
7 changed files with 34 additions and 28 deletions

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -53,13 +53,13 @@ public class Wire<T extends WireDataType, InputConnectorType extends InputConnec
samplePath.moveTo(_xinit, _yinit);
samplePath.cubicTo(
_xinit + _pathRunWay, _yinit,
_xend - _pathRunWay, _yend,
_xinit, _yinit + _pathRunWay,
_xend, _yend - _pathRunWay,
_xend, _yend);
Paint pathPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
pathPaint.setColor(Color.GREEN);
pathPaint.setStrokeWidth(5.0f);
pathPaint.setColor(Color.parseColor("#44FF44"));
pathPaint.setStrokeWidth(10.0f);
pathPaint.setStrokeCap(Paint.Cap.ROUND);
pathPaint.setStyle(Paint.Style.STROKE);

View File

@ -26,7 +26,7 @@
<com.codigoparallevar.minicards.CanvasView
android:id="@+id/canvasView"
android:layout_width="383dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="1dp" />