use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class Netlist method GetHiddenSinkNets.
private ArrayList<ConnectionPoint> GetHiddenSinkNets(Net thisNet, Byte bitIndex, ArrayList<Component> SplitterList, Component ActiveSplitter, Set<String> HandledNets, Boolean isSourceNet) {
ArrayList<ConnectionPoint> result = new ArrayList<ConnectionPoint>();
/*
* to prevent deadlock situations we check if we already looked at this
* net
*/
String NetId = Integer.toString(MyNets.indexOf(thisNet)) + "-" + Byte.toString(bitIndex);
if (HandledNets.contains(NetId)) {
return result;
} else {
HandledNets.add(NetId);
}
if (thisNet.hasBitSinks(bitIndex) && !isSourceNet) {
ConnectionPoint SolderPoint = new ConnectionPoint(null);
SolderPoint.SetParrentNet(thisNet, bitIndex);
result.add(SolderPoint);
}
/* Check if we have a connection to another splitter */
for (Component currentSplitter : SplitterList) {
if (ActiveSplitter != null) {
if (currentSplitter.equals(ActiveSplitter)) {
continue;
}
}
List<EndData> ends = currentSplitter.getEnds();
for (byte end = 0; end < ends.size(); end++) {
if (thisNet.contains(ends.get(end).getLocation())) {
/* Here we have to process the inherited bits of the parent */
byte[] BusBitConnection = ((Splitter) currentSplitter).GetEndpoints();
if (end == 0) {
/* this is a main net, find the connected end */
Byte SplitterEnd = BusBitConnection[bitIndex];
/* Find the corresponding Net index */
Byte Netindex = 0;
for (int index = 0; index < bitIndex; index++) {
if (BusBitConnection[index] == SplitterEnd) {
Netindex++;
}
}
/* Find the connected Net */
Net SlaveNet = null;
for (Net thisnet : MyNets) {
if (thisnet.contains(ends.get(SplitterEnd).getLocation())) {
SlaveNet = thisnet;
}
}
if (SlaveNet != null) {
if (SlaveNet.IsRootNet()) {
/* Trace down the slavenet */
result.addAll(GetHiddenSinkNets(SlaveNet, Netindex, SplitterList, currentSplitter, HandledNets, false));
} else {
result.addAll(GetHiddenSinkNets(SlaveNet.getParent(), SlaveNet.getBit(Netindex), SplitterList, currentSplitter, HandledNets, false));
}
}
} else {
ArrayList<Byte> Rootindices = new ArrayList<Byte>();
for (byte b = 0; b < BusBitConnection.length; b++) {
if (BusBitConnection[b] == end) {
Rootindices.add(b);
}
}
Net RootNet = null;
for (Net thisnet : MyNets) {
if (thisnet.contains(currentSplitter.getEnd(0).getLocation())) {
RootNet = thisnet;
}
}
if (RootNet != null) {
if (RootNet.IsRootNet()) {
result.addAll(GetHiddenSinkNets(RootNet, Rootindices.get(bitIndex), SplitterList, currentSplitter, HandledNets, false));
} else {
result.addAll(GetHiddenSinkNets(RootNet.getParent(), RootNet.getBit(Rootindices.get(bitIndex)), SplitterList, currentSplitter, HandledNets, false));
}
}
}
}
}
}
return result;
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class Netlist method HasHiddenSource.
private boolean HasHiddenSource(Net thisNet, Byte bitIndex, List<Component> SplitterList, Component ActiveSplitter, Set<String> HandledNets) {
/*
* to prevent deadlock situations we check if we already looked at this
* net
*/
String NetId = Integer.toString(MyNets.indexOf(thisNet)) + "-" + Byte.toString(bitIndex);
if (HandledNets.contains(NetId)) {
return false;
} else {
HandledNets.add(NetId);
}
if (thisNet.hasBitSource(bitIndex)) {
return true;
}
/* Check if we have a connection to another splitter */
for (Component currentSplitter : SplitterList) {
if (currentSplitter.equals(ActiveSplitter)) {
continue;
}
List<EndData> ends = currentSplitter.getEnds();
for (byte end = 0; end < ends.size(); end++) {
if (thisNet.contains(ends.get(end).getLocation())) {
/* Here we have to process the inherited bits of the parent */
byte[] BusBitConnection = ((Splitter) currentSplitter).GetEndpoints();
if (end == 0) {
/* this is a main net, find the connected end */
Byte SplitterEnd = BusBitConnection[bitIndex];
/* Find the corresponding Net index */
Byte Netindex = 0;
for (int index = 0; index < bitIndex; index++) {
if (BusBitConnection[index] == SplitterEnd) {
Netindex++;
}
}
/* Find the connected Net */
Net SlaveNet = null;
for (Net thisnet : MyNets) {
if (thisnet.contains(ends.get(SplitterEnd).getLocation())) {
SlaveNet = thisnet;
}
}
if (SlaveNet != null) {
if (SlaveNet.IsRootNet()) {
/* Trace down the slavenet */
if (HasHiddenSource(SlaveNet, Netindex, SplitterList, currentSplitter, HandledNets)) {
return true;
}
} else {
if (HasHiddenSource(SlaveNet.getParent(), SlaveNet.getBit(Netindex), SplitterList, currentSplitter, HandledNets)) {
return true;
}
}
}
} else {
ArrayList<Byte> Rootindices = new ArrayList<Byte>();
for (byte b = 0; b < BusBitConnection.length; b++) {
if (BusBitConnection[b] == end) {
Rootindices.add(b);
}
}
Net RootNet = null;
for (Net thisnet : MyNets) {
if (thisnet.contains(currentSplitter.getEnd(0).getLocation())) {
RootNet = thisnet;
}
}
if (RootNet != null) {
if (RootNet.IsRootNet()) {
if (HasHiddenSource(RootNet, Rootindices.get(bitIndex), SplitterList, currentSplitter, HandledNets)) {
return true;
}
} else {
if (HasHiddenSource(RootNet.getParent(), RootNet.getBit(Rootindices.get(bitIndex)), SplitterList, currentSplitter, HandledNets)) {
return true;
}
}
}
}
}
}
}
return false;
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class CanvasPainter method exposeHaloedComponent.
private void exposeHaloedComponent(Graphics g) {
Component c = haloedComponent;
if (c == null)
return;
Bounds bds = c.getBounds(g).expand(7);
int w = bds.getWidth();
int h = bds.getHeight();
double a = Canvas.SQRT_2 * w;
double b = Canvas.SQRT_2 * h;
canvas.repaint((int) Math.round(bds.getX() + w / 2.0 - a / 2.0), (int) Math.round(bds.getY() + h / 2.0 - b / 2.0), (int) Math.round(a), (int) Math.round(b));
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class Frame method setAttrTableModel.
void setAttrTableModel(AttrTableModel value) {
attrTable.setAttrTableModel(value);
if (value instanceof AttrTableToolModel) {
Tool tool = ((AttrTableToolModel) value).getTool();
toolbox.setHaloedTool(tool);
layoutToolbarModel.setHaloedTool(tool);
} else {
toolbox.setHaloedTool(null);
layoutToolbarModel.setHaloedTool(null);
}
if (value instanceof AttrTableComponentModel) {
Circuit circ = ((AttrTableComponentModel) value).getCircuit();
Component comp = ((AttrTableComponentModel) value).getComponent();
layoutCanvas.setHaloedComponent(circ, comp);
} else {
layoutCanvas.setHaloedComponent(null, null);
}
}
use of com.cburch.logisim.comp.Component in project logisim-evolution by reds-heig.
the class SelectionActions method drop.
// clears the selection, anchoring all floating elements in selection
public static Action drop(Selection sel, Collection<Component> comps) {
HashSet<Component> floating = new HashSet<Component>(sel.getFloatingComponents());
HashSet<Component> anchored = new HashSet<Component>(sel.getAnchoredComponents());
ArrayList<Component> toDrop = new ArrayList<Component>();
ArrayList<Component> toIgnore = new ArrayList<Component>();
for (Component comp : comps) {
if (floating.contains(comp)) {
toDrop.add(comp);
} else if (anchored.contains(comp)) {
toDrop.add(comp);
toIgnore.add(comp);
}
}
if (toDrop.size() == toIgnore.size()) {
for (Component comp : toIgnore) {
sel.remove(null, comp);
}
return null;
} else {
int numDrop = toDrop.size() - toIgnore.size();
return new Drop(sel, toDrop, numDrop);
}
}
Aggregations