private void cascata(JInternalFrame jIFrame, JInternalFrame jIFrameAnt) { if (dPane.getAllFrames().length > 0) { if (autoManager) { maxX = dPane.getWidth() - jIFrame.getWidth(); maxY = dPane.getHeight() - jIFrame.getHeight(); minX = 0; minY = 0; } if (jIFrameAnt.getY() < maxY) { y = jIFrameAnt.getY() + distanceXY; } else { y = minY; } if (jIFrameAnt.getX() < maxX) { x = jIFrameAnt.getX() + distanceXY; } else { x = minX; y = minY; } } else { x = minX; y = minY; } }
/** * Ajusta el tamaño de la ventana al envelope pasado como parámetro * * @param ctx * @param newWrapperEnvelope * @param viewport */ public static void resizeViewToEnvelope( PlugInContext ctx, Envelope newWrapperEnvelope, IViewport viewport) { // ajustamos las proporciones de la ventana a las de la feature JInternalFrame activeInternalFrame = ctx.getActiveInternalFrame(); Dimension dimView = ((Dimension) ctx.getLayerViewPanel()).getSize(); Double widthView = dimView.getWidth(); Double heightView = dimView.getHeight(); int widthDiff = (int) (activeInternalFrame.getWidth() - widthView); int heightDiff = (int) (activeInternalFrame.getHeight() - heightView); Integer newWidth = (int) ((newWrapperEnvelope.getWidth() / viewport.getEnvelopeInModelCoordinates().getWidth()) * widthView); Integer newHeight = (int) ((newWrapperEnvelope.getHeight() / viewport.getEnvelopeInModelCoordinates().getHeight()) * heightView); Dimension newDimensionView = new Dimension(newWidth + widthDiff, newHeight + heightDiff); activeInternalFrame.setSize(newDimensionView); // zoom al envelope actual try { viewport.zoom(newWrapperEnvelope); } catch (NoninvertibleTransformException e) { log.warn("No se ha podido alcanzar el zoom " + newWrapperEnvelope); } }
public void centrarFrm(JInternalFrame hijo, VistaMDI padre) { hijo.setLocation( padre.getWidth() / 2 - hijo.getWidth() / 2, padre.getHeight() / 2 - hijo.getHeight() / 2 - 20); // CENTRA EL FORMULARIO }
public Object showWindow(final MkWindow macWindow, String title, boolean isModal) { listMkWindow.add(macWindow); if (isModal) { JDialog modalFrame = new JDialog(this, title, true); // macWindow.setJanela(modalFrame); final MkRun onCloseWindow = macWindow.onCloseWindow; modalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); modalFrame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { if (onCloseWindow != null) { onCloseWindow.execute(); } disposeWindow(macWindow); } }); modalFrame.setLayout(new BorderLayout()); modalFrame.add(macWindow, BorderLayout.CENTER); modalFrame.pack(); Dimension desktopSize = desktopPane.getSize(); int x = (desktopSize.width - modalFrame.getWidth()) / 2; int y = (desktopSize.height - modalFrame.getHeight()) / 2; modalFrame.setLocation((x < 0 ? 0 : x), (y < 0 ? 0 : y)); if (macWindow.panelButton != null) { modalFrame.getRootPane().setDefaultButton((JButton) macWindow.panelButton.getComponent(0)); } modalFrame.setVisible(true); return modalFrame; } else { JInternalFrame internalFrame = new JInternalFrame(title, true, true, true, true); internalFrame.setContentPane(macWindow); internalFrame.pack(); // internalFrame.setBounds(internalFrame.getBounds()); //pq? desktopPane.add(internalFrame); internalFrame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); final MkRun onCloseWindow = macWindow.onCloseWindow; if (onCloseWindow != null) { internalFrame.setDefaultCloseOperation(JInternalFrame.DO_NOTHING_ON_CLOSE); internalFrame.addInternalFrameListener( new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { onCloseWindow.execute(); } }); } Dimension desktopSize = desktopPane.getSize(); int x = (desktopSize.width - internalFrame.getWidth()) / 2; int y = (desktopSize.height - internalFrame.getHeight()) / 2; internalFrame.setLocation((x < 0 ? 0 : x), (y < 0 ? 0 : y)); internalFrame.setVisible(true); return internalFrame; } }
// aqui se añade los internalframe al destop pane private void agregarMarcoInterno(JInternalFrame marco) { marco.setLocation(xSigMarco, ySigMarco); marco.setVisible(true); jDesktopPane.add(marco); try { marco.setSelected(true); } catch (PropertyVetoException ex) { } if (distanciaEntreMarcos == 0) distanciaEntreMarcos = marco.getHeight() - marco.getContentPane().getHeight(); xSigMarco += distanciaEntreMarcos; ySigMarco += distanciaEntreMarcos; if (xSigMarco + marco.getWidth() > jDesktopPane.getWidth()) xSigMarco = 0; if (ySigMarco + marco.getHeight() > jDesktopPane.getHeight()) ySigMarco = 0; }
public void loadFrameConfiguration() { jif.setBounds( pref.getInt(jif.getTitle() + posXPreferenceKey, jif.getX()), pref.getInt(jif.getTitle() + posYPreferenceKey, jif.getY()), pref.getInt(jif.getTitle() + sizeXPreferenceKey, jif.getWidth()), pref.getInt(jif.getTitle() + sizeYPreferenceKey, jif.getHeight())); try { jif.setVisible(pref.getBoolean(jif.getTitle() + isVisiblePreferenceKey, true)); } catch (Exception e) { System.err.println("failed setting JInternalFrame to visible/invisible"); e.printStackTrace(); } }
private void saveSettings() { if (localSettings != null) { localSettings.objectDirectory = levelHolder.getPalette().getDirectoryPath(); localSettings.mainWidth = this.getWidth(); localSettings.mainHeight = this.getHeight(); localSettings.paletteX = palette.getX(); localSettings.paletteY = palette.getY(); localSettings.paletteWidth = palette.getWidth(); localSettings.paletteHeight = palette.getHeight(); localSettings.levelHolderX = levelHolderFrame.getX(); localSettings.levelHolderY = levelHolderFrame.getY(); localSettings.levelHolderWidth = levelHolderFrame.getWidth(); localSettings.levelHolderHeight = levelHolderFrame.getHeight(); localSettings.store(); } else { localSettings = new LocalSettings(); } }
/** * Sets the location for the 3 internal frames * * @author susiefu * @param direction * @param tilt * @param x * @param y */ protected void setFrameGeometry(String direction, int tilt, int x, int y) { Dimension editwindowsize = editFrame.getSize(); Dimension trisize = triangleFrame.getSize(); int tribase = (Math.round((Math.min(editwindowsize.width, editwindowsize.height))) / 10 > 15) ? Math.round((Math.min(editwindowsize.width, editwindowsize.height))) / 10 : 15; // How // wide // the // base // of // the // triangle // is int fudge = 1; // For the different directions if (direction == "SE") { // Default location if (tilt == 0) { triangleFrame.setLocation(x + tribase - trisize.width, y + 24 - trisize.height + fudge); } else { triangleFrame.setLocation(x, y + 24 - trisize.height + fudge); } } else if (direction == "S") { // SAME AS "SE" DIRECTION if (tilt == 0) { triangleFrame.setLocation(x + tribase - trisize.width, y + 24 - trisize.height + fudge); } else { triangleFrame.setLocation(x, y + 24 - trisize.height + fudge); } } else if (direction == "W") { if (tilt == 0) { triangleFrame.setLocation( x + editwindowsize.width - fudge, y + 24 - trisize.height + tribase); } else { triangleFrame.setLocation(x + editwindowsize.width - fudge, y + 24); } } else if (direction == "NW") { if (tilt == 0) { triangleFrame.setLocation( x + editwindowsize.width - trisize.width, y + 24 + editwindowsize.height - 2 * fudge); } else { triangleFrame.setLocation( x + editwindowsize.width - tribase, y + 25 + editwindowsize.height - 2 * fudge); } } else if (direction == "N") { if (tilt == 0) { triangleFrame.setLocation( x - trisize.width + tribase, y + 24 + editwindowsize.height - 2 * fudge); } else { triangleFrame.setLocation(x, y + 24 + editwindowsize.height - 2 * fudge); } } else if (direction == "E") { if (tilt == 0) { // Pointing up triangleFrame.setLocation(x - trisize.width + fudge, y + 24 - trisize.height + tribase); } else { triangleFrame.setLocation(x - trisize.width + fudge, y + 24); } } else if (direction == "NONE") { if (tilt == 0) { triangleFrame.setLocation(x + tribase - trisize.width, y + 24 - trisize.height + fudge); } else { triangleFrame.setLocation(x, y + 24 - trisize.height + fudge); } } editFrame.setLocation(x, y + 24); buttonFrame.setLocation( x + editwindowsize.width - buttonFrame.getWidth() + fudge, y + buttonFrame.getHeight() / 2 + fudge * 2); }
/** * Will update the triangle assuming that the cell center has moved but that the edit window and * button panel has not. * * @author achang */ public void updateTriangle() { Point buttonLocation = buttonFrame.getLocation(); updateTriangle( buttonFrame.getWidth() / 4 + buttonLocation.x, buttonFrame.getHeight() / 2 + buttonLocation.y); }