show markers

This commit is contained in:
Bane Stojkovic
2025-03-27 19:18:43 +01:00
parent 8267d17ff7
commit b3ad9cc0d9
9 changed files with 44 additions and 40 deletions
@@ -21,7 +21,9 @@
*/
package org.diylc.core;
import java.awt.*;
import java.awt.Color;
import java.util.List;
import java.util.Map;
/**
* Interface for all component that can act as switches. They must have at least one position.
@@ -81,4 +83,6 @@ public interface ISwitch extends IContinuity {
}
return arePointsConnected(index1, index2, getSelectedPosition());
}
List<Integer> getCommonPoints();
}
@@ -27,6 +27,26 @@ import java.util.*;
public class SwitchUtils {
public static Map<Integer, List<List<Integer>>> getSwitchingMatrix(ISwitch switchComponent, int numPoints) {
Map<Integer, List<List<Integer>>> result = new HashMap<>();
for (Integer commonPoint : switchComponent.getCommonPoints()) {
List<List<Integer>> connectedPoints = new ArrayList<>();
result.put(commonPoint, connectedPoints);
for (int i = 0; i < switchComponent.getPositionCount(); i++) {
List<Integer> positionPoints = new ArrayList<>();
for (int j = 0; j < numPoints; j++) {
if (commonPoint != j && switchComponent.arePointsConnected(commonPoint, j, i)) {
positionPoints.add(j);
}
}
connectedPoints.add(positionPoints);
}
}
return result;
}
public static List<Set<Integer>> getConnectedTerminals(ISwitch switchComponent, int numPoints) {
if (!Boolean.TRUE.equals(switchComponent.getHighlightConnectedTerminals())) {
@@ -33,8 +33,7 @@ public class SwitchUtilsTest {
return selectedPosition;
}
@Override
public Boolean getHighlightConnectedTerminals() {
public Boolean getShowMarkers() {
return renderConnected;
}