⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clickzoomwirelistener.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * Use to track sticky move of objects     * @param evt the MouseEvent     */    public void mouseMoved(MouseEvent evt) {        mouseX = evt.getX();        mouseY = evt.getY();        //if (debug) System.out.println("  ["+modeLeft+","+modeRight+"] "+evt.paramString());		if (evt.getSource() instanceof EditWindow)		{			EditWindow wnd = (EditWindow)evt.getSource();            Highlighter highlighter = wnd.getHighlighter();            Cell cell = wnd.getCell();			if (cell == null) return;			specialSelect = ToolBar.isSelectSpecial();            Point2D dbMouse = wnd.screenToDatabase(mouseX, mouseY);			if (modeLeft == Mode.stickyMove) {				if (another)					dbMouse = convertToOrthogonal(new Point2D.Double(dbMoveStartX, dbMoveStartY), dbMouse);				Point2D dbDelta = new Point2D.Double(dbMouse.getX() - dbMoveStartX, dbMouse.getY() - dbMoveStartY);				EditWindow.gridAlign(dbDelta);				Point2D screenDelta = wnd.deltaDatabaseToScreen((int)dbDelta.getX(), (int)dbDelta.getY());				highlighter.setHighlightOffset((int)screenDelta.getX(), (int)screenDelta.getY());				wnd.repaint();			}            mouseOver(dbMouse, wnd);        }    }    /**     * Draw a mouse over highlight     * @param dbMouse     * @param wnd     */    private void mouseOver(Point2D dbMouse, EditWindow wnd) {        if (!User.isMouseOverHighlightingEnabled()) return;        if (ToolBar.getSelectMode() == ToolBar.SelectMode.AREA) return;        Highlighter highlighter = wnd.getHighlighter();        Highlighter mouseOverHighlighter = wnd.getMouseOverHighlighter();        // create temporary highlighter        Highlighter tempHighlighter = new Highlighter(Highlighter.MOUSEOVER_HIGHLIGHTER, null);        tempHighlighter.copyState(highlighter);        Point2D screenMouse = wnd.databaseToScreen(dbMouse);        Highlight2 found = null;        if (!another && !invertSelection)            // maintain current selection            found = tempHighlighter.overHighlighted(wnd, (int)screenMouse.getX(), (int)screenMouse.getY());        if (found == null)        {            // find something that would get selected            found = tempHighlighter.findObject(dbMouse, wnd, false, another, invertSelection, true, false, specialSelect, true);        }        // Checking if found highlight is not found in existing list and then force the update.        tempHighlighter.clear();        if (found != null)            tempHighlighter.addHighlight(found);        // check if mouse-over highlight needs to change        boolean changed = false;        List<Highlight2> mouseOld = mouseOverHighlighter.getHighlights();//        assert(mouseOld.size() <= 1);        List<Highlight2> mouseNew = tempHighlighter.getHighlights();//        assert(mouseNew.size() <= 1);        if (mouseOld.size() == mouseNew.size()) {            for (int i=0; i<mouseOld.size(); i++) {                Highlight2 h1 = mouseOld.get(i);                Highlight2 h2 = mouseNew.get(i);                if (!h1.equals(h2)) { changed = true; break; }            }        } else            changed = true;        if (changed) {            // copy state into mouse highlighter, signal change (using finished)            mouseOverHighlighter.copyState(tempHighlighter);            mouseOverHighlighter.finished();            wnd.repaint();        }        // JFluid results.        tempHighlighter.delete();  // remove from database        tempHighlighter = null;    }        public void mouseClicked(MouseEvent e) {        //To change body of implemented methods use File | Settings | File Templates	    // to detect connection with other WindowContents.	    if (e.getSource() instanceof EditWindow)	    {            EditWindow wnd = (EditWindow)e.getSource();            Highlighter highlighter = wnd.getHighlighter();            wnd.getWindowFrame().getFrame().getStatusBar().highlightChanged(highlighter);	        WindowFrame.show3DHighlight();	    }    }    public void mouseEntered(MouseEvent e) {        //To change body of implemented methods use File | Settings | File Templates.    }    public void mouseExited(MouseEvent e) {        //To change body of implemented methods use File | Settings | File Templates.    }    /** Mouse Wheel Events are used for panning     * Wheel Forward: scroll up     * Wheel Back: scroll down     * SHIFT + Wheel Forward: scroll right     * SHIFT + Wheel Back: scroll left     * @param evt the MouseWheelEvent     */    public void mouseWheelMoved(MouseWheelEvent evt) {        if (debug) System.out.println("  "+evt.paramString());		if (evt.getSource() instanceof EditWindow)		{			EditWindow wnd = (EditWindow)evt.getSource();			Cell cell = wnd.getCell();			if (cell == null) return;			boolean sideways = (evt.getModifiersEx()&MouseEvent.SHIFT_DOWN_MASK) != 0;			boolean sideways2 = (evt.getModifiersEx()&MouseEvent.CTRL_DOWN_MASK) != 0;			int rotation = evt.getWheelRotation();			// scroll left right if sideways			if (sideways || sideways2) {				// scroll right if roll foward (pos)				// scroll left if roll back (neg)				ZoomAndPanListener.panXOrY(0, wnd.getWindowFrame(), rotation > 0 ? 1 : -1);			} else {				// scroll up if roll forward (pos)				// scroll down if roll back (neg)				ZoomAndPanListener.panXOrY(1, wnd.getWindowFrame(), rotation > 0 ? 1 : -1);			}		}    }    /** Key pressed event     * Delete or Move selected objects     * @param evt the KeyEvent     */    public void keyPressed(KeyEvent evt) {        if (debug) System.out.println("  ["+modeLeft+","+modeRight+"] "+evt.paramString());        int chr = evt.getKeyCode();		if (evt.getSource() instanceof EditWindow)		{			EditWindow wnd = (EditWindow)evt.getSource();			Cell cell = wnd.getCell();			if (cell == null) return;            boolean redrawMouseOver = false;			// move stuff around			if (chr == KeyEvent.VK_LEFT) {				moveSelected(-1, 0, evt.isShiftDown(), evt.isControlDown());			} else if (chr == KeyEvent.VK_RIGHT) {				moveSelected(1, 0, evt.isShiftDown(), evt.isControlDown());			} else if (chr == KeyEvent.VK_UP) {				moveSelected(0, 1, evt.isShiftDown(), evt.isControlDown());			} else if (chr == KeyEvent.VK_DOWN) {				moveSelected(0, -1, evt.isShiftDown(), evt.isControlDown());			} else			// cancel current mode			if (chr == KeyEvent.VK_ESCAPE) {                escapePressed(wnd);            }            else if (chr == KeyEvent.VK_CONTROL) {                if (!another) redrawMouseOver = true;                another = true;            }            else if (chr == KeyEvent.VK_SHIFT) {                if (!invertSelection) redrawMouseOver = true;                invertSelection = true;            }            if (redrawMouseOver) {                mouseOver(wnd.screenToDatabase(mouseX, mouseY), wnd);            }			// wiring popup cloud selection			/*			if (wiringPopupCloudUp && (modeRight == Mode.stickyWiring || modeRight == Mode.wiringFind)) {				for (int i=0; i<wiringPopupCloudList.size(); i++) {					if (chr == (KeyEvent.VK_1 + i)) {						PortInst pi = wiringPopupCloudList.get(i);						EditWindow.gridAlign(wiringLastDBMouse);						router.makeRoute(wnd, startObj, pi, wiringLastDBMouse);						wnd.clearShowPopupCloud();      // clear popup cloud						wiringPopupCloudUp = false;						modeRight = Mode.none;						return;					}				}			} */		}    }    private void escapePressed(EditWindow wnd) {        Highlighter highlighter = wnd.getHighlighter();        if (modeRight == Mode.wiringConnect || modeRight == Mode.wiringFind ||            modeRight == Mode.stickyWiring)            router.cancelInteractiveRoute();        if (modeRight == Mode.zoomBox || modeRight == Mode.zoomBoxSingleShot || modeRight == Mode.zoomOut ||            modeLeft == Mode.drawBox || modeLeft == Mode.selectBox)        {            wnd.clearDoingAreaDrag();        }        modeLeft = Mode.none;        modeRight = Mode.none;        highlighter.setHighlightOffset(0, 0);        wnd.repaint();    }    public void keyReleased(KeyEvent evt) {        int chr = evt.getKeyCode();		if (evt.getSource() instanceof EditWindow)		{			EditWindow wnd = (EditWindow)evt.getSource();			Cell cell = wnd.getCell();			if (cell == null) return;            boolean redrawMouseOver = false;            if (chr == KeyEvent.VK_CONTROL) {                if (another) redrawMouseOver = true;                another = false;            }            else if (chr == KeyEvent.VK_SHIFT) {                if (invertSelection) redrawMouseOver = true;                invertSelection = false;            }            if (redrawMouseOver) {                mouseOver(wnd.screenToDatabase(mouseX, mouseY), wnd);            }        }    }    public void keyTyped(KeyEvent evt) {        if (debug) System.out.println("  ["+modeLeft+","+modeRight+"] "+evt.paramString());    }    // ********************************* Moving Stuff ********************************    /** Move selected object(s) via keystroke.  If either scaleMove or scaleMove2     * is true, the move is multiplied by the grid Bold frequency.  If both are     * true the move gets multiplied twice.     * @param dX amount to move in X in lambda     * @param dY amount to move in Y in lambda     * @param scaleMove scales move up if true     * @param scaleMove2 scales move up if true (stacks with scaleMove)     */    public static void moveSelected(double dX, double dY, boolean scaleMove, boolean scaleMove2) {        // scale distance according to arrow motion        EditWindow wnd = EditWindow.getCurrent();        if (wnd == null) return;        Highlighter highlighter = wnd.getHighlighter();		Dimension2D arrowDistance = User.getAlignmentToGrid();		dX *= arrowDistance.getWidth();		dY *= arrowDistance.getHeight();		int scaleX = User.getDefGridXBoldFrequency();        int scaleY = User.getDefGridYBoldFrequency();		if (scaleMove) { dX *= scaleX;   dY *= scaleY; }		if (scaleMove2) { dX *= scaleX;   dY *= scaleY; }		highlighter.setHighlightOffset(0, 0);		if (wnd.isInPlaceEdit())		{			Point2D delta = new Point2D.Double(dX, dY);			AffineTransform trans = wnd.getInPlaceTransformIn();	        double m00 = trans.getScaleX();	        double m01 = trans.getShearX();	        double m10 = trans.getShearY();	        double m11 = trans.getScaleY();			AffineTransform justRot = new AffineTransform(m00, m10, m01, m11, 0, 0);			justRot.transform(delta, delta);			dX = delta.getX();			dY = delta.getY();		}		CircuitChanges.manyMove(dX, dY);		wnd.fullRepaint();	}    /**     * Convert the mousePoint to be orthogonal to the startPoint.     * Chooses direction which is orthogonally farther from startPoint     * @param startPoint the reference point     * @param mousePoint the mouse point     * @return a new point orthogonal to start

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -