Search in sources :

Example 1 with AppearancePort

use of com.cburch.logisim.circuit.appear.AppearancePort in project logisim-evolution by reds-heig.

the class LayoutPopupManager method showPopup.

private void showPopup(Set<AppearancePort> portObjects) {
    dragStart = null;
    CircuitState circuitState = canvas.getCircuitState();
    if (circuitState == null)
        return;
    ArrayList<Instance> ports = new ArrayList<Instance>(portObjects.size());
    for (AppearancePort portObject : portObjects) {
        ports.add(portObject.getPin());
    }
    hideCurrentPopup();
    LayoutThumbnail layout = new LayoutThumbnail();
    layout.setCircuit(circuitState, ports);
    JViewport owner = canvasPane.getViewport();
    Point ownerLoc = owner.getLocationOnScreen();
    Dimension ownerDim = owner.getSize();
    Dimension layoutDim = layout.getPreferredSize();
    int x = ownerLoc.x + Math.max(0, ownerDim.width - layoutDim.width - 5);
    int y = ownerLoc.y + Math.max(0, ownerDim.height - layoutDim.height - 5);
    PopupFactory factory = PopupFactory.getSharedInstance();
    Popup popup = factory.getPopup(canvasPane.getViewport(), layout, x, y);
    popup.show();
    curPopup = popup;
    curPopupTime = System.currentTimeMillis();
}
Also used : CircuitState(com.cburch.logisim.circuit.CircuitState) AppearancePort(com.cburch.logisim.circuit.appear.AppearancePort) PopupFactory(javax.swing.PopupFactory) Instance(com.cburch.logisim.instance.Instance) JViewport(javax.swing.JViewport) Popup(javax.swing.Popup) ArrayList(java.util.ArrayList) Point(java.awt.Point) Dimension(java.awt.Dimension) Point(java.awt.Point)

Aggregations

CircuitState (com.cburch.logisim.circuit.CircuitState)1 AppearancePort (com.cburch.logisim.circuit.appear.AppearancePort)1 Instance (com.cburch.logisim.instance.Instance)1 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 JViewport (javax.swing.JViewport)1 Popup (javax.swing.Popup)1 PopupFactory (javax.swing.PopupFactory)1