📄 routeelementarc.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: RouteElementArc.java * Written by: Jonathan Gainsley, Sun Microsystems. * * Copyright (c) 2003 Sun Microsystems and Static Free Software * * Electric(tm) is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Electric(tm) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Electric(tm); see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. */package com.sun.electric.tool.routing;import com.sun.electric.database.geometry.Dimension2D;import com.sun.electric.database.geometry.EPoint;import com.sun.electric.database.geometry.GenMath;import com.sun.electric.database.geometry.Poly;import com.sun.electric.database.geometry.PolyMerge;import com.sun.electric.database.geometry.GenMath.MutableBoolean;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.EDatabase;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.topology.PortInst;import com.sun.electric.database.variable.ElectricObject;import com.sun.electric.database.variable.TextDescriptor;import com.sun.electric.technology.ArcProto;import com.sun.electric.technology.Layer;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.technologies.Generic;import com.sun.electric.tool.routing.RouteElement.RouteElementAction;import com.sun.electric.tool.user.Highlighter;import java.awt.geom.Point2D;import java.awt.geom.Rectangle2D;/** * Class for defining RouteElements that are arcs. */public class RouteElementArc extends RouteElement { // ---- New Arc info ---- /** Arc type to create */ private ArcProto arcProto; /** width of arc */ private double arcBaseWidth; /** Head of arc */ private RouteElementPort headRE; /** Tail of arc */ private RouteElementPort tailRE; /** Head connecting point */ private EPoint headConnPoint; /** Tail connecting point */ private EPoint tailConnPoint; /** Name of arc */ private String arcName; /** Text descriptor of name */ private TextDescriptor arcNameDescriptor; /** Angle of arc */ private int arcAngle; /** inherit properties from this arc */ private ArcInst inheritFrom; /** set the arc extension if inheritFrom is null */ private boolean extendArcHead; /** set the arc extension if inheritFrom is null */ private boolean extendArcTail; /** This contains the newly create instance, or the instance to delete */ private ArcInst arcInst; /** * Private Constructor * @param action the action this RouteElementAction will do. */ private RouteElementArc(RouteElementAction action, Cell cell) { super(action, cell); } /** * Factory method for making a newArc RouteElement * @param ap Type of ArcInst to make * @param headRE RouteElement (must be newNode or existingPortInst) at head of arc * @param tailRE RouteElement (must be newNode or existingPortInst) at tail or arc * @param nameTextDescriptor * @param inheritFrom * @param extendArcHead only applied if inheritFrom is null * @param extendArcTail only applied if inheritFrom is null * @param stayInside a polygonal area in which the new arc must reside (if not null). * The arc is narrowed and has its ends extended in an attempt to stay inside this area. */ public static RouteElementArc newArc(Cell cell, ArcProto ap, double arcBaseWidth, RouteElementPort headRE, RouteElementPort tailRE, Point2D headConnPoint, Point2D tailConnPoint, String name, TextDescriptor nameTextDescriptor, ArcInst inheritFrom, boolean extendArcHead, boolean extendArcTail, PolyMerge stayInside) { EPoint headEP = EPoint.snap(headConnPoint); EPoint tailEP = EPoint.snap(tailConnPoint); MutableBoolean headExtend = new MutableBoolean(extendArcHead); MutableBoolean tailExtend = new MutableBoolean(extendArcTail); if (stayInside != null) {// Technology.ArcLayer al = ap.getArcLayer(0); Layer layer = ap.getLayer(0); double layerExtend = ap.getLayerLambdaExtend(0);// double offset = al.getLambdaOffset(); double arcExtendOverMin = arcBaseWidth*0.5 - ap.getLambdaBaseExtend();// double arcBaseWidth = arcWidth - ap.getLambdaWidthOffset(); boolean good = stayInside.arcPolyFits(layer, headEP, tailEP, 2*(arcExtendOverMin+layerExtend), headExtend, tailExtend);// double area = stayInside.getAreaOfLayer(layer);// boolean good = stayInside.arcPolyFits(layer, headEP, tailEP, arcWidth-offset, headExtend, tailExtend); // try reducing to default width if it doesn't fit if (!good && arcBaseWidth > ap.getDefaultLambdaBaseWidth())// if (!good && arcFullWidth > ap.getDefaultLambdaFullWidth()) { arcBaseWidth = ap.getDefaultLambdaBaseWidth();// arcFullWidth = ap.getDefaultLambdaFullWidth(); good = stayInside.arcPolyFits(layer, headEP, tailEP, 2*(ap.getDefaultLambdaExtendOverMin() + layerExtend), headExtend, tailExtend);// good = stayInside.arcPolyFits(layer, headEP, tailEP, arcWidth-offset, headExtend, tailExtend); } // make it zero-width if it doesn't fit if (!good) // && area > 0) { arcBaseWidth = 0; ap = Generic.tech().universal_arc;// arcFullWidth = ap.getLambdaWidthOffset(); } } RouteElementArc e = new RouteElementArc(RouteElementAction.newArc, cell); e.arcProto = ap; e.arcBaseWidth = arcBaseWidth; e.headRE = headRE; e.tailRE = tailRE; e.arcName = name; e.arcNameDescriptor = nameTextDescriptor; if (headRE.getAction() != RouteElement.RouteElementAction.newNode && headRE.getAction() != RouteElement.RouteElementAction.existingPortInst) System.out.println(" ERROR: headRE of newArc RouteElementArc must be newNode or existingPortInst"); if (tailRE.getAction() != RouteElement.RouteElementAction.newNode && tailRE.getAction() != RouteElement.RouteElementAction.existingPortInst) System.out.println(" ERROR: tailRE of newArc RouteElementArc must be newNode or existingPortInst"); headRE.addConnectingNewArc(e); tailRE.addConnectingNewArc(e); e.headConnPoint = headEP; e.tailConnPoint = tailEP; assert(e.headConnPoint != null); assert(e.tailConnPoint != null); e.arcAngle = 0; e.arcInst = null; e.inheritFrom = inheritFrom; e.extendArcHead = headExtend.booleanValue(); e.extendArcTail = tailExtend.booleanValue(); return e; } /** * Factory method for making a deleteArc RouteElement * @param arcInstToDelete the arcInst to delete */ public static RouteElementArc deleteArc(ArcInst arcInstToDelete) { RouteElementArc e = new RouteElementArc(RouteElementAction.deleteArc, arcInstToDelete.getParent()); e.arcProto = arcInstToDelete.getProto(); e.arcBaseWidth = arcInstToDelete.getLambdaBaseWidth();// e.arcBaseWidth = arcInstToDelete.getLambdaFullWidth(); e.headRE = RouteElementPort.existingPortInst(arcInstToDelete.getHeadPortInst(), arcInstToDelete.getHeadLocation()); e.tailRE = RouteElementPort.existingPortInst(arcInstToDelete.getTailPortInst(), arcInstToDelete.getTailLocation()); e.arcName = arcInstToDelete.getName(); e.arcNameDescriptor = arcInstToDelete.getTextDescriptor(ArcInst.ARC_NAME); e.headConnPoint = arcInstToDelete.getHeadLocation(); e.tailConnPoint = arcInstToDelete.getTailLocation(); e.arcAngle = 0; e.arcInst = arcInstToDelete; e.inheritFrom = null; e.extendArcHead = e.extendArcTail = true; return e; } /** * Get the arc proto to be created/deleted. * @return the arc proto. */ public ArcProto getArcProto() { return arcProto; } public RouteElementPort getHead() { return headRE; } public RouteElementPort getTail() { return tailRE; } public Point2D getHeadConnPoint() { return headConnPoint; } public Point2D getTailConnPoint() { return tailConnPoint; } public boolean getHeadExtension() { return extendArcHead; } public boolean getTailExtension() { return extendArcTail; }// /**// * Return arc width// */// public double getArcFullWidth() { return arcBaseWidth; } /** * Return arc width. * This returns the arc width taking into account any offset */ public double getArcBaseWidth() { return arcBaseWidth;// return arcBaseWidth - arcProto.getLambdaWidthOffset(); }// /**// * Set the arc width if this is a newArc RouteElement, otherwise does nothing.// * This is the non-offset width (i.e. the bloated width).// */// public void setArcFullWidth(double width) {// if (getAction() == RouteElementAction.newArc)// arcBaseWidth = width;// } /** * Set the arc width if this is a newArc RouteElement, otherwise does nothing. * This is offset arc width (i.e. what the user sees). */ public void setArcBaseWidth(double width) { if (getAction() == RouteElementAction.newArc) arcBaseWidth = width;// arcBaseWidth = width + arcProto.getLambdaWidthOffset(); } /** * Set a newArc's angle. This only does something if both the * head and tail of the arc are coincident points. This does * nothing if the RouteElement is not a newArc * @param angle the angle, in tenth degrees */ public void setArcAngle(int angle) { if (getAction() == RouteElementAction.newArc) arcAngle = angle; } public int getArcAngle() { if (isArcHorizontal() && isArcVertical()) return arcAngle; if (isArcHorizontal()) return 0; return 900; } public void setHeadExtension(boolean e) { extendArcHead = e; } public void setTailExtension(boolean e) { extendArcTail = e; } /** * Return true if the new arc is a vertical arc, false otherwise */ public boolean isArcVertical() { Point2D head = headConnPoint; Point2D tail = tailConnPoint; if (head == null) head = headRE.getLocation(); if (tail == null) tail = tailRE.getLocation(); if ((head == null) || (tail == null)) return false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -