public void layoutContainer(Container target) { /* * Algorithm is as follows: - the "left-hand" components take 33% of * horizontal space - scrollPane takes the remaining space */ synchronized (target.getTreeLock()) { if (pane == null || spane == null) return; Dimension dim = target.getSize(); if (dim.height < 20) return; spane.setBounds(new Rectangle(0, 0, dim.width, dim.height)); // Dimension dim0 = new Dimension(dim.width-2, dim.height-2); // pane.setPreferredSize(dim0); // JViewport viewPort = spane.getViewport(); // viewPort.setViewSize(dim0); // paramsLayout.setReferenceSize(dim0.width, dim0.height); } }
public void layoutContainer(Container parent) { Dimension size = parent.getSize(); Dimension captionSize = caption.getPreferredSize(); caption.setBounds(PADDING, PADDING, captionSize.width, captionSize.height); // make all buttons the same size Dimension buttonSize = cancelButton.getPreferredSize(); buttonSize.width = Math.max(buttonSize.width, prevButton.getPreferredSize().width); buttonSize.width = Math.max(buttonSize.width, nextButton.getPreferredSize().width); // cancel button goes on far left cancelButton.setBounds( PADDING, size.height - buttonSize.height - PADDING, buttonSize.width, buttonSize.height); // prev and next buttons are on the right prevButton.setBounds( size.width - buttonSize.width * 2 - 6 - PADDING, size.height - buttonSize.height - PADDING, buttonSize.width, buttonSize.height); nextButton.setBounds( size.width - buttonSize.width - PADDING, size.height - buttonSize.height - PADDING, buttonSize.width, buttonSize.height); // calculate size for current page Rectangle currentPageBounds = new Rectangle(); currentPageBounds.x = PADDING; currentPageBounds.y = PADDING * 2 + captionSize.height; currentPageBounds.width = size.width - currentPageBounds.x - PADDING; currentPageBounds.height = size.height - buttonSize.height - currentPageBounds.y - PADDING * 2; for (int i = 0; i < pages.length; i++) { Component page = pages[i]; page.setBounds(currentPageBounds); page.setVisible(i == currentPage); } }
@Override public void layoutContainer(final Container parent) { assert parent.getComponentCount() == 2; // 1. info; 2. progress Component infoPanel = parent.getComponent(0); Component progressPanel = parent.getComponent(1); int progressPrefWidth = progressPanel.getPreferredSize().width; final Dimension size = parent.getSize(); int maxProgressWidth = (int) (size.width * 0.8); int minProgressWidth = (int) (size.width * 0.5); if (progressPrefWidth > myProgressWidth) { myProgressWidth = progressPrefWidth; } if (myProgressWidth > maxProgressWidth) { myProgressWidth = maxProgressWidth; } if (myProgressWidth < minProgressWidth) { myProgressWidth = minProgressWidth; } infoPanel.setBounds(0, 0, size.width - myProgressWidth, size.height); progressPanel.setBounds(size.width - myProgressWidth, 0, myProgressWidth, size.height); }
private void rotateLayout() { Dimension pSize = cont.getSize(); int x, x1; int y, y1; int n, k, i; int pw = pSize.width - 12; int ph = pSize.height - 12; float fw, fh; float rx, ry, rd; boolean multiZone = false; SmsSample obj; Vector<SmsSample> oList; GrkZone zone; fw = 0; fh = 0; if (zList.size() == 1) { zone = zList.elementAt(0); x = 0; y = 0; fh = zone.newWidth; fw = zone.newHeight; } else { multiZone = true; ph = ph - 12; for (n = 0; n < zList.size(); n++) { zone = zList.elementAt(n); rx = zone.orgx + zone.newWidth; if (rx > fh) fh = rx; rx = zone.orgy + zone.newHeight; if (rx > fw) fw = rx; } } rx = (float) pw / fw; ry = (float) ph / fh; scaleDir = 0; rd = 0; if (rx > ry) { rd = (rx - ry) / rx; rx = ry; scaleDir = 1; } else if (rx < ry) { rd = (ry - rx) / ry; scaleDir = 2; } if (rd < 0.1) scaleDir = 0; x1 = (int) (fw * rx); x1 = (pw - x1) / 2 + 6; y1 = (int) (fh * rx); y1 = (ph - y1) / 2; y1 = ph - y1 + 6; if (multiZone) y1 += 12; for (n = 0; n < zList.size(); n++) { zone = zList.elementAt(n); oList = zone.getSampleList(); if (multiZone) { x = x1 + (int) (zone.orgy * rx); y = y1 - (int) (zone.orgx * rx); } else { x = x1; y = y1; } zone.locX = x; zone.locX2 = x + (int) (zone.newHeight * rx); zone.locY = y - (int) (zone.newWidth * rx); zone.locY2 = y; i = (int) (zone.newDiam * rx); if (i < 4) i = 4; zone.minWidth = i; k = oList.size(); for (i = 0; i < k; i++) { obj = oList.elementAt(i); obj.locX = x + (int) (obj.orgy * rx); // obj.locY = y - (int) (obj.orgx * rx); obj.width = (int) (obj.newDiam * rx); obj.locY = y - (int) (obj.orgx * rx) - obj.width; } } }
public void layoutContainer(Container target) { synchronized (target.getTreeLock()) { cont = target; if (zList == null) return; if (zList.size() < 1) return; if (rotated) { rotateLayout(); return; } Dimension pSize = target.getSize(); int x, x1; int y, y1; int n, k, i; int ox, oy, ow; int pw = pSize.width - 12; int ph = pSize.height - 12; float fw, fh; float rx, ry, rd; boolean multiZone = false; boolean marvin = false; SmsSample obj; Vector<SmsSample> oList; GrkZone zone; fw = 0; fh = 0; zone = zList.elementAt(0); if (zone.trayType == GRK49 || zone.trayType == GRK97) marvin = true; if (zList.size() == 1) { // one zone only // zone = (GrkZone) zList.elementAt(0); x = 0; y = 0; fw = zone.newWidth; fh = zone.newHeight; if (marvin) { ph = ph - 34; pw = pw - 20; } } else { multiZone = true; ph = ph - 14; if (marvin) { ph = ph - 14; pw = pw - 14; } for (n = 0; n < zList.size(); n++) { zone = zList.elementAt(n); rx = zone.orgx + zone.newWidth; if (rx > fw) fw = rx; rx = zone.orgy + zone.newHeight; if (rx > fh) fh = rx; } } rx = (float) pw / fw; ry = (float) ph / fh; scaleDir = 0; rd = 0; if (rx > ry) { rd = (rx - ry) / rx; rx = ry; scaleDir = 1; } else if (rx < ry) { rd = (ry - rx) / ry; scaleDir = 2; } if (rd < 0.1) scaleDir = 0; x1 = (int) (fw * rx); x1 = (pw - x1) / 2 + 6; y1 = (int) (fh * rx); y1 = (ph - y1) / 2 + 6; if (multiZone || marvin) { y1 += 14; if (marvin) x1 += 14; } for (n = 0; n < zList.size(); n++) { zone = zList.elementAt(n); oList = zone.getSampleList(); if (multiZone) { x = x1 + (int) (zone.orgx * rx); y = y1 + (int) (zone.orgy * rx); } else { x = x1; y = y1; } zone.locX = x; zone.locY = y; zone.locX2 = x + (int) (zone.newWidth * rx); zone.locY2 = y + (int) (zone.newHeight * rx); i = (int) (zone.newDiam * rx); if (i < 4) i = 4; zone.minWidth = i; zone.ratio = rx; k = oList.size(); for (i = 0; i < k; i++) { obj = oList.elementAt(i); // obj.locX = x + (int) (obj.orgx * rx); // obj.locY = y + (int) (obj.orgy * rx); // obj.width = (int) (obj.newDiam * rx); ox = x + (int) (obj.orgx * rx); oy = y + (int) (obj.orgy * rx); ow = (int) (obj.newDiam * rx); obj.setBounds(ox, oy, ow, ow); } } } }