mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Multi-layer PCB support
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
|||||||
|
package org.diylc.common;
|
||||||
|
|
||||||
|
public enum PCBLayer {
|
||||||
|
|
||||||
|
_1, _2, _3, _4, _5;
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return name().substring(1);
|
||||||
|
};
|
||||||
|
}
|
||||||
-23
@@ -1,23 +0,0 @@
|
|||||||
package org.diylc.presenter;
|
|
||||||
|
|
||||||
import org.diylc.common.ComponentType;
|
|
||||||
import org.diylc.common.IComponentFiler;
|
|
||||||
import org.diylc.core.IDIYComponent;
|
|
||||||
|
|
||||||
public class ComponentZOrderFiler implements IComponentFiler {
|
|
||||||
|
|
||||||
private int zOrder;
|
|
||||||
|
|
||||||
public ComponentZOrderFiler(int zOrder) {
|
|
||||||
super();
|
|
||||||
this.zOrder = zOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public boolean testComponent(IDIYComponent<?> component) {
|
|
||||||
ComponentType componentType = ComponentProcessor.getInstance().extractComponentTypeFrom(
|
|
||||||
(Class<? extends IDIYComponent<?>>) component.getClass());
|
|
||||||
return Math.round(componentType.getZOrder()) == zOrder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package org.diylc.presenter;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.diylc.common.IComponentFiler;
|
||||||
|
import org.diylc.common.PCBLayer;
|
||||||
|
import org.diylc.core.IDIYComponent;
|
||||||
|
|
||||||
|
public class PCBLayerFiler implements IComponentFiler {
|
||||||
|
|
||||||
|
private PCBLayer layer;
|
||||||
|
|
||||||
|
public PCBLayerFiler(PCBLayer layer) {
|
||||||
|
super();
|
||||||
|
this.layer = layer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean testComponent(IDIYComponent<?> component) {
|
||||||
|
Class<?> clazz = component.getClass();
|
||||||
|
try {
|
||||||
|
Method m = clazz.getMethod("getLayer", null);
|
||||||
|
PCBLayer l = (PCBLayer) m.invoke(component);
|
||||||
|
return layer == l;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user