PartJunction* implemented
This commit is contained in:
parent
da23e1d40a
commit
b832482606
@ -22,6 +22,12 @@ public class CircuitPanelDropTarget extends AbstractDropTarget {
|
|||||||
final Point raster = div(point, RASTER);
|
final Point raster = div(point, RASTER);
|
||||||
if (data.equals(PartBattery.class.getSimpleName())) {
|
if (data.equals(PartBattery.class.getSimpleName())) {
|
||||||
circuitPanel.getCircuit().partAdd(new PartBattery(raster));
|
circuitPanel.getCircuit().partAdd(new PartBattery(raster));
|
||||||
|
} else if (data.equals(PartJunctionCorner.class.getSimpleName())) {
|
||||||
|
circuitPanel.getCircuit().partAdd(new PartJunctionCorner(raster));
|
||||||
|
} else if (data.equals(PartJunctionEdge.class.getSimpleName())) {
|
||||||
|
circuitPanel.getCircuit().partAdd(new PartJunctionEdge(raster));
|
||||||
|
} else if (data.equals(PartJunctionMiddle.class.getSimpleName())) {
|
||||||
|
circuitPanel.getCircuit().partAdd(new PartJunctionMiddle(raster));
|
||||||
} else if (data.equals(PartLight.class.getSimpleName())) {
|
} else if (data.equals(PartLight.class.getSimpleName())) {
|
||||||
circuitPanel.getCircuit().partAdd(new PartLight(raster));
|
circuitPanel.getCircuit().partAdd(new PartLight(raster));
|
||||||
} else if (data.equals(PartSwitch1x1.class.getSimpleName())) {
|
} else if (data.equals(PartSwitch1x1.class.getSimpleName())) {
|
||||||
@ -31,7 +37,7 @@ public class CircuitPanelDropTarget extends AbstractDropTarget {
|
|||||||
} else if (data.equals(PartSwitchCross.class.getSimpleName())) {
|
} else if (data.equals(PartSwitchCross.class.getSimpleName())) {
|
||||||
circuitPanel.getCircuit().partAdd(new PartSwitchCross(raster));
|
circuitPanel.getCircuit().partAdd(new PartSwitchCross(raster));
|
||||||
} else {
|
} else {
|
||||||
return false;
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
circuitPanel.repaint();
|
circuitPanel.repaint();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -0,0 +1,53 @@
|
|||||||
|
package de.ph87.electro.circuit.part.impl;
|
||||||
|
|
||||||
|
import de.ph87.electro.circuit.dto.PartSwitchCrossDto;
|
||||||
|
import de.ph87.electro.circuit.part.Junction;
|
||||||
|
import de.ph87.electro.circuit.part.Orientation;
|
||||||
|
import de.ph87.electro.circuit.part.PartOther;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
import static de.ph87.electro.CONFIG.*;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class PartJunctionCorner extends PartOther {
|
||||||
|
|
||||||
|
private final Junction j0;
|
||||||
|
|
||||||
|
private final Junction j1;
|
||||||
|
|
||||||
|
public PartJunctionCorner(final Point position) {
|
||||||
|
this("", position, Orientation.R0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PartJunctionCorner(final String name, final Point position, final Orientation orientation) {
|
||||||
|
super(name, position, orientation);
|
||||||
|
j0 = newJunction(this, "", JUNCTION_LEFT, JUNCTION_LEFT);
|
||||||
|
j1 = newJunction(this, "", JUNCTION_RIGHT, JUNCTION_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PartJunctionCorner(final PartSwitchCrossDto dto) {
|
||||||
|
super(dto);
|
||||||
|
j0 = newJunction(this, dto.getCommon0(), JUNCTION_LEFT, FOURTH1);
|
||||||
|
j1 = newJunction(this, dto.getOutput1(), JUNCTION_RIGHT, FOURTH3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void propagate(final Junction source) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void _render(final Graphics2D g) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action() {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package de.ph87.electro.circuit.part.impl;
|
||||||
|
|
||||||
|
import de.ph87.electro.circuit.dto.PartSwitchCrossDto;
|
||||||
|
import de.ph87.electro.circuit.part.Junction;
|
||||||
|
import de.ph87.electro.circuit.part.Orientation;
|
||||||
|
import de.ph87.electro.circuit.part.PartOther;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
import static de.ph87.electro.CONFIG.HALF;
|
||||||
|
import static de.ph87.electro.CONFIG.JUNCTION_LEFT;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class PartJunctionEdge extends PartOther {
|
||||||
|
|
||||||
|
private final Junction j0;
|
||||||
|
|
||||||
|
private final Junction j1;
|
||||||
|
|
||||||
|
public PartJunctionEdge(final Point position) {
|
||||||
|
this("", position, Orientation.R0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PartJunctionEdge(final String name, final Point position, final Orientation orientation) {
|
||||||
|
super(name, position, orientation);
|
||||||
|
j0 = newJunction(this, "", JUNCTION_LEFT, HALF);
|
||||||
|
j1 = newJunction(this, "", HALF, JUNCTION_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PartJunctionEdge(final PartSwitchCrossDto dto) {
|
||||||
|
super(dto);
|
||||||
|
j0 = newJunction(this, dto.getCommon0(), 0, HALF);
|
||||||
|
j1 = newJunction(this, dto.getOutput1(), HALF, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void propagate(final Junction source) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void _render(final Graphics2D g) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action() {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
package de.ph87.electro.circuit.part.impl;
|
||||||
|
|
||||||
|
import de.ph87.electro.circuit.dto.PartSwitchCrossDto;
|
||||||
|
import de.ph87.electro.circuit.part.Junction;
|
||||||
|
import de.ph87.electro.circuit.part.Orientation;
|
||||||
|
import de.ph87.electro.circuit.part.PartOther;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
import static de.ph87.electro.CONFIG.HALF;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class PartJunctionMiddle extends PartOther {
|
||||||
|
|
||||||
|
private final Junction junction;
|
||||||
|
|
||||||
|
public PartJunctionMiddle(final Point position) {
|
||||||
|
this("", position, Orientation.R0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PartJunctionMiddle(final String name, final Point position, final Orientation orientation) {
|
||||||
|
super(name, position, orientation);
|
||||||
|
junction = newJunction(this, "", HALF, HALF);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PartJunctionMiddle(final PartSwitchCrossDto dto) {
|
||||||
|
super(dto);
|
||||||
|
junction = newJunction(this, dto.getCommon0(), HALF, HALF);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void propagate(final Junction source) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void _render(final Graphics2D g) {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action() {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -10,6 +10,9 @@ public class Sidebar extends JPanel {
|
|||||||
|
|
||||||
public Sidebar() {
|
public Sidebar() {
|
||||||
add(new PartBattery(new Point(0, 0)));
|
add(new PartBattery(new Point(0, 0)));
|
||||||
|
add(new PartJunctionCorner(new Point(0, 0)));
|
||||||
|
add(new PartJunctionEdge(new Point(0, 0)));
|
||||||
|
add(new PartJunctionMiddle(new Point(0, 0)));
|
||||||
add(new PartLight(new Point(0, 0)));
|
add(new PartLight(new Point(0, 0)));
|
||||||
add(new PartSwitch1x1(new Point(0, 0)));
|
add(new PartSwitch1x1(new Point(0, 0)));
|
||||||
add(new PartSwitch1x2(new Point(0, 0)));
|
add(new PartSwitch1x2(new Point(0, 0)));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user