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

📄 highlighter.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	public void selectArea(EditWindow wnd, double minSelX, double maxSelX, double minSelY, double maxSelY,		boolean invertSelection, boolean findSpecial)	{		Rectangle2D searchArea = new Rectangle2D.Double(minSelX, minSelY, maxSelX - minSelX, maxSelY - minSelY);		List<Highlight2> underCursor = findAllInArea(this, wnd.getCell(), false, false, false, false, findSpecial, true, searchArea, wnd);		if (invertSelection)		{			for(Highlight2 newHigh : underCursor)			{				boolean found = false;                for (Highlight2 oldHigh : getHighlights()) {                    if (newHigh.sameThing(oldHigh)) {                        remove(oldHigh);                        found = true;                        break;                    }                }				if (found) continue;				addHighlight(newHigh);			}		} else		{			setHighlightList(underCursor);		}	}    /**	 * Method to tell whether a point is over this Highlight.	 * @param wnd the window being examined.	 * @param x the X screen coordinate of the point.	 * @param y the Y screen coordinate of the point.	 * @return Highlight2 if the point is over this Highlight.	 */	public Highlight2 overHighlighted(EditWindow wnd, int x, int y)	{		for(Highlight2 h : getHighlights())		{            if (h.overHighlighted(wnd, x, y, this)) return h;		}		return null;	}    /**	 * Method to describe an object/variable-key pair.	 * @param wnd the EditWindow in which the object/variable-key is displayed.	 * @param eObj the object.	 * @param varKey the variable-key.	 * @param bounds gets filled with the bounds of the text on the screen (in object space).	 * @return the style of the text (null on error).	 */	private static Poly.Type getHighlightTextStyleBounds(EditWindow wnd, ElectricObject eObj, Variable.Key varKey, Rectangle2D bounds)	{        if (eObj == null) return null; // in case of massive delete -> Swing accesses objects that are currently being modified        Poly poly = eObj.computeTextPoly(wnd, varKey);        if (poly == null) return null;        bounds.setRect(poly.getBounds2D());        Poly.Type style = poly.getStyle();		if (style != Poly.Type.TEXTCENT && style != Poly.Type.TEXTBOX)		{            style = Poly.rotateType(style, eObj);			TextDescriptor td = poly.getTextDescriptor();			if (td != null)			{				int rotation = td.getRotation().getIndex();				if (rotation != 0)				{					int angle = style.getTextAngle();					style = Poly.Type.getTextTypeFromAngle((angle+900*rotation) % 3600);				}			}		}        if (style == Poly.Type.TEXTBOX && (eObj instanceof Geometric))        {            bounds.setRect(((Geometric)eObj).getBounds());        }        return style;	}    /**	 * Method to describe an object/variable-key pair as a set of points to draw.	 * @param wnd the EditWindow in which the object/variable-key is displayed.	 * @param eObj the object.	 * @param varKey the variable-key.	 * @return the set of points to draw, two points per line.	 * Returns null on error.	 */	public static Point2D [] describeHighlightText(EditWindow wnd, ElectricObject eObj, Variable.Key varKey)	{		Rectangle2D bounds = new Rectangle2D.Double();		Poly.Type style = null;        if (!Job.acquireExamineLock(false)) return null;        try        {    		style = getHighlightTextStyleBounds(wnd, eObj, varKey, bounds);            Job.releaseExamineLock();        } catch (Error e)        {            Job.releaseExamineLock();            throw e;        }		if (style == null) return null;        Point2D[] points = null;        if (style == Poly.Type.TEXTCENT)        {            points = new Point2D.Double[4];            points[0] = new Point2D.Double(bounds.getMinX(), bounds.getMinY());            points[1] = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());            points[2] = new Point2D.Double(bounds.getMinX(), bounds.getMaxY());            points[3] = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());        }        else if (style == Poly.Type.TEXTBOT)        {            points = new Point2D.Double[6];            points[0] = new Point2D.Double(bounds.getMinX(), bounds.getMaxY());            points[1] = new Point2D.Double(bounds.getMinX(), bounds.getMinY());            points[2] = new Point2D.Double(bounds.getMinX(), bounds.getMinY());            points[3] = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());            points[4] = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());            points[5] = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());        }        else if (style == Poly.Type.TEXTTOP)        {            points = new Point2D.Double[6];            points[0] = new Point2D.Double(bounds.getMinX(), bounds.getMinY());            points[1] = new Point2D.Double(bounds.getMinX(), bounds.getMaxY());            points[2] = new Point2D.Double(bounds.getMinX(), bounds.getMaxY());            points[3] = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());            points[4] = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());            points[5] = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());        }        else if (style == Poly.Type.TEXTLEFT)        {            points = new Point2D.Double[6];            points[0] = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());            points[1] = new Point2D.Double(bounds.getMinX(), bounds.getMinY());            points[2] = new Point2D.Double(bounds.getMinX(), bounds.getMinY());            points[3] = new Point2D.Double(bounds.getMinX(), bounds.getMaxY());            points[4] = new Point2D.Double(bounds.getMinX(), bounds.getMaxY());            points[5] = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());        }        else if (style == Poly.Type.TEXTRIGHT)        {            points = new Point2D.Double[6];            points[0] = new Point2D.Double(bounds.getMinX(), bounds.getMinY());            points[1] = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());            points[2] = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());            points[3] = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());            points[4] = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());            points[5] = new Point2D.Double(bounds.getMinX(), bounds.getMaxY());        }        else if (style == Poly.Type.TEXTTOPLEFT)        {            points = new Point2D.Double[4];            points[0] = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());            points[1] = new Point2D.Double(bounds.getMinX(), bounds.getMaxY());            points[2] = new Point2D.Double(bounds.getMinX(), bounds.getMaxY());            points[3] = new Point2D.Double(bounds.getMinX(), bounds.getMinY());        }        else if (style == Poly.Type.TEXTBOTLEFT)        {            points = new Point2D.Double[4];            points[0] = new Point2D.Double(bounds.getMinX(), bounds.getMaxY());            points[1] = new Point2D.Double(bounds.getMinX(), bounds.getMinY());            points[2] = new Point2D.Double(bounds.getMinX(), bounds.getMinY());            points[3] = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());        }        else if (style == Poly.Type.TEXTTOPRIGHT)        {            points = new Point2D.Double[4];            points[0] = new Point2D.Double(bounds.getMinX(), bounds.getMaxY());            points[1] = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());            points[2] = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());            points[3] = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());        }        else if (style == Poly.Type.TEXTBOTRIGHT)        {            points = new Point2D.Double[4];            points[0] = new Point2D.Double(bounds.getMinX(), bounds.getMinY());            points[1] = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());            points[2] = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());            points[3] = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());        }        else if (style == Poly.Type.TEXTBOX)        {            points = new Point2D.Double[12];            double lX = bounds.getMinX();            double hX = bounds.getMaxX();            double lY = bounds.getMinY();            double hY = bounds.getMaxY();            points[0] = new Point2D.Double(lX, lY);            points[1] = new Point2D.Double(hX, hY);            points[2] = new Point2D.Double(lX, hY);            points[3] = new Point2D.Double(hX, lY);            double shrinkX = (hX - lX) / 5;            double shrinkY = (hY - lY) / 5;            points[4] = new Point2D.Double(lX+shrinkX, lY);            points[5] = new Point2D.Double(hX-shrinkX, lY);            points[6] = new Point2D.Double(lX+shrinkX, hY);            points[7] = new Point2D.Double(hX-shrinkX, hY);            points[8] = new Point2D.Double(lX, lY+shrinkY);            points[9] = new Point2D.Double(lX, hY-shrinkY);            points[10] = new Point2D.Double(hX, lY+shrinkY);            points[11] = new Point2D.Double(hX, hY-shrinkY);        }        return points;	}    /**	 * Method to handle a click in a window and select the appropriate objects.	 * @param pt the coordinates of the click (in database units).	 * @param wnd the window being examined.	 * @param exclusively true if the currently selected object must remain selected.	 * This happens during "outline edit" when the node doesn't change, just the point on it.	 * @param another true to find another object under the point (when there are multiple ones).	 * @param invert true to invert selection (add if not selected, remove if already selected).	 * @param findPort true to also show the closest port on a selected node.	 * @param findPoint true to also show the closest point on a selected outline node.	 * @param findSpecial true to select hard-to-find objects.	 * @param findText true to select text objects.	 * The name of an unexpanded cell instance is always hard-to-select.	 * Other objects are set this way by the user (although the cell-center is usually set this way).	 */	public Highlight2 findObject(Point2D pt, EditWindow wnd, boolean exclusively,		boolean another, boolean invert, boolean findPort, boolean findPoint, boolean findSpecial, boolean findText)	{		// search the relevant objects in the circuit		Cell cell = wnd.getCell();        Rectangle2D bounds = new Rectangle2D.Double(pt.getX(), pt.getY(), 0, 0);		List<Highlight2> underCursor = findAllInArea(this, cell, exclusively, another, findPort, findPoint, findSpecial, findText, bounds, wnd);        Highlight2 found = null;		// if nothing under the cursor, stop now		if (underCursor.size() == 0)		{			if (!invert)			{				clear();				finished();			}			return found;		}        // get last selected object. Next selected object should be related        Highlight2 lastSelected = getLastSelected(underCursor);        if (lastSelected != null) {            // sort under cursor by relevance to lastSelected. first object is most relevant.            List<Highlight2> newUnderCursor = new ArrayList<Highlight2>();            while (!underCursor.isEmpty()) {                Highlight2 h = getSimiliarHighlight(underCursor, lastSelected);                newUnderCursor.add(h);                underCursor.remove(h);            }            underCursor = newUnderCursor;        }		// multiple objects under the cursor		if (underCursor.size() > 1 && another)		{            // I don't think you should loop and get getHighlight() every time                List<Highlight2> highlightList = getHighlights();			for(int j=0; j<getNumHighlights(); j++)			{				Highlight2 oldHigh = highlightList.get(j);				for(int i=0; i<underCursor.size(); i++)				{					if (oldHigh.sameThing(underCursor.get(i)))					{						// found the same thing: loop						if (invert)						{							remove(oldHigh);						} else						{							clear(false);						}						if (i < underCursor.size()-1)						{							found = (underCursor.get(i+1));						} else						{							found = (underCursor.get(0));						}                        addHighlight(found);						finished();						return found;					}				}			}		}		// just use the first in the list        found = underCursor.get(0);		if (invert)		{            List<Highlight2> highlightList = getHighlights();            for (Highlight2 h : highlightList)			{				if (found.sameThing(h))				{					remove(h);					finished();					return found; // return 1;				}			}		} else		{			clear();		}        addHighlight(found);        finished();		return found;	}	/**	 * Method to search a Cell for all objects at a point.	 * @param cell the cell to search.	 * @param exclusively true if the currently selected object must remain selected.	 * This happens during "outline edit" when the node doesn't change, just the point on it.	 * @param another true to find another object under the point (when there are multiple ones).	 * @param findPort true to also show the closest port on a selected node.	 * @param findPoint true to also show the closest point on a selected outline node.	 * @param findSpecial true to select hard-to-find objects.	 * @param findText true to select text objects.	 * The name of an unexpanded cell instance is always hard-to-select.	 * Other objects are set this way by the user (although the cell-center is usually set this way).	 * @param bounds the area of the search (in database units).	 * @param wnd the window being examined (null to ignore window scaling).	 * @return a list of Highlight objects.	 * The list is ordered by importance, so the deault action is to select the first entry.	 */	public static List<Highlight2> findAllInArea(Highlighter highlighter, Cell cell, boolean exclusively, boolean another, boolean findPort,		 boolean findPoint, boolean findSpecial, boolean findText, Rectangle2D bounds, EditWindow wnd)	{		// make a list of things under the cursor		List<Highlight2> list = new ArrayList<Highlight2>();        if (!Job.acquireExamineLock(false)) return list;        try        {    		// this is the distance from an object that is necessary for a "direct hit"    		double directHitDist = Double.MIN_VALUE;    		if (wnd != null)    		{    			Point2D extra = wnd.deltaScreenToDatabase(EXACTSELECTDISTANCE, EXACTSELECTDISTANCE);    			directHitDist = Math.abs(extra.getX()); // + 0.4;    		}    		// look for text if a window was given            if (findText && wnd != null)            {            	findTextNow(cell, wnd, directHitDist, bounds, findSpecial, list);

⌨️ 快捷键说明

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