📄 windowmenu.java
字号:
{ if (window != null) window.requestFocus(); else // message window. This could be done by creating another interface TopLevel.getMessagesWindow().requestFocus(); } } public static void fullDisplay() { // get the current frame WindowFrame wf = WindowFrame.getCurrentWindowFrame(); if (wf == null) return; // make the circuit fill the window wf.getContent().fillScreen(); } public static void zoomOutDisplay() { // get the current frame WindowFrame wf = WindowFrame.getCurrentWindowFrame(); if (wf == null) return; // zoom out wf.getContent().zoomOutContents(); } public static void zoomInDisplay() { // get the current frame WindowFrame wf = WindowFrame.getCurrentWindowFrame(); if (wf == null) return; // zoom in wf.getContent().zoomInContents(); } public static void zoomBoxCommand() { // only works with click zoom wire listener EventListener oldListener = WindowFrame.getListener(); WindowFrame.setListener(ClickZoomWireListener.theOne); ClickZoomWireListener.theOne.zoomBoxSingleShot(oldListener); } /** * Method to make the current window's grid be just visible. * If it is zoomed-out beyond grid visibility, it is zoomed-in so that the grid is shown. * If it is zoomed-in such that the grid is not at minimum pitch, * it is zoomed-out so that the grid is barely able to fit. */ public static void makeGridJustVisibleCommand() { EditWindow wnd = EditWindow.needCurrent(); if (wnd == null) return; Rectangle2D displayable = wnd.displayableBounds(); Dimension sz = wnd.getSize(); double scaleX = wnd.getGridXSpacing() * sz.width / 5.01 / displayable.getWidth(); double scaleY = wnd.getGridYSpacing() * sz.height / 5.01 / displayable.getHeight(); double scale = Math.min(scaleX, scaleY); wnd.setScale(wnd.getScale() / scale); wnd.setGrid(true); } /** * Method to adjust the current window so that it matches that of the "other" window. * For this to work, there must be exactly one other window shown. * @param how 0 to match scale; 1 to match in X; 2 to match in Y; 3 to match all. */ public static void matchOtherWindowCommand(int how) { EditWindow wnd = EditWindow.needCurrent(); if (wnd == null) return; int numOthers = 0; EditWindow other = null; for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); if (wf.getContent() instanceof EditWindow) { EditWindow wfWnd = (EditWindow)wf.getContent(); if (wfWnd == wnd) continue; numOthers++; other = wfWnd; } } if (numOthers != 1) { System.out.println("There must be exactly two windows in order for one to match the other"); return; } switch (how) { case 0: wnd.setScale(other.getScale()); break; case 1: wnd.setOffset(new Point2D.Double(other.getOffset().getX(), wnd.getOffset().getY())); break; case 2: wnd.setOffset(new Point2D.Double(wnd.getOffset().getX(), other.getOffset().getY())); break; case 3: wnd.setScale(other.getScale()); wnd.setOffset(new Point2D.Double(other.getOffset().getX(), other.getOffset().getY())); break; } wnd.fullRepaint(); } public static void focusOnHighlighted() { // get the current frame WindowFrame wf = WindowFrame.getCurrentWindowFrame(); if (wf == null) return; // focus on highlighted wf.getContent().focusOnHighlighted(); } /** * This method implements the command to toggle the display of the grid. */ public static void toggleGridCommand() { // get the current frame WindowFrame wf = WindowFrame.getCurrentWindowFrame(); if (wf == null) return; if (wf.getContent() instanceof EditWindow) { EditWindow wnd = (EditWindow)wf.getContent(); if (wnd == null) return; wnd.setGrid(!wnd.isGrid()); } else if (wf.getContent() instanceof WaveformWindow) { WaveformWindow ww = (WaveformWindow)wf.getContent(); ww.toggleGridPoints(); } else { System.out.println("Cannot draw a grid in this type of window"); } } /** * This method implements the command to tile the windows horizontally. */ public static void tileHorizontallyCommand() { // get the overall area in which to work Rectangle [] areas = getArrangementWindowAreas(); // tile the windows in each area for (Rectangle area : areas) { // see how many windows are on this screen int count = 0; for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); Rectangle wfBounds = wf.getFrame().getBounds(); int locX = (int)wfBounds.getCenterX(); int locY = (int)wfBounds.getCenterY(); if (locX >= area.x && locX < area.x+area.width && locY >= area.y && locY < area.y+area.height) count++; } if (count == 0) continue; int windowHeight = area.height / count; count = 0; for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); Rectangle wfBounds = wf.getFrame().getBounds(); int locX = (int)wfBounds.getCenterX(); int locY = (int)wfBounds.getCenterY(); if (locX >= area.x && locX < area.x+area.width && locY >= area.y && locY < area.y+area.height) { Rectangle windowArea = new Rectangle(area.x, area.y + count*windowHeight, area.width, windowHeight); count++; wf.setWindowSize(windowArea); } } } } /** * This method implements the command to tile the windows vertically. */ public static void tileVerticallyCommand() { // get the overall area in which to work Rectangle [] areas = getArrangementWindowAreas(); // tile the windows in each area for (Rectangle area : areas) { // see how many windows are on this screen int count = 0; for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); Rectangle wfBounds = wf.getFrame().getBounds(); int locX = (int)wfBounds.getCenterX(); int locY = (int)wfBounds.getCenterY(); if (locX >= area.x && locX < area.x+area.width && locY >= area.y && locY < area.y+area.height) count++; } if (count == 0) continue; int windowWidth = area.width / count; count = 0; for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); Rectangle wfBounds = wf.getFrame().getBounds(); int locX = (int)wfBounds.getCenterX(); int locY = (int)wfBounds.getCenterY(); if (locX >= area.x && locX < area.x+area.width && locY >= area.y && locY < area.y+area.height) { Rectangle windowArea = new Rectangle(area.x + count*windowWidth, area.y, windowWidth, area.height); count++; wf.setWindowSize(windowArea); } } } } /** * This method implements the command to tile the windows cascaded. */ public static void cascadeWindowsCommand() { // get the overall area in which to work Rectangle [] areas = getArrangementWindowAreas(); // tile the windows in each area for (Rectangle area : areas) { // see how many windows are on this screen int count = 0; for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); Rectangle wfBounds = wf.getFrame().getBounds(); int locX = (int)wfBounds.getCenterX(); int locY = (int)wfBounds.getCenterY(); if (locX >= area.x && locX < area.x+area.width && locY >= area.y && locY < area.y+area.height) count++; } if (count == 0) continue; int numRuns = 1; int windowXSpacing = 0, windowYSpacing = 0; int windowWidth = area.width; int windowHeight = area.height; if (count > 1) { windowWidth = area.width * 3 / 4; windowHeight = area.height * 3 / 4; int windowSpacing = Math.min(area.width - windowWidth, area.height - windowHeight) / (count-1); if (windowSpacing < 70) { numRuns = 70 / windowSpacing; if (70 % windowSpacing != 0) numRuns++; windowSpacing *= numRuns; } windowXSpacing = (area.width - windowWidth) / (count-1) * numRuns; windowYSpacing = (area.height - windowHeight) / (count-1) * numRuns; } count = 0; for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); Rectangle wfBounds = wf.getFrame().getBounds(); int locX = (int)wfBounds.getCenterX(); int locY = (int)wfBounds.getCenterY(); if (locX >= area.x && locX < area.x+area.width && locY >= area.y && locY < area.y+area.height) { int index = count / numRuns; Rectangle windowArea = new Rectangle(area.x + index*windowXSpacing, area.y + index*windowYSpacing, windowWidth, windowHeight); count++; wf.setWindowSize(windowArea); } } } } private static void closeWindowCommand() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -