mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +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;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -533,8 +533,7 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Highlight Connected")
|
||||
@Override
|
||||
public Boolean getHighlightConnectedTerminals() {
|
||||
public Boolean getShowMarkers() {
|
||||
if (highlightConnectedTerminals == null) {
|
||||
highlightConnectedTerminals = false;
|
||||
}
|
||||
|
||||
-14
@@ -107,7 +107,6 @@ public class RotarySwitchOpen extends AbstractAngledComponent<RotarySwitchOpenTy
|
||||
private double[] pointAngles;
|
||||
|
||||
private Integer selectedPosition;
|
||||
private Boolean highlightConnectedTerminals;
|
||||
|
||||
public RotarySwitchOpen() {
|
||||
super();
|
||||
@@ -600,19 +599,6 @@ public class RotarySwitchOpen extends AbstractAngledComponent<RotarySwitchOpenTy
|
||||
this.selectedPosition = selectedPosition;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Highlight Connected")
|
||||
@Override
|
||||
public Boolean getHighlightConnectedTerminals() {
|
||||
if (highlightConnectedTerminals == null) {
|
||||
highlightConnectedTerminals = false;
|
||||
}
|
||||
return highlightConnectedTerminals;
|
||||
}
|
||||
|
||||
public void setHighlightConnectedTerminals(Boolean highlightConnectedTerminals) {
|
||||
this.highlightConnectedTerminals = highlightConnectedTerminals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
Shape[] body = getBody();
|
||||
|
||||
+1
-2
@@ -505,8 +505,7 @@ public class SlideSwitch extends AbstractTransparentComponent<SlideSwitchType> i
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Highlight Connected")
|
||||
@Override
|
||||
public Boolean getHighlightConnectedTerminals() {
|
||||
public Boolean getShowMarkers() {
|
||||
if (highlightConnectedTerminals == null) {
|
||||
highlightConnectedTerminals = false;
|
||||
}
|
||||
|
||||
@@ -451,8 +451,7 @@ public class Freeway3x3_03 extends AbstractTransparentComponent<Void> implements
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Highlight Connected")
|
||||
@Override
|
||||
public Boolean getHighlightConnectedTerminals() {
|
||||
public Boolean getShowMarkers() {
|
||||
if (highlightConnectedTerminals == null) {
|
||||
highlightConnectedTerminals = false;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class LeverSwitch extends AbstractAngledComponent<LeverSwitch.LeverSwitch
|
||||
@Deprecated
|
||||
private Boolean highlightCommon;
|
||||
private Integer selectedPosition;
|
||||
private Boolean highlightConnectedTerminals;
|
||||
private Boolean showMarkers;
|
||||
|
||||
public LeverSwitch() {
|
||||
super();
|
||||
@@ -521,17 +521,16 @@ public class LeverSwitch extends AbstractAngledComponent<LeverSwitch.LeverSwitch
|
||||
this.body = null;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Highlight Connected")
|
||||
@Override
|
||||
public Boolean getHighlightConnectedTerminals() {
|
||||
if (highlightConnectedTerminals == null) {
|
||||
highlightConnectedTerminals = false;
|
||||
@EditableProperty(name = "Markers")
|
||||
public Boolean getShowMarkers() {
|
||||
if (showMarkers == null) {
|
||||
showMarkers = false;
|
||||
}
|
||||
return highlightConnectedTerminals;
|
||||
return showMarkers;
|
||||
}
|
||||
|
||||
public void setHighlightConnectedTerminals(Boolean highlightConnectedTerminals) {
|
||||
this.highlightConnectedTerminals = highlightConnectedTerminals;
|
||||
public void setShowMarkers(Boolean showMarkers) {
|
||||
this.showMarkers = showMarkers;
|
||||
this.body = null;
|
||||
}
|
||||
|
||||
|
||||
+7
-8
@@ -90,7 +90,7 @@ public class SchallerMegaSwitch extends AbstractAngledComponent<String> implemen
|
||||
private transient Double labelDy = null;
|
||||
|
||||
private Integer selectedPosition;
|
||||
private Boolean highlightConnectedTerminals;
|
||||
private Boolean showMarkers;
|
||||
|
||||
public SchallerMegaSwitch() {
|
||||
super();
|
||||
@@ -570,16 +570,15 @@ public class SchallerMegaSwitch extends AbstractAngledComponent<String> implemen
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Highlight Connected")
|
||||
@Override
|
||||
public Boolean getHighlightConnectedTerminals() {
|
||||
if (highlightConnectedTerminals == null) {
|
||||
highlightConnectedTerminals = false;
|
||||
public Boolean getShowMarkers() {
|
||||
if (showMarkers == null) {
|
||||
showMarkers = false;
|
||||
}
|
||||
return highlightConnectedTerminals;
|
||||
return showMarkers;
|
||||
}
|
||||
|
||||
public void setHighlightConnectedTerminals(Boolean highlightConnectedTerminals) {
|
||||
this.highlightConnectedTerminals = highlightConnectedTerminals;
|
||||
public void setShowMarkers(Boolean showMarkers) {
|
||||
this.showMarkers = showMarkers;
|
||||
this.body = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user