private void computeSize(boolean immediate) { hidePopup(); Bounds bounds; CircuitState circState = circuitState; if (circState == null) { bounds = Bounds.create(0, 0, 50, 50); } else { bounds = circState.getCircuit().getAppearance().getAbsoluteBounds(); } int width = bounds.getX() + bounds.getWidth() + BOUNDS_BUFFER; int height = bounds.getY() + bounds.getHeight() + BOUNDS_BUFFER; Size dim; if (canvasPane == null) { dim = new Size(width, height); } else { dim = canvasPane.supportPreferredSize(width, height); } if (!immediate) { Bounds old = oldPreferredSize; if (old != null && Math.abs(old.getWidth() - dim.width) < THRESH_SIZE_UPDATE && Math.abs(old.getHeight() - dim.height) < THRESH_SIZE_UPDATE) { return; } } oldPreferredSize = Bounds.create(0, 0, dim.width, dim.height); setPreferredSize(dim); revalidate(); }
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(); }
public int getScrollableUnitIncrement(Rect visibleRect, int orientation, int direction) { return canvasPane.supportScrollableUnitIncrement(visibleRect, orientation, direction); }