📄 highlight2.java
字号:
} // highlight NodeInst PortProto pp = null; ElectricObject realEObj = eobj; PortInst originalPi = null; if (realEObj instanceof PortInst) { originalPi = ((PortInst)realEObj); pp = originalPi.getPortProto(); realEObj = ((PortInst)realEObj).getNodeInst(); } if (realEObj instanceof NodeInst) { NodeInst ni = (NodeInst)realEObj; AffineTransform trans = ni.rotateOutAboutTrueCenter(); int offX = highOffX; int offY = highOffY;/* boolean drewOutline = false; if (!ni.isCellInstance()) { // special case for outline nodes if (np.isHoldsOutline()) { Point2D [] outline = ni.getTrace(); if (outline != null) { int numPoints = outline.length; Point2D [] pointList = new Point2D.Double[numPoints]; for(int i=0; i<numPoints; i++) { pointList[i] = new Point2D.Double(ni.getTrueCenterX() + outline[i].getX(), ni.getTrueCenterY() + outline[i].getY()); } trans.transform(pointList, 0, pointList, 0, numPoints); drawOutlineFromPoints(wnd, g, pointList, 0, 0, true, null); drewOutline = true; } } } // setup outline of node with standard offset if (!drewOutline) { SizeOffset so = ni.getSizeOffset(); double nodeLowX = ni.getTrueCenterX() - ni.getXSize()/2 + so.getLowXOffset(); double nodeHighX = ni.getTrueCenterX() + ni.getXSize()/2 - so.getHighXOffset(); double nodeLowY = ni.getTrueCenterY() - ni.getYSize()/2 + so.getLowYOffset(); double nodeHighY = ni.getTrueCenterY() + ni.getYSize()/2 - so.getHighYOffset(); if (nodeLowX == nodeHighX && nodeLowY == nodeHighY) { float x = (float)nodeLowX; float y = (float)nodeLowY; float size = 3 / (float)wnd.getScale(); Point c1 = wnd.databaseToScreen(x+size, y); Point c2 = wnd.databaseToScreen(x-size, y); Point c3 = wnd.databaseToScreen(x, y+size); Point c4 = wnd.databaseToScreen(x, y-size); drawLine(g, wnd, c1.x + offX, c1.y + offY, c2.x + offX, c2.y + offY); drawLine(g, wnd, c3.x + offX, c3.y + offY, c4.x + offX, c4.y + offY); } else { double nodeX = (nodeLowX + nodeHighX) / 2; double nodeY = (nodeLowY + nodeHighY) / 2; Poly poly = new Poly(nodeX, nodeY, nodeHighX-nodeLowX, nodeHighY-nodeLowY); poly.transform(trans); drawOutlineFromPoints(wnd, g, poly.getPoints(), offX, offY, false, null); } }*/ // draw the selected point if (point >= 0) { Point2D [] points = ni.getTrace(); if (points != null) { // if this is a spline, highlight the true shape if (ni.getProto() == Artwork.tech().splineNode) { Point2D [] changedPoints = new Point2D[points.length]; for(int i=0; i<points.length; i++) { changedPoints[i] = points[i]; if (i == point) { double x = ni.getAnchorCenterX() + points[point].getX(); double y = ni.getAnchorCenterY() + points[point].getY(); Point2D thisPt = new Point2D.Double(x, y); trans.transform(thisPt, thisPt); Point cThis = wnd.databaseToScreen(thisPt); Point2D db = wnd.screenToDatabase(cThis.x+offX, cThis.y+offY); changedPoints[i] = new Point2D.Double(db.getX() - ni.getAnchorCenterX(), db.getY() - ni.getAnchorCenterY()); } } Point2D [] spPoints = Artwork.tech().fillSpline(ni.getAnchorCenterX(), ni.getAnchorCenterY(), changedPoints); Point cLast = wnd.databaseToScreen(spPoints[0]); for(int i=1; i<spPoints.length; i++) { Point cThis = wnd.databaseToScreen(spPoints[i]); drawLine(g, wnd, cLast.x, cLast.y, cThis.x, cThis.y); cLast = cThis; } } // draw an "x" through the selected point if (points[point] != null) { double x = ni.getAnchorCenterX() + points[point].getX(); double y = ni.getAnchorCenterY() + points[point].getY(); Point2D thisPt = new Point2D.Double(x, y); trans.transform(thisPt, thisPt); Point cThis = wnd.databaseToScreen(thisPt); int size = 3; drawLine(g, wnd, cThis.x + size + offX, cThis.y + size + offY, cThis.x - size + offX, cThis.y - size + offY); drawLine(g, wnd, cThis.x + size + offX, cThis.y - size + offY, cThis.x - size + offX, cThis.y + size + offY); // find previous and next point, and draw lines to them boolean showWrap = ni.traceWraps(); Point2D prevPt = null, nextPt = null; int prevPoint = point - 1; if (prevPoint < 0 && showWrap) prevPoint = points.length - 1; if (prevPoint >= 0 && points[prevPoint] != null) { prevPt = new Point2D.Double(ni.getAnchorCenterX() + points[prevPoint].getX(), ni.getAnchorCenterY() + points[prevPoint].getY()); trans.transform(prevPt, prevPt); if (prevPt.getX() == thisPt.getX() && prevPt.getY() == thisPt.getY()) prevPoint = -1; else { Point cPrev = wnd.databaseToScreen(prevPt); drawLine(g, wnd, cThis.x + offX, cThis.y + offY, cPrev.x, cPrev.y); } } int nextPoint = point + 1; if (nextPoint >= points.length) { if (showWrap) nextPoint = 0; else nextPoint = -1; } if (nextPoint >= 0 && points[nextPoint] != null) { nextPt = new Point2D.Double(ni.getAnchorCenterX() + points[nextPoint].getX(), ni.getAnchorCenterY() + points[nextPoint].getY()); trans.transform(nextPt, nextPt); if (nextPt.getX() == thisPt.getX() && nextPt.getY() == thisPt.getY()) nextPoint = -1; else { Point cNext = wnd.databaseToScreen(nextPt); drawLine(g, wnd, cThis.x + offX, cThis.y + offY, cNext.x, cNext.y); } } // draw arrows on the lines if (offX == 0 && offY == 0 && points.length > 2 && prevPt != null && nextPt != null) { double arrowLen = Double.MAX_VALUE; if (prevPoint >= 0) arrowLen = Math.min(thisPt.distance(prevPt), arrowLen); if (nextPoint >= 0) arrowLen = Math.min(thisPt.distance(nextPt), arrowLen); arrowLen /= 10; double angleOfArrow = Math.PI * 0.8; if (prevPoint >= 0) { Point2D prevCtr = new Point2D.Double((prevPt.getX()+thisPt.getX()) / 2, (prevPt.getY()+thisPt.getY()) / 2); double prevAngle = DBMath.figureAngleRadians(prevPt, thisPt); Point2D prevArrow1 = new Point2D.Double(prevCtr.getX() + Math.cos(prevAngle+angleOfArrow) * arrowLen, prevCtr.getY() + Math.sin(prevAngle+angleOfArrow) * arrowLen); Point2D prevArrow2 = new Point2D.Double(prevCtr.getX() + Math.cos(prevAngle-angleOfArrow) * arrowLen, prevCtr.getY() + Math.sin(prevAngle-angleOfArrow) * arrowLen); Point cPrevCtr = wnd.databaseToScreen(prevCtr); Point cPrevArrow1 = wnd.databaseToScreen(prevArrow1); Point cPrevArrow2 = wnd.databaseToScreen(prevArrow2); drawLine(g, wnd, cPrevCtr.x, cPrevCtr.y, cPrevArrow1.x, cPrevArrow1.y); drawLine(g, wnd, cPrevCtr.x, cPrevCtr.y, cPrevArrow2.x, cPrevArrow2.y); } if (nextPoint >= 0) { Point2D nextCtr = new Point2D.Double((nextPt.getX()+thisPt.getX()) / 2, (nextPt.getY()+thisPt.getY()) / 2); double nextAngle = DBMath.figureAngleRadians(thisPt, nextPt); Point2D nextArrow1 = new Point2D.Double(nextCtr.getX() + Math.cos(nextAngle+angleOfArrow) * arrowLen, nextCtr.getY() + Math.sin(nextAngle+angleOfArrow) * arrowLen); Point2D nextArrow2 = new Point2D.Double(nextCtr.getX() + Math.cos(nextAngle-angleOfArrow) * arrowLen, nextCtr.getY() + Math.sin(nextAngle-angleOfArrow) * arrowLen); Point cNextCtr = wnd.databaseToScreen(nextCtr); Point cNextArrow1 = wnd.databaseToScreen(nextArrow1); Point cNextArrow2 = wnd.databaseToScreen(nextArrow2); drawLine(g, wnd, cNextCtr.x, cNextCtr.y, cNextArrow1.x, cNextArrow1.y); drawLine(g, wnd, cNextCtr.x, cNextCtr.y, cNextArrow2.x, cNextArrow2.y); } } } // do not offset the node, just this point offX = offY = 0; } } // draw nodeInst outline if ((offX == 0 && offY == 0) || point < 0) { Poly niPoly = getNodeInstOutline(ni); boolean niOpened = (niPoly.getStyle() == Poly.Type.OPENED); Point2D [] points = niPoly.getPoints(); drawOutlineFromPoints(wnd, g, points, offX, offY, niOpened, false); } // draw the selected port if (pp != null) { //@TODO MAYBE I need the main color// g.setColor(mainColor); Poly poly = ni.getShapeOfPort(pp); boolean opened = true; Point2D [] points = poly.getPoints(); if (poly.getStyle() == Poly.Type.FILLED || poly.getStyle() == Poly.Type.CLOSED) opened = false; if (poly.getStyle() == Poly.Type.CIRCLE || poly.getStyle() == Poly.Type.THICKCIRCLE || poly.getStyle() == Poly.Type.DISC) { double sX = points[0].distance(points[1]) * 2; Point2D [] pts = Artwork.fillEllipse(points[0], sX, sX, 0, 360); poly = new Poly(pts); poly.transform(ni.rotateOut()); points = poly.getPoints(); } else if (poly.getStyle() == Poly.Type.CIRCLEARC) { double [] angles = ni.getArcDegrees(); double sX = points[0].distance(points[1]) * 2; Point2D [] pts = Artwork.fillEllipse(points[0], sX, sX, angles[0], angles[1]); poly = new Poly(pts); poly.transform(ni.rotateOut()); points = poly.getPoints(); } drawOutlineFromPoints(wnd, g, points, offX, offY, opened, false);// g.setColor(mainColor); // show name of port if (ni.isCellInstance() && (g instanceof Graphics2D)) { // only show name if port is wired (because all other situations already show the port) boolean wired = false; for(Iterator<Connection> cIt = ni.getConnections(); cIt.hasNext(); ) { Connection con = cIt.next(); if (con.getPortInst().getPortProto() == pp) { wired = true; break; } } if (wired) { Font font = new Font(User.getDefaultFont(), Font.PLAIN, (int)(1.5*EditWindow.getDefaultFontSize())); GlyphVector v = wnd.getGlyphs(pp.getName(), font); Point2D point = wnd.databaseToScreen(poly.getCenterX(), poly.getCenterY()); ((Graphics2D)g).drawGlyphVector(v, (float)point.getX()+offX, (float)point.getY()+offY); } } // if this is a port on an "example icon", show the equivalent port in the cell// if (ni.isIconOfParent())// {// // find export in parent// Export equiv = (Export)cell.findPortProto(pp.getName());// if (equiv != null)// {// PortInst ePi = equiv.getOriginalPort();// Poly ePoly = ePi.getPoly();// Point eP = wnd.databaseToScreen(ePoly.getCenterX(), ePoly.getCenterY());// Point p = wnd.databaseToScreen(poly.getCenterX(), poly.getCenterY());// drawLine(g, wnd, eP.x, eP.y, p.x + offX, p.y + offY);// }// } // highlight objects that are electrically connected to this object // unless specified not to. HighlightConnected is set to false by addNetwork when // it figures out what's connected and adds them manually. Because they are added // in addNetwork, we shouldn't try and add connected objects here. if (highlightConnected && onlyHighlight) { Netlist netlist = cell.acquireUserNetlist(); if (netlist == null) return; NodeInst originalNI = ni; if (ni.isIconOfParent()) { // find export in parent Export equiv = (Export)cell.findPortProto(pp.getName()); if (equiv != null) { originalPi = equiv.getOriginalPort(); ni = originalPi.getNodeInst(); pp = originalPi.getPortProto(); } } Set<Network> networks = new HashSet<Network>(); networks = NetworkTool.getNetworksOnPort(originalPi, netlist, networks); HashSet<Geometric> markObj = new HashSet<Geometric>(); for(Iterator<ArcInst> it = cell.getArcs(); it.hasNext(); ) { ArcInst ai = it.next(); Name arcName = ai.getNameKey(); for (int i=0; i<arcName.busWidth(); i++) { if (networks.contains(netlist.getNetwork(ai, i))) { markObj.add(ai); markObj.add(ai.getHeadPortInst().getNodeInst()); markObj.add(ai.getTailPortInst().getNodeInst()); break; } } } for (Iterator<Nodable> it = netlist.getNodables(); it.hasNext(); ) { Nodable no = it.next(); NodeInst oNi = no.getNodeInst(); if (oNi == originalNI) continue; if (markObj.contains(ni)) continue; boolean highlightNo = false; for(Iterator<PortProto> eIt = no.getProto().getPorts(); eIt.hasNext(); ) { PortProto oPp = eIt.next(); Name opName = oPp.getNameKey(); for (int j=0; j<opName.busWidth(); j++) { if (networks.contains(netlist.getNetwork(no, oPp, j))) { highlightNo = true; break; } } if (highlightNo) break; } if (highlightNo) markObj.add(oNi); } //System.out.println("Search took "+com.sun.electric.database.text.TextUtils.getElapsedTime(System.currentTimeMillis()-start)); // draw lines along all of the arcs on the network Stroke origStroke = g2.getStroke(); g2.setStroke(dashedLine); for(Iterator<ArcInst> it = cell.getArcs(); it.hasNext(); ) { ArcInst ai = it.next(); if (!markObj.contains(ai)) continue; Point c1 = wnd.databaseToScreen(ai.getHeadLocation()); Point c2 = wnd.databaseToScreen(ai.getTailLocation()); drawLine(g, wnd, c1.x, c1.y, c2.x, c2.y); } // draw dots in all connected nodes g2.setStroke(solidLine); for (Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); ) { NodeInst oNi = it.next(); if (!markObj.contains(oNi)) continue; Point c = wnd.databaseToScreen(oNi.getTrueCenter()); g.fillOval(c.x-4, c.y-4, 8, 8); // connect the center dots to the input arcs Point2D nodeCenter = oNi.getTrueCenter(); for(Iterator<Connection> pIt = oNi.getConnections(); pIt.hasNext(); ) { Connection con = pIt.next(); ArcInst ai = con.getArc(); if (!markObj.contains(ai)) continue; Point2D arcEnd = con.getLocation(); if (arcEnd.getX() != nodeCenter.getX() || arcEnd.getY() != nodeCenter.getY()) { Point c1 = wnd.databaseToScreen(arcEnd); Point c2 = wnd.databaseToScreen(nodeCenter); //g2.setStroke(dottedLine); //if (c1.distance(c2) < 15) g2.setStroke(solidLine); drawLine(g, wnd, c1.x, c1.y, c2.x, c2.y); } } } g2.setStroke(origStroke); } } } // switch back to old color if switched if (oldColor != null) g.setColor(oldColor); } void getHighlightedEObjs(Highlighter highlighter, List<Geometric> list, boolean wantNodes, boolean wantArcs) { getHighlightedEObjsInternal(getGeometric(), list, wantNodes, wantArcs); } void getHighlightedNodes(Highlighter highlighter, List<NodeInst> list) { getHighlightedNodesInternal(getGeometric(), list); } void getHighlightedArcs(Highlighter highlighter, List<ArcInst> list) { getHighlightedArcsInternal(getGeometric(), list); } void getHighlightedNetworks(Set<Network> nets, Netlist netlist) { ElectricObject eObj = eobj; if (eObj instanceof NodeInst) { NodeInst ni = (NodeInst)eObj; if (ni.getNumPortInsts() == 1) { PortInst pi = ni.getOnlyPortInst(); if (pi != null) eObj = pi; } } if (eObj instanceof PortInst) { PortInst pi = (PortInst)eObj; nets = NetworkTool.getNetworksOnPort(pi, netlist, nets);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -