@Override public void deiconifyFrame(JInternalFrame f) { super.deiconifyFrame(f); if (f instanceof CardInfoWindowDialog) { JInternalFrame.JDesktopIcon icon = f.getDesktopIcon(); f.setBounds(icon.getX() + (DESKTOP_ICON_WIDTH - f.getWidth()), icon.getY(), f.getWidth(), f.getHeight()); } }
protected void sortFramesByHeight(JInternalFrame[] _frames) { sortFramesByTitle(_frames); JInternalFrame tmp; int i, l; l = _frames.length; for (i = 0; i + 1 < l; i++) if (_frames[i].getHeight() > _frames[i + 1].getHeight()) { tmp = _frames[i]; _frames[i] = _frames[i + 1]; _frames[i + 1] = tmp; i--; if (i >= 0) i--; } }
public static Point getPointForCentering(JInternalFrame window) { try { //assert window != null; Point mousePoint = MouseInfo.getPointerInfo().getLocation(); GraphicsDevice[] devices = GraphicsEnvironment .getLocalGraphicsEnvironment().getScreenDevices(); for (GraphicsDevice device : devices) { Rectangle bounds = device.getDefaultConfiguration(). getBounds(); //check to see if the mouse cursor is within these bounds if (mousePoint.x >= bounds.x && mousePoint.y >= bounds.y && mousePoint.x <= (bounds.x + bounds.width) && mousePoint.y <= (bounds.y + bounds.height)) { int screenWidth = bounds.width;//this is it int screenHeight = bounds.height; int width = window.getWidth(); int height = window.getHeight(); return new Point(((screenWidth - width) / 2) + bounds.x, ((screenHeight - height) / 2) + bounds.y); } } } catch (Exception e) { LOG.log(Level.FINE, e.getLocalizedMessage() + " - this can occur do to a Security exception in sandboxed apps"); } return new Point(0, 0); }
/** * Center the specified internal frame on it's container (don't modify * size). * * @param window Target window. */ public static void center( @NotNull final JInternalFrame window ) { final Container parent = window.getParent(); if ( parent != null ) { final Insets parentInsets = parent.getInsets(); final int x = parentInsets.left + ( parent.getWidth() - parentInsets.left - parentInsets.right - window.getWidth() ) / 2; final int y = parentInsets.top + ( parent.getHeight() - parentInsets.top - parentInsets.bottom - window.getHeight() ) / 2; window.setLocation( x, y ); } }
int screenHeight = usableBounds.height; int width = window.getWidth(); int height = window.getHeight();
int screenHeight = usableBounds.height; int width = window.getWidth(); int height = window.getHeight();
public void mouseDragged(MouseEvent _evt) { if(frame_!=null) getManager(frame_).resizeFrame (frame_,frame_.getX(),frame_.getY(), frame_.getWidth ()+_evt.getX()-resizeCorner_.getWidth(), frame_.getHeight()+_evt.getY()-resizeCorner_.getHeight()); } }
void dodo( MouseEvent ev) { if ( ev.getComponent() instanceof NimRODInternalFrameTitlePane ) { if ( frame.getDesktopPane() != null ) { frame.getDesktopPane().updateUI(); } } else { int x = ev.getX(); int w = frame.getWidth(); int y = ev.getY(); int h = frame.getHeight(); if ( ( x <= 5 ) || ( x >= w - ins.right) || ( y >= h - ins.bottom ) ) { if ( frame.getDesktopPane() != null ) { frame.getDesktopPane().updateUI(); } } } } }
/** * Calculate the required size of this desktop pane so that * all visible intenal frames will be fully shown. * * @return <TT>Dimension</TT> required size. */ public Dimension getRequiredSize() { JInternalFrame[] frames = getAllFrames(); int maxX = 0; int maxY = 0; for (int i = 0; i < frames.length; ++i) { if (frames[i].isVisible()) { JInternalFrame frame = frames[i]; int x = frame.getX() + frame.getWidth(); if (x > maxX) { maxX = x; } int y = frame.getY() + frame.getHeight(); if (y > maxY) { maxY = y; } } } return new Dimension(maxX, maxY); }
public void deiconifyFrame(JInternalFrame f) { JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon(); Container c = desktopIcon.getParent(); if (c != null) { c = c.getParent(); if (c != null) { c.add(f); if (f.isMaximum()) { int w = c.getWidth(); int h = c.getHeight() - taskBar.getHeight(); if (f.getWidth() != w || f.getHeight() != h) { setBoundsForFrame(f, 0, 0, w, h); } } if (f.isSelected()) { f.moveToFront(); } else { try { f.setSelected(true); } catch (PropertyVetoException e2) { } } } } }
/** * Organizes the icons nicely in the visible screen space. */ public void refresh() { // Resize so that our width is that of the viewport in the scrollpane. // Remember there's spacing at the front too. Dimension size = getVisibleRect().getSize(); int defaultWidth = (SPACING+DEFAULT_ICON_WIDTH)*DEFAULT_ROW_SIZE; int width = size.width<defaultWidth ? defaultWidth : size.width; int x = SPACING; int y = SPACING; JInternalFrame[] frames = getAllFrames(); int num = frames==null ? 0 : frames.length; for (int i=0; i<num; i++) { frames[i].setLocation(x,y); x += DEFAULT_ICON_WIDTH + SPACING; if (x+DEFAULT_ICON_WIDTH>width) { x = SPACING; y += frames[i].getHeight() + SPACING; } } size.height = y+DEFAULT_ICON_WIDTH; setPreferredSize(size); setSize(size); // Causes the scroll pane to revalidate. }
public/* synchronized */void tile() { if (isTabbed()) return; JInternalFrame[] frames = getNormalFrames(); int i, l, x, y, h, wd/* ,hd */; l = frames.length; if (l > 0) { sortFramesByHeight(frames); wd = getWidth(); // getSize().width; // hd=getHeight(); // getSize().height; wd = (wd < 200 ? 200 : wd); // hd=(hd<200 ? 200 : hd-60); x = 0; y = 0; h = 0; for (i = 0; i < l; i++) { int wf = frames[i].getWidth(); // Size().width; int hf = frames[i].getHeight(); // Size().height; if (x + wf > wd) { x = 0; y += h; h = 0; } frames[i].setLocation(x, y); x += wf; h = Math.max(h, hf); moveToFront(frames[i]); checkInternalFrame(frames[i]); } } }
private void setDesktopStates() throws JAXBException { DesktopSize dSize = factory.createDesktopSize(); NetworkFrames frames = factory.createNetworkFrames(); Component[] networkFrames = Cytoscape.getDesktop().getNetworkViewManager().getDesktopPane() .getComponents(); for (int i = 0; i < networkFrames.length; i++) { if(networkFrames[i] instanceof JInternalFrame) { JInternalFrame networkFrame = (JInternalFrame) networkFrames[i]; NetworkFrame frame = factory.createNetworkFrame(); frame.setFrameID(networkFrame.getTitle()); frame.setWidth(BigInteger.valueOf(networkFrame.getWidth())); frame.setHeight(BigInteger.valueOf(networkFrame.getHeight())); frame.setX(BigInteger.valueOf(networkFrame.getX())); frame.setY(BigInteger.valueOf(networkFrame.getY())); frames.getNetworkFrame().add(frame); } } dSize.setHeight(BigInteger.valueOf(Cytoscape.getDesktop().getSize().height)); dSize.setWidth(BigInteger.valueOf(Cytoscape.getDesktop().getSize().width)); Desktop desktop = factory.createDesktop(); desktop.setDesktopSize(dSize); desktop.setNetworkFrames(frames); sState.setDesktop(desktop); }
public void deiconifyFrame(JInternalFrame f) { JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon(); Container c = desktopIcon.getParent(); if (c != null) { c.add(f); // If the frame is to be restored to a maximized state make // sure it still fills the whole desktop. if (f.isMaximum()) { Rectangle desktopBounds = c.getBounds(); if (f.getWidth() != desktopBounds.width || f.getHeight() != desktopBounds.height) { setBoundsForFrame(f, 0, 0, desktopBounds.width, desktopBounds.height); } } removeIconFor(f); if (f.isSelected()) { f.moveToFront(); } else { try { f.setSelected(true); } catch (PropertyVetoException e2) { } } } }
public void closeFrame(JInternalFrame f) { boolean findNext = f.isSelected(); Container c = f.getParent(); if (findNext) try { f.setSelected(false); } catch (PropertyVetoException e2) { } if (c != null) { c.remove(f); c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight()); } removeIconFor(f); if (f.getNormalBounds() != null) f.setNormalBounds(null); if (wasIcon(f)) setWasIcon(f, null); if (findNext) activateNextFrame(c); }
/** * Removes the frame, and, if necessary, the * <code>desktopIcon</code>, from its parent. This method is overridden so * that the "next internal frame" isn't selected after this one is closed. * @param f the <code>JInternalFrame</code> to be removed */ @Override public void closeFrame(JInternalFrame f) { Container c = f.getParent(); if (f.isSelected()) { try { f.setSelected(false); } catch (PropertyVetoException e2) { // Do nothing } } if(c != null) { c.remove(f); c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight()); } removeIconFor(f); if(f.getNormalBounds() != null) f.setNormalBounds(null); if(wasIcon(f)) setWasIcon(f, null); }
/** * Creates and shows a new internal frame for the given image. */ final void addImage(final RenderedImage image, final String title) { final JInternalFrame internal = new JInternalFrame(title, true, true); internal.add(new ImagePanel(image)); internal.pack(); internal.show(); desktop.add(internal); if (location > min(desktop.getWidth() - internal.getWidth(), desktop.getHeight() - internal.getHeight())) { location = 0; } internal.setLocation(location, location); location += 30; internal.toFront(); }
/** * Creates and shows a new internal frame for the given image. */ private void addImage(final RenderedImage image, final String title) { final JInternalFrame internal = new JInternalFrame(title, true, true); internal.add(new ImagePanel(image)); internal.pack(); internal.show(); desktop.add(internal); if (location > min(desktop.getWidth() - internal.getWidth(), desktop.getHeight() - internal.getHeight())) { location = 0; } internal.setLocation(location, location); location += 30; internal.toFront(); }