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

📄 highlighter.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: Highlighter.java * * 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.user;import com.sun.electric.database.change.DatabaseChangeEvent;import com.sun.electric.database.change.DatabaseChangeListener;import com.sun.electric.database.geometry.DBMath;import com.sun.electric.database.geometry.GenMath;import com.sun.electric.database.geometry.Poly;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.Export;import com.sun.electric.database.network.Netlist;import com.sun.electric.database.network.Network;import com.sun.electric.database.prototype.NodeProto;import com.sun.electric.database.prototype.PortProto;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.Connection;import com.sun.electric.database.topology.Geometric;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.topology.PortInst;import com.sun.electric.database.topology.RTBounds;import com.sun.electric.database.topology.RTNode;import com.sun.electric.database.variable.DisplayedText;import com.sun.electric.database.variable.ElectricObject;import com.sun.electric.database.variable.TextDescriptor;import com.sun.electric.database.variable.Variable;import com.sun.electric.technology.ArcProto;import com.sun.electric.technology.Layer;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.PrimitivePort;import com.sun.electric.technology.Technology;import com.sun.electric.technology.technologies.Generic;import com.sun.electric.tool.Job;import com.sun.electric.tool.routing.Router;import com.sun.electric.tool.user.ui.EditWindow;import com.sun.electric.tool.user.ui.WindowFrame;import com.sun.electric.tool.user.waveform.WaveformWindow;import java.awt.Color;import java.awt.Graphics;import java.awt.Stroke;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.geom.AffineTransform;import java.awt.geom.Point2D;import java.awt.geom.Rectangle2D;import java.util.ArrayList;import java.util.Collections;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Set;import javax.swing.SwingUtilities;import javax.swing.Timer;/** * Class for per-window highlighting information. */public class Highlighter implements DatabaseChangeListener {    private static Highlighter currentHighlighter = null;    /** Screen offset for display of highlighting. */			private int highOffX; private int highOffY;    /** the highlighted objects. */								private List<Highlight2> highlightList;    /** the stack of highlights. */								private List<List<Highlight2>> highlightStack;    /** true if highlights have changed recently */             private boolean changed;    /** last object selected before last clear() */             private Highlight2 lastHighlightListEndObj;    /** what was the last level of "showNetwork" */             private int showNetworkLevel;	/** the type of highlighter */                              private int type;	/** the WindowFrame associated with the highlighter */      private WindowFrame wf;    /** List of HighlightListeners */                           private static Set<HighlightListener> highlightListeners = new HashSet<HighlightListener>();    /** the selection highlighter type */       				public static final int SELECT_HIGHLIGHTER = 0;    /** the mouse over highlighter type */      				public static final int MOUSEOVER_HIGHLIGHTER = 1;    /** the "measurement" highlighter type */   				public static final int RULER_HIGHLIGHTER = 2;    /** the max pixel distance that's acceptable selection */	public static final int EXACTSELECTDISTANCE = 5;    /**     * Create a new Highlighter object     * @param type     */    public Highlighter(int type, WindowFrame wf) {        highOffX = highOffY = 0;        highlightList = new ArrayList<Highlight2>();        highlightStack = new ArrayList<List<Highlight2>>();        changed = false;        UserInterfaceMain.addDatabaseChangeListener(this);        if (currentHighlighter == null) currentHighlighter = this;        lastHighlightListEndObj = null;        showNetworkLevel = 0;		this.type = type;		this.wf = wf;    }    void setChanged(boolean c) { changed = c; }    /**     * Destructor     */    public void delete()    {        UserInterfaceMain.removeDatabaseChangeListener(this);    }    /**	 * Method to add an ElectricObject to the list of highlighted objects.	 * @param eobj the ElectricObject to add to the list of highlighted objects.	 * @param cell the Cell in which the ElectricObject resides.	 * @return the newly created Highlight object.	 */    public Highlight2 addElectricObject(ElectricObject eobj, Cell cell)    {        return addElectricObject(eobj, cell, true);    }    /**     * Method to add an ElectricObject to the list of highlighted objects.     * @param eobj the ElectricObject to add to the list of highlighted objects.     * @param cell the Cell in which the ElectricObject resides.     * @param highlightConnected if true, highlight all objects that are in some way connected     * to this object.  If false, do not. This is used by addNetwork to prevent extra     * things from being highlighted later that are not connected to the network.     * @return the newly created Highlight object.     */	public Highlight2 addElectricObject(ElectricObject eobj, Cell cell, boolean highlightConnected)	{        Highlight2 h1 = new HighlightEOBJ(eobj, cell, highlightConnected, -1);		addHighlight(h1);		return h1;	}	/**	 * Method to add an ElectricObject to the list of highlighted objects.	 * @param eobj the ElectricObject to add to the list of highlighted objects.	 * @param cell the Cell in which the ElectricObject resides.	 * @return the newly created Highlight object.	 */	public Highlight2 addElectricObject(ElectricObject eobj, Cell cell, Color col)	{		return addElectricObject(eobj, cell, true, col);	}	/**	 * Method to add an ElectricObject to the list of highlighted objects.	 * @param eobj the ElectricObject to add to the list of highlighted objects.	 * @param cell the Cell in which the ElectricObject resides.	 * @param highlightConnected if true, highlight all objects that are in some way connected	 * to this object.  If false, do not. This is used by addNetwork to prevent extra	 * things from being highlighted later that are not connected to the network.	 * @return the newly created Highlight object.	 */	public Highlight2 addElectricObject(ElectricObject eobj, Cell cell, boolean highlightConnected, Color col)	{		Highlight2 h1 = new HighlightEOBJ(eobj, cell, highlightConnected, -1, col);		addHighlight(h1);		return h1;	}	/**	 * Method to add a text selection to the list of highlighted objects.	 * @param cell the Cell in which this area resides.	 * @param varKey the Variable.Key associated with the text (text is then a visual of that variable).	 * @return the newly created Highlight object.	 */	public Highlight2 addText(ElectricObject eobj, Cell cell, Variable.Key varKey)	{		HighlightText h1 = new HighlightText(eobj, cell, varKey);		addHighlight(h1);		return h1;	}	/**	 * Method to add a message display to the list of highlighted objects.	 * @param cell the Cell in which this area resides.	 * @param message the String to display.	 * @param loc the location of the string (in database units).	 * @return the newly created Highlight object.	 */	public Highlight2 addMessage(Cell cell, String message, Point2D loc)	{		Highlight2 h1 = new HighlightMessage(cell, message, loc);		addHighlight(h1);		return h1;	}	/**	 * Method to add an area to the list of highlighted objects.	 * @param area the Rectangular area to add to the list of highlighted objects.	 * @param cell the Cell in which this area resides.	 * @return the newly created Highlight object.	 */	public Highlight2 addArea(Rectangle2D area, Cell cell)	{        Highlight2 h1 = new HighlightArea(cell, area);        addHighlight(h1);		return h1;	}	/**	 * Method to generic Object.	 * @param obj object to add.	 * @param cell the Cell in which this object resides.	 * @return the newly created Highlight object.	 */	public Highlight2 addObject(Object obj, Cell cell)	{        Highlight2 h1 = new HighlightObject(cell, obj);        addHighlight(h1);		return h1;	}    /**	 * Method to add a line to the list of highlighted objects.	 * @param start the start point of the line to add to the list of highlighted objects.	 * @param end the end point of the line to add to the list of highlighted objects.	 * @param cell the Cell in which this line resides.	 * @return the newly created Highlight object.	 */	public Highlight2 addLine(Point2D start, Point2D end, Cell cell)	{        Highlight2 h1 = new HighlightLine(cell, start, end, null, false);        addHighlight(h1);		return h1;	}    /**	 * Method to add a line to the list of highlighted objects.	 * @param start the start point of the line to add to the list of highlighted objects.	 * @param end the end point of the line to add to the list of highlighted objects.	 * @param cell the Cell in which this line resides.	 * @param thick true for a thick line.	 * @return the newly created Highlight object.	 */	public Highlight2 addLine(Point2D start, Point2D end, Cell cell, boolean thick)	{        Highlight2 h1 = new HighlightLine(cell, start, end, null, thick);        addHighlight(h1);		return h1;	}    /**	 * Method to add a line to the list of highlighted objects.	 * @param start the start point of the line to add to the list of highlighted objects.	 * @param end the end point of the line to add to the list of highlighted objects.	 * @param cell the Cell in which this line resides.	 * @return the newly created Highlight object.	 */	public Highlight2 addThickLine(Point2D start, Point2D end, Cell cell)	{        Highlight2 h1 = new HighlightLine(cell, start, end, null, true);        addHighlight(h1);		return h1;	}    /**     * Method to add a Poly to the list of highlighted objects     * @param poly the poly to add     * @param cell the cell in which to display the poly     * @param color the color to draw the poly with (if null, uses default)     * @return the newly created highlight object     */    public Highlight2 addPoly(Poly poly, Cell cell, Color color)    {        Highlight2 h1 = new HighlightPoly(cell, poly, color);        addHighlight(h1);        return h1;    }    /**	 * Method to add a network to the list of highlighted objects.	 * Many arcs may be highlighted as a result.	 * @param net the network to highlight.	 * @param cell the Cell in which this line resides.	 */	public void addNetwork(Network net, Cell cell)	{		Netlist netlist = cell.acquireUserNetlist();		if (netlist == null)		{			System.out.println("Sorry, a deadlock aborted highlighting (network information unavailable).  Please try again");			return;		}        Set<Network> nets = new HashSet<Network>();        nets.add(net);        List<Highlight2> highlights = NetworkHighlighter.getHighlights(cell, netlist, nets, 0, 0);        for (Highlight2 h : highlights) {            addHighlight(h);        }	}    /**     * This is the show network command. It is similar to addNetwork, however     * each time it is used without first clearing     * the highlighter, it shows connections to the network another level down     * in the hierarchy.     * @param cell the cell in which to create the highlights     */    public void showNetworks(Cell cell)    {    	// find out what is selected		Netlist netlist = cell.acquireUserNetlist();		if (netlist == null)		{			System.out.println("Sorry, a deadlock aborted netlist display (network information unavailable).  Please try again");			return;		}		Set<Network> nets = getHighlightedNetworks();		if (nets.size() == 0)		{			// no nets selected.  If a cell instance is selected, use all nets on it that are wired			List<NodeInst> nodes = getHighlightedNodes();			if (nodes.size() == 1)			{				NodeInst ni = nodes.get(0);				for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); )				{					Connection con = it.next();					Network net = netlist.getNetwork(con.getPortInst());					nets.add(net);				}			}		}		int showNetworkLevel;        synchronized(this) {            showNetworkLevel = this.showNetworkLevel;        }        if (showNetworkLevel == 0)

⌨️ 快捷键说明

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