📄 textinfopanel.java
字号:
int newColorIndex = 0; int [] colorIndices = EGraphics.getColorIndices(); int newColorComboIndex = textColorComboBox.getSelectedIndex(); if (newColorComboIndex > 0) newColorIndex = colorIndices[newColorComboIndex-1]; if (newColorIndex != initialColorIndex) changed = true; if (td != null) { // no changes on current td, return false if (!changed) return false; } else { // because this is a new var, check if owner is a Cell // if so, increment the Y-offset so that sequentially created // new vars do not overlap on the schematic if (owner instanceof Cell) {// currentYOffset -= 2.0; Point2D offset = ((Cell)owner).newVarOffset(); currentYOffset = offset.getY(); currentXOffset = offset.getX(); } } // changes made: generate job and update initial values Integer absSize = null; Double relSize = null; if (newSize.isAbsolute()) absSize = new Integer((int)newSize.getSize()); else relSize = new Double(newSize.getSize()); new ChangeText( owner, unTransformNi, varKey, absSize, relSize, newPosition.getIndex(), newBoxedWidth, newBoxedHeight, newRotation.getIndex(), (String)font.getSelectedItem(), currentXOffset, currentYOffset, newItalic, newBold, newUnderlined, newInvis, newColorIndex); initialSize = newSize; initialXOffset = currentXOffset; initialYOffset = currentYOffset; initialPos = newPosition; initialRotation = newRotation; initialFont = newFont; initialItalic = newItalic; initialUnderline = newUnderlined; initialBold = newBold; initialInvisibleOutsideCell = newInvis; initialBoxedWidth = newBoxedWidth; initialBoxedHeight = newBoxedHeight; initialColorIndex = newColorIndex; return true; } private static class ChangeText extends Job { private ElectricObject owner; private NodeInst unTransformNi; private Variable.Key varKey; private Integer absSize; private Double relSize; private int position; private double boxedWidth, boxedHeight; private int rotation; private String font; private double xoffset, yoffset; private boolean italic, bold, underline, invis; private int newColorIndex; private ChangeText( ElectricObject owner, NodeInst unTransformNi, Variable.Key varKey, Integer absSize, Double relSize, int position, double boxedWidth, double boxedHeight, int rotation, String font, double xoffset, double yoffset, boolean italic, boolean bold, boolean underline, boolean invis, int newColorIndex ) { super("Modify Text", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.owner = owner; this.unTransformNi = unTransformNi; this.varKey = varKey; this.absSize = absSize; this.relSize = relSize; this.position = position; this.boxedWidth = boxedWidth; this.boxedHeight = boxedHeight; this.rotation = rotation; this.font = font; this.xoffset = xoffset; this.yoffset = yoffset; this.italic = italic; this.bold = bold; this.underline = underline; this.invis = invis; this.newColorIndex = newColorIndex; startJob(); } public boolean doIt() throws JobException { MutableTextDescriptor td = owner.getMutableTextDescriptor(varKey); if (td == null) return false; // handle changes to the size if (absSize != null) td.setAbsSize(absSize.intValue()); else td.setRelSize(relSize.doubleValue()); // handle changes to the text corner TextDescriptor.Position realPos = TextDescriptor.Position.getPositionAt(position); td.setPos(realPos); if (owner instanceof NodeInst) { NodeInst ni = (NodeInst)owner; if (realPos == TextDescriptor.Position.BOXED) { // set the boxed size ni.resize(boxedWidth-ni.getXSize(), boxedHeight-ni.getYSize()); // make invisible pin zero size if no longer boxed if (ni.getProto() == Generic.tech().invisiblePinNode) { if (ni.getXSize() != 0 || ni.getYSize() != 0) { // no longer boxed: make it zero size ni.resize(-ni.getXSize(), -ni.getYSize()); } } } } // handle changes to the rotation td.setRotation(TextDescriptor.Rotation.getRotationAt(rotation)); // handle changes to the offset NodeInst ni = null; if (owner != null) { if (owner instanceof NodeInst) { ni = (NodeInst)owner; if (ni.getProto() != Generic.tech().invisiblePinNode) { ni = null; // ni is null unless owner is invisible pin } } } // set the offset if (ni != null) { double dX = xoffset - ni.getAnchorCenterX(); double dY = yoffset - ni.getAnchorCenterY(); ni.move(dX, dY); } else { if (unTransformNi != null) { Point2D off = new Point2D.Double(xoffset, yoffset); AffineTransform trans = unTransformNi.pureRotateIn(); trans.transform(off, off); xoffset = off.getX(); yoffset = off.getY();; } td.setOff(xoffset, yoffset); } // handle changes to "invisible outside cell" td.setInterior(invis); // handle changes to the font td.setFaceWithActiveFont(font); // handle changes to italic / bold / underline td.setItalic(italic); td.setBold(bold); td.setUnderline(underline); td.setColorIndex(newColorIndex); owner.setTextDescriptor(varKey, TextDescriptor.newTextDescriptor(td)); return true; } } /** 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; sizes = new javax.swing.ButtonGroup(); jLabel4 = new javax.swing.JLabel(); pointsSize = new javax.swing.JTextField(); unitsSize = new javax.swing.JTextField(); pointsButton = new javax.swing.JRadioButton(); unitsButton = new javax.swing.JRadioButton(); jLabel5 = new javax.swing.JLabel(); font = new javax.swing.JComboBox(); italic = new javax.swing.JCheckBox(); bold = new javax.swing.JCheckBox(); underline = new javax.swing.JCheckBox(); jLabel6 = new javax.swing.JLabel(); rotation = new javax.swing.JComboBox(); jLabel8 = new javax.swing.JLabel(); xOffset = new javax.swing.JTextField(); jLabel9 = new javax.swing.JLabel(); yOffset = new javax.swing.JTextField(); invisibleOutsideCell = new javax.swing.JCheckBox(); seeNode = new javax.swing.JButton(); textAnchor = new javax.swing.JComboBox(); jLabel1 = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); boxedWidth = new javax.swing.JTextField(); boxedHeight = new javax.swing.JTextField(); jLabelX = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); textColorComboBox = new javax.swing.JComboBox(); jPanel2 = new javax.swing.JPanel(); jLabel10 = new javax.swing.JLabel(); globalTextScale = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jLabel7 = new javax.swing.JLabel(); jLabel12 = new javax.swing.JLabel(); setLayout(new java.awt.GridBagLayout()); setBorder(new javax.swing.border.EtchedBorder()); setName(""); jLabel4.setText("Text Size:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); add(jLabel4, gridBagConstraints); pointsSize.setColumns(8); pointsSize.setMinimumSize(new java.awt.Dimension(92, 20)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.insets = new java.awt.Insets(4, 2, 1, 4); add(pointsSize, gridBagConstraints); unitsSize.setColumns(8); unitsSize.setMinimumSize(new java.awt.Dimension(92, 20)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; gridBagConstraints.weightx = 0.1; gridBagConstraints.insets = new java.awt.Insets(1, 2, 4, 4); add(unitsSize, gridBagConstraints); sizes.add(pointsButton); pointsButton.setText("Points (max 63)"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(4, 0, 0, 0); add(pointsButton, gridBagConstraints); sizes.add(unitsButton); unitsButton.setText("Units (max 127.75)"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0); add(unitsButton, gridBagConstraints); jLabel5.setText("Font:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); add(jLabel5, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 6; gridBagConstraints.gridwidth = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); add(font, gridBagConstraints); italic.setText("Italic"); gridBagConstraints = new java.awt.GridBagConstraints();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -