📄 waveformwindow.java
字号:
* Method to return the waveform window associated with a Cell. * There may be multiple such windows, and the most recently used is returned. * @param cell the Cell whose waveform window is desired. * @return the waveform window that is linked to a cell. * Returns null if none can be found. */ public static WaveformWindow findWaveformWindow(Cell cell) { // look for the original cell to highlight it WaveformWindow found = null; int bestClock = 0; for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); if (wf.getContent().getCell() != cell) continue; if (wf.getContent() instanceof WaveformWindow) { WaveformWindow ww = (WaveformWindow)wf.getContent(); if (found == null || wf.getUsageClock() > bestClock) { found = ww; bestClock = wf.getUsageClock(); } } } return found; } /** * Method to return the WindowFrame in which this WaveformWindow lives. * @return the WindowFrame in which this WaveformWindow lives. */ public WindowFrame getWindowFrame() { return wf; } public int getScreenLowX() { return screenLowX; } public int getScreenHighX() { return screenHighX; } public void setScreenXSize(int lowX, int highX) { screenLowX = lowX; screenHighX = highX; } public JPanel getSignalNamesPanel() { return left; } public JPanel getSignalTracesPanel() { return right; } public JTable getWaveformTable() { return table; } // ************************************* CONTROL OF PANELS IN THE WINDOW ************************************* /** * Method to create a new panel with an X range similar to others on the display. * @return the newly created Panel. */ public Panel makeNewPanel(Analysis analysis) { // determine panel's analysis type Analysis.AnalysisType analysisType; if (analysis != null) analysisType = analysis.getAnalysisType(); else { analysisType = Analysis.ANALYSIS_SIGNALS; if (sd.isAnalog()) { if (sd.getNumAnalyses() > 0) analysisType = sd.getAnalyses().next().getAnalysisType(); if (xAxisLocked && xAxisSignalAll != null) { AnalogSignal as = (AnalogSignal)xAxisSignalAll; analysisType = as.getAnalysis().getAnalysisType(); } } } int panelSize = User.getWaveformDigitalPanelHeight(); if (sd.isAnalog()) panelSize = User.getWaveformAnalogPanelHeight(); // determine the X and Y ranges Rectangle2D bounds = null; double leftEdge, rightEdge; Analysis an = sd.findAnalysis(analysisType); if (an != null) { bounds = an.getBounds(); leftEdge = an.getLeftEdge(); rightEdge = an.getRightEdge(); } else { bounds = sd.getBounds(); leftEdge = sd.getLeftEdge(); rightEdge = sd.getRightEdge(); } double lowValue = bounds.getMinY(); double highValue = bounds.getMaxY(); int vertAxisPos = -1; if (xAxisLocked && wavePanels.size() > 0) { Panel aPanel = wavePanels.get(0); leftEdge = aPanel.getMinXAxis(); rightEdge = aPanel.getMaxXAxis(); vertAxisPos = aPanel.getVertAxisPos(); } int [] rowHeights = null; if (USETABLES) { int rows = table.getRowCount(); rowHeights = new int[rows+1]; for(int i=0; i<rows; i++) rowHeights[i] = table.getRowHeight(i); rowHeights[rows] = panelSize; } // create the new panel Panel panel = new Panel(this, sd.isAnalog(), analysisType); // set the X and Y ranges panel.setXAxisRange(leftEdge, rightEdge); if (analysisType != null) panel.setYAxisRange(lowValue, highValue); if (vertAxisPos > 0) panel.setVertAxisPos(vertAxisPos); // show and return the panel panel.makeSelectedPanel(-1, -1); getPanel().validate(); if (getMainHorizRuler() != null) getMainHorizRuler().repaint(); if (USETABLES) { table.tableChanged(new TableModelEvent(tableModel)); for(int i=0; i<rowHeights.length; i++) table.setRowHeight(i, rowHeights[i]); } return panel; } /** * Method to return the number of Panels in this WaveformWindow. * @return the number of Panels in this WaveformWindow. */ public int getNumPanels() { return wavePanels.size(); } /** * Method to return a Panel in this window. * @param index the panel number to get. * @return a Panel in this window. */ public Panel getPanel(int index) { return wavePanels.get(index); } /** * Method to return the index of a Panel in this window. * @param panel the Panel to find. * @return the index of that Panel in this window. */ public int getPanelIndex(Panel panel) { return wavePanels.indexOf(panel); } /** * Method to add a Panel to this window. */ public void addPanel(Panel panel) { wavePanels.add(panel); } /** * Method to add a Panel to this window. */ public void addPanel(Panel panel, int index) { wavePanels.add(index, panel); } /** * Method to remove a Panel from this window. */ public void removePanel(Panel panel) { wavePanels.remove(panel); } /** * Method to return an Iterator over the Panel in this window. * @return an Iterator over the Panel in this window. */ public Iterator<Panel> getPanels() { return wavePanels.iterator(); } /** * Method to return the current printing mode. * @return 0: color display (default), 1: color printing, 2: B&W printing */ public int getPrintingMode() { return nowPrinting; } /** * Method to return a Panel, given its number. * @param panelNumber the number of the desired Panel. * @return the Panel with that number (null if not found). */ private Panel getPanelFromNumber(int panelNumber) { for(Panel wp : wavePanels) { if (wp.getPanelNumber() == panelNumber) return wp; } return null; } private void togglePanelName() { if (rebuildingSignalNameList) return; String panelName = (String)signalNameList.getSelectedItem(); int spacePos = panelName.indexOf(' '); if (spacePos >= 0) panelName = panelName.substring(spacePos+1); int index = TextUtils.atoi(panelName); // toggle its state for(Panel wp : wavePanels) { if (wp.getPanelNumber() == index) { if (wp.isHidden()) { showPanel(wp); } else { hidePanel(wp); } break; } } } public void validatePanel() { overall.validate(); } public void rebuildPanelList() { rebuildingSignalNameList = true; signalNameList.removeAllItems(); boolean hasSignals = false; for(Panel wp : wavePanels) { signalNameList.addItem("Panel " + Integer.toString(wp.getPanelNumber()) + (wp.isHidden() ? " (HIDDEN)" : "")); hasSignals = true; } if (hasSignals) signalNameList.setSelectedIndex(0); rebuildingSignalNameList = false; } public void redrawAllPanels() { if (mainHorizRulerPanel != null) mainHorizRulerPanel.repaint(); for(Panel wp : wavePanels) { wp.repaintContents(); } if (USETABLES) { table.repaint(); } else { left.repaint(); right.repaint(); } } public void repaintAllPanels() { if (USETABLES) { table.repaint(); } else { right.repaint(); } } /** * Method called when a Panel is to be closed. * @param wp the Panel to close. */ public void closePanel(Panel wp) { if (USETABLES) { int rows = wavePanels.size(); int [] rowHeights = new int[rows]; int closedPanelIndex = wavePanels.indexOf(wp); int validPanels = 0; int visRow = 0; for(int i=0; i<rows; i++) { if (wavePanels.get(i).isHidden()) continue; int rowHeight = table.getRowHeight(visRow++); if (i == closedPanelIndex) continue; rowHeights[validPanels++] = rowHeight; } stopEditing(); reloadTable(); wavePanels.remove(wp); for(int i=0; i<validPanels; i++) table.setRowHeight(i, rowHeights[i]); } else { left.remove(wp.getLeftHalf()); right.remove(wp.getRightHalf()); wavePanels.remove(wp); } rebuildPanelList(); overall.validate(); redrawAllPanels(); } /** * Method called when a Panel is to be hidden. * @param wp the Panel to hide. */ public void hidePanel(Panel wp) { if (wp.isHidden()) return; if (USETABLES) { int rows = wavePanels.size(); int [] rowHeights = new int[rows]; int hiddenPanelIndex = wavePanels.indexOf(wp); int validPanels = 0; int visRow = 0; for(int i=0; i<rows; i++) { if (wavePanels.get(i).isHidden()) continue; int rowHeight = table.getRowHeight(visRow++); if (i == hiddenPanelIndex) continue; rowHeights[validPanels++] = rowHeight; } wp.setHidden(true); stopEditing(); reloadTable(); for(int i=0; i<validPanels; i++) table.setRowHeight(i, rowHeights[i]); } else { wp.setHidden(true); left.remove(wp.getLeftHalf()); right.remove(wp.getRightHalf()); } rebuildPanelList(); overall.validate(); redrawAllPanels(); } /** * Method called when a Panel is to be shown. * @param wp the Panel to show. */ public void showPanel(Panel wp) { if (!wp.isHidden()) return; if (USETABLES) { int rows = wavePanels.size(); int [] rowHeights = new int[rows]; int openedPanelIndex = wavePanels.indexOf(wp); int validPanels = 0; int visRow = 0; int openedPanelHeightIndex = -1; int averageHeight = 0; int numAverages = 0; for(int i=0; i<rows; i++) { if (i == openedPanelIndex) { openedPanelHeightIndex = validPanels; int height = User.getWaveformDigitalPanelHeight(); if (sd.isAnalog()) height = User.getWaveformAnalogPanelHeight(); rowHeights[validPanels++] = height; continue; } if (wavePanels.get(i).isHidden()) continue; int rowHeight = table.getRowHeight(visRow++); rowHeights[validPanels++] = rowHeight; averageHeight += rowHeight; numAverages++; } wp.setHidden(false); stopEditing(); reloadTable(); if (numAverages != 0) rowHeights[openedPanelHeightIndex] = averageHeight / numAverages; for(int i=0; i<validPanels; i++) table.setRowHeight(i, rowHeights[i]); } else { wp.setHidden(false); left.add(wp.getLeftHalf()); right.add(wp.getRightHalf()); } rebuildPanelList(); overall.validate(); redrawAllPanels(); } /** * Method called to grow or shrink the panels vertically. */ public void growPanels(double scale) { // if minimum doesn't apply to this display, stop now int minHeight; if (sd.isAnalog()) { int origPanelSize = User.getWaveformAnalogPanelHeight();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -