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

📄 attributes.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            super("Create Attribute", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);            this.owner = owner;            this.dialog = dialog;            this.addToInstances = addToInstances;            // determine textdescriptor for the variable            TextDescriptor td = useThis;            if (useThis == null)            {	            if (owner instanceof Cell)	            {	            	td = TextDescriptor.getCellTextDescriptor().withParam(true).withInherit(true);	            } else if (owner instanceof NodeInst)	            {	            	td = TextDescriptor.getNodeTextDescriptor();	            } else if (owner instanceof ArcInst)	            {	            	td = TextDescriptor.getArcTextDescriptor();	            } else if (owner instanceof Export)	            {	            	td = TextDescriptor.getExportTextDescriptor();	            } else if (owner instanceof PortInst)	            {	            	td = TextDescriptor.getPortInstTextDescriptor();	            } else return;	            // add in specified factors	            td = dialog.attrPanel.withPanelValues(td);	            td = dialog.textPanel.withPanelValues(td);	            if (owner instanceof Cell)	            {	            	// find nonconflicting location of this cell attribute	            	Point2D offset = ((Cell)owner).newVarOffset();	            	td = td.withOff(offset.getX(), offset.getY());	            }            }            newValue = dialog.attrPanel.withPanelCode(newValue);            newVar = Variable.newInstance(Variable.newKey(newName), newValue, td);            startJob();        }        public boolean doIt() throws JobException        {            // check if var of this name already exists on object            if (owner.getParameterOrVariable(newVar.getKey()) != null)                throw new JobException("Can't create new attribute "+newVar+", already exists");            if (owner instanceof Cell && newVar.getTextDescriptor().isParam())            {            	// create the parameter            	CellGroup group = ((Cell)owner).getCellGroup();            	group.addParam(newVar);            	owner.setTextDescriptor(newVar.getKey(), newVar.getTextDescriptor());                if (addToInstances)                {	                for (Iterator<Cell> it = group.getCells(); it.hasNext(); )	                {	                	Cell cell = it.next();	                    if (!cell.isIcon()) continue;	                    for(Iterator<NodeInst> nIt = cell.getInstancesOf(); nIt.hasNext(); )	                    {	                    	NodeInst ni = nIt.next();		                    CircuitChangeJobs.inheritCellParameter(newVar, ni);	                    }	                }                }            } else if (owner instanceof NodeInst && ((NodeInst)owner).isParam(newVar.getKey()))            {                ((NodeInst)owner).addParameter(newVar.withParam(true));            } else            {                // create the attribute                owner.addVar(newVar);            }            return true;        }        public void terminateOK()        {        	dialog.updateList();            dialog.showSelectedAttribute(newVar.getKey());        }    }    private static class RenameAttribute extends Job    {        private String varName;        private String newVarName;        private ElectricObject owner;        protected RenameAttribute(String varName, String newVarName, ElectricObject owner)        {            super("Rename Attribute", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);            this.varName = varName;            this.newVarName = newVarName;            this.owner = owner;            startJob();        }        public boolean doIt() throws JobException        {            Variable.Key varKey = Variable.newKey(varName);            if (owner.isParam(varKey)) {                if (owner instanceof Cell) {                    Variable.AttrKey newParamKey = (Variable.AttrKey)Variable.newKey(newVarName);                    ((Cell)owner).getCellGroup().renameParam((Variable.AttrKey)varKey, newParamKey);                } else if (owner instanceof NodeInst) {                    System.out.println("Can't rename parameter on instance. Rename it on icon cell.");                }            } else {                Variable var = owner.renameVar(varName, newVarName);                if (var == null)                {                    System.out.println("Rename of variable failed");                    return false;                }            }            return true;        }    }    /**     * Class to create or modify an attribute in a new thread.     */    private static class ChangeAttribute extends Job	{        private Variable.Key varKey;        private ElectricObject owner;        private Object newValue;        protected ChangeAttribute(Variable.Key varKey, ElectricObject owner, Object newValue)        {            super("Change Attribute", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);            this.varKey = varKey;            this.owner = owner;            this.newValue = newValue;            startJob();        }        public boolean doIt() throws JobException        {            // get Variable by name            Variable var = owner.getParameterOrVariable(varKey);            if (var == null)				throw new JobException("Could not update Attribute " + varKey + ": it does not exist");            // change the Value field if a new Variable is being created or if the value changed            newValue = Variable.withCode(newValue, var.getCode());            if (owner instanceof Cell && owner.isParam(varKey)) {                ((Cell)owner).getCellGroup().updateParam((Variable.AttrKey)varKey, newValue);            } else {                var = owner.updateVar(varKey, newValue);                if (var == null)                    throw new JobException("Error updating Attribute " + varKey);            }            return true;        }    }	/**	 * Used to display Variables in the JList	 */	private class VariableCellRenderer extends JLabel implements ListCellRenderer {		private VariableCellRenderer() { }		public Component getListCellRendererComponent(JList list, Object value, int index,			boolean isSelected, boolean cellHasFocus)		{			if (value instanceof Variable.Key)			{				setText(getVariableText((Variable.Key)value));			} else if (value instanceof Variable)			{				setText(getVariableText(((Variable)value).getKey()));			} else			{				setText(value.toString());			}			if (isSelected) {				setBackground(list.getSelectionBackground());				setForeground(list.getSelectionForeground());			} else {				setBackground(list.getBackground());				setForeground(list.getForeground());			}			setEnabled(list.isEnabled());			setFont(list.getFont());			setOpaque(true);			return this;		}	}	private String getVariableText(Variable.Key varKey)	{		String varName = varKey.getName();		// two modes: show attributes only, and show everything		if (showParamsOnly)		{			if (varName.startsWith("ATTR_"))				return varName.substring(5);		}		// else this is not an attribute		// see if any cell, node, or arc variables are available to the user		String betterName = Variable.betterVariableName(varName);		if (betterName != null) return betterName;		return varName;	}    /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents    private void initComponents() {        java.awt.GridBagConstraints gridBagConstraints;        which = new javax.swing.ButtonGroup();        jSeparator1 = new javax.swing.JSeparator();        debugSelect = new javax.swing.JPanel();        currentCell = new javax.swing.JRadioButton();        cellName = new javax.swing.JLabel();        jLabel1 = new javax.swing.JLabel();        currentNode = new javax.swing.JRadioButton();        currentArc = new javax.swing.JRadioButton();        currentPort = new javax.swing.JRadioButton();        currentExport = new javax.swing.JRadioButton();        body = new javax.swing.JPanel();        mainLabel = new javax.swing.JLabel();        listPane = new javax.swing.JScrollPane();        jLabel2 = new javax.swing.JLabel();        name = new javax.swing.JTextField();        jLabel11 = new javax.swing.JLabel();        value = new javax.swing.JTextField();        evaluation = new javax.swing.JLabel();        evalLabel = new javax.swing.JLabel();        jPanel1 = new javax.swing.JPanel();        newButton = new javax.swing.JButton();        deleteButton = new javax.swing.JButton();        renameButton = new javax.swing.JButton();        done = new javax.swing.JButton();        applyToInstances = new javax.swing.JCheckBox();        copyButton = new javax.swing.JButton();        editValue = new javax.swing.JButton();        getContentPane().setLayout(new java.awt.GridBagLayout());        setTitle("Edit Attributes");        setName("");        addWindowListener(new java.awt.event.WindowAdapter() {            public void windowClosing(java.awt.event.WindowEvent evt) {                closeDialog(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 2;        gridBagConstraints.gridwidth = 5;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        getContentPane().add(jSeparator1, gridBagConstraints);        debugSelect.setLayout(new java.awt.GridBagLayout());        which.add(currentCell);        currentCell.setText("On Current Cell:");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 0;        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;        debugSelect.add(currentCell, gridBagConstraints);        cellName.setText("clock{sch}");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 1;        gridBagConstraints.gridy = 0;        gridBagConstraints.gridwidth = 4;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;        debugSelect.add(cellName, gridBagConstraints);        jLabel1.setText("or Highlighted Object:");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 1;        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;        debugSelect.add(jLabel1, gridBagConstraints);        which.add(currentNode);        currentNode.setText(" Node");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 1;        gridBagConstraints.gridy = 1;        debugSelect.add(currentNode, gridBagConstraints);        which.add(currentArc);        currentArc.setText(" Arc");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 2;        gridBagConstraints.gridy = 1;        debugSelect.add(currentArc, gridBagConstraints);        which.add(currentPort);        currentPort.setText("Port on Node");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 4;        gridBagConstraints.gridy = 1;        debugSelect.add(currentPort, gridBagConstraints);        which.add(currentExport);        currentExport.setText(" Export");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 3;        gridBagConstraints.gridy = 1;        debugSelect.add(currentExport, gridBagConstraints);        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridwidth = 5;        gridBagConstraints.gridheight = 2;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;        getContentPane().add(debugSelect, gridBagConstraints);        body.setLayout(new java.awt.GridBagLayout());

⌨️ 快捷键说明

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