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

📄 textinfopanel.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        	}        }        xOffset.setText(TextUtils.formatDouble(initialXOffset));        yOffset.setText(TextUtils.formatDouble(initialYOffset));        // set the "invisible outside cell"        initialInvisibleOutsideCell = td.isInterior();        invisibleOutsideCell.setSelected(initialInvisibleOutsideCell);        // set the size        initialSize = td.getSize();        EditWindow wnd = EditWindow.getCurrent();        if (initialSize.isAbsolute())        {            pointsButton.setSelected(true);            pointsSize.setText(TextUtils.formatDouble(initialSize.getSize()));            unitsSize.setText("");            if (wnd != null)            {                double unitSize = initialSize.getSize() / wnd.getScale();                if (unitSize > TextDescriptor.Size.TXTMAXQGRID)                    unitSize = TextDescriptor.Size.TXTMAXQGRID;                else if (unitSize < TextDescriptor.Size.TXTMINQGRID)                    unitSize = TextDescriptor.Size.TXTMINQGRID;                unitsSize.setText(TextUtils.formatDouble(unitSize));            }        } else        {            unitsButton.setSelected(true);            unitsSize.setText(TextUtils.formatDouble(initialSize.getSize()));            pointsSize.setText("");            if (wnd != null)            {                double pointSize = initialSize.getSize()*wnd.getScale();                if (pointSize > TextDescriptor.Size.TXTMAXPOINTS)                    pointSize = TextDescriptor.Size.TXTMAXPOINTS;                else if (pointSize < TextDescriptor.Size.TXTMINPOINTS)                    pointSize = TextDescriptor.Size.TXTMINPOINTS;                pointsSize.setText(String.valueOf((int)pointSize));            }        }        // set Position        initialPos = td.getPos();        boxedWidth.setText("");        boxedHeight.setText("");        initialBoxedWidth = -1.0;        initialBoxedHeight = -1.0;        boolean ownerIsNodeInst = false;        if (owner instanceof NodeInst) ownerIsNodeInst = true;        if (ownerIsNodeInst) {            // make sure BOXED option is part of pull down menu            boolean found = false;            for (int i=0; i<textAnchor.getModel().getSize(); i++) {                TextDescriptor.Position pos = (TextDescriptor.Position)textAnchor.getModel().getElementAt(i);                if (pos == TextDescriptor.Position.BOXED) {                    found = true; break;                }            }            if (!found) {                textAnchor.addItem(TextDescriptor.Position.BOXED);            }            // set current boxed width and height, even if disabled            // later call to textAnchorItemStateChanged(null) will set enabled/disabled state            NodeInst ni2 = (NodeInst)owner;            initialBoxedWidth = ni2.getXSize();            initialBoxedHeight = ni2.getYSize();            boxedWidth.setText(TextUtils.formatDouble(ni2.getXSize()));            boxedHeight.setText(TextUtils.formatDouble(ni2.getYSize()));        }        if (!ownerIsNodeInst) {            // The TextDescriptor cannot be set to boxed, so remove it from the list            textAnchor.removeItem(TextDescriptor.Position.BOXED);        }		// set anchor		Poly.Type type = td.getPos().getPolyType();		type = Poly.rotateType(type, owner);		TextDescriptor.Position pos = TextDescriptor.Position.getPosition(type);        textAnchor.setSelectedItem(pos);        // update enable/disabled state of boxed height, width textfields        textAnchorItemStateChanged(null);        // set the font        initialFont = td.getFace();        if (initialFont == 0) font.setSelectedIndex(0); else        {            TextDescriptor.ActiveFont af = TextDescriptor.ActiveFont.findActiveFont(initialFont);            if (af != null)            {            	String fontName = af.getName();    			EDialog.ensureComboBoxFont(font, fontName);                font.setSelectedItem(fontName);            }        }        // set italic / bold / underline        initialItalic = td.isItalic();        italic.setSelected(initialItalic);        initialBold = td.isBold();        bold.setSelected(initialBold);        initialUnderline = td.isUnderline();        underline.setSelected(initialUnderline);        // set the rotation        initialRotation = td.getRotation();        rotation.setSelectedIndex(td.getRotation().getIndex());        // set the color        initialColorIndex = td.getColorIndex();        int [] colorIndices = EGraphics.getColorIndices();//        int colorComboIndex = Arrays.binarySearch(colorIndices, initialColorIndex);  // Arrays.binarySearch doesn't work on non-sorted array      int colorComboIndex = -1;		for(int i=0; i<colorIndices.length; i++)        {			if (colorIndices[i] == initialColorIndex)            {                colorComboIndex = i; // +1;                break; // No need of checking the rest of the array            }        }        colorComboIndex = (colorComboIndex != -1) ? colorComboIndex + 1 : 0;        textColorComboBox.setSelectedIndex(colorComboIndex);        // report the global text scale        double textScale = wnd != null ? wnd.getGlobalTextScale() : User.getGlobalTextScale();        globalTextScale.setText("Scaled by " + TextUtils.formatDouble(textScale*100) + "%");        loading = false;    }	/**	 * Class to handle special changes to changes to a Text Info Panel edit fields.	 */	private static class TextInfoDocumentListener implements DocumentListener	{		TextInfoPanel dialog;		TextInfoDocumentListener(TextInfoPanel dialog) { this.dialog = dialog; }		public void changedUpdate(DocumentEvent e) { dialog.fieldChanged(); }		public void insertUpdate(DocumentEvent e) { dialog.fieldChanged(); }		public void removeUpdate(DocumentEvent e) { dialog.fieldChanged(); }	}	private void fieldChanged()	{		if (!updateChangesInstantly) return;		if (loading) return;		applyChanges(false);	}    /**     * Method to modify a TextDescriptor to match the settings in this panel.     * @param td the input TextDescriptor.     * @return the TextDescriptor with code/units/display in this panel.     */    public TextDescriptor withPanelValues(TextDescriptor td)    {        // handle changes to the size        if (pointsButton.isSelected())        {            String s = pointsSize.getText().trim();            if (s.length() > 0)            	td = td.withAbsSize(TextUtils.atoi(s));        } else        {            String s = unitsSize.getText().trim();            if (s.length() > 0)            	td = td.withRelSize(TextUtils.atof(s));        }        // handle changes to the offset        double xd = TextUtils.atof(xOffset.getText());        double yd = TextUtils.atof(yOffset.getText());        td = td.withOff(xd, yd);        // handle changes to the rotation        int index = rotation.getSelectedIndex();        TextDescriptor.Rotation r = TextDescriptor.Rotation.getRotationAt(index);        td = td.withRotation(r);        // handle changes to the anchor point        TextDescriptor.Position p = (TextDescriptor.Position)textAnchor.getSelectedItem();        td = td.withPos(p);        // handle changes to the font        int f = font.getSelectedIndex();        td = td.withFace(f);        // handle changes to checkboxes        boolean it = italic.isSelected();        td = td.withItalic(it);        boolean bo = bold.isSelected();        td = td.withBold(bo);        boolean ul = underline.isSelected();        td = td.withUnderline(ul);        boolean invis = invisibleOutsideCell.isSelected();        td = td.withInterior(invis);		// handle changes to the color        int colorIndex = textColorComboBox.getSelectedIndex();        if (colorIndex > 0)        {    		int [] colorIndices = EGraphics.getColorIndices();        	td = td.withColorIndex(colorIndices[colorIndex-1]);        }		return td;    }	/**     * Apply any changes the user made to the Text options.     * @return true if any changes made to database, false if no changes made.     * @param adjustErrors     */    public synchronized boolean applyChanges(boolean adjustErrors) {        if (varKey == null) return false;        boolean changed = false;        // handle changes to the size        TextDescriptor.Size newSize = null;        if (pointsButton.isSelected())        {            String s = pointsSize.getText();            if (s.equals("")) return false; // removing all data from field            int size = TextUtils.atoi(s);            newSize = TextDescriptor.Size.newAbsSize(size);        } else        {            String s = unitsSize.getText();            if (s.equals("")) return false; // removing all data from field            double size = TextUtils.atof(s);            newSize = TextDescriptor.Size.newRelSize(size);        }        // default size        if (newSize == null)        {            // if values given in pointsSize or unitsSize are invalid            String value = (pointsButton.isSelected())? pointsSize.getText() : unitsSize.getText();            if (adjustErrors)                pointsSize.setText(String.valueOf(TextDescriptor.Size.TXTMAXPOINTS));            System.out.println("Error: given size value of " + value + " is out of range. Setting default value.");            newSize = TextDescriptor.Size.newRelSize(1.0);        }        if (!newSize.equals(initialSize)) changed = true;        // handle changes to the offset        double currentXOffset = TextUtils.atof(xOffset.getText());        double currentYOffset = TextUtils.atof(yOffset.getText());        if (!DBMath.doublesEqual(currentXOffset, initialXOffset) ||                !DBMath.doublesEqual(currentYOffset, initialYOffset))            changed = true;        // handle changes to the anchor point        TextDescriptor.Position newPosition = (TextDescriptor.Position)textAnchor.getSelectedItem();		Poly.Type type = newPosition.getPolyType();		type = Poly.unRotateType(type, owner);		newPosition = TextDescriptor.Position.getPosition(type);        if (newPosition != initialPos) changed = true;        double newBoxedWidth = 10;        double newBoxedHeight = 10;        if (newPosition == TextDescriptor.Position.BOXED) {            Double width, height;            try {                width = new Double(boxedWidth.getText());                height = new Double(boxedHeight.getText());                newBoxedWidth = width.doubleValue();                newBoxedHeight = height.doubleValue();            } catch (java.lang.NumberFormatException e) {                if (owner instanceof NodeInst) {                    NodeInst ni = (NodeInst)owner;                    newBoxedWidth = ni.getXSize();                    newBoxedHeight = ni.getYSize();                }            }            if (newBoxedWidth != initialBoxedWidth) changed = true;            if (newBoxedHeight != initialBoxedHeight) changed = true;        }        // handle changes to the rotation        int index = rotation.getSelectedIndex();        TextDescriptor.Rotation newRotation = TextDescriptor.Rotation.getRotationAt(index);        if (newRotation != initialRotation) changed = true;        // handle changes to the font        int newFont = font.getSelectedIndex();        if (newFont != initialFont) changed = true;        // handle changes to checkboxes        boolean newItalic = italic.isSelected();        if (newItalic != initialItalic) changed = true;        boolean newBold = bold.isSelected();        if (newBold != initialBold) changed = true;        boolean newUnderlined = underline.isSelected();        if (newUnderlined != initialUnderline) changed = true;        boolean newInvis = invisibleOutsideCell.isSelected();        if (newInvis != initialInvisibleOutsideCell) changed = true;		// handle changes to the color

⌨️ 快捷键说明

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