public void resize(){ layout.removeLayoutComponent(this); layout.removeLayoutComponent(this.apiSelectLabel); layout.removeLayoutComponent(this.apiSelectDropdown); layout.putConstraint(SpringLayout.EAST, this, ViewUtils.WINDOW_WIDTH-30, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.SOUTH, this, 40, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, apiSelectLabel, Spring.constant(5, 5, 20), SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, apiSelectLabel, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.EAST, apiSelectDropdown, ViewUtils.WINDOW_WIDTH - 350, SpringLayout.WEST, apiSelectDropdown); layout.putConstraint(SpringLayout.SOUTH, apiSelectDropdown, 30, SpringLayout.NORTH, apiSelectDropdown); layout.putConstraint(SpringLayout.WEST, apiSelectDropdown, Spring.constant(20, 20, 20), SpringLayout.EAST, apiSelectLabel); layout.putConstraint(SpringLayout.NORTH, apiSelectDropdown, Spring.constant(5, 5, 10), SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, help, Spring.constant(20, 20, 20), SpringLayout.EAST, apiSelectDropdown); layout.putConstraint(SpringLayout.NORTH, help, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); this.revalidate(); this.repaint(); }
private void initLayout() { SpringLayout layout = new SpringLayout(); setLayout(layout); add(introLabel); layout.putConstraint(north, introLabel, panelMargin, north, this); layout.putConstraint(west, introLabel, panelMargin, west, this); add(checkingLabel2); layout.putConstraint(north, checkingLabel2, 8 * panelMargin, north, introLabel); layout.putConstraint(west, checkingLabel2, 6 * panelMargin, west, this); add(checkingLabel); layout.putConstraint(north, checkingLabel, 9 * panelMargin, north, introLabel); layout.putConstraint(west, checkingLabel, 6 * panelMargin, west, this); add(introScrollPane); layout.getConstraints(introScrollPane).setConstraint(east, Spring.sum(Spring.constant(-panelMargin), layout.getConstraint(east, this))); layout.getConstraints(introScrollPane).setConstraint(south, Spring.sum(Spring.constant(-panelMargin), layout.getConstraint(south, this))); layout.putConstraint(north, introScrollPane, vDist, south, introLabel); layout.putConstraint(west, introScrollPane, 0, west, introLabel); }
private void initLayout() { SpringLayout layout = new SpringLayout(); setLayout(layout); add(licenseTitleLabel); layout.putConstraint(north, licenseTitleLabel, panelMargin, north, this); layout.putConstraint(west, licenseTitleLabel, panelMargin, west, this); add(licenseScrollPane); layout.getConstraints(licenseScrollPane).setConstraint(east, Spring.sum(Spring.constant(-panelMargin), layout.getConstraint(east, this))); layout.getConstraints(licenseScrollPane).setConstraint(south, Spring.sum(Spring.constant(-vDist*2), layout.getConstraint(north, agreeButton))); layout.putConstraint(north, licenseScrollPane, vDist, south, licenseTitleLabel); layout.putConstraint(west, licenseScrollPane, 0, west, licenseTitleLabel); add(agreeButton); layout.putConstraint(south, agreeButton, -panelMargin, south, this); layout.putConstraint(east, agreeButton, -panelMargin*6, east, this); add(disagreeButton); layout.putConstraint(south, disagreeButton, 0, south, agreeButton); layout.putConstraint(east, disagreeButton, -panelMargin*2, west, agreeButton); }
public void resize(){ layout.removeLayoutComponent(this); layout.removeLayoutComponent(this.loggedInButton); layout.removeLayoutComponent(this.loginButton); layout.removeLayoutComponent(this.loginNameLabel); layout.removeLayoutComponent(this.loginNameTextfield); layout.removeLayoutComponent(this.loginPasswordField); layout.removeLayoutComponent(this.loginPasswordLabel); layout.putConstraint(SpringLayout.EAST, this, ViewUtils.WINDOW_WIDTH-30, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.SOUTH, this, 40, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, loginNameLabel, Spring.constant(5, 5, 20), SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, loginNameLabel, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, loginNameTextfield, Spring.constant(10, 10, 20), SpringLayout.EAST, loginNameLabel); layout.putConstraint(SpringLayout.NORTH, loginNameTextfield, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, loginPasswordLabel, Spring.constant(10, 10, 20), SpringLayout.EAST, loginNameTextfield); layout.putConstraint(SpringLayout.NORTH, loginPasswordLabel, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, loginPasswordField, Spring.constant(10, 10, 20), SpringLayout.EAST, loginPasswordLabel); layout.putConstraint(SpringLayout.NORTH, loginPasswordField, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, loginButton, Spring.constant(20, 20, 20), SpringLayout.EAST, loginPasswordField); layout.putConstraint(SpringLayout.NORTH, loginButton, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, loggedInButton, Spring.constant(20, 20, 20), SpringLayout.EAST, loginButton); layout.putConstraint(SpringLayout.NORTH, loggedInButton, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); this.revalidate(); this.repaint(); }
private Spring getBestWidth(Container parent, int rows, int cols) { Spring x = Spring.constant(0); Spring width = Spring.constant(0); for (int c = 0; c < cols; c++) { for (int r = 0; r < rows; r++) { width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth()); } } return width; }
private void initLayout() { SpringLayout layout = new SpringLayout(); setLayout(layout); add(titleLabel); layout.putConstraint(north, titleLabel, panelMargin, north, this); layout.putConstraint(west, titleLabel, panelMargin, west, this); add(additionalActionsLabel); layout.putConstraint(north, additionalActionsLabel, vDist * 3, south, titleLabel); layout.putConstraint(west, additionalActionsLabel, panelMargin, west, this); add(startPLConfigButton); layout.putConstraint(north, startPLConfigButton, vDist * 3, south, additionalActionsLabel); layout.putConstraint(west, startPLConfigButton, panelMargin * 3, west, this); add(startPLServerCheckbox); layout.putConstraint(north, startPLServerCheckbox, vDist * 3, south, startPLConfigButton); layout.putConstraint(west, startPLServerCheckbox, panelMargin * 3, west, this); add(startPLClientCheckbox); layout.putConstraint(north, startPLClientCheckbox, vDist, south, startPLServerCheckbox); layout.putConstraint(west, startPLClientCheckbox, 0, west, startPLServerCheckbox); add(testWorkflowsLabel); layout.putConstraint(north, testWorkflowsLabel, vDist, south, startPLClientCheckbox); layout.putConstraint(west, testWorkflowsLabel, 5 * dist, west, startPLClientCheckbox); add(workflowsTableScrollPane); //layout.getConstraints(workflowsTableScrollPane).setConstraint(east, Spring.sum(Spring.constant( -panelMargin ), layout.getConstraint(east, this))); layout.getConstraints(workflowsTableScrollPane).setConstraint(south, Spring.sum(Spring.constant( -vDist ), layout.getConstraint(north, bottomNoteLabel))); layout.putConstraint(north, workflowsTableScrollPane, vDist, south, testWorkflowsLabel); layout.putConstraint(west, workflowsTableScrollPane, 5 * dist, west, testWorkflowsLabel); add(bottomNoteLabel); layout.putConstraint(north, bottomNoteLabel, -panelMargin, south, this); layout.putConstraint(west, bottomNoteLabel, panelMargin, west, this); }
public void resize(){ basicLayout.removeLayoutComponent(basic); basicLayout.removeLayoutComponent(loginPanel); basicLayout.removeLayoutComponent(sep1); basicLayout.removeLayoutComponent(apiPanel); basicLayout.removeLayoutComponent(sep2); basicLayout.removeLayoutComponent(centralPanel); basicLayout.removeLayoutComponent(sep3); basicLayout.removeLayoutComponent(goPanel); basicLayout.removeLayoutComponent(sep4); basicLayout.removeLayoutComponent(progressPanel); basicLayout.putConstraint(SpringLayout.EAST, basic, Spring.constant(0, ViewUtils.WINDOW_WIDTH, 1200), SpringLayout.WEST, basic); basicLayout.putConstraint(SpringLayout.SOUTH, basic, Spring.constant(0, ViewUtils.WINDOW_HEIGHT, 1200), SpringLayout.NORTH, basic); basicLayout.putConstraint(SpringLayout.WEST, loginPanel, 10, SpringLayout.WEST, basic); basicLayout.putConstraint(SpringLayout.NORTH, loginPanel, 10, SpringLayout.NORTH, basic); // basicLayout.putConstraint(SpringLayout.WEST, sep1, 0, SpringLayout.WEST, basic); // basicLayout.putConstraint(SpringLayout.NORTH, sep1, 50, SpringLayout.NORTH, basic); // basicLayout.putConstraint(SpringLayout.EAST, sep1, 0, SpringLayout.EAST, basic); basicLayout.putConstraint(SpringLayout.WEST, apiPanel, 10, SpringLayout.WEST, basic); basicLayout.putConstraint(SpringLayout.NORTH, apiPanel, 65, SpringLayout.NORTH, basic); // basicLayout.putConstraint(SpringLayout.WEST, sep2, 0, SpringLayout.WEST, basic); // basicLayout.putConstraint(SpringLayout.NORTH, sep2, 100, SpringLayout.NORTH, basic); // basicLayout.putConstraint(SpringLayout.EAST, sep2, 0, SpringLayout.EAST, basic); basicLayout.putConstraint(SpringLayout.WEST, centralPanel, 10, SpringLayout.WEST, basic); basicLayout.putConstraint(SpringLayout.NORTH, centralPanel, 120, SpringLayout.NORTH, basic); // basicLayout.putConstraint(SpringLayout.WEST, sep3, 0, SpringLayout.WEST, basic); // basicLayout.putConstraint(SpringLayout.NORTH, sep3, 5, SpringLayout.SOUTH, centralPanel); // basicLayout.putConstraint(SpringLayout.EAST, sep3, 0, SpringLayout.EAST, basic); basicLayout.putConstraint(SpringLayout.WEST, goPanel, 10, SpringLayout.WEST, basic); basicLayout.putConstraint(SpringLayout.NORTH, goPanel, 10, SpringLayout.SOUTH, centralPanel); // basicLayout.putConstraint(SpringLayout.WEST, sep4, 0, SpringLayout.WEST, basic); // basicLayout.putConstraint(SpringLayout.NORTH, sep4, 5, SpringLayout.SOUTH, goPanel); // basicLayout.putConstraint(SpringLayout.EAST, sep4, 0, SpringLayout.EAST, basic); basicLayout.putConstraint(SpringLayout.WEST, progressPanel, 10, SpringLayout.WEST, basic); basicLayout.putConstraint(SpringLayout.NORTH, progressPanel, 10, SpringLayout.SOUTH, goPanel); // basic.revalidate(); // this.repaint(); }
private void makeProgressBars(SpringLayout l) { JComponent prevLabel = null, prevBar = null; bars = new JProgressBar[SummaryItem.STATES.length]; SpringLayout ls = new SpringLayout(); JPanel appSummary = new JPanel(); appSummary.setBorder(BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "App Summary")); add(appSummary); l.putConstraint(SpringLayout.WEST, appSummary, 5, SpringLayout.WEST, this); l.putConstraint(SpringLayout.EAST, appSummary, -5, SpringLayout.EAST, this); l.putConstraint(SpringLayout.NORTH, appSummary, 25, SpringLayout.NORTH, this); appSummary.setLayout(ls); for (int i = 0; i < SummaryItem.STATES.length; i++) { JLabel label = new JLabel(SummaryItem.STATES[i] + ":"); appSummary.add(label); JProgressBar lb = new JProgressBar(); bars[i] = lb; lb.setString("0"); lb.setStringPainted(true); appSummary.add(lb); fixEdges(ls, label, lb, appSummary); if (prevLabel == null) { ls.putConstraint(SpringLayout.NORTH, label, 5, SpringLayout.NORTH, appSummary); } else { ls.putConstraint(SpringLayout.NORTH, label, 10, SpringLayout.SOUTH, prevLabel); } prevLabel = label; prevBar = lb; } JLabel hl = new JLabel("Heap:"); memory = makeProgress(l, hl); l.putConstraint(SpringLayout.SOUTH, appSummary, -25, SpringLayout.NORTH, hl); l.putConstraint(SpringLayout.SOUTH, hl, -25, SpringLayout.SOUTH, this); Spring maxW = Spring.constant(0); for (int i = 0; i < SummaryItem.STATES.length; i++) { maxW = Spring.max(maxW, ls.getConstraints(appSummary.getComponent(i * 2)).getWidth()); } for (int i = 0; i < SummaryItem.STATES.length; i++) { SpringLayout.Constraints c = ls.getConstraints(appSummary.getComponent(i * 2)); c.setWidth(maxW); } }
/** * Called when the mouse is dragged and the shift key is down. * @param event the event */ private void mouseDragged(MouseEvent event) { // How much we've moved from the original location int deltaX = event.getXOnScreen() - screenX; int deltaY = event.getYOnScreen() - screenY; Container parent = legend.getParent(); SpringLayout layout = (SpringLayout) parent.getLayout(); layout.removeLayoutComponent(legend); // The new location, in parent coordinates int x = myX + deltaX; int y = myY + deltaY; // See if we snap to anything. boolean snapLeft = false; boolean snapRight = false; boolean snapTop = false; boolean snapBottom = false; int legendWidth = legend.getWidth(); int legendHeight = legend.getHeight(); for(Component snapTo : this.snapTo) { // Current location of the top left corner of the legend, in snapTo coordinates. Point p = SwingUtilities.convertPoint(parent, x, y, snapTo); if(!snapLeft && !snapRight) { if(Math.abs(p.x) <= snapDist) { snapLeft = true; layout.putConstraint(SpringLayout.WEST, legend, 0, SpringLayout.WEST, snapTo); x = SwingUtilities.convertPoint(snapTo, 0, 0, parent).x; } else if(Math.abs(p.x + legendWidth - snapTo.getWidth()) <= snapDist) { snapRight = true; layout.putConstraint(SpringLayout.EAST, legend, 0, SpringLayout.EAST, snapTo); x = SwingUtilities.convertPoint(snapTo, snapTo.getWidth() - legendWidth, 0, parent).x; } } if(!snapTop && !snapBottom) { if(Math.abs(p.y) <= snapDist) { snapTop = true; layout.putConstraint(SpringLayout.NORTH, legend, 0, SpringLayout.NORTH, snapTo); y = SwingUtilities.convertPoint(snapTo, 0, 0, parent).y; } else if(Math.abs(p.y + legendHeight - snapTo.getHeight()) <= snapDist) { snapBottom = true; layout.putConstraint(SpringLayout.SOUTH, legend, 0, SpringLayout.SOUTH, snapTo); y = SwingUtilities.convertPoint(snapTo, 0, snapTo.getHeight() - legendHeight, parent).y; } } } // Set the location directly for immediate effect legend.setLocation(x, y); // Set the location in the layout so it stays where it was, percentagewise. // In other words, if the center of the legend was 33% of the way from the left to the right of the parent, // it will remain 33% of the way from the left to the right of the parent even if the parent is resized. Constraints constraints = layout.getConstraints(legend); if(!snapTop && !snapBottom) { float py = (y + legendHeight * .5f) / (float) parent.getHeight(); constraints.setConstraint(SpringLayout.VERTICAL_CENTER, Spring.scale(new HeightSpring(parent), py)); } if(!snapLeft && !snapRight) { float px = (x + legendWidth * .5f) / (float) parent.getWidth(); constraints.setConstraint(SpringLayout.HORIZONTAL_CENTER, Spring.scale(new WidthSpring(parent), px)); } // Hide borders on the sides that have been snapped to. Border outsideBorder = BorderFactory.createMatteBorder(snapTop ? 0 : 1, snapLeft ? 0 : 1, snapBottom ? 0 : 1, snapRight ? 0 : 1, Color.darkGray); Border insideBorder = ((CompoundBorder) legend.getBorder()).getInsideBorder(); legend.setBorder(BorderFactory.createCompoundBorder(outsideBorder, insideBorder)); }
private void displaySteps() { setNextEnabled(false); StringBuilder sb = new StringBuilder("<html><br><br>"); int counter = 1; for(String s : stepsList) { sb.append("<font color=\""); if(counter < currentStepIndex) { if (stepsPanelList.get(counter - 1) instanceof ServerConfigurationPanel) { if (!Boolean.parseBoolean(Configuration.getConfig(Configuration.CONFIG_INSTALL_PIPELINE)) ) sb.append("gray"); } else if (stepsPanelList.get(counter - 1) instanceof SGEConfigurationPanel ) { if (!Boolean.parseBoolean(Configuration.getConfig(Configuration.CONFIG_INSTALL_SGE)) ) sb.append("gray"); } else if (stepsPanelList.get(counter - 1) instanceof NIToolsConfigurationPanel ) { if (!Boolean.parseBoolean(Configuration.getConfig(Configuration.CONFIG_INSTALL_NI_TOOLS)) ) sb.append("gray"); } else if (stepsPanelList.get(counter - 1) instanceof BioinformaticsToolsConfigurationPanel ) { if (!Boolean.parseBoolean(Configuration.getConfig(Configuration.CONFIG_INSTALL_BI_TOOLS)) ) sb.append("gray"); } else sb.append("darkGray"); } else if ( counter == currentStepIndex ) { sb.append("#273791"); } else { sb.append("gray"); } sb.append("\">"); if ( counter == currentStepIndex ) sb.append("<b>"); sb.append(counter); sb.append(". "); sb.append(s); if ( counter == currentStepIndex ) sb.append("</b>"); sb.append("</font><br><br>"); counter++; } sb.append("</html>"); stepsLabel.setText(sb.toString()); if(currentPanel!=null) remove(currentPanel); AbstractStepPanel panel = stepsPanelList.get(currentStepIndex-1); add(panel); layout.getConstraints(panel).setConstraint(south, Spring.sum(Spring.constant(-vDist), layout.getConstraint(north, helpButton))); layout.getConstraints(panel).setConstraint(east, Spring.sum(Spring.constant(-panelMargin), layout.getConstraint(east, getContentPane()))); layout.putConstraint(north, panel, vDist, south, topSeparator); layout.putConstraint(west, panel, dist, east, sideSeparator); currentPanel = panel; panel.panelActivated(); validate(); repaint(); }
private void initLayout() { layout = new SpringLayout(); this.setLayout(layout); Container pane = this.getContentPane(); add(titleIconLabel); layout.putConstraint(north, titleIconLabel, panelMargin, north, pane); layout.putConstraint(west, titleIconLabel, panelMargin*2, west, pane); add(titleLabel); layout.putConstraint(south, titleLabel, -2 * vDist, south, titleIconLabel); layout.putConstraint(west, titleLabel, dist, west, topSeparator); add(subTitleLabel); layout.putConstraint(south, subTitleLabel, 0, south, versionLabel); layout.putConstraint(east, subTitleLabel, -dist * 2, west, versionLabel); add(versionLabel); layout.putConstraint(south, versionLabel, -dist, north, topSeparator); layout.putConstraint(east, versionLabel, -panelMargin, east, pane); add(topSeparator); layout.getConstraints(topSeparator).setConstraint(east, Spring.sum(Spring.constant(-panelMargin), layout.getConstraint(east, pane))); layout.putConstraint(north, topSeparator, vDist, south, titleLabel); layout.putConstraint(west, topSeparator, 0, west, sideSeparator); add(stepsLabel); layout.putConstraint(north, stepsLabel, vDist, south, topSeparator); layout.putConstraint(west, stepsLabel, panelMargin, west, pane); add(sideSeparator); layout.getConstraints(sideSeparator).setConstraint(south, Spring.sum(Spring.constant(-vDist), layout.getConstraint(north, helpButton))); layout.putConstraint(north, sideSeparator, vDist, south, titleLabel); layout.putConstraint(west, sideSeparator, dist, east, stepsLabel); add(copyrightLabel); layout.putConstraint(south, copyrightLabel, -5, south, pane); layout.putConstraint(west, copyrightLabel, dist, west, pane); add(helpButton); layout.putConstraint(south, helpButton, -panelMargin, north, copyrightLabel); layout.putConstraint(west, helpButton, panelMargin*2, west, pane); add(cancelButton); layout.putConstraint(south, cancelButton, 0, south, helpButton); layout.putConstraint(east, cancelButton, -panelMargin*2, west, backButton); add(finishButton); layout.putConstraint(south, finishButton, 0, south, helpButton); layout.putConstraint(east, finishButton, -panelMargin*2, east, pane); add(nextButton); layout.putConstraint(south, nextButton, 0, south, helpButton); layout.putConstraint(east, nextButton, -dist*2, west, finishButton); add(backButton); layout.putConstraint(south, backButton, 0, south, helpButton); layout.putConstraint(east, backButton, -dist*2, west, nextButton); }
private void initLayout() { SpringLayout layout = new SpringLayout(); setLayout(layout); add(titleLabel); layout.putConstraint(north, titleLabel, panelMargin, north, this); layout.putConstraint(west, titleLabel, panelMargin, west, this); add(topSeparator); layout.getConstraints(topSeparator).setConstraint(east, Spring.sum(Spring.constant(-panelMargin),layout.getConstraint(east, this))); layout.putConstraint(north, topSeparator, vDist, south, titleLabel); layout.putConstraint(west, topSeparator, panelMargin, west, this); add(sideSeparator); layout.getConstraints(sideSeparator).setConstraint(south, layout.getConstraint(south, this)); layout.putConstraint(north, sideSeparator, 2 * vDist, south, titleLabel); layout.putConstraint(west, sideSeparator, 15 * dist, east, titleLabel); add(sgeLocationLabel); layout.putConstraint(north, sgeLocationLabel, vDist, north, sideSeparator); layout.putConstraint(west, sgeLocationLabel, 4 * dist, west, titleLabel); add(sgeLocationField); layout.putConstraint(north, sgeLocationField, vDist, south, sgeLocationLabel); layout.putConstraint(west, sgeLocationField, 0, west, sgeLocationLabel); add(sgeClusterLabel); layout.putConstraint(north, sgeClusterLabel, 2 * vDist, south, sgeLocationField); layout.putConstraint(west, sgeClusterLabel, 0 , west, sgeLocationLabel); add(sgeClusterField); layout.putConstraint(north, sgeClusterField, vDist, south, sgeClusterLabel); layout.putConstraint(west, sgeClusterField, 0, west, sgeLocationLabel); add(sgeSpoolDirLabel); layout.putConstraint(north, sgeSpoolDirLabel, 2 * vDist, south, sgeClusterField); layout.putConstraint(west, sgeSpoolDirLabel, 0 , west, sgeLocationLabel); add(sgeSpoolDirField); layout.putConstraint(north, sgeSpoolDirField, vDist, south, sgeSpoolDirLabel); layout.putConstraint(west, sgeSpoolDirField, 0, west, sgeLocationLabel); add(sgeAdminCheckbox); layout.putConstraint(north, sgeAdminCheckbox, vDist, south, sgeSpoolDirField); layout.putConstraint(west, sgeAdminCheckbox, 0, west, sgeLocationLabel); add(sgeAdminLabel); layout.putConstraint(north, sgeAdminLabel, vDist, south, sgeAdminCheckbox); layout.putConstraint(west, sgeAdminLabel, 0, west, sgeLocationLabel); add(sgeAdminField); layout.putConstraint(north, sgeAdminField, vDist, south, sgeAdminLabel); layout.putConstraint(west, sgeAdminField, 0, west, sgeLocationLabel); add(sgeAdminWarningArea); layout.putConstraint(north, sgeAdminWarningArea, vDist / 2, south, sgeAdminField); layout.getConstraints(sgeAdminWarningArea).setConstraint(east, Spring.sum(Spring.constant(-dist),layout.getConstraint(west, sideSeparator))); layout.putConstraint(west, sgeAdminWarningArea, 0, west, sgeLocationLabel); add(sgeExecHostsLabel); layout.putConstraint(north, sgeExecHostsLabel, vDist, north, sideSeparator); layout.putConstraint(west, sgeExecHostsLabel, 4 * dist , east, sideSeparator); add(sgeExecHostsScrollPane); layout.getConstraints(sgeExecHostsScrollPane).setConstraint(east, Spring.sum(Spring.constant(-panelMargin),layout.getConstraint(east, this))); layout.getConstraints(sgeExecHostsScrollPane).setConstraint(south, Spring.sum(Spring.constant(-vDist),layout.getConstraint(north, sgeExecHostsExampleScrollPane))); layout.putConstraint(north, sgeExecHostsScrollPane, vDist, south, sgeExecHostsLabel); layout.putConstraint(west, sgeExecHostsScrollPane, 0, west, sgeExecHostsLabel); add(sgeExecHostsExampleScrollPane); layout.getConstraints(sgeExecHostsExampleScrollPane).setConstraint(east, Spring.sum(Spring.constant(-panelMargin),layout.getConstraint(east, this))); layout.getConstraints(sgeExecHostsExampleScrollPane).setConstraint(south, Spring.sum(Spring.constant(-panelMargin),layout.getConstraint(south, this))); layout.putConstraint(west, sgeExecHostsExampleScrollPane, 0, west, sgeExecHostsLabel); add(validatingHostsLabel); layout.putConstraint(north, validatingHostsLabel, vDist, south, sgeExecHostsScrollPane); layout.putConstraint(west, validatingHostsLabel, 0, west, sgeExecHostsScrollPane); }
private void initLayout() { SpringLayout layout = new SpringLayout(); setLayout(layout); add(titleLabel); layout.putConstraint(north, titleLabel, panelMargin, north, this); layout.putConstraint(west, titleLabel, panelMargin, west, this); add(topSeparator); layout.getConstraints(topSeparator).setConstraint(east, Spring.sum(Spring.constant(-panelMargin),layout.getConstraint(east, this))); layout.putConstraint(north, topSeparator, vDist, south, titleLabel); layout.putConstraint(west, topSeparator, panelMargin, west, this); add(fsPathLabel); layout.putConstraint(north, fsPathLabel, vDist * 3, south, titleLabel); layout.putConstraint(west, fsPathLabel, dist * 4, west, titleLabel); add(fsPathField); layout.putConstraint(north, fsPathField, 0, north, fsPathLabel); layout.putConstraint(west, fsPathField, dist, east, fsPathLabel); add(fsPathBrowseButton); layout.putConstraint(north, fsPathBrowseButton, -dist, north, fsPathLabel); layout.getConstraints(fsPathBrowseButton).setConstraint(east, Spring.sum(Spring.constant(-panelMargin),layout.getConstraint(east, this))); layout.putConstraint(west, fsPathBrowseButton, dist, east, fsPathField); add(middleSeparator); layout.getConstraints(middleSeparator).setConstraint(east, Spring.sum(Spring.constant(-panelMargin),layout.getConstraint(east, this))); layout.putConstraint(north, middleSeparator, vDist, south, fsPathBrowseButton); layout.putConstraint(west, middleSeparator, panelMargin, west, this); add(selectComponentsLabel); layout.putConstraint(north, selectComponentsLabel, vDist * 2, south, middleSeparator); layout.putConstraint(west, selectComponentsLabel, panelMargin, west, this); add(pipelineCheckbox); layout.putConstraint(north, pipelineCheckbox, vDist * 2, south, selectComponentsLabel); layout.putConstraint(west, pipelineCheckbox, 0, west, fsPathLabel); add(pipelineDescription); layout.putConstraint(north, pipelineDescription, vDist, south, pipelineCheckbox); layout.putConstraint(west, pipelineDescription, dist * 5, west, pipelineCheckbox); add(sgeCheckbox); layout.putConstraint(north, sgeCheckbox, vDist, south, pipelineDescription); layout.putConstraint(west, sgeCheckbox, 0, west, pipelineCheckbox); add(sgeDescription); layout.putConstraint(north, sgeDescription, vDist, south, sgeCheckbox); layout.putConstraint(west, sgeDescription, dist * 5, west, pipelineCheckbox); add(niToolsCheckbox); layout.putConstraint(north, niToolsCheckbox, vDist, south, sgeDescription); layout.putConstraint(west, niToolsCheckbox, 0, west, pipelineCheckbox); add(niToolsDescription); layout.putConstraint(north, niToolsDescription, vDist, south, niToolsCheckbox); layout.putConstraint(west, niToolsDescription, dist * 5, west, pipelineCheckbox); add(biToolsCheckbox); layout.putConstraint(north, biToolsCheckbox, vDist, south, niToolsDescription); layout.putConstraint(west, biToolsCheckbox, 0, west, pipelineCheckbox); add(biToolsDescription); layout.putConstraint(north, biToolsDescription, vDist, south, biToolsCheckbox); layout.putConstraint(west, biToolsDescription, dist * 5, west, pipelineCheckbox); add(bottomSeparator); layout.getConstraints(bottomSeparator).setConstraint(east, Spring.sum(Spring.constant(-panelMargin),layout.getConstraint(east, this))); layout.putConstraint(south, bottomSeparator, -panelMargin, south, this); layout.putConstraint(west, bottomSeparator, panelMargin, west, this); }
private void initLayout() { SpringLayout layout = new SpringLayout(); setLayout(layout); add(titleLabel); layout.putConstraint(north, titleLabel, 0, north, this); layout.putConstraint(west, titleLabel, panelMargin, west, this); add(executablesCheckbox); layout.putConstraint(north, executablesCheckbox, vDist * 2, south, titleLabel); layout.putConstraint(west, executablesCheckbox, panelMargin, west, this); add(serverLibCheckbox); layout.putConstraint(north, serverLibCheckbox, vDist, south, executablesCheckbox); layout.putConstraint(west, serverLibCheckbox, panelMargin, west, this); add(serverPrefsLabel); layout.putConstraint(north, serverPrefsLabel, vDist, south, serverLibCheckbox); layout.putConstraint(west, serverPrefsLabel, dist * 4, west, serverLibCheckbox); add(serverPrefsField); layout.putConstraint(north, serverPrefsField, vDist, south, serverLibCheckbox); layout.putConstraint(west, serverPrefsField, dist, east, serverPrefsLabel); add(serverPrefsBrowseButton); layout.putConstraint(north, serverPrefsBrowseButton, vDist, south, serverLibCheckbox); layout.putConstraint(west, serverPrefsBrowseButton, dist, east, serverPrefsField); add(toolsDescLabel); layout.putConstraint(north, toolsDescLabel, 0, south, serverPrefsBrowseButton); layout.putConstraint(west, toolsDescLabel, panelMargin, west, this); add(toolsTableScrollPane); layout.getConstraints(toolsTableScrollPane).setConstraint(east, Spring.sum(Spring.constant( -panelMargin ), layout.getConstraint(east, this))); layout.getConstraints(toolsTableScrollPane).setConstraint(south, Spring.sum(Spring.constant( -vDist ), layout.getConstraint(north, totalSizeLabel))); layout.putConstraint(north, toolsTableScrollPane, vDist, south, toolsDescLabel); layout.putConstraint(west, toolsTableScrollPane, 0, west, toolsDescLabel); add(totalSizeLabel); layout.putConstraint(south, totalSizeLabel, -vDist, north, descriptionTextArea); layout.putConstraint(east, totalSizeLabel, 0, east, toolsTableScrollPane); add(descriptionTextArea); layout.getConstraints(descriptionTextArea).setConstraint(east, Spring.sum(Spring.constant( -panelMargin ), layout.getConstraint(east, this))); layout.putConstraint(south, descriptionTextArea, -vDist, north, toolLocationLabel); layout.putConstraint(west, descriptionTextArea, 0, west, toolsTableScrollPane); add(toolLocationLabel); layout.putConstraint(south, toolLocationLabel, -panelMargin, south, this); layout.putConstraint(west, toolLocationLabel, panelMargin, west, this); }
private void initLayout() { SpringLayout layout = new SpringLayout(); setLayout(layout); add(titleLabel); layout.putConstraint(north, titleLabel, 0, north, this); layout.putConstraint(west, titleLabel, panelMargin, west, this); add(executablesCheckbox); layout.putConstraint(north, executablesCheckbox, vDist * 2, south, titleLabel); layout.putConstraint(west, executablesCheckbox, panelMargin, west, this); add(serverLibCheckbox); layout.putConstraint(north, serverLibCheckbox, vDist, south, executablesCheckbox); layout.putConstraint(west, serverLibCheckbox, panelMargin, west, this); add(serverPrefsLabel); layout.putConstraint(north, serverPrefsLabel, vDist, south, serverLibCheckbox); layout.putConstraint(west, serverPrefsLabel, panelMargin, west, this); add(serverPrefsField); layout.putConstraint(north, serverPrefsField, vDist, south, serverLibCheckbox); layout.putConstraint(west, serverPrefsField, dist, east, serverPrefsLabel); add(serverPrefsBrowseButton); layout.putConstraint(north, serverPrefsBrowseButton, vDist, south, serverLibCheckbox); layout.putConstraint(west, serverPrefsBrowseButton, dist, east, serverPrefsField); add(toolsDescLabel); layout.putConstraint(north, toolsDescLabel, 0, south, serverPrefsBrowseButton); layout.putConstraint(west, toolsDescLabel, panelMargin, west, this); add(toolsTableScrollPane); layout.getConstraints(toolsTableScrollPane).setConstraint(east, Spring.sum(Spring.constant( -panelMargin ), layout.getConstraint(east, this))); layout.getConstraints(toolsTableScrollPane).setConstraint(south, Spring.sum(Spring.constant( -vDist ), layout.getConstraint(north, totalSizeLabel))); layout.putConstraint(north, toolsTableScrollPane, vDist, south, toolsDescLabel); layout.putConstraint(west, toolsTableScrollPane, 0, west, toolsDescLabel); add(totalSizeLabel); layout.putConstraint(south, totalSizeLabel, -vDist, north, descriptionTextArea); layout.putConstraint(east, totalSizeLabel, 0, east, toolsTableScrollPane); add(descriptionTextArea); layout.getConstraints(descriptionTextArea).setConstraint(east, Spring.sum(Spring.constant( -panelMargin ), layout.getConstraint(east, this))); layout.putConstraint(south, descriptionTextArea, -vDist, north, toolLocationLabel); layout.putConstraint(west, descriptionTextArea, 0, west, toolsTableScrollPane); add(toolLocationLabel); layout.putConstraint(south, toolLocationLabel, -panelMargin, south, this); layout.putConstraint(west, toolLocationLabel, panelMargin, west, this); }
public ExpanSearchFieldPanel(String name, int columns) { super(); this.name = name; if (columns < MIN_COLUMNS) throw new IllegalArgumentException(this.getClass().getName() +" requires at least "+ MIN_COLUMNS +" columns"); //this.setBorder(BorderFactory.createEtchedBorder(1)); SpringLayout layout = new SpringLayout(); this.setLayout(layout); JTextField dummyField = new JTextField(10); String[] fullSetNames = Prefs.textDat.getTextSetNames(); String[] choices = new String[fullSetNames.length+1]; choices[0] = ""; for (int i=0; i < fullSetNames.length; i++) { String tmpFullName = fullSetNames[fullSetNames.length-1-i]; choices[i+1] = Prefs.textDat.getSetAbbrevFromName(tmpFullName) +"-"+ tmpFullName; } componentsByColumn = new Component[columns]; int currentCol = 0; nameLbl = new JLabel(this.name); componentsByColumn[currentCol++] = nameLbl; this.add(nameLbl); JPanel comboHolder = new JPanel(new GridBagLayout()); GridBagConstraints gridC = new GridBagConstraints(); gridC.fill = GridBagConstraints.HORIZONTAL; gridC.weightx = 1.0; expanCombo = new WideComboBox(choices); expanCombo.setEditable(true); expanCombo.setEditor(new ExpanSearchFieldEditor()); expanCombo.setFont(dummyField.getFont()); expanCombo.recachePopupWidth(); expanCombo.setPreferredSize(dummyField.getPreferredSize()); comboHolder.add(expanCombo, gridC); componentsByColumn[currentCol++] = comboHolder; this.add(comboHolder); JPanel typeHolder = new JPanel(new GridBagLayout()); typeBtn = new RegexToggleButton(); typeHolder.add(typeBtn); componentsByColumn[currentCol++] = typeHolder; this.add(typeHolder); for (int i=currentCol; i < columns; i++) { Component tmpComp = Box.createHorizontalStrut(0); componentsByColumn[i] = tmpComp; this.add(tmpComp); } // Find the tallest component and use that as a fixed value Spring height = Spring.constant(0); for (int i=0; i < componentsByColumn.length; i++) { height = Spring.max(height, layout.getConstraints(componentsByColumn[i]).getHeight()); } height = Spring.constant(height.getValue()); // Standardize the heights, base X pos on prev's East edge for (int i=0; i < componentsByColumn.length; i++) { SpringLayout.Constraints cons = layout.getConstraints(componentsByColumn[i]); cons.setHeight(height); cons.setY(SearchFieldPanel.PadY_Spring); if (i == 0) { cons.setX(SearchFieldPanel.PadX_Spring); } else { cons.setX(Spring.sum(Spring.constant(5), layout.getConstraint("East", componentsByColumn[i-1]))); } } // Make this panel's preferred size depend on its contents SpringLayout.Constraints thisCons = layout.getConstraints(this); thisCons.setConstraint("East", Spring.sum(layout.getConstraint("East", componentsByColumn[componentsByColumn.length-1]), SearchFieldPanel.PadX_Spring)); thisCons.setConstraint("South", Spring.sum(height, Spring.sum(SearchFieldPanel.PadY_Spring, SearchFieldPanel.PadY_Spring))); }
private void populateFieldComponents() { filterLFields.removeAll(); filterRFields.removeAll(); DatParser textDat = Prefs.textDat; synchronized (textDat) { fieldPanels = Prefs.textDat.getSearchFieldPanels(); } // Calc the left half's count int leftCount = (fieldPanels.length+1)/2; // Find the max column count among nested components int cols = 0; for (int i=0; i < fieldPanels.length; i++) { int n = fieldPanels[i].getMinColumnCount(); if (n > cols) cols = n; } // For each half, standardize widths for each column int[] minRanges = new int[] {0, leftCount}; int[] maxRanges = new int[] {leftCount, fieldPanels.length}; for (int r=0; r < minRanges.length; r++) { for (int c=0; c < cols; c++) { Spring width = Spring.constant(0); for (int i=minRanges[r]; i < maxRanges[r]; i++) { width = Spring.max(width, fieldPanels[i].getSpringConstraintsForColumn(c).getWidth()); } width = Spring.constant(width.getValue()); for (int i=minRanges[r]; i < maxRanges[r]; i++) { fieldPanels[i].getSpringConstraintsForColumn(c).setWidth(width); } } } for (int i=0; i < fieldPanels.length; i++) { if (i < leftCount) { filterLFields.add(fieldPanels[i]); } else { filterRFields.add(fieldPanels[i]); } } if (leftCount > 0 && fieldPanels.length % 2 != 0) { filterRFields.add(Box.createVerticalStrut(fieldPanels[leftCount-1].getPreferredSize().height)); } revalidate(); }
public ColorBarSearchFieldPanel(String name, int columns) { super(); this.name = name; if (columns < MIN_COLUMNS) throw new IllegalArgumentException(this.getClass().getName() +" requires at least "+ MIN_COLUMNS +" columns"); //this.setBorder(BorderFactory.createEtchedBorder(1)); SpringLayout layout = new SpringLayout(); this.setLayout(layout); componentsByColumn = new Component[columns]; int currentCol = 0; nameLbl = new JLabel(this.name); componentsByColumn[currentCol++] = nameLbl; this.add(nameLbl); JPanel colorHolder = new JPanel(new GridBagLayout()); colorBar = new ColorBar(); colorHolder.add(colorBar); componentsByColumn[currentCol++] = colorHolder; this.add(colorHolder); for (int i=currentCol; i < columns; i++) { Component tmpComp = Box.createHorizontalStrut(0); componentsByColumn[i] = tmpComp; this.add(tmpComp); } // Find the tallest component and use that as a fixed value Spring height = Spring.constant(0); for (int i=0; i < componentsByColumn.length; i++) { height = Spring.max(height, layout.getConstraints(componentsByColumn[i]).getHeight()); } height = Spring.constant(height.getValue()); // Standardize the heights, base X pos on prev's East edge for (int i=0; i < componentsByColumn.length; i++) { SpringLayout.Constraints cons = layout.getConstraints(componentsByColumn[i]); cons.setHeight(height); cons.setY(SearchFieldPanel.PadY_Spring); if (i == 0) { cons.setX(SearchFieldPanel.PadX_Spring); } else { cons.setX(Spring.sum(Spring.constant(5), layout.getConstraint("East", componentsByColumn[i-1]))); } } // Make this panel's preferred size depend on its contents SpringLayout.Constraints thisCons = layout.getConstraints(this); thisCons.setConstraint("East", Spring.sum(layout.getConstraint("East", componentsByColumn[componentsByColumn.length-1]), SearchFieldPanel.PadX_Spring)); thisCons.setConstraint("South", Spring.sum(height, Spring.sum(SearchFieldPanel.PadY_Spring, SearchFieldPanel.PadY_Spring))); }
public TextSearchFieldPanel(String name, int columns) { super(); this.name = name; if (columns < MIN_COLUMNS) throw new IllegalArgumentException(this.getClass().getName() +" requires at least "+ MIN_COLUMNS +" columns"); //this.setBorder(BorderFactory.createEtchedBorder(1)); SpringLayout layout = new SpringLayout(); this.setLayout(layout); componentsByColumn = new Component[columns]; int currentCol = 0; nameLbl = new JLabel(this.name); componentsByColumn[currentCol++] = nameLbl; this.add(nameLbl); JPanel textHolder = new JPanel(new GridBagLayout()); GridBagConstraints gridC = new GridBagConstraints(); gridC.fill = GridBagConstraints.HORIZONTAL; gridC.weightx = 1.0; textField = new JTextField(10); textHolder.add(textField, gridC); componentsByColumn[currentCol++] = textHolder; this.add(textHolder); JPanel typeHolder = new JPanel(new GridBagLayout()); typeBtn = new RegexToggleButton(); typeHolder.add(typeBtn); componentsByColumn[currentCol++] = typeHolder; this.add(typeHolder); for (int i=currentCol; i < columns; i++) { Component tmpComp = Box.createHorizontalStrut(0); componentsByColumn[i] = tmpComp; this.add(tmpComp); } // Find the tallest component and use that as a fixed value Spring height = Spring.constant(0); for (int i=0; i < componentsByColumn.length; i++) { height = Spring.max(height, layout.getConstraints(componentsByColumn[i]).getHeight()); } height = Spring.constant(height.getValue()); // Standardize the heights, base X pos on prev's East edge for (int i=0; i < componentsByColumn.length; i++) { SpringLayout.Constraints cons = layout.getConstraints(componentsByColumn[i]); cons.setHeight(height); cons.setY(SearchFieldPanel.PadY_Spring); if (i == 0) { cons.setX(SearchFieldPanel.PadX_Spring); } else { cons.setX(Spring.sum(Spring.constant(5), layout.getConstraint("East", componentsByColumn[i-1]))); } } // Make this panel's preferred size depend on its contents SpringLayout.Constraints thisCons = layout.getConstraints(this); thisCons.setConstraint("East", Spring.sum(layout.getConstraint("East", componentsByColumn[componentsByColumn.length-1]), SearchFieldPanel.PadX_Spring)); thisCons.setConstraint("South", Spring.sum(height, Spring.sum(SearchFieldPanel.PadY_Spring, SearchFieldPanel.PadY_Spring))); }
public void resize(){ settingsWindow.setLocationRelativeTo(settings); layout.removeLayoutComponent(this); layout.removeLayoutComponent(this.go); layout.putConstraint(SpringLayout.EAST, this, ViewUtils.WINDOW_WIDTH-30, SpringLayout.WEST, this); layout.putConstraint(SpringLayout.SOUTH, this, 40, SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, this.currentFile, Spring.constant(5, 5, 5), SpringLayout.WEST, this); layout.putConstraint(SpringLayout.NORTH, this.currentFile, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, this.currentFileTextField, Spring.constant(10, 10, 10), SpringLayout.EAST, this.currentFile); layout.putConstraint(SpringLayout.NORTH, this.currentFileTextField, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, this.browse, Spring.constant(10, 10, 10), SpringLayout.EAST, this.currentFileTextField); layout.putConstraint(SpringLayout.NORTH, this.browse, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.WEST, this.settings, Spring.constant(20, 20, 20), SpringLayout.EAST, this.browse); layout.putConstraint(SpringLayout.NORTH, this.settings, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); layout.putConstraint(SpringLayout.EAST, this.go, Spring.constant(-10, -10, -10), SpringLayout.EAST, this); layout.putConstraint(SpringLayout.NORTH, this.go, Spring.constant(10, 10, 10), SpringLayout.NORTH, this); this.revalidate(); this.repaint(); }