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

📄 baseapplicationpane.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    leftSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);                }                leftSplitPane.setRightComponent(c);                break;            case SwingConstants.EAST:                if (rightSplitPane == null) {                    rightSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);                }                leftSplitPane.setRightComponent(c);                break;             */                        }            }    /**     *  Invoked when a mouse button has been released on a tab.     *     * @param the encapsulating event object     */    public void dockedTabReleased(DockedDragEvent e) {        try {            if (dragPanel != null) {                desktopMediator.removeDragPanel(dragPanel);                repaint();                int x = e.getX();                int y = e.getY();                                if (fromTabPane == null) {                    fromTabPane = e.getSourceTabPane();                }                int fromIndex = fromTabPane.getDraggingIndex();                // check if we are moving to an area with no tab pane                if (newTabPanePosition != -1) {                    TabComponent tabComponent = fromTabPane.getTabComponentAt(fromIndex);                    if (tabComponent == null) {                        return;                    }                    fromTabPane.removeIndex(fromIndex);                    tabComponent.setPosition(newTabPanePosition);                    desktopMediator.addDockedTab(tabComponent, newTabPanePosition, true);                    return;                }                                // move tab if required                if (fromTabPane != null && toTabPane != null) {                    if (fromTabPane == toTabPane) {                        int toIndex = fromTabPane.getTabAtLocation(x, y);                        fromTabPane.moveTab(fromIndex, toIndex);                    }                    else {                        Rectangle tabRect = dragPanel.getTabRectangle();                        int toIndex = toTabPane.getTabRectangleIndex(tabRect);                        TabComponent tabComponent = fromTabPane.getTabComponentAt(fromIndex);                        if (tabComponent == null) {                            return;                        }                        fromTabPane.removeIndex(fromIndex);                        tabComponent.setPosition(toTabPane.getTabPanePosition());                        tabComponent.setIndex(toIndex);                        toTabPane.insertTab(tabComponent, toIndex);                    }                }            }        }        // make sure we clean up and reset the cursor        finally {            dragPanel = null;            fromTabPane = null;            toTabPane = null;            newTabPanePosition = -1;            desktopMediator.setFrameCursor(                    Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));        }    }        /**     * Invoked when a mouse button is pressed on a tab and then dragged.     *     * @param the encapsulating event object     */    public void dockedTabDragged(DockedDragEvent e) {        desktopMediator.setFrameCursor(                Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));        int x = e.getX();        int y = e.getY();        // convert the point for this base component -         // starting search from the bottom up        Point point = SwingUtilities.convertPoint(e.getSourceTabPane(), x, y, this);        x = point.x;        y = point.y;                int height = getHeight();        int width = getWidth();                double placementFactor = 0.2;        int heightRange = (int)(height * placementFactor);        int widthRange =  (int)(width * placementFactor);                int leftPaneWidth = desktopMediator.getPaneWidth(SwingConstants.WEST);        int rightPaneWidth = desktopMediator.getPaneWidth(SwingConstants.EAST);        int centerPaneWidth = desktopMediator.getPaneWidth(SwingConstants.CENTER);                //Log.debug("west: "+desktopMediator.isPaneVisible(SwingConstants.WEST));                // check left/right extremes where there may no tab and split panes        if (x < widthRange) { // left side            //Log.debug("AA");            if (!desktopMediator.isPaneVisible(SwingConstants.WEST)) {                //Log.debug("BB");                Rectangle tabPaneRect = new Rectangle(0,                                                       0,                                                      widthRange,                                                      height);                // add the y offset for this panel                tabPaneRect.y += getYOffset();                if (dragPanel == null) {                    dragPanel = new DragPanel(tabPaneRect);                    desktopMediator.addDragPanel(dragPanel);                }                else {                    dragPanel.reset(tabPaneRect);                }                newTabPanePosition = SwingConstants.NORTH_WEST;                return;            }        }        else if (x > (width - widthRange)) { // right side            //Log.debug("CC");            if (!desktopMediator.isPaneVisible(SwingConstants.EAST)) {                //Log.debug("DD");                Rectangle tabPaneRect = new Rectangle(width - widthRange,                                                       0,                                                      widthRange,                                                      height);                // add the y offset for this panel                tabPaneRect.y += getYOffset();                if (dragPanel == null) {                    dragPanel = new DragPanel(tabPaneRect);                    desktopMediator.addDragPanel(dragPanel);                }                else {                    dragPanel.reset(tabPaneRect);                }                newTabPanePosition = SwingConstants.NORTH_EAST;                return;            }        }        // bottom region        if (y > (height - heightRange)) {            //Log.debug("ZZ");            // bottom-left region            if (x < leftPaneWidth &&                     !desktopMediator.hasDockedComponentAtPosition(SwingConstants.SOUTH_WEST)) {                if (leftSplitPane == null || leftSplitPane.getLeftComponent() == null) return;                Rectangle tabPaneRect =                         new Rectangle(leftSplitPane.getLeftComponent().getX(),                                      height - heightRange - ApplicationConstants.SPLIT_PANE_DIVIDER_SIZE,                                      leftPaneWidth,                                      heightRange);                // add the y offset for this panel                tabPaneRect.y += getYOffset();                if (dragPanel == null) {                    dragPanel = new DragPanel(tabPaneRect);                    desktopMediator.addDragPanel(dragPanel);                }                else {                    dragPanel.reset(tabPaneRect);                }                newTabPanePosition = SwingConstants.SOUTH_WEST;                return;            }            // bottom-right region            else if (x > (width - rightPaneWidth) &&                         !desktopMediator.hasDockedComponentAtPosition(SwingConstants.SOUTH_EAST)) {                //Log.debug("YY");                Rectangle tabPaneRect =                         new Rectangle(rightSplitPane.getRightComponent().getX(),                                      height - heightRange - ApplicationConstants.SPLIT_PANE_DIVIDER_SIZE,                                      rightPaneWidth - ApplicationConstants.SPLIT_PANE_DIVIDER_SIZE,                                      heightRange);                // add the y offset for this panel                tabPaneRect.y += getYOffset();                if (dragPanel == null) {                    dragPanel = new DragPanel(tabPaneRect);                    desktopMediator.addDragPanel(dragPanel);                }                else {                    dragPanel.reset(tabPaneRect);                }                newTabPanePosition = SwingConstants.SOUTH_EAST;                return;            }            // bottom-center region            else if (x > leftPaneWidth && x < (width - rightPaneWidth) &&                         !desktopMediator.hasDockedComponentAtPosition(SwingConstants.SOUTH)) {                //Log.debug("XX");                Rectangle tabPaneRect =                         new Rectangle(                            leftPaneWidth +                                 ApplicationConstants.SPLIT_PANE_DIVIDER_SIZE +                                 ApplicationConstants.TAB_COMPONENT_BORDER_THICKNESS,                             height - heightRange,                            centerPaneWidth,                            heightRange - ApplicationConstants.SPLIT_PANE_DIVIDER_SIZE);                // add the y offset for this panel                tabPaneRect.y += getYOffset();                                if (dragPanel == null) {                    dragPanel = new DragPanel(tabPaneRect);                    desktopMediator.addDragPanel(dragPanel);                }                else {                    dragPanel.reset(tabPaneRect);                }                newTabPanePosition = SwingConstants.SOUTH;                return;            }                    }                //Log.debug("XXXXXXXXXX");                // ------------------------------------------------------------        // otherwise we must be in the region with existing tab panes                newTabPanePosition = -1;        DockedTabPane tabPane = null;        Component component = null;        Component lastComponent = this;        //Log.debug("BEFORE - x: " + x + " y: " + y);                // need to loop through the split pane layers        // until the end or when we locate a tab pane                while ((component = lastComponent.getComponentAt(x, y)) != null) {            if (component == lastComponent) { // short-circuit                //Log.debug("component: " + component.getClass().getName());                                if (component instanceof DockedTabPane) {                    tabPane = (DockedTabPane)component;                    break;                }                //Log.debug("KK");                return;            }            point = SwingUtilities.convertPoint(lastComponent, x, y, component);            x = point.x;            y = point.y;            // check if we're over a glass pane on the tab pane            if (component instanceof BaseRootPane.GlassPanePanel) {                component = ((BaseRootPane.GlassPanePanel)component).getComponentBelow();            }            if (component instanceof DockedTabPane) {                tabPane = (DockedTabPane)component;                break;            }            lastComponent = component;        }        // return if we have nothing        if (tabPane == null) {            //Log.debug("LL");            return;        }                //Log.debug("AFTER - x: " + x + " y: " + y);                if (tabPane.intersectsTabArea(x, y)) {            Rectangle tabRect = tabPane.getTabRectangleAtLocation(x, y);            if (tabRect == null) {                return;            }            // recalculate based on the position of the tab pane            point = SwingUtilities.convertPoint(                        tabPane, tabPane.getLocation(), this);            //Log.debug("point calced: "+point);                        Rectangle tabPaneRect = new Rectangle(tabPane.getBounds());            // reset the origin            tabPaneRect.x = point.x;// - ApplicationConstants.TAB_COMPONENT_BORDER_THICKNESS;            tabPaneRect.y = point.y;                        // add the y offset for this panel            tabPaneRect.y += getYOffset();// + tabRect.height;                        //Log.debug("setting rect: " + tabPaneRect);                        // ----------            // this works but need to do same where no tab pane above            // tabPaneRect.y += getYOffset() + tabRect.height;            // ----------                        if (dragPanel == null) {                dragPanel = new DragPanel(tabRect, tabPaneRect);                desktopMediator.addDragPanel(dragPanel);            }             else {                dragPanel.reset(tabRect, tabPaneRect);            }            //Log.debug("bounds: " + dragPanel.getBounds());                    }        else {            if (dragPanel != null) {                desktopMediator.removeDragPanel(dragPanel);                dragPanel = null;                repaint();            }        }        fromTabPane = e.getSourceTabPane();        toTabPane = tabPane;    }        private int getYOffset() {        //Log.debug("base location " + getLocation());        //Point offsetPoint = SwingUtilities.convertPoint(        //                            this, getLocation(), desktopMediator.getFrame().getContentPane());                //Log.debug("offset calc: " + offsetPoint.y);        return getLocation().y + 20;//offsetPoint.y;// + 17;        //return getBounds().y + 34; //17;    }    }

⌨️ 快捷键说明

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