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

📄 routeelementport.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        if (getAction() == RouteElementAction.existingPortInst) {            // find all arcs of type ap connected to this            for (Iterator<Connection> it = portInst.getConnections(); it.hasNext(); ) {                Connection conn = it.next();                ArcInst arc = conn.getArc();                if (arc.getProto() == ap) {                    double newWidth = arc.getLambdaBaseWidth();                    if (newWidth > width) width = newWidth;                }            }        }        if (getAction() == RouteElementAction.newNode) {            if (newArcs == null) return -1;            for (RouteElementArc re : newArcs) {                if (re.getArcProto() == ap) {                    if (re.getArcBaseWidth() > width) width = re.getArcBaseWidth();                }            }        }        return width;    }    /**     * Get the angle of any arcs connected to this RouteElement.     * If there are multiple arcs, it returns the angle of the widest     * connecting arc.     * @param ap the arc prototype     * @return the angle in centidegrees, 0 if no arcs of the specified type connected.     */    public int getConnectingArcAngle(ArcProto ap) {        int angle = 0;        double width = -1;        if (getAction() == RouteElementAction.existingPortInst) {            // find all arcs of type ap connected to this            for (Iterator<Connection> it = portInst.getConnections(); it.hasNext(); ) {                Connection conn = it.next();                ArcInst arc = conn.getArc();                if (arc.getProto() == ap) {                    double newWidth = arc.getLambdaBaseWidth();                    if (newWidth > width) {                        width = newWidth;                        angle = arc.getAngle() % 1800;                    }                }            }        }        if (getAction() == RouteElementAction.newNode) {            if (newArcs == null) return -1;            for (RouteElementArc re : newArcs) {                if (re.getArcProto() == ap) {                    if (re.getArcBaseWidth() > width) {                        width = re.getArcBaseWidth();                        if (re.isArcVertical()) angle = 900;                        if (re.isArcHorizontal()) angle = 0;                    }                }            }        }        return angle;    }    /**     * Get an iterator over any newArc RouteElements connected to this     * newNode RouteElement.  Returns an iterator over an empty list     * if no new arcs.     */    public Iterator<RouteElement> getNewArcs() {        ArrayList<RouteElement> list = new ArrayList<RouteElement>();        list.addAll(newArcs);        return list.iterator();    }    /**     * Get the size of a newNode, or the NodeInst an existingPortInst     * is attached to.     * @return the width,height of the node, or (-1, -1) if not a node     */    public Dimension2D.Double getNodeSize() {        return new Dimension2D.Double(width, height);    }    /**     * Set the size of a newNode.  Does not make it smaller     * than the default size if this is a PrimitiveNode.     * Does nothing for other RouteElements.     * @param size the new size     */    public void setNodeSize(Dimension2D size) {        SizeOffset so = np.getProtoSizeOffset();        double widthoffset = so.getLowXOffset() + so.getHighXOffset();        double heightoffset = so.getLowYOffset() + so.getHighYOffset();        double defWidth = np.getDefWidth() - widthoffset;       // this is width we see on the screen        double defHeight = np.getDefHeight() - heightoffset;    // this is height we see on the screen        if (size.getWidth() > defWidth) width = size.getWidth(); else width = defWidth;        if (size.getHeight() > defHeight) height = size.getHeight(); else height = defHeight;    }    /**     * Get a polygon that defines the port dimensions.     * May return null.     */    public Poly getConnectingSite() { return portInstSite; }    /**     * Perform the action specified by RouteElementAction <i>action</i>.     * Note that this method performs database editing, and should only     * be called from within a Job.     * @return the object created, or null if deleted or nothing done.     */    public ElectricObject doAction() {        EDatabase.serverDatabase().checkChanging();        if (isDone()) return null;        ElectricObject returnObj = null;        if (getAction() == RouteElementAction.newNode) {            // create new Node            SizeOffset so = np.getProtoSizeOffset();            double widthso = width +  so.getLowXOffset() + so.getHighXOffset();            double heightso = height + so.getLowYOffset() + so.getHighYOffset();            nodeInst = NodeInst.makeInstance(np, location, widthso, heightso, getCell());            if (nodeInst == null) return null;            portInst = nodeInst.findPortInstFromProto(portProto);            returnObj = nodeInst;        }        if (getAction() == RouteElementAction.deleteNode) {            // delete existing arc            nodeInst.kill();        }        setDone();        return returnObj;    }    /**     * Adds RouteElement to highlights     */    public void addHighlightArea(Highlighter highlighter) {        if (!isShowHighlight()) return;        if (getAction() == RouteElementAction.newNode) {            // create box around new Node            Rectangle2D bounds = new Rectangle2D.Double(location.getX()-0.5*width,                    location.getY()-0.5*height, width, height);            highlighter.addArea(bounds, getCell());        }        if (getAction() == RouteElementAction.existingPortInst) {            highlighter.addElectricObject(portInst, getCell());        }    }    /** Return string decribing the RouteElement */    public String toString() {        if (getAction() == RouteElementAction.newNode) {            return "RouteElementPort newNode "+np+" size "+width+","+height+" at "+location;        }        else if (getAction() == RouteElementAction.deleteNode) {            return "RouteElementPort deleteNode "+nodeInst;        }        else if (getAction() == RouteElementAction.existingPortInst) {            return "RouteElementPort existingPortInst "+portInst;        }        return "RouteElement bad action";    }    /**     * Save the state of the <tt>RouteElementPort</tt> instance to a stream (that     * is, serialize it).     *     * @serialData The numnber of points in portInstSite polygon is emitted (int),     * followed by all of its coordianates ( as pair of doubles ) in the proper order.     */    private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {        s.defaultWriteObject();        if (portInstSite != null) {            Point2D[] points = portInstSite.getPoints();            s.writeInt(points.length);            for (int i = 0; i < points.length; i++) {                s.writeDouble(points[i].getX());                s.writeDouble(points[i].getY());            }        } else {            s.writeInt(-1);        }    }    /**     * Reconstitute the <tt>RouteElementPort</tt> instance from a stream (that is,     * deserialize it).     */    private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException {        s.defaultReadObject();        int len = s.readInt();        if (len >= 0) {            Point2D[] points = new Point2D[len];            for (int i = 0; i < len; i++) {                double x = s.readDouble();                double y = s.readDouble();                points[i] = new Point2D.Double(x, y);            }        }    }}

⌨️ 快捷键说明

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