public Bounds getOffsetBounds() { InstanceComponent c = comp; if (c == null) { return factory.getOffsetBounds(attrs); } else { Location loc = c.getLocation(); return c.getBounds().translate(-loc.getX(), -loc.getY()); } }
public Value getPortValue(int portIndex) { InstanceComponent c = comp; CircuitState s = context.getCircuitState(); if (c != null && s != null) { return s.getValue(c.getEnd(portIndex).getLocation()); } else { return Value.UNKNOWN; } }
public void drawLabel() { if (comp != null) { comp.drawLabel(context); } }
public boolean isPortConnected(int index) { Circuit circ = context.getCircuit(); Location loc = comp.getEnd(index).getLocation(); return circ.isConnected(loc, comp); }
// // methods related to the instance // public Instance getInstance() { InstanceComponent c = comp; return c == null ? null : c.getInstance(); }
public Location getLocation() { InstanceComponent c = comp; return c == null ? Location.create(0, 0) : c.getLocation(); }
public InstanceFactory getFactory() { return comp == null ? factory : (InstanceFactory) comp.getFactory(); }
public Bounds getBounds() { InstanceComponent c = comp; return c == null ? factory.getOffsetBounds(attrs) : c.getBounds(); }
public <E> E getAttributeValue(Attribute<E> attr) { InstanceComponent c = comp; AttributeSet as = c == null ? attrs : c.getAttributeSet(); return as.getValue(attr); }
public AttributeSet getAttributeSet() { InstanceComponent c = comp; return c == null ? attrs : c.getAttributeSet(); }
public void fireInvalidated() { comp.fireInvalidated(); }