Java 类javax.swing.JLayeredPane 实例源码

项目:incubator-netbeans    文件:DragOperation.java   
void start(PaletteItem item, Point pt) {
    // clean up prev is necessary
    if(dragComponent != null) {
        menuEditLayer.layers.remove(dragComponent);
        dragComponent = null;
    }

    if(!menuEditLayer.doesFormContainMenuBar()) {
        //op = Op.NO_MENUBAR;
        menuEditLayer.showMenubarWarning = true;
        FormEditor.getAssistantModel(menuEditLayer.formDesigner.getFormModel()).setContext("missingMenubar"); // NOI18N
        menuEditLayer.repaint();
    }

    op = Op.PICK_AND_PLOP_FROM_PALETTE;
    started = true;
    dragComponent = createDragFeedbackComponent(null, item.getComponentClass());
    dragComponent.setSize(dragComponent.getPreferredSize());
    dragComponent.setLocation(pt);
    menuEditLayer.layers.add(dragComponent, JLayeredPane.DRAG_LAYER);
    menuEditLayer.repaint();
    currentItem = item;
    menuEditLayer.glassLayer.requestFocusInWindow();
}
项目:incubator-netbeans    文件:ComponentPeer.java   
private int[] computeVisibleSpan() {
    Component parent = pane.getParent();

    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }

    if (parent instanceof JViewport) {
        JViewport vp = (JViewport) parent;

        Point start = vp.getViewPosition();
        Dimension size = vp.getExtentSize();
        Point end = new Point((int) (start.getX() + size.getWidth()), (int) (start.getY() + size.getHeight()));

        int startPosition = pane.viewToModel(start);
        int endPosition = pane.viewToModel(end);

        if (parentWithListener != vp) {
            vp.addChangeListener(WeakListeners.change(this, vp));
            parentWithListener = vp;
        }
        return new int[] {startPosition, endPosition};
    }

    return new int[] {0, pane.getDocument().getLength()};
}
项目:incubator-netbeans    文件:AnnotationView.java   
double getUsableHeight() {
    //fix for issue #54080:
    //find the scrollpane which contains the pane:
    Component scrollPaneCandidade = pane.getParent();

    if (scrollPaneCandidade instanceof JLayeredPane) {
        scrollPaneCandidade = scrollPaneCandidade.getParent();
    }

    if (scrollPaneCandidade != null && !(scrollPaneCandidade instanceof JScrollPane)) {
        scrollPaneCandidade = scrollPaneCandidade.getParent();
    }

    if (scrollPaneCandidade == null || !(scrollPaneCandidade instanceof JScrollPane) || scrollBar == null) {
        //no help for #54080:
        return getHeight() - HEIGHT_OFFSET;
    }

    JScrollPane scrollPane = (JScrollPane) scrollPaneCandidade;
    int visibleHeight = scrollPane.getViewport().getExtentSize().height;

    int topButton = topOffset();
    int bottomButton = scrollBar.bottom;

    return visibleHeight - topButton - bottomButton;
}
项目:incubator-netbeans    文件:SlideOperationImpl.java   
private void performOperation(JLayeredPane pane, Integer layer) {
    // XXX - TBD
    switch (type) {
        case SLIDE_IN:
            component.setBounds(finishBounds);
            pane.add(component, layer);
            if( isHeavyWeightShowing() ) {
                repaintLayeredPane();
            }
            break;
        case SLIDE_OUT:
            pane.remove(component);
            break;
        case SLIDE_RESIZE:
            component.setBounds(finishBounds);
            ((JComponent)component).revalidate();
            if( isHeavyWeightShowing() ) {
                repaintLayeredPane();
            }
            break;
    }
}
项目:incubator-netbeans    文件:WindowBuilders.java   
static ComponentBuilder getBuilder(Instance instance, Heap heap) {
    if (DetailsUtils.isSubclassOf(instance, JRootPane.class.getName())) {
        return new JRootPaneBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JDesktopPane.class.getName())) {
        return new JDesktopPaneBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JLayeredPane.class.getName())) {
        return new JLayeredPaneBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, Frame.class.getName())) {
        return new FrameBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, Dialog.class.getName())) {
        return new DialogBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JInternalFrame.class.getName())) {
        return new JInternalFrameBuilder(instance, heap);
    }
    return null;
}
项目:incubator-netbeans    文件:QuickSearchPopup.java   
private void computePopupBounds (Rectangle result, JLayeredPane lPane, int modelSize) {
    Dimension cSize = comboBar.getSize();
    int width = getPopupWidth();
    Point location = new Point(cSize.width - width - 1, comboBar.getBottomLineY() - 1);
    if (SwingUtilities.getWindowAncestor(comboBar) != null) {
        location = SwingUtilities.convertPoint(comboBar, location, lPane);
    }
    result.setLocation(location);

    // hack to make jList.getpreferredSize work correctly
    // JList is listening on ResultsModel same as us and order of listeners
    // is undefined, so we have to force update of JList's layout data
    jList1.setFixedCellHeight(15);
    jList1.setFixedCellHeight(-1);
    // end of hack

    jList1.setVisibleRowCount(modelSize);
    Dimension preferredSize = jList1.getPreferredSize();

    preferredSize.width = width;
    preferredSize.height += statusPanel.getPreferredSize().height + 3;

    result.setSize(preferredSize);
}
项目:incubator-netbeans    文件:QuickSearchPopup.java   
private void computePopupBounds (Rectangle result, JLayeredPane lPane, int modelSize) {
    Point location =
            new Point(
                comboBar.getIssueComponent().getX(),
                comboBar.getIssueComponent().getY() + comboBar.getIssueComponent().getHeight() - 1);
    location = SwingUtilities.convertPoint(comboBar, location, lPane); // XXX terrible hack! fix this
    result.setLocation(location);

    // hack to make jList.getpreferredSize work correctly
    // JList is listening on ResultsModel same as us and order of listeners
    // is undefined, so we have to force update of JList's layout data
    jList1.setFixedCellHeight(15);
    jList1.setFixedCellHeight(-1);
    // end of hack

    jList1.setVisibleRowCount(modelSize);
    Dimension preferredSize = jList1.getPreferredSize();

    preferredSize.width = comboBar.getIssueComponent().getWidth();
    preferredSize.height += statusPanel.getPreferredSize().height + 3;
    if(preferredSize.height > 150) {
        preferredSize.height = 150;
    }

    result.setSize(preferredSize);
}
项目:VASSAL-src    文件:GenericListener.java   
/**
 * Return true if the given component is likely to be a container such the each
 * component within the container should be be considered as a user input.
 * 
 * @param c
 * @return true if the component children should have this listener added.
 */
protected boolean isProbablyAContainer (Component c) {
    boolean result = extListener != null ? extListener.isContainer(c) : false;
    if (!result) {
        boolean isSwing = isSwingClass(c);
        if (isSwing) {
           result = c instanceof JPanel || c instanceof JSplitPane || c instanceof
                   JToolBar || c instanceof JViewport || c instanceof JScrollPane ||
                   c instanceof JFrame || c instanceof JRootPane || c instanceof
                   Window || c instanceof Frame || c instanceof Dialog ||
                   c instanceof JTabbedPane || c instanceof JInternalFrame ||
                   c instanceof JDesktopPane || c instanceof JLayeredPane;
        } else {
            result = c instanceof Container;
        }
    }
    return result;
}
项目:VASSAL-src    文件:PrivateMap.java   
public JComponent getView() {
  if (theMap == null) {
    theMap = new View(this);
    scroll = new AdjustableSpeedScrollPane(
          theMap,
          JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
          JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scroll.unregisterKeyboardAction(KeyStroke.getKeyStroke(
          KeyEvent.VK_PAGE_DOWN, 0));
    scroll.unregisterKeyboardAction(KeyStroke.getKeyStroke(
          KeyEvent.VK_PAGE_UP, 0));

    layeredPane.setLayout(new InsetLayout(layeredPane, scroll));
    layeredPane.add(scroll, JLayeredPane.DEFAULT_LAYER);
  }
  return theMap;
}
项目:VASSAL-src    文件:GlobalMap.java   
/**
 * Expects to be added to a {@link Map}. Adds itself as a {@link
 * GameComponent} and a {@link Drawable}component
 */
public void addTo(Buildable b) {
  map = (Map) b;

  mouseOverViewer = new CounterViewer();

  GameModule.getGameModule().getGameState().addGameComponent(this);

  GameModule.getGameModule().addKeyStrokeSource(
    new KeyStrokeSource(view, JComponent.WHEN_FOCUSED));

  map.addDrawComponent(this);
  map.getToolBar().add(launch);

  if (b instanceof Translatable) {
    getI18nData().setOwningComponent((Translatable) b);
  }

  map.getLayeredPane().add(scroll, JLayeredPane.PALETTE_LAYER);
}
项目:VASSAL-src    文件:PieceMover.java   
/**
 * creates or moves cursor object to given JLayeredPane. Usually called by setDrawWinToOwnerOf()
 */
private void setDrawWin(JLayeredPane newDrawWin) {
  if (newDrawWin != drawWin) {
    // remove cursor from old window
    if (dragCursor.getParent() != null) {
      dragCursor.getParent().remove(dragCursor);
    }
    if (drawWin != null) {
      drawWin.repaint(dragCursor.getBounds());
    }
    drawWin = newDrawWin;
    calcDrawOffset();
    dragCursor.setVisible(false);
    drawWin.add(dragCursor, JLayeredPane.DRAG_LAYER);
  }
}
项目:VASSAL-src    文件:Map.java   
/** @return the Swing component representing the map */
public JComponent getView() {
  if (theMap == null) {
    theMap = new View(this);

    scroll = new AdjustableSpeedScrollPane(
      theMap,
      JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
      JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.unregisterKeyboardAction(
      KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0));
    scroll.unregisterKeyboardAction(
      KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0));
    scroll.setAlignmentX(0.0f);
    scroll.setAlignmentY(0.0f);

    layeredPane.setLayout(new InsetLayout(layeredPane, scroll));
    layeredPane.add(scroll, JLayeredPane.DEFAULT_LAYER);
  }
  return theMap;
}
项目:Cognizant-Intelligent-Test-Scripter    文件:SlideContainer.java   
@Override
public Component add(Component comp) {
    setsize(comp.getPreferredSize());
    Component[] comps = getComponents();
    if (comps.length > 0) {
        oldComponent = comps[0];
    }
    if (comp.equals(oldComponent)) {
        return super.add(comp);
    }
    if (oldComponent != null) {
        putLayer((JComponent) oldComponent, JLayeredPane.DEFAULT_LAYER);
    }
    Component returnResult = super.add(comp);
    putLayer((JComponent) comp, JLayeredPane.DRAG_LAYER);
    comp.setSize(getPreferredSize());
    comp.setVisible(true);
    comp.setLocation(0, 0 - getPreferredSize().height);
    slideFromTop(comp, oldComponent);
    return returnResult;
}
项目:Cognizant-Intelligent-Test-Scripter    文件:SlideContainer.java   
private void slideFromTop(final Component comp,
        final Component oldComponent2) {
    new Timer(DELAY, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent aEvt) {
            int y = comp.getY();
            if (y >= -2) {
                comp.setLocation(0, 0);
                putLayer((JComponent) comp, JLayeredPane.DEFAULT_LAYER);
                if (oldComponent2 != null) {
                    remove(oldComponent2);
                }
                ((Timer) aEvt.getSource()).stop();
            } else {
                y += DY;
                comp.setLocation(0, y);
            }
            repaint();
        }
    }).start();
}
项目:VISNode    文件:JNodeContainer.java   
@Override
public void dragStarted(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1 && e.getSource() instanceof JLayeredPane) {
        selectionContainer = new JNodeContainerSelection(e.getPoint());
        add(selectionContainer, JLayeredPane.POPUP_LAYER);
    }
}
项目:incubator-netbeans    文件:AnnotationHolder.java   
private void addViewportListener(JEditorPane pane) {
    Container parent = pane.getParent();

    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }

    if (parent instanceof JViewport) {
        JViewport viewport = (JViewport) parent;

        viewport.addChangeListener(WeakListeners.change(AnnotationHolder.this, viewport));
    }
}
项目:incubator-netbeans    文件:HintsUI.java   
private int getUsableWidth(JTextComponent component) {
    Container parent = component.getParent();
    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }
    return (parent instanceof JViewport)
        ? ((JViewport)parent).getExtentSize().width
        : component.getSize().width;
}
项目:incubator-netbeans    文件:DragOperation.java   
void start(JMenuItem item, Point pt) {
    op = Op.INTER_MENU_DRAG;
    started = true;


    //josh: intial support for dragging multiple items
    //in the future we should use the payloadComponents variable
    //for dragging components instead of the payloadComponent variable.
    List<RADComponent> rads = menuEditLayer.getSelectedRADComponents();

    payloadComponents = new ArrayList<JMenuItem>();
    if(rads.size() > 1) {
        for(RADComponent rad : rads) {
            Object comp = menuEditLayer.formDesigner.getComponent(rad);
            if(comp instanceof JMenuItem) {
                payloadComponents.add((JMenuItem)comp);
            } else {
                fastEnd();
                return;
            }
        }
    } else {
        payloadComponents.add(item);
    }

    dragComponent = (JMenuItem) createDragFeedbackComponent(item, null);
    dragComponent.setSize(dragComponent.getPreferredSize());
    dragComponent.setLocation(pt);
    menuEditLayer.layers.add(dragComponent, JLayeredPane.DRAG_LAYER);
    menuEditLayer.repaint();
    payloadComponent = item;
}
项目:incubator-netbeans    文件:DragOperation.java   
void setTargetVisible(boolean vis) {
    if(!vis) {
        menuEditLayer.layers.remove(dragComponent);
    } else {
        menuEditLayer.layers.add(dragComponent, JLayeredPane.DRAG_LAYER);
    }
    menuEditLayer.repaint();
}
项目:incubator-netbeans    文件:DragOperation.java   
public JComponent getDeepestComponentInPopups(Point pt) {
    Component[] popups = menuEditLayer.layers.getComponentsInLayer(JLayeredPane.DEFAULT_LAYER);
    for(Component popup : popups) {
        if(popup.isVisible()) {
            Point pt2 = SwingUtilities.convertPoint(menuEditLayer, pt, popup);
            JComponent child = (JComponent) javax.swing.SwingUtilities.getDeepestComponentAt(popup, pt2.x, pt2.y);
            if(child != null) return child;
        }
    }
    return null;
}
项目:FreeCol    文件:Canvas.java   
/**
 * Adds a component to this Canvas.
 *
 * Make sure the status panel is not present unless the component
 * *is* the status panel.
 *
 * @param comp The {@code Component} to add to this canvas.
 * @param i The layer to add the component to (see JLayeredPane).
 */
private void addToCanvas(Component comp, Integer i) {
    if (statusPanel.isVisible()) {
        if (comp == statusPanel) return;
        if (!(comp instanceof JMenuItem)) removeFromCanvas(statusPanel);
    }

    if (i == null) i = JLayeredPane.DEFAULT_LAYER;
    try {
        super.add(comp, i);
    } catch (Exception e) {
        logger.log(Level.WARNING, "addToCanvas(" + comp + ", " + i
            + ") failed.", e);
    }
}
项目:incubator-netbeans    文件:EditorUI.java   
/** Is the parent of some editor component a viewport */
private JViewport getParentViewport() {
    Component pc = component.getParent();
    if (pc instanceof JLayeredPane) {
        pc = pc.getParent();
    }
    return (pc instanceof JViewport) ? (JViewport)pc : null;
}
项目:incubator-netbeans    文件:PopupManager.java   
/** Install popup panel to current textComponent root pane */
private void installToRootPane(JComponent c) {
    JRootPane rp = textComponent.getRootPane();
    if (rp != null) {
        rp.getLayeredPane().add(c, JLayeredPane.POPUP_LAYER, 0);
    }
}
项目:incubator-netbeans    文件:PopupManager.java   
/** Variation of the method for computing the bounds
 * for the concrete view component. As the component can possibly
 * be placed in a scroll pane it's first necessary
 * to translate the cursor bounds and also translate
 * back the resulting popup bounds.
 * @param popup  popup panel to be displayed
 * @param view component over which the popup is displayed.
 * @param cursorBounds the bounds of the caret or mouse cursor
 *    relative to the upper-left corner of the visible view.
 * @param placement where to place the popup panel according to
 *    the cursor position.
 * @return bounds of popup panel relative to the upper-left corner
 *    of the underlying view component.
 *    <CODE>null</CODE> if there is no place to display popup.
 */
protected static Rectangle computeBounds(JComponent popup,
JComponent view, Rectangle cursorBounds, Placement placement, HorizontalBounds horizontalBounds) {

    if (horizontalBounds == null) horizontalBounds = ViewPortBounds;

    Rectangle ret;
    Component viewParent = view.getParent();

    if (viewParent instanceof JLayeredPane) {
        viewParent = viewParent.getParent();
    }

    if (viewParent instanceof JViewport) {
        Rectangle viewBounds = ((JViewport)viewParent).getViewRect();

        Rectangle translatedCursorBounds = (Rectangle)cursorBounds.clone();
        if (placement != FixedPoint) {
            translatedCursorBounds.translate(-viewBounds.x, -viewBounds.y);
        }

        ret = computeBounds(popup, viewBounds.width, viewBounds.height,
            translatedCursorBounds, placement, horizontalBounds);

        if (ret != null) { // valid bounds
            ret.translate(viewBounds.x, viewBounds.y);
        }

    } else { // not in scroll pane
        ret = computeBounds(popup, view.getWidth(), view.getHeight(),
            cursorBounds, placement);
    }

    return ret;
}
项目:incubator-netbeans    文件:StickyWindowSupport.java   
StickyWindowSupport(final JTextComponent jtc) {
    this.jtc = jtc;
    ViewHierarchy.get(jtc).addViewHierarchyListener(new ViewHierarchyListener() {
        @Override
        public void viewHierarchyChanged(ViewHierarchyEvent evt) {
            JTextComponent editor = jtc;
            Container container = editor.getParent();
            if(container instanceof JLayeredPane && evt.isChangeY()) {
                JLayeredPane pane = (JLayeredPane) container;
                double deltaY = evt.deltaY();
                Component[] components = pane.getComponentsInLayer(JLayeredPane.PALETTE_LAYER);
                Rectangle rv = null;
                for (final Component component : components) {
                    rv = component.getBounds(rv);
                    if(rv.getY() > evt.startY() ||
                            rv.contains(new Point(rv.x, (int) evt.startY())) ||
                            rv.contains(new Point(rv.x, (int) evt.endY()))) {
                        final Point p = rv.getLocation();
                        p.translate(0, (int) deltaY);
                        EventQueue.invokeLater(new Runnable() {

                            @Override
                            public void run() {      
                              component.setLocation(p);
                            }
                        });

                    }
                }
            }
        }
    });
}
项目:incubator-netbeans    文件:StickyWindowSupport.java   
/**
 * Add a sticky window to the editor.
 * @param window the JComponent to add to the editor
 */
public void addWindow(JComponent window) {
    Container container = jtc.getParent();
    if(container instanceof JLayeredPane) {
        JLayeredPane pane = (JLayeredPane) container;
        pane.add(window, JLayeredPane.PALETTE_LAYER);
        window.setVisible(true);
    }
}
项目:incubator-netbeans    文件:StickyWindowSupport.java   
/**
 * Convert a <code>aPoint</code> in root component coordinate system to the
 * editor coordinate system. <code>aPoint</code> is assumed to be in the
 * root component coordinate system of the editor. If conversion is not
 * possible, return <code>aPoint</code> without any conversion.
 *
 * @param aPoint the Point to convert
 * @return aPoint converted to editor coordinate system
 */
public @NonNull Point convertPoint(Point aPoint) {
    Point value = aPoint;
    Container container = jtc.getParent();
    if(container instanceof JLayeredPane) {
        JLayeredPane pane = (JLayeredPane) container;
        value = SwingUtilities.convertPoint(pane.getRootPane(), value, pane);
    }
    return value;
}
项目:incubator-netbeans    文件:StickyWindowSupport.java   
/**
 * Remove a sticky window from the editor.
 * @param window the JComponent to remove
 */
public void removeWindow(JComponent window) {
    Container container = jtc.getParent();
    if(container instanceof JLayeredPane) {
        JLayeredPane pane = (JLayeredPane) container;
        pane.remove(window);
        pane.repaint(window.getBounds());
    }
}
项目:incubator-netbeans    文件:BraceMatchingSidebarComponent.java   
@SuppressWarnings("LeakingThisInConstructor")
public BraceMatchingSidebarComponent(JTextComponent editor) {
    this.editor = editor;
    this.mimeType = DocumentUtilities.getMimeType(editor);
    this.prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);

    final Lookup.Result r = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(editor)).lookupResult(
            FontColorSettings.class);
    prefListenerGC = new PrefListener();
    this.colorResult = r;
    r.addLookupListener(WeakListeners.create(LookupListener.class, this , r));
    prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefListenerGC, prefs));
    loadPreferences();

    editorPane = findEditorPane(editor);
    Component parent = editor.getParent();
    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }
    if (parent instanceof JViewport) {
        this.viewport = (JViewport)parent;
        // see #219015; need to listen on viewport change to show/hide the tooltip
        viewport.addChangeListener(WeakListeners.change(this, viewport));
    }
    TextUI ui = editor.getUI();
    if (ui instanceof BaseTextUI) {
        baseUI = (BaseTextUI)ui;
        MasterMatcher.get(editor).addMatchListener(this);
    } else {
        baseUI = null;
    }
    setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    updatePreferredSize();
}
项目:incubator-netbeans    文件:DesktopImpl.java   
/** Creates a new instance of DesktopImpl */
public DesktopImpl () {
    // layered pane with absolute positioning, to enable overlapping
    layeredPane = new JLayeredPane();
    layeredPane.setLayout(new LayeredLayout());
    // desktop represents regular layer of layeredPane
    desktop = new JPanel() {
        @Override
        public boolean isOpaque() {
            if( UIManager.getBoolean( "NbMainWindow.showCustomBackground" ) ) //NOI18N
                return false;
            return super.isOpaque();
        }

        @Override
        public void updateUI() {
            Mutex.EVENT.readAccess( new Runnable() {
                @Override
                public void run() {
                    superUpdateUI();
                }
            });
        }

        private void superUpdateUI() {
            super.updateUI();
        }
    };
    desktop.setLayout(new GridBagLayout());
    Color bkColor = UIManager.getColor("NbSplitPane.background"); //NOI18N
    if( null != bkColor ) {
        desktop.setBackground(bkColor);
        desktop.setOpaque(true);
    }
    layeredPane.add(desktop);
}
项目:incubator-netbeans    文件:DefaultSlidingFx.java   
public void showEffect(JLayeredPane pane, Integer layer, SlideOperation operation) {
//        Component comp = operation.getComponent();
//        Graphics2D gr2d = (Graphics2D)pane.getGraphics();
//        Color original = gr2d.getColor();
//        gr2d.setColor(Color.BLUE.darker().darker());
//        Rectangle start = operation.getStartBounds();
//        Rectangle finish = operation.getFinishBounds();
//        Rectangle current = start;
//        for (int i = 0; i < 6 /** magic constant **/; i++) {
//            Rectangle newRect;
//            if (i > 0) {
//                // wipe out old
//            } 
//            newRect = new Rectangle();
//            newRect.x = Math.abs((current.x + finish.x) / 2);
//            newRect.y = Math.abs((current.y + finish.y) / 2);
//            newRect.height = Math.abs((current.height + finish.height) / 2);
//            newRect.width = Math.abs((current.width + finish.width) / 2);
//            gr2d.drawRect(newRect.x, newRect.y, newRect.width, newRect.height);
//            gr2d.setColor(gr2d.getColor().brighter());
//            current = newRect;
//        }
//        gr2d.setColor(original);
////        try {
////            Thread.sleep(5000);
////        } catch (Throwable th) {
////            
////        }

    }
项目:incubator-netbeans    文件:ScaleFx.java   
public void showEffect(JLayeredPane pane, Integer layer, SlideOperation operation) {
    this.pane = pane;
    this.operation = operation;
    Component comp = operation.getComponent();
    Graphics2D gr2d = (Graphics2D)pane.getGraphics();
    Rectangle start = operation.getStartBounds();
    Rectangle finish = operation.getFinishBounds();
    Dimension finishSize = finish.getSize();
    Dimension startSize = start.getSize();
    Rectangle current = start;
    Image compImage = preparedImage;

   /* if (compImage == null) {
        if (finishSize.width * finishSize.height > startSize.width * startSize.height) {
            compImage = renderCompIntoImage(comp, finishSize, pane);
        } else {
            compImage = renderCompIntoImage(comp, startSize, pane);
        }
    }*/
    pane.add(stretchedImage, layer);

    path = computePath(start, finish);

    curIter = 1;
    if (compImage != null) {
        stretchedImage.setOrigImage(compImage);
    } else {
        if (finishSize.width * finishSize.height > startSize.width * startSize.height) {
            stretchedImage.setComp(comp, finishSize);
        } else {
            stretchedImage.setComp(comp, startSize);
        }
    }
    stretchedImage.setBoundsAndAlpha(start, initialAlpha);

    getTimer().start();
}
项目:incubator-netbeans    文件:SlideOperationImpl.java   
public void run(JLayeredPane pane, Integer layer) {
    if (effect != null && effect.shouldOperationWait()) {
        // OK, effect is asynchronous and we should wait for effect finish,
        // so register and wait for stateChanged notification
        this.pane = pane;
        this.layer = layer;
        effect.setFinishListener(this);
        effect.showEffect(pane, layer, this);
    } else {
        if (effect != null) {
            effect.showEffect(pane, layer, this);
        }
        performOperation(pane, layer);
    }
}
项目:incubator-netbeans    文件:SlideOperationImpl.java   
private void repaintLayeredPane() {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            Frame f = WindowManagerImpl.getInstance().getMainWindow();
            if( f instanceof JFrame ) {
                JLayeredPane lp = ((JFrame)f).getLayeredPane();
                if( null != lp ) {
                    lp.invalidate();
                    lp.revalidate();
                    lp.repaint();
                }
            }
        }
    });
}
项目:incubator-netbeans    文件:ConsoleEditor.java   
private void removeProgressIndicator() {
    if (lastLayeredPane == null || progressIndicator == null) {
        return;
    }
    progressIndicator.setVisible(false);
    JLayeredPane lp = lastLayeredPane;
    lp.remove(progressIndicator);
    lp.repaint();
    progressIndicator = null;

}
项目:incubator-netbeans    文件:QuickSearchPopup.java   
/**
 * Updates size and visibility of this panel according to model content
 */
public void updatePopup () {
    int modelSize = rModel.getSize();

    // plug this popup into layered pane if needed
    JLayeredPane lPane = JLayeredPane.getLayeredPaneAbove(comboBar);
    // lPane can be null when the corresponding dialog is closed already
    // for example, when the user didn't want to wait until the search finishes
    if (!isDisplayable() && (lPane != null)) {
        lPane.add(this, new Integer(JLayeredPane.POPUP_LAYER + 1) );
    }

    boolean statusVisible = updateStatusPanel();

    if(lPane != null) {
        computePopupBounds(popupBounds, lPane, modelSize);
        setBounds(popupBounds);
    }

    // popup visibility constraints
    if ((modelSize > 0 || statusVisible) && comboBar.isTextFieldFocusOwner()) {
        if (jList1.getSelectedIndex() >= modelSize) {
            jList1.setSelectedIndex(modelSize - 1);
        }
        setVisible(true);
    } else {
        setVisible(false);
    }

    // needed on JDK 1.5.x to repaint correctly
    revalidate();
}
项目:AgentWorkbench    文件:GraphEnvironmentControllerGUI.java   
/**
  * Returns the BasicGraphGuiJDesktopPane
  * @return the BasicGraphGuiJDesktopPane
  */
 public BasicGraphGuiJDesktopPane getBasicGraphGuiJDesktopPane() {
    if (basicGraphGuiJDesktopPane==null) {
        basicGraphGuiJDesktopPane = new BasicGraphGuiJDesktopPane((GraphEnvironmentController) this.environmentController);
        basicGraphGuiJDesktopPane.add(this.getBasicGraphGuiRootJSplitPane(), JLayeredPane.DEFAULT_LAYER);
        try {
    this.getBasicGraphGuiRootJSplitPane().setMaximum(true);
} catch (PropertyVetoException pvex) {
    pvex.printStackTrace();
}
    }
    return basicGraphGuiJDesktopPane;
 }
项目:rapidminer    文件:CSVFormatSpecificationPanel.java   
/**
 * Fills the tablePane with content.
 */
private JComponent makePreviewTable() {
    previewTable = new ExtendedJTable(false, false, false);
    // ensure same background as JPanels in case of only few rows
    previewTable.setBackground(Colors.PANEL_BACKGROUND);
    previewTable.setColoredTableCellRenderer(new ColoredTableCellRenderer() {

        private final Font boldFont = getFont().deriveFont(Font.BOLD);

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
                int row, int column) {
            JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            adjustCell(row, label, boldFont);
            return label;
        }

    });

    loadingContentPane = new LoadingContentPane("loading_data", previewTable);

    tablePane = new JScrollPane(loadingContentPane);
    tablePane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    tablePane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tablePane.setBorder(null);

    // add PREVIEW label in front of scrollpane
    JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.setLayout(new OverlayLayout(layeredPane));
    layeredPane.add(tablePane, JLayeredPane.DEFAULT_LAYER);

    JPanel overlayPanel = new JPanel(new BorderLayout());
    overlayPanel.setOpaque(false);
    overlayLabel = new JLabel("", SwingConstants.CENTER);
    showPreviewLettering();
    overlayPanel.add(overlayLabel, BorderLayout.CENTER);

    layeredPane.add(overlayPanel, JLayeredPane.PALETTE_LAYER);
    return layeredPane;
}
项目:VASSAL-src    文件:RegionGrid.java   
protected void setDragCursor() {
  final JRootPane rootWin = SwingUtilities.getRootPane(this);
  if (rootWin != null) {
    // remove cursor from old window
    if (dragCursor.getParent() != null) {
      dragCursor.getParent().remove(dragCursor);
    }
    drawWin = rootWin.getLayeredPane();

    dragCursor.setVisible(true);
    drawWin.add(dragCursor, JLayeredPane.DRAG_LAYER);
  }
}
项目:Progetto-B    文件:CardPanel.java   
/**
 * 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.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    cardsPane = new javax.swing.JLayeredPane();

    cardsPane.setMaximumSize(new java.awt.Dimension(1000, 300));
    cardsPane.setMinimumSize(new java.awt.Dimension(1000, 300));

    javax.swing.GroupLayout cardsPaneLayout = new javax.swing.GroupLayout(cardsPane);
    cardsPane.setLayout(cardsPaneLayout);
    cardsPaneLayout.setHorizontalGroup(
        cardsPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 1000, Short.MAX_VALUE)
    );
    cardsPaneLayout.setVerticalGroup(
        cardsPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 300, Short.MAX_VALUE)
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addComponent(cardsPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(0, 312, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(cardsPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
}