📄 highlight2.java
字号:
break; } if (Technology.DUPLICATEPOINTSAREBROKENOUTLINES) { if (outline[i].getX() == outline[i-1].getX() && outline[i].getY() == outline[i-1].getY()) { whole = false; break; } } } } if (whole) { Point2D [] pointList = new Point2D.Double[numPoints]; for(int i=0; i<numPoints; i++) { pointList[i] = new Point2D.Double(ni.getAnchorCenterX() + outline[i].getX(), ni.getAnchorCenterY() + outline[i].getY()); } trans.transform(pointList, 0, pointList, 0, numPoints); poly = new Poly(pointList); if (ni.getFunction() == PrimitiveNode.Function.NODE) { poly.setStyle(Poly.Type.FILLED); } else { poly.setStyle(Poly.Type.OPENED); } return poly; } } } // special case for circular nodes if (pn == Artwork.tech().circleNode || pn == Artwork.tech().thickCircleNode) { // see if this circle is only a partial one double [] angles = ni.getArcDegrees(); if (angles[0] != 0.0 || angles[1] != 0.0) { Point2D [] pointList = Artwork.fillEllipse(ni.getAnchorCenter(), ni.getXSize(), ni.getYSize(), angles[0], angles[1]); poly = new Poly(pointList); poly.setStyle(Poly.Type.OPENED); poly.transform(ni.rotateOut()); } } } // setup outline of node with standard offset if (poly == null) poly = ni.getBaseShape(); return poly; } /** * Implementing clipping here speeds things up a lot if there are * many large highlights off-screen */ public static void drawLine(Graphics g, EditWindow wnd, int x1, int y1, int x2, int y2) { Dimension size = wnd.getScreenSize(); // first clip the line Point pt1 = new Point(x1, y1); Point pt2 = new Point(x2, y2); if (GenMath.clipLine(pt1, pt2, 0, size.width-1, 0, size.height-1)) return; g.drawLine(pt1.x, pt1.y, pt2.x, pt2.y);// if (((x1 >= 0) && (x1 <= size.getLambdaFullWidth())) || ((x2 >= 0) && (x2 <= size.getLambdaFullWidth())) ||// ((y1 >= 0) && (y1 <= size.getHeight())) || ((y2 >= 0) && (y2 <= size.getHeight()))) {// g.drawLine(x1, y1, x2, y2);// } }}class HighlightPoly extends Highlight2{ /** The highlighted polygon */ private Poly polygon; /** The color used when drawing polygons */ private Color color; HighlightPoly(Cell c, Poly p, Color col) { super(c); this.polygon = p; this.color = col; } public void showInternalHighlight(EditWindow wnd, Graphics g, int highOffX, int highOffY, boolean onlyHighlight, boolean setConnected) { // switch colors if specified Color oldColor = null; if (color != null) { oldColor = g.getColor(); g.setColor(color); } // draw outline of poly boolean opened = (polygon.getStyle() == Poly.Type.OPENED); drawOutlineFromPoints(wnd, g, polygon.getPoints(), highOffX, highOffY, opened, false); // switch back to old color if switched if (oldColor != null) g.setColor(oldColor); }}class HighlightLine extends Highlight2{ /** The highlighted line. */ protected Point2D start, end, center; /** The highlighted line is thick. */ protected boolean thickLine; HighlightLine(Cell c, Point2D s, Point2D e, Point2D cen, boolean thick) { super(c); this.start = s; this.end = e; this.center = cen; this.thickLine = thick; } public void showInternalHighlight(EditWindow wnd, Graphics g, int highOffX, int highOffY, boolean onlyHighlight, boolean setConnected) { Point2D [] points = new Point2D.Double[2]; points[0] = new Point2D.Double(start.getX(), start.getY()); points[1] = new Point2D.Double(end.getX(), end.getY()); drawOutlineFromPoints(wnd, g, points, highOffX, highOffY, false, thickLine); } Rectangle2D getHighlightedArea(EditWindow wnd) {// double cX = (start.getX() + end.getX()) / 2;// double cY = (start.getY() + end.getY()) / 2; double cX = Math.min(start.getX(), end.getX()); double cY = Math.min(start.getY(), end.getY()); double sX = Math.abs(start.getX() - end.getX()); double sY = Math.abs(start.getY() - end.getY()); return new Rectangle2D.Double(cX, cY, sX, sY); } public String getInfo() { String description = "Line from (" + start.getX() + "," + start.getY() + ") to (" + end.getX() + "," + end.getY() + ")"; return description; }}class HighlightObject extends Highlight2{ /** The highlighted generic object */ private Object object; HighlightObject(Cell c, Object obj) { super(c); this.object = obj; } public Object getObject() { return object; } public void showInternalHighlight(EditWindow wnd, Graphics g, int highOffX, int highOffY, boolean onlyHighlight, boolean setConnected) { System.out.println("SHould call this one?"); }}class HighlightArea extends Highlight2{ /** The highlighted area. */ protected Rectangle2D bounds; HighlightArea(Cell c, Rectangle2D area) { super(c); bounds = new Rectangle2D.Double(); bounds.setRect(area); } public void showInternalHighlight(EditWindow wnd, Graphics g, int highOffX, int highOffY, boolean onlyHighlight, boolean setConnected) { Point2D [] points = new Point2D.Double[5]; points[0] = new Point2D.Double(bounds.getMinX(), bounds.getMinY()); points[1] = new Point2D.Double(bounds.getMinX(), bounds.getMaxY()); points[2] = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY()); points[3] = new Point2D.Double(bounds.getMaxX(), bounds.getMinY()); points[4] = new Point2D.Double(bounds.getMinX(), bounds.getMinY()); drawOutlineFromPoints(wnd, g, points, highOffX, highOffY, false, false); } void getHighlightedEObjs(Highlighter highlighter, List<Geometric> list, boolean wantNodes, boolean wantArcs) { List<Highlight2> inArea = Highlighter.findAllInArea(highlighter, cell, false, false, false, false, false, false, bounds, null); for(Highlight2 ah : inArea) { if (!(ah instanceof HighlightEOBJ)) continue; ElectricObject eobj = ((HighlightEOBJ)ah).eobj; if (eobj instanceof ArcInst) { if (wantArcs) list.add((ArcInst)eobj); } else if (eobj instanceof NodeInst) { if (wantNodes) list.add((NodeInst)eobj); } else if (eobj instanceof PortInst) { if (wantNodes) list.add(((PortInst)eobj).getNodeInst()); }// if (!wantNodes)// {// if (eobj instanceof NodeInst || eobj instanceof PortInst) continue;// }// if (!wantArcs && eobj instanceof ArcInst) continue;// if (eobj instanceof PortInst) eobj = ((PortInst)eobj).getNodeInst();// highlightedGeoms.add(eobj); } } void getHighlightedNodes(Highlighter highlighter, List<NodeInst> list) { List<Highlight2> inArea = Highlighter.findAllInArea(highlighter, cell, false, false, false, false, false, false, bounds, null); for(Highlight2 ah : inArea) { if (!(ah instanceof HighlightEOBJ)) continue; ElectricObject eobj = ((HighlightEOBJ)ah).eobj; if (eobj instanceof NodeInst) list.add((NodeInst)eobj); else if (eobj instanceof PortInst) list.add(((PortInst)eobj).getNodeInst()); } } void getHighlightedArcs(Highlighter highlighter, List<ArcInst> list) { List<Highlight2> inArea = Highlighter.findAllInArea(highlighter, cell, false, false, false, false, false, false, bounds, null); for(Highlight2 ah : inArea) { if (!(ah instanceof HighlightEOBJ)) continue; ElectricObject eobj = ((HighlightEOBJ)ah).eobj; if (eobj instanceof ArcInst) list.add((ArcInst)eobj); } } Rectangle2D getHighlightedArea(EditWindow wnd) { return bounds; } public String getInfo() { String description = "Area from " + bounds.getMinX() + "<=X<=" + bounds.getMaxX() + " and " + bounds.getMinY() + "<=Y<=" + bounds.getMaxY(); return description; }}class HighlightMessage extends Highlight2{ /** The highlighted message. */ protected String msg; /** Location of the message highlight */ protected Point2D loc; HighlightMessage(Cell c, String m, Point2D p) { super(c); this.msg = m; this.loc = p; } void internalDescribe(StringBuffer desc) { desc.append(", "); desc.append(msg); } public void showInternalHighlight(EditWindow wnd, Graphics g, int highOffX, int highOffY, boolean onlyHighlight, boolean setConnected) { Point location = wnd.databaseToScreen(loc.getX(), loc.getY()); Color oldColor = g.getColor(); g.setColor(new Color(255-oldColor.getRed(), 255-oldColor.getGreen(), 255-oldColor.getBlue())); g.drawString(msg, location.x+1, location.y+1); g.setColor(oldColor); g.drawString(msg, location.x, location.y); } Rectangle2D getHighlightedArea(EditWindow wnd) { return new Rectangle2D.Double(loc.getX(), loc.getY(), 0, 0); }}class HighlightEOBJ extends Highlight2{ /** The highlighted object. */ protected ElectricObject eobj; /** For Highlighted networks, this prevents excess highlights */ private boolean highlightConnected; /** The highlighted outline point (only for NodeInst). */ protected int point; /** The color used when drawing polygons */ private Color color; public HighlightEOBJ(ElectricObject e, Cell c, boolean connected, int p) { super(c); this.eobj = e; this.highlightConnected = connected; this.point = p; this.color = null; } public HighlightEOBJ(ElectricObject e, Cell c, boolean connected, int p, Color col) { super(c); this.eobj = e; this.highlightConnected = connected; this.point = p; this.color = col; } void internalDescribe(StringBuffer desc) { desc.append(", "); if (eobj instanceof PortInst) { desc.append(((PortInst)eobj).describe(true)); } if (eobj instanceof NodeInst) { desc.append(((NodeInst)eobj).describe(true)); } if (eobj instanceof ArcInst) { desc.append(((ArcInst)eobj).describe(true)); } } public ElectricObject getElectricObject() { return eobj; } public boolean isHighlightEOBJ() { return true; } public void setPoint(int p) { point = p;} public int getPoint() { return point; } boolean isValid() { if (!super.isValid()) return false; if (eobj instanceof PortInst) return ((PortInst)eobj).getNodeInst().isLinked(); return eobj.isLinked(); } boolean sameThing(Highlight2 obj) { if (this == obj) return (true); // Consider already obj==null if (obj == null || getClass() != obj.getClass()) return (false); ElectricObject realEObj = eobj; if (realEObj instanceof PortInst) realEObj = ((PortInst)realEObj).getNodeInst(); HighlightEOBJ other = (HighlightEOBJ)obj; ElectricObject realOtherEObj = other.eobj; if (realOtherEObj instanceof PortInst) realOtherEObj = ((PortInst)realOtherEObj).getNodeInst(); if (realEObj != realOtherEObj) return false; return true; } public void showInternalHighlight(EditWindow wnd, Graphics g, int highOffX, int highOffY, boolean onlyHighlight, boolean setConnected) { Graphics2D g2 = (Graphics2D)g; highlightConnected = setConnected; // switch colors if specified Color oldColor = null; if (color != null) { oldColor = g.getColor(); g.setColor(color); } // highlight ArcInst if (eobj instanceof ArcInst) { ArcInst ai = (ArcInst)eobj; if (!Job.acquireExamineLock(false)) return; try { // construct the polygons that describe the basic arc Poly poly = ai.makeLambdaPoly(ai.getGridBaseWidth(), Poly.Type.CLOSED); if (poly == null) return; drawOutlineFromPoints(wnd, g, poly.getPoints(), highOffX, highOffY, false, false); if (onlyHighlight) { // this is the only thing highlighted: give more information about constraints String constraints = "X"; if (ai.isRigid()) constraints = "R"; else { if (ai.isFixedAngle()) { if (ai.isSlidable()) constraints = "FS"; else constraints = "F"; } else if (ai.isSlidable()) constraints = "S"; } Point p = wnd.databaseToScreen(ai.getTrueCenterX(), ai.getTrueCenterY()); Font font = wnd.getFont(null); if (font != null) { GlyphVector gv = wnd.getGlyphs(constraints, font); Rectangle2D glyphBounds = gv.getVisualBounds(); g.drawString(constraints, (int)(p.x - glyphBounds.getWidth()/2 + highOffX), p.y + font.getSize()/2 + highOffY); } } Job.releaseExamineLock(); } catch (Error e) { Job.releaseExamineLock(); throw e; } return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -