List of usage examples for com.jgoodies.forms.layout FormLayout setColumnGroups
public void setColumnGroups(int[][] groupOfIndices)
From source file:com.isencia.passerelle.hmi.specific.HMITest.java
License:Open Source License
private JPanel getRockingCurvePanel() { // Initialization rockingCurveTextField = new JTextField("100"); registerBinding("rockingCurveField", rockingCurveTextField, (ParameterToWidgetBinder) new ParameterToTextFieldBinder()); // Create panel final FormLayout layout = new FormLayout("p, 3dlu, p", // cols "pref, 3dlu, p"); // rows // Specify that columns 1 & 5 as well as 3 & 7 have equal widths. layout.setColumnGroups(new int[][] { { 1, 3 } }); // Create a builder that assists in adding components to the container. // Wrap the panel with a standardized border. final PanelBuilder builder = new PanelBuilder(layout); builder.setDefaultDialogBorder();/*from w w w . j av a 2 s . c o m*/ // Obtain a reusable constraints object to place components in the grid. final CellConstraints cc = new CellConstraints(); builder.addSeparator("Rocking curve", cc.xyw(1, 1, 3)); builder.addLabel("Rocking curve (%)", cc.xy(1, 3)); builder.add(rockingCurveTextField, cc.xy(3, 3)); return builder.getPanel(); }
From source file:com.jhash.oimadmin.ui.ConnectionDetails.java
License:Apache License
private JPanel buildComponent() { FormLayout eventHandlerFormLayout = new FormLayout( "3dlu, right:pref, 3dlu, pref:grow, 5dlu, right:pref, 3dlu, pref:grow, 5dlu", "5dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu,p, 3dlu, p, 3dlu, p, 3dlu, p,3dlu, p, 3dlu, p "); eventHandlerFormLayout.setColumnGroups(new int[][] { { 2, 6 } }); CellConstraints cellConstraint = new CellConstraints(); PanelBuilder builder = new PanelBuilder(eventHandlerFormLayout); builder.addLabel("Name", cellConstraint.xy(2, 2)); builder.add(nameLabel, cellConstraint.xy(4, 2)); builder.addLabel("OIM Home Directory", cellConstraint.xy(6, 2)); JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); oimHome.addFocusListener(new FocusListener() { boolean focusAfterShowFileChooser = false; @Override/*from w w w . jav a2 s . co m*/ public void focusGained(FocusEvent e) { if (focusAfterShowFileChooser) return; fileChooser.setSelectedFile(new File(oimHome.getText())); int returnedResult = fileChooser.showOpenDialog(ConnectionDetails.this); if (returnedResult == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); oimHome.setText(file.getAbsolutePath()); } } @Override public void focusLost(FocusEvent e) { focusAfterShowFileChooser = fileChooser.isShowing(); } }); builder.add(oimHome, cellConstraint.xy(8, 2)); builder.addSeparator("OIM Connection", cellConstraint.xyw(2, 4, 7)); builder.addLabel("Server Platform", cellConstraint.xy(2, 6)); builder.add(platform, cellConstraint.xy(4, 6)); builder.addLabel("OIM Server URL", cellConstraint.xy(6, 6)); builder.add(oimURL, cellConstraint.xy(8, 6)); builder.addLabel("User", cellConstraint.xy(2, 8)); builder.add(oimUser, cellConstraint.xy(4, 8)); builder.addLabel("Password", cellConstraint.xy(6, 8)); builder.add(oimUserPassword, cellConstraint.xy(8, 8)); builder.addSeparator("Weblogic Admin Server (JMX)", cellConstraint.xyw(2, 10, 7)); builder.addLabel("Protocol", cellConstraint.xy(2, 12)); builder.add(jmxProtocol, cellConstraint.xy(4, 12)); builder.addLabel("Host name", cellConstraint.xy(2, 14)); builder.add(jmxHostname, cellConstraint.xy(4, 14)); builder.addLabel("Port", cellConstraint.xy(6, 14)); builder.add(jmxPort, cellConstraint.xy(8, 14)); builder.addLabel("User", cellConstraint.xy(2, 16)); builder.add(jmxUser, cellConstraint.xy(4, 16)); builder.addLabel("Password", cellConstraint.xy(6, 16)); builder.add(jmxUserPassword, cellConstraint.xy(8, 16)); builder.addSeparator("Database", cellConstraint.xyw(2, 18, 5)); JButton testDBButton = JGComponentFactory.getCurrent().createButton("Test"); testDBButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Utils.executeAsyncOperation("Test Database Connection", new Runnable() { public void run() { logger.debug("Trying to test connection using configuration {}", connectionDetails); DBConnection connection = new DBConnection(); try { connection.initialize(connectionDetails); displayMessage("Database Connection", "Successfully connected to database", null); } catch (Exception exception) { displayMessage("Database Connection Failed", "Failed to create data base connection using details", exception); } try { connection.destroy(); } catch (Exception exception) { logger.warn("Failed to destroy new connection. Ignoring error", exception); } logger.debug("Tested connection"); } }); } }); builder.add(testDBButton, cellConstraint.xy(8, 18)); builder.addLabel("Driver Class", cellConstraint.xy(2, 20)); builder.add(dbJDBCDriverClass, cellConstraint.xy(4, 20)); builder.addLabel("JDBC URL", cellConstraint.xy(6, 20)); builder.add(dbJDBCURL, cellConstraint.xy(8, 20)); builder.addLabel("User", cellConstraint.xy(2, 22)); builder.add(dbUser, cellConstraint.xy(4, 22)); builder.addLabel("Password", cellConstraint.xy(6, 22)); builder.add(dbPassword, cellConstraint.xy(8, 22)); builder.add(dbAutoCommit, cellConstraint.xy(4, 24)); JButton saveButton = JGComponentFactory.getCurrent().createButton("&Save"); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logger.debug("Trying to save configuration {}", connectionDetails); connectionDetails.getConfig().saveConfiguration(connectionDetails, false); String connectionName = connectionDetails.getProperty(Connection.ATTR_CONN_NAME); if (isNewConnection) ConnectionTreeNode.ConnectionsRegisterUI.addNewNode(connectionName, connectionDetails.getConfig(), selectionTree, displayArea); destroy(); logger.debug("Saved configuration"); } }); JButton cancelButton = JGComponentFactory.getCurrent().createButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { destroy(); } }); builder.add(saveButton, cellConstraint.xy(4, 26)); builder.add(cancelButton, cellConstraint.xy(6, 26)); return builder.build(); }
From source file:com.jhash.oimadmin.ui.EventHandlerDetails.java
License:Apache License
private JPanel buildDetailScreen() { JPanel eventHandlerDetailPanel = new JPanel(new BorderLayout()); JideSplitPane splitPane = new JideSplitPane(JideSplitPane.VERTICAL_SPLIT); FormLayout eventHandlerFormLayout = new FormLayout( "right:pref, 3dlu, pref:grow, 7dlu, right:pref, 3dlu, pref:grow", "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu"); eventHandlerFormLayout.setColumnGroups(new int[][] { { 1, 5 } }); CellConstraints cellConstraint = new CellConstraints(); PanelBuilder builder = new PanelBuilder(eventHandlerFormLayout); builder.addLabel("Name", cellConstraint.xy(1, 1)); builder.add(nameLabel, cellConstraint.xy(3, 1)); switch (connection.getVersion()) { case OIM11GR2PS2: builder.addLabel("Custom", cellConstraint.xy(5, 1)); builder.add(customLabel, cellConstraint.xy(7, 1)); break;/*from w w w . j ava2s . c om*/ default: builder.addLabel("Sync", cellConstraint.xy(5, 1)); builder.add(sync, cellConstraint.xy(7, 1)); break; } builder.addLabel("Stage", cellConstraint.xy(1, 3)); builder.add(stageLabel, cellConstraint.xy(3, 3)); builder.addLabel("Order", cellConstraint.xy(5, 3)); builder.add(orderLabel, cellConstraint.xy(7, 3)); builder.addLabel("Conditional", cellConstraint.xy(1, 5)); builder.add(conditionalLabel, cellConstraint.xy(3, 5)); switch (connection.getVersion()) { case OIM11GR2PS2: builder.addLabel("Off Band", cellConstraint.xy(5, 5)); builder.add(offBandLabel, cellConstraint.xy(7, 5)); break; default: builder.addLabel("Exception", cellConstraint.xy(5, 5)); builder.add(exception, cellConstraint.xy(7, 5)); break; } builder.addLabel("Location", cellConstraint.xy(1, 7)); builder.add(locationLabel, cellConstraint.xyw(3, 7, 5)); builder.addLabel("Class", cellConstraint.xy(1, 9)); builder.add(classNameLabel, cellConstraint.xyw(3, 9, 5)); switch (connection.getVersion()) { case OIM11GR2PS2: break; default: builder.addLabel("Transactional", cellConstraint.xy(1, 11)); builder.add(transactional, cellConstraint.xyw(3, 11, 5)); break; } splitPane.add(new JideScrollPane(table), 0); splitPane.add(builder.getPanel(), 1); splitPane.setProportionalLayout(true); splitPane.setProportions(new double[] { 0.6 }); eventHandlerDetailPanel.add(splitPane, BorderLayout.CENTER); logger.debug("Returning the developed component {}", eventHandlerDetailPanel); return eventHandlerDetailPanel; }
From source file:com.jhash.oimadmin.ui.EventHandlerUI.java
License:Apache License
public JPanel buildEventHandlerUI() { logger.debug("Trying to create New Event Handler screen"); JPanel newEventHandlerPanel = new JPanel(new BorderLayout()); FormLayout eventHandlerFormLayout = new FormLayout( "right:pref, 3dlu, pref, 7dlu, right:pref, 3dlu, pref:grow", "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu"); eventHandlerFormLayout.setColumnGroups(new int[][] { { 1, 5 } }); CellConstraints cellConstraint = new CellConstraints(); PanelBuilder builder = new PanelBuilder(eventHandlerFormLayout); builder.addLabel("Name", cellConstraint.xy(1, 1)); builder.add(nameField, cellConstraint.xy(3, 1)); builder.addLabel("Type", cellConstraint.xy(5, 1)); builder.add(eventHandlerTypes, cellConstraint.xy(7, 1)); builder.addLabel("Entity Type", cellConstraint.xy(1, 3)); builder.add(entityType, cellConstraint.xy(3, 3)); builder.addLabel("Operation", cellConstraint.xy(5, 3)); builder.add(operationType, cellConstraint.xy(7, 3)); builder.addLabel("Order", cellConstraint.xy(1, 5)); builder.add(orderField, cellConstraint.xy(3, 5)); builder.addLabel("Type of orchestration", cellConstraint.xy(5, 5)); builder.add(orcTargetLabel, cellConstraint.xy(7, 5)); builder.addLabel("Synchronous ?", cellConstraint.xy(1, 7)); builder.add(syncCheckBox, cellConstraint.xy(3, 7)); builder.addLabel("Internal Transaction ?", cellConstraint.xy(1, 9)); builder.add(txCheckBox, cellConstraint.xy(3, 9)); builder.addLabel("Stage", cellConstraint.xy(5, 7)); builder.add(stageComboBox, cellConstraint.xy(7, 7)); builder.addLabel("Class", cellConstraint.xy(1, 11)); builder.add(classNameText, cellConstraint.xyw(3, 11, 5)); // builder.addLabel("MDS Location", cellConstraint.xy(1, 13)); // builder.add(new JGTextField("/custom/eventhandler.xml"), // cellConstraint.xyw(3, 13, 5)); JideTabbedPane newEventHandlerControlPane = new JideTabbedPane(); newEventHandlerControlPane.setTabShape(JideTabbedPane.SHAPE_ROUNDED_FLAT); newEventHandlerControlPane.setColorTheme(JideTabbedPane.COLOR_THEME_OFFICE2003); newEventHandlerControlPane.setTabResizeMode(JideTabbedPane.RESIZE_MODE_NONE); newEventHandlerControlPane.setUseDefaultShowCloseButtonOnTab(false); newEventHandlerControlPane.setBoldActiveTab(true); newEventHandlerControlPane.setShowCloseButtonOnTab(true); newEventHandlerControlPane.addTab(javaCompiler.getName(), javaCompiler.getComponent()); newEventHandlerControlPane.addTab("Configure", configurationPanel.getComponent()); newEventHandlerControlPane.addTab("Package", packagePanel.getComponent()); JideSplitPane eventHandlerSplitPane = new JideSplitPane(JideSplitPane.VERTICAL_SPLIT); eventHandlerSplitPane.add(builder.build(), 0); eventHandlerSplitPane.add(newEventHandlerControlPane, 1); eventHandlerSplitPane.setProportionalLayout(true); eventHandlerSplitPane.setProportions(new double[] { 0.3 }); newEventHandlerPanel.add(eventHandlerSplitPane); logger.debug("Completed creation of New Event Handler screen"); return newEventHandlerPanel; }
From source file:com.lyndir.lhunath.opal.gui.template.shade.AbstractUi.java
License:Apache License
/** * Override this method if you have stuff that needs to be initialized before or after the UI building.<br> <br> Don't forget to call * super.buildUi() as well./*from w w w .j a v a 2s . c o m*/ */ protected void buildUi() { /* Container. */ contentPane = new JPanel(new BorderLayout()); contentPane.add(contentPanel = PaintPanel.gradientPanel()); FormLayout layout = new FormLayout("0dlu, 0dlu, 0dlu:g, 0dlu, r:p", "t:m, f:0dlu:g, 4dlu, m"); DefaultFormBuilder builder = new DefaultFormBuilder(layout, contentPanel); layout.setColumnGroups(new int[][] { { 1, 5 } }); builder.setDefaultDialogBorder(); /* Prepare the look and feel. */ execute(BasicRequest.THEME, false); /* Header */ logo = new JLabel(); logo.setHorizontalAlignment(SwingConstants.CENTER); logo.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) BaseConfig.dump(); else toggleOverlay(); } }); titleBar = new JPanel(new FlowLayout(FlowLayout.RIGHT)); titleBar.setLayout(new BoxLayout(titleBar, BoxLayout.X_AXIS)); titleBar.setOpaque(false); windowedTitleButton = new JButton(UIUtils.getIcon("windowed-sss.png")); windowedTitleButton.setActionCommand("windowed"); windowedTitleButton.addActionListener(this); windowedTitleButton.setBorderPainted(false); windowedTitleButton.setContentAreaFilled(false); fullscreenTitleButton = new JButton(UIUtils.getIcon("fullscreen-sss.png")); fullscreenTitleButton.setActionCommand("fullscreen"); fullscreenTitleButton.addActionListener(this); fullscreenTitleButton.setBorderPainted(false); fullscreenTitleButton.setContentAreaFilled(false); closeTitleButton = new JButton(UIUtils.getIcon("close-sss.png")); closeTitleButton.setActionCommand("close"); closeTitleButton.addActionListener(this); closeTitleButton.setBorderPainted(false); closeTitleButton.setContentAreaFilled(false); titleBar.add(closeTitleButton); builder.nextColumn(2); builder.append(logo); builder.append(titleBar); /* Panels */ window = new SimpleInternalFrame(null, new JToolBar(), null, true); window.setSelected(true); window.setOpaque(false); /* Tabs */ List<Tab> tabs = appendCustomTabs(); tabs.addAll(buildTabs()); for (Plugin plugin : plugins) { List<? extends Tab> pluginTabs = plugin.buildTabs(); if (pluginTabs != null) tabs.addAll(pluginTabs); } for (Tab tab : tabs) tab.setAction(addPanelButton(tab)); if (showingTab == null) showingTab = tabs.get(0); execute(BasicRequest.PANEL, false); builder.append(window, 5); builder.nextLine(2); progress = new JProgressBar() { @Override public void repaint(long tm, int x, int y, int width, int height) { setOpaque(getValue() != 0 || isIndeterminate()); if (getParent() != null) getParent().repaint(tm, x, y, width, height); super.repaint(tm, x, y, width, height); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); if (isOpaque()) { ((Graphics2D) g).setPaint(getBackground()); g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); } } }; progress.setString(""); progress.setStringPainted(true); progress.setBorderPainted(false); progress.setBackground(UIUtils.setAlpha(progress.getBackground(), 100)); for (int level = 0; level <= 5; ++level) { messageStack.add(new Stack<String>()); progressStack.add(0d); } builder.append(progress, 5); /* Frame. */ execute(BasicRequest.LOGO, false); execute(BasicRequest.FULLSCREEN, false); }
From source file:com.lyndir.lhunath.opal.gui.template.shade.AbstractUi.java
License:Apache License
private JComponent getOperationsPane() { FormLayout layout = new FormLayout("10dlu, 15dlu, p:g, 10dlu, p:g, 15dlu, 10dlu", //$NON-NLS-1$ "0dlu, f:1dlu:g, 5dlu, p, 10dlu"); //$NON-NLS-1$ layout.setColumnGroups(new int[][] { { 3, 5 } }); JButton button;/* www . j av a 2 s.c om*/ PanelBuilder builder = new PanelBuilder(layout, new ScrollPanel()); CellConstraints constraints = new CellConstraints(); log = new JEditorPane("text/html", ""); log.setOpaque(false); log.setEditable(false); JScrollPane pane = new JScrollPane(log); pane.setBorder(Borders.EMPTY_BORDER); pane.setOpaque(false); pane.getViewport().setOpaque(false); builder.add(pane, constraints.xyw(2, 2, 5)); button = new JButton(Locale.explain("ui.clearLog"), UIUtils.getIcon("clear-s.png")); //$NON-NLS-1$ //$NON-NLS-2$ button.setHorizontalTextPosition(SwingConstants.CENTER); button.setVerticalTextPosition(SwingConstants.BOTTOM); button.setActionCommand("logClear"); //$NON-NLS-1$ button.addActionListener(this); builder.add(button, constraints.xy(3, 4)); button = new JButton(Locale.explain("ui.saveLog"), UIUtils.getIcon("save-s.png")); //$NON-NLS-1$ //$NON-NLS-2$ button.setHorizontalTextPosition(SwingConstants.CENTER); button.setVerticalTextPosition(SwingConstants.BOTTOM); button.setActionCommand("logSave"); //$NON-NLS-1$ button.addActionListener(this); builder.add(button, constraints.xy(5, 4)); builder.getPanel().setOpaque(false); return builder.getPanel(); }
From source file:com.lyndir.lhunath.opal.gui.template.shade.AbstractUi.java
License:Apache License
private JComponent getLicensePane() { FormLayout layout = new FormLayout("10dlu, 15dlu, p:g, 10dlu, p:g, 15dlu, 10dlu", //$NON-NLS-1$ "0dlu, f:1dlu:g, 5dlu, p, 10dlu"); //$NON-NLS-1$ layout.setColumnGroups(new int[][] { { 3, 5 } }); String doc = ""; JButton button;/* w ww. ja v a 2 s . c o m*/ PanelBuilder builder = new PanelBuilder(layout, new ScrollPanel()); CellConstraints constraints = new CellConstraints(); try { doc = getLicense(); } catch (IOException e) { logger.err(e, "err.readLicense"); } JEditorPane changelog = new JEditorPane("text/html", doc); //$NON-NLS-1$ changelog.setOpaque(false); changelog.setEditable(false); changelog.setFont(Font.decode("Monospaced-15")); //$NON-NLS-1$ JScrollPane pane = new JScrollPane(changelog); pane.setBorder(Borders.EMPTY_BORDER); pane.setOpaque(false); pane.getViewport().setOpaque(false); builder.add(pane, constraints.xyw(2, 2, 5)); button = new JButton(Locale.explain("ui.reportOffense"), UIUtils.getIcon("problem-s.png")); //$NON-NLS-1$ //$NON-NLS-2$ button.setHorizontalTextPosition(SwingConstants.CENTER); button.setVerticalTextPosition(SwingConstants.BOTTOM); button.setActionCommand("reportOffense"); //$NON-NLS-1$ button.addActionListener(this); builder.add(new ToolTip(Locale.explain("ui.reportOffenceTip"), button), constraints.xyw(3, 4, 3)); builder.getPanel().setOpaque(false); return builder.getPanel(); }
From source file:com.lyndir.lhunath.opal.gui.template.shade.AbstractUi.java
License:Apache License
private JComponent getDevelopmentPane() { FormLayout layout = new FormLayout("10dlu, 15dlu, p:g, 10dlu, p:g, 15dlu, 10dlu", //$NON-NLS-1$ "0dlu, f:1dlu:g, 5dlu, p, 10dlu"); //$NON-NLS-1$ layout.setColumnGroups(new int[][] { { 3, 5 } }); JButton button;// www . j a va 2s .co m PanelBuilder builder = new PanelBuilder(layout, new ScrollPanel()); CellConstraints constraints = new CellConstraints(); builder.add(getDevelopmentComponent(), constraints.xyw(2, 2, 5)); button = new JButton(Locale.explain("ui.reportProblem"), UIUtils.getIcon("problem-s.png")); //$NON-NLS-1$ //$NON-NLS-2$ button.setHorizontalTextPosition(SwingConstants.CENTER); button.setVerticalTextPosition(SwingConstants.BOTTOM); button.setActionCommand("reportIssue"); //$NON-NLS-1$ button.addActionListener(this); builder.add(new ToolTip(Locale.explain("ui.reportProblemTip"), button), constraints.xy(3, 4)); button = new JButton(Locale.explain("ui.toggleConsole"), UIUtils.getIcon("terminal-s.png")); //$NON-NLS-1$ //$NON-NLS-2$ button.setHorizontalTextPosition(SwingConstants.CENTER); button.setVerticalTextPosition(SwingConstants.BOTTOM); button.setActionCommand("toggleConsole"); //$NON-NLS-1$ button.addActionListener(this); builder.add(new ToolTip(Locale.explain("ui.toggleConsoleTip"), button), constraints.xy(5, 4)); builder.getPanel().setOpaque(false); return builder.getPanel(); }
From source file:com.tecnoven.notify.ui.NotifyBulkNotificationDispatch.java
private void buildForm() { FormLayout layout = new FormLayout( "max(50dlu;min), 3dlu,right:pref, 3dlu,fill:pref:grow, 7dlu, fill:pref:grow, 3dlu, 50dlu, max(90dlu;min)", // columns "p, 3dlu, p, 3dlu, p, 3dlu,p, 3dlu, max(50dlu;min), 9dlu, p, 9dlu, max(150dlu;min), 10dlu, p, 9dlu, 9dlu , 9dlu, p , 9dlu, p"); // rows layout.setColumnGroups(new int[][] { { 3 }, { 5, 7 } }); PanelBuilder builder = new PanelBuilder(layout); builder.setDefaultDialogBorder();//from w ww . ja v a 2 s . co m CellConstraints cc = new CellConstraints(); builder.addSeparator("Carga Masiva de Datos", cc.xyw(1, 1, 10)); builder.addLabel(templateLabel.getText(), cc.xy(3, 3)); builder.add(templateText, cc.xyw(5, 3, 3)); builder.add(catalogueButton, cc.xy(9, 3)); builder.addLabel(fileLabel.getText(), cc.xy(3, 5)); builder.add(fileSelectedText, cc.xyw(5, 5, 3)); builder.add(searchButton, cc.xy(9, 5)); if (LicenseManager.getInstance().getLicense().getListSupportedServices().length > 1) { builder.addLabel("Tipo de Notificaci\u00f3n", cc.xy(3, 7)); builder.add(typeList, cc.xyw(5, 7, 3)); } builder.addSeparator("Resultado", cc.xyw(1, 9, 10)); builder.add(jScrollPane1, cc.xywh(5, 10, 3, 4)); builder.addSeparator("", cc.xyw(1, 19, 10)); builder.add(this.executeProcess, cc.xyw(5, 21, 3)); JPanel content = builder.getPanel(); this.removeAll(); this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); this.add(content); }
From source file:de.htwk_leipzig.naoteam.motion.editor.gui.panel.NaoPanel.java
License:Open Source License
/** * Layout the components from the panel//w w w . j av a 2 s . c o m */ private JPanel buildPanel() { btnSetStiffness = new JToggleButton("Set Stiff"); btnSetStiffness.setMnemonic(KeyEvent.VK_SPACE); btnSetStiffness.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { INaoCommunication comm = MainApplication.comm; try { if (btnSetStiffness.isSelected()) { NaoFrame frame = null; frame = new NaoFrame(comm.getBodyAngles()); LinearTransformationStrategy strg = new LinearTransformationStrategy(5); frame = frame.setTransformationStrategy(strg); frame.moveSlowlyTo(comm); for (Actuator ac : Actuator.values()) { comm.setJointStiffness(ac.position, 0.1f, 0); } Thread.sleep(100); for (Actuator ac : Actuator.values()) { comm.setJointStiffness(ac.position, NaoConstants.STIFF_MAX, 0); } } else { /* only set selected things */ for (BodyPart bodyPart : BodyPart.values()) { /* if not selected to nothing */ Object o = bodyPart.action.getValue(Action.SELECTED_KEY); if (!(o instanceof Boolean) || (Boolean) o == Boolean.FALSE) { continue; } for (Actuator a : bodyPart.dependendActuators) { MainApplication.comm.setJointStiffness(a.position, NaoConstants.STIFF_MIN, 0); } /* set dependent parts */ for (BodyPart part : bodyPart.dependendParts) { for (Actuator a : part.dependendActuators) { MainApplication.comm.setJointStiffness(a.position, NaoConstants.STIFF_MIN, 0); } } } } } catch (Exception e2) { e2.printStackTrace(); } } }); LayoutMap.getRoot().columnPut("btn", "fill:[pref,50dlu]"); LayoutMap.getRoot().columnPut("txt", "fill:[pref,44dlu]"); LayoutMap.getRoot().columnPut("space", "5dlu"); final FormLayout mainLayout = new FormLayout( "$btn, $lcgap, right:pref, $lcgap, $txt, $space, " + "$btn, $lcgap, right:pref, $lcgap, $txt, ", "fill:pref, $lgap," + /* part button */ "fill:pref, $lgap, fill:pref, 15dlu, " + "fill:pref, $lgap," + /* part button */ "fill:pref, $lgap, fill:pref, 10dlu, " + "fill:pref, $lgap, fill:pref, 15dlu, " + "fill:pref, $lgap," + /* part button */ "fill:pref, $lgap, fill:pref, $lgap, fill:pref, 10dlu, " + "fill:pref, 10dlu, " + "fill:pref, $lgap, fill:pref"); final int LCOL_BTN = 1; final int LCOL_LBL = 3; final int LCOL_TXT = 5; final int RCOL_BTN = 7; final int RCOL_LBL = 9; final int RCOL_TXT = 11; mainLayout.setColumnGroups( new int[][] { { LCOL_BTN, RCOL_BTN }, { LCOL_LBL, RCOL_LBL }, { LCOL_TXT, RCOL_TXT }, }); final PanelBuilder builder = new PanelBuilder(mainLayout); builder.setBorder(NaoBorderFactory.getInnerFrameBorder()); int row = 1; /* Head */ builder.add(buttons.get(BodyPart.Body), CC.xywh(LCOL_BTN, row, 11, 1)); row++; /* empty row */ row++; builder.add(buttons.get(BodyPart.Head), CC.xywh(LCOL_BTN, row, 1, 3)); builder.addLabel(Actuator.HeadPitch.paramName, CC.xy(LCOL_LBL, row)); builder.add(textFields.get(Actuator.HeadPitch), CC.xy(LCOL_TXT, row)); builder.add(btnSetStiffness, CC.xywh(RCOL_BTN, row, 5, 3)); row++; /*gap */ row++; builder.addLabel(Actuator.HeadYaw.paramName, CC.xy(LCOL_LBL, row)); builder.add(textFields.get(Actuator.HeadYaw), CC.xy(LCOL_TXT, row)); /* shoulder */ row++; /*gap*/ row++; builder.add(buttons.get(BodyPart.LArm), CC.xywh(LCOL_BTN, row, 5, 1)); builder.add(buttons.get(BodyPart.RArm), CC.xywh(RCOL_BTN, row, 5, 1)); row++; /*gap*/ row++; builder.add(buttons.get(BodyPart.LShoulder), CC.xywh(LCOL_BTN, row, 1, 3)); builder.add(buttons.get(BodyPart.RShoulder), CC.xywh(RCOL_BTN, row, 1, 3)); builder.addLabel(Actuator.LShoulderPitch.paramName, CC.xy(LCOL_LBL, row)); builder.addLabel(Actuator.RShoulderPitch.paramName, CC.xy(RCOL_LBL, row)); builder.add(textFields.get(Actuator.LShoulderPitch), CC.xy(LCOL_TXT, row)); builder.add(textFields.get(Actuator.RShoulderPitch), CC.xy(RCOL_TXT, row)); row++; /*gap */ row++; builder.addLabel(Actuator.LShoulderRoll.paramName, CC.xy(LCOL_LBL, row)); builder.addLabel(Actuator.RShoulderRoll.paramName, CC.xy(RCOL_LBL, row)); builder.add(textFields.get(Actuator.LShoulderRoll), CC.xy(LCOL_TXT, row)); builder.add(textFields.get(Actuator.RShoulderRoll), CC.xy(RCOL_TXT, row)); /* Elbow */ row++; /* empty row */ row++; builder.add(buttons.get(BodyPart.LElbow), CC.xywh(LCOL_BTN, row, 1, 3)); builder.add(buttons.get(BodyPart.RElbow), CC.xywh(RCOL_BTN, row, 1, 3)); builder.addLabel(Actuator.LElbowYaw.paramName, CC.xy(LCOL_LBL, row)); builder.addLabel(Actuator.RElbowYaw.paramName, CC.xy(RCOL_LBL, row)); builder.add(textFields.get(Actuator.LElbowYaw), CC.xy(LCOL_TXT, row)); builder.add(textFields.get(Actuator.RElbowYaw), CC.xy(RCOL_TXT, row)); row++; /*gap */ row++; builder.addLabel(Actuator.LElbowRoll.paramName, CC.xy(LCOL_LBL, row)); builder.addLabel(Actuator.RElbowRoll.paramName, CC.xy(RCOL_LBL, row)); builder.add(textFields.get(Actuator.LElbowRoll), CC.xy(LCOL_TXT, row)); builder.add(textFields.get(Actuator.RElbowRoll), CC.xy(RCOL_TXT, row)); /* hip */ row++; /* empty row */ row++; builder.add(buttons.get(BodyPart.LLeg), CC.xywh(LCOL_BTN, row, 5, 1)); builder.add(buttons.get(BodyPart.RLeg), CC.xywh(RCOL_BTN, row, 5, 1)); row++; /*gap*/ row++; builder.add(buttons.get(BodyPart.LHip), CC.xywh(LCOL_BTN, row, 1, 5)); builder.add(buttons.get(BodyPart.RHip), CC.xywh(RCOL_BTN, row, 1, 5)); builder.addLabel(Actuator.LHipPitch.paramName, CC.xy(LCOL_LBL, row)); builder.addLabel(Actuator.RHipPitch.paramName, CC.xy(RCOL_LBL, row)); builder.add(textFields.get(Actuator.LHipPitch), CC.xy(LCOL_TXT, row)); builder.add(textFields.get(Actuator.RHipPitch), CC.xy(RCOL_TXT, row)); row++; /*gap*/ row++; builder.addLabel(Actuator.LHipRoll.paramName, CC.xy(LCOL_LBL, row)); builder.addLabel(Actuator.RHipRoll.paramName, CC.xy(RCOL_LBL, row)); builder.add(textFields.get(Actuator.LHipRoll), CC.xy(LCOL_TXT, row)); builder.add(textFields.get(Actuator.RHipRoll), CC.xy(RCOL_TXT, row)); row++; /*gap*/ row++; builder.addLabel(Actuator.LHipYawPitch.paramName, CC.xy(LCOL_LBL, row)); builder.addLabel(Actuator.RHipYawPitch.paramName, CC.xy(RCOL_LBL, row)); builder.add(textFields.get(Actuator.LHipYawPitch), CC.xy(LCOL_TXT, row)); builder.add(textFields.get(Actuator.RHipYawPitch), CC.xy(RCOL_TXT, row)); /* knee */ row++; /* empty row */ row++; builder.add(buttons.get(BodyPart.LKnee), CC.xywh(LCOL_BTN, row, 1, 1)); builder.add(buttons.get(BodyPart.RKnee), CC.xywh(RCOL_BTN, row, 1, 1)); builder.addLabel(Actuator.LKneePitch.paramName, CC.xy(LCOL_LBL, row)); builder.addLabel(Actuator.RKneePitch.paramName, CC.xy(RCOL_LBL, row)); builder.add(textFields.get(Actuator.LKneePitch), CC.xy(LCOL_TXT, row)); builder.add(textFields.get(Actuator.RKneePitch), CC.xy(RCOL_TXT, row)); /* Ankle */ row++; /* empty row */ row++; builder.add(buttons.get(BodyPart.LAnkle), CC.xywh(LCOL_BTN, row, 1, 3)); builder.add(buttons.get(BodyPart.RAnkle), CC.xywh(RCOL_BTN, row, 1, 3)); builder.addLabel(Actuator.LAnklePitch.paramName, CC.xy(LCOL_LBL, row)); builder.addLabel(Actuator.RAnklePitch.paramName, CC.xy(RCOL_LBL, row)); builder.add(textFields.get(Actuator.LAnklePitch), CC.xy(LCOL_TXT, row)); builder.add(textFields.get(Actuator.RAnklePitch), CC.xy(RCOL_TXT, row)); row++; /*gap */ row++; builder.addLabel(Actuator.LAnkleRoll.paramName, CC.xy(LCOL_LBL, row)); builder.addLabel(Actuator.RAnkleRoll.paramName, CC.xy(RCOL_LBL, row)); builder.add(textFields.get(Actuator.LAnkleRoll), CC.xy(LCOL_TXT, row)); builder.add(textFields.get(Actuator.RAnkleRoll), CC.xy(RCOL_TXT, row)); return builder.getPanel(); }