mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
show markers
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user