📄 highlighter.java
字号:
* Called when the Highlighter owner has gained focus, and the * current highlighter switches to this. */ public void gainedFocus() { Highlighter oldHighlighter = null; synchronized(currentHighlighter) { oldHighlighter = currentHighlighter; currentHighlighter = this; } // fire focus changed on old highlighter if ((oldHighlighter != null) && (oldHighlighter != this)) oldHighlighter.fireHighlighterLostFocus(this); } /** * Method to push the current highlight list onto a stack. */ public synchronized void pushHighlight() { // make a copy of the highlighted list List<Highlight2> pushable = new ArrayList<Highlight2>(); for(Highlight2 h : highlightList) pushable.add(h); highlightStack.add(pushable); } /** * Method to pop the current highlight list from the stack. */ public synchronized void popHighlight() { int stackSize = highlightStack.size(); if (stackSize <= 0) { System.out.println("There is no highlighting saved on the highlight stack"); return; } // get the stacked highlight List<Highlight2> popable = highlightStack.get(stackSize-1); highlightStack.remove(stackSize-1); // validate each highlight as it is added clear(); for(Highlight2 h : popable) { Cell cell = h.getCell(); if (h instanceof HighlightEOBJ) { HighlightEOBJ hh = (HighlightEOBJ)h; ElectricObject eobj = hh.eobj; if (cell.objInCell(eobj)) { HighlightEOBJ newH = (HighlightEOBJ)addElectricObject(eobj, cell); newH.point = hh.point; } } else if (h instanceof HighlightText) { HighlightText hh = (HighlightText)h; ElectricObject eobj = hh.eobj; if (cell.objInCell(eobj)) { addText(eobj, cell, hh.varKey); } } else if (h instanceof HighlightArea) { HighlightArea hh = (HighlightArea)h; addArea(hh.bounds, cell); } else if (h instanceof HighlightLine) { HighlightLine hh = (HighlightLine)h; if (hh.thickLine) addThickLine(hh.start, hh.end, cell); else addLine(hh.start, hh.end, cell); } else if (h instanceof HighlightMessage) //type == Highlight.Type.MESSAGE) { HighlightMessage hh = (HighlightMessage)h; addMessage(cell, hh.msg, hh.loc); } } finished(); } /** * Removes a Highlight object from the current set of highlights. * @param h the Highlight to remove */ public synchronized void remove(Highlight2 h) { highlightList.remove(h); } /** * Method to return the number of highlighted objects. * @return the number of highlighted objects. */ public synchronized int getNumHighlights() { return highlightList.size(); } /** * Method to return a list that is a copy of the list of current highlights. * @return an list of highlights */ public synchronized List<Highlight2> getHighlights() { List<Highlight2> highlightsCopy = new ArrayList<Highlight2>(highlightList); return highlightsCopy; } /** * Method to load a list of Highlights into the highlighting. * @param newHighlights a List of Highlight objects. */ public synchronized void setHighlightListGeneral(List<Highlight2> newHighlights) { clear(); for(Highlight2 obj : newHighlights) { highlightList.add(obj); } changed = true; } /** * Method to load a list of Highlights into the highlighting. * @param newHighlights a List of Highlight objects. */ public synchronized void setHighlightList(List<Highlight2> newHighlights) { clear(); for(Highlight2 obj : newHighlights) { highlightList.add(obj); } changed = true; } /** * Method to return a List of all highlighted Geometrics. * @param wantNodes true if NodeInsts should be included in the list. * @param wantArcs true if ArcInsts should be included in the list. * @return a list with the highlighted Geometrics. */ public List<Geometric> getHighlightedEObjs(boolean wantNodes, boolean wantArcs) { // now place the objects in the list List<Geometric> highlightedGeoms = new ArrayList<Geometric>(); for(Highlight2 h : getHighlights()) { h.getHighlightedEObjs(this, highlightedGeoms, wantNodes, wantArcs); } return highlightedGeoms; } /** * Method to return a List of all highlighted NodeInsts. * @return a list with the highlighted NodeInsts. */ public List<NodeInst> getHighlightedNodes() { // now place the objects in the list List<NodeInst> highlightedNodes = new ArrayList<NodeInst>(); for(Highlight2 h : getHighlights()) { h.getHighlightedNodes(this, highlightedNodes); } return highlightedNodes; } /** * Method to return a List of all highlighted ArcInsts. * @return a list with the highlighted ArcInsts. */ public List<ArcInst> getHighlightedArcs() { // now place the objects in the list List<ArcInst> highlightedArcs = new ArrayList<ArcInst>(); for(Highlight2 h : getHighlights()) { h.getHighlightedArcs(this, highlightedArcs); } return highlightedArcs; } /** * Method to return a set of the currently selected networks. * @return a set of the currently selected networks. * If there are no selected networks, the list is empty. */ public Set<Network> getHighlightedNetworks() { WindowFrame wf = WindowFrame.getCurrentWindowFrame(); if (wf.getContent() instanceof WaveformWindow) { WaveformWindow ww = (WaveformWindow)wf.getContent(); return ww.getHighlightedNetworks(); } Set<Network> nets = new HashSet<Network>(); Cell cell = WindowFrame.getCurrentCell(); if (cell != null) { Netlist netlist = cell.acquireUserNetlist(); if (netlist == null) { String msg = "Selected networks are not ready"; System.out.println(msg); ActivityLogger.logMessage(msg); return nets; } for(Highlight2 h : getHighlights()) { h.getHighlightedNetworks(nets, netlist); } } return nets; } /** * Method to return a List of all highlighted text. * @param unique true to request that the text objects be unique, * and not attached to another object that is highlighted. * For example, if a node and an export on that node are selected, * the export text will not be included if "unique" is true. * @return a list with the Highlight objects that point to text. */ public List<DisplayedText> getHighlightedText(boolean unique) { // now place the objects in the list List<DisplayedText> highlightedText = new ArrayList<DisplayedText>(); for(Highlight2 h : getHighlights()) { h.getHighlightedText(highlightedText, unique, getHighlights()); } return highlightedText; } /** * Method to return the bounds of the highlighted objects. * @param wnd the window in which to get bounds. * @return the bounds of the highlighted objects (null if nothing is highlighted). */ public Rectangle2D getHighlightedArea(EditWindow wnd) { // initially no area Rectangle2D bounds = null; // look at all highlighted objects for(Highlight2 h : getHighlights()) { // find the bounds of this highlight Rectangle2D highBounds = h.getHighlightedArea(wnd); // combine this highlight's bounds with the overall one if (highBounds != null) { if (bounds == null) { bounds = new Rectangle2D.Double(); bounds.setRect(highBounds); } else { Rectangle2D.union(bounds, highBounds, bounds); } } } // return the overall bounds return bounds; } /** * Method to return the only highlight that encompases an object in Cell cell. * If there is not one highlighted object, an error is issued. * @return the highlight that selects an object (null if error). */ public Highlight2 getOneHighlight() { if (getNumHighlights() == 0) { System.out.println("Must select an object first"); return null; } Highlight2 h = null; for(Highlight2 theH : getHighlights()) { if (theH.getElectricObject() != null) return theH; } if (h == null) { System.out.println("Must select an object first"); return null; } return h; } /** * Method to return the only highlighted object. * If there is not one highlighted object, an error is issued. * @return the highlighted object (null if error). */ public ElectricObject getOneElectricObject(Class type) { Highlight2 high = getOneHighlight(); if (high == null) return null; if (!(high instanceof HighlightEOBJ)) { System.out.println("Must first select an object"); return null; } ElectricObject eobj = high.getElectricObject(); if (type == NodeInst.class) { if (eobj instanceof PortInst) eobj = ((PortInst)eobj).getNodeInst(); } if (!type.isInstance(eobj)) { System.out.println("Wrong type of object is selected"); System.out.println(" (Wanted "+type.toString()+" but got "+eobj.getClass().toString()+")"); return null; } return eobj; } /** * Method to set a screen offset for the display of highlighting. * @param offX the X offset (in pixels) of the highlighting. * @param offY the Y offset (in pixels) of the highlighting. */ public synchronized void setHighlightOffset(int offX, int offY) { highOffX = offX; highOffY = offY; } /** * Method to return the screen offset for the display of highlighting * @return a Point2D containing the x and y offset. */ public synchronized Point2D getHighlightOffset() { return new Point2D.Double(highOffX, highOffY); } /** * Method to add everything in an area to the selection. * @param wnd the window being examined. * @param minSelX the low X coordinate of the area in database units. * @param maxSelX the high X coordinate of the area in database units. * @param minSelY the low Y coordinate of the area in database units. * @param maxSelY the high Y coordinate of the area in database units. * @param invertSelection is true to invert the selection (remove what is already highlighted and add what is new). * @param findSpecial is true to find hard-to-select objects. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -