📄 waveformwindow.java
字号:
int newPanelSize = (int)(origPanelSize * scale); if (newPanelSize < MINANALOGPANELSIZE) newPanelSize = MINANALOGPANELSIZE; if (origPanelSize == newPanelSize) return; User.setWaveformAnalogPanelHeight(newPanelSize); minHeight = MINANALOGPANELSIZE; } else { int origPanelSize = User.getWaveformDigitalPanelHeight(); int newPanelSize = (int)(origPanelSize * scale); if (newPanelSize < MINDIGITALPANELSIZE) newPanelSize = MINDIGITALPANELSIZE; if (origPanelSize == newPanelSize) return; User.setWaveformDigitalPanelHeight(newPanelSize); minHeight = MINDIGITALPANELSIZE; } // resize the panels if (USETABLES) { for(int i=0; i<table.getRowCount(); i++) { int rowHeight = table.getRowHeight(i); int newRowHeight = (int)(rowHeight*scale); if (newRowHeight < minHeight) newRowHeight = minHeight; table.setRowHeight(i, newRowHeight); } } else { for(Panel wp : wavePanels) { Dimension sz = wp.getSize(); sz.height = (int)(sz.height * scale); if (sz.height < minHeight) sz.height = minHeight; wp.setSize(sz.width, sz.height); wp.setMinimumSize(sz); wp.setPreferredSize(sz); sz = wp.getLeftHalf().getSize(); sz.height = (int)(sz.height * scale); if (sz.height < minHeight) sz.height = minHeight; wp.getLeftHalf().setPreferredSize(sz); wp.getLeftHalf().setMinimumSize(sz); wp.getLeftHalf().setSize(sz.width, sz.height); sz = wp.getRightHalf().getSize(); sz.height = (int)(sz.height * scale); if (sz.height < minHeight) sz.height = minHeight; wp.getRightHalf().setPreferredSize(sz); wp.getRightHalf().setMinimumSize(sz); wp.getRightHalf().setSize(sz.width, sz.height); } } overall.validate(); redrawAllPanels(); } /** * Method called to delete the highlighted signal from its Panel. * @param wp the Panel with the signal to be deleted. */ public void deleteSignalFromPanel(Panel wp) { boolean found = true; while (found) { found = false; for(WaveSignal ws : wp.getSignals()) { if (!ws.isHighlighted()) continue; wp.removeHighlightedSignal(ws, true); wp.removeSignal(ws.getButton()); found = true; break; } } if (wp.getSignalButtons() != null) { wp.getSignalButtons().validate(); wp.getSignalButtons().repaint(); } wp.repaintContents(); saveSignalOrder(); } /** * Method called to delete all signals from a Panel. * @param wp the Panel to clear. */ public void deleteAllSignalsFromPanel(Panel wp) { wp.clearHighlightedSignals(); wp.getSignalButtons().removeAll(); wp.getSignalButtons().validate(); wp.getSignalButtons().repaint(); wp.removeAllSignals(); wp.repaintContents(); saveSignalOrder(); } // ************************************* THE HORIZONTAL RULER ************************************* public HorizRuler getMainHorizRuler() { return mainHorizRulerPanel; } public Signal getXAxisSignalAll() { return xAxisSignalAll; } public void setXAxisSignalAll(Signal sig) { xAxisSignalAll = sig; } private void addMainHorizRulerPanel() { mainHorizRulerPanel = new HorizRuler(null, this); mainHorizRulerPanel.setToolTipText("One X axis ruler applies to all signals when the X axes are locked"); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 10; gbc.gridy = 1; gbc.weightx = 1; gbc.weighty = 0; gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.BOTH; overall.add(mainHorizRulerPanel, gbc); } private void removeMainHorizRulerPanel() { overall.remove(mainHorizRulerPanel); mainHorizRulerPanel = null; } // ************************************* SWEEP CONTROL ************************************* private void resetSweeps() { sweepSignals = new ArrayList<SweepSignal>(); for(Iterator<Analysis> it = sd.getAnalyses(); it.hasNext(); ) { Analysis an = it.next(); if (!(an instanceof AnalogAnalysis)) continue; AnalogAnalysis aa = (AnalogAnalysis)an; int maxNum = aa.getNumSweeps(); if (maxNum <= 1) continue; for (int i = 0; i < maxNum; i++) { Object obj = aa.getSweep(i); new SweepSignal(obj, this, an); } } } public int addSweep(SweepSignal ss) { if (sweepSignals.add(ss)) return sweepSignals.size()-1; return -1; } public void setIncludeInAllSweeps(List<SweepSignal> sweeps, boolean include) { for(int i=0; i<sweeps.size(); i++) { SweepSignal ss = sweeps.get(i); boolean update = (i == sweeps.size()-1); ss.setIncluded(include, update); } } /** * Method to check whether this particular sweep is included. * @return true if the sweep is included */ public boolean isSweepSignalIncluded(AnalogAnalysis an, int index) { Object sweep = an.getSweep(index); for (SweepSignal ss : sweepSignals) { if (ss.getObject() == sweep) return ss.isIncluded(); } return true; // in case no sweep, always true } public int getHighlightedSweep() { return highlightedSweep; } public void setHighlightedSweep(int sweep) { highlightedSweep = sweep; } // ************************************* VCR CONTROL ************************************* private void tick() { // see if it is time to advance the VCR long curtime = System.currentTimeMillis(); if (curtime - vcrLastAdvance < 100) return; vcrLastAdvance = curtime; if (wavePanels.size() == 0) return; Panel wp = wavePanels.iterator().next(); int xValueScreen = wp.convertXDataToScreen(mainXPosition); Rectangle2D bounds = sd.getBounds(); if (vcrPlayingBackwards) { int newXValueScreen = xValueScreen - vcrAdvanceSpeed; double newXValue = wp.convertXScreenToData(newXValueScreen); double lowXValue = bounds.getMinX(); if (newXValue <= lowXValue) { newXValue = lowXValue; vcrClickStop(); } setMainXPositionCursor(newXValue); } else { int newXValueScreen = xValueScreen + vcrAdvanceSpeed; double newXValue = wp.convertXScreenToData(newXValueScreen); double highXValue = bounds.getMaxX(); if (newXValue >= highXValue) { newXValue = highXValue; vcrClickStop(); } setMainXPositionCursor(newXValue); } redrawAllPanels(); } private void vcrClickRewind() { vcrClickStop(); Rectangle2D bounds = sd.getBounds(); double lowXValue = bounds.getMinX(); setMainXPositionCursor(lowXValue); redrawAllPanels(); } private void vcrClickPlayBackwards() { if (vcrTimer == null) { ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent evt) { tick(); } }; vcrTimer = new Timer(100, taskPerformer); vcrLastAdvance = System.currentTimeMillis(); vcrTimer.start(); } vcrPlayingBackwards = true; } /** * Method to stop the auto-playing in the simulation window. */ public void vcrClickStop() { if (vcrTimer == null) return; vcrTimer.stop(); vcrTimer = null; } private void vcrClickPlay() { if (vcrTimer == null) { ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent evt) { tick(); } }; vcrTimer = new Timer(100, taskPerformer); vcrLastAdvance = System.currentTimeMillis(); vcrTimer.start(); } vcrPlayingBackwards = false; } private void vcrClickToEnd() { vcrClickStop(); Rectangle2D bounds = sd.getBounds(); double highXValue = bounds.getMaxX(); setMainXPositionCursor(highXValue); redrawAllPanels(); } private void vcrClickFaster() { int j = vcrAdvanceSpeed / 4; if (j <= 0) j = 1; vcrAdvanceSpeed += j; } private void vcrClickSlower() { int j = vcrAdvanceSpeed / 4; if (j <= 0) j = 1; vcrAdvanceSpeed -= j; if (vcrAdvanceSpeed <= 0) vcrAdvanceSpeed = 1; } // ************************************* HIGHLIGHTING ************************************* /** * Method to remove all highlighting from waveform window. */ public void clearHighlighting() { // look at all signal names in the cell for(Panel wp : wavePanels) { // look at all traces in this panel boolean changed = false; for(WaveSignal ws : wp.getSignals()) { if (ws.isHighlighted()) changed = true; ws.setHighlighted(false); } if (changed) wp.repaintContents(); } } /** * Method to return a List of highlighted simulation signals. * @return a List of highlighted simulation signals. */ public List<Signal> getHighlightedNetworkNames() { List<Signal> highlightedSignals = new ArrayList<Signal>(); // look at all signal names in the cell for(Panel wp : wavePanels) { // look at all traces in this panel for(WaveSignal ws : wp.getSignals()) { if (ws.isHighlighted()) highlightedSignals.add(ws.getSignal()); } } // also include what is in the SIGNALS tree ExplorerTree sigTree = wf.getExplorerTab(); Object nodeInfo = sigTree.getCurrentlySelectedObject(0); if (nodeInfo != null && nodeInfo instanceof Signal) { Signal sig = (Signal)nodeInfo; highlightedSignals.add(sig); } return highlightedSignals; } /** * Method to get a Set of currently highlighted networks in this WaveformWindow. */ public Set<Network> getHighlightedNetworks() { // make empty set Set<Network> nets = new HashSet<Network>(); // if no cell in the window, stop now Cell cell = sd.getCell(); if (cell == null) return nets; Netlist netlist = cell.acquireUserNetlist(); if (netlist == null) { System.out.println("Sorry, a deadlock aborted crossprobing (network information unavailable). Please try again"); return nets; } // look at all signal names in the cell for(Panel wp : wavePanels) { // look at all traces in this panel for(WaveSignal ws : wp.getSignals()) { Network net = findNetwork(netlist, ws.getSignal().getSignalName()); if (net != null) nets.add(net); } } // also include what is in the SIGNALS tree ExplorerTree sigTree = wf.getExplorerTab(); Object nodeInfo = sigTree.getCurrentlySelectedObject(0); if (nodeInfo != null && nodeInfo instanceof Signal) { Signal sig = (Signal)nodeInfo; Network net = findNetwork(netlist, sig.getSignalName()); if (net != null) nets.add(net); } return nets; } /** * Get the highlighter for this window content. * @return the highlighter */ public Highlighter getHighlighter() { return highlighter; } // ************************************* PRINTING ************************************* /** * Method to get a list of polygons describing the waveform window. * @return a List of PolyBase objects that describe this window. */ public List<PolyBase> getPolysForPrinting() { int offY = 0; List<PolyBase> override = new ArrayList<PolyBase>(); HorizRuler mainHR = getMainHorizRuler(); if (mainHR != null) { List<PolyBase> horizPolys = mainHR.getPolysForPrinting(getPanels().next()); for(PolyBase poly : hori
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -