List of usage examples for com.jgoodies.forms.layout CellConstraints xyw
public CellConstraints xyw(int col, int row, int colSpan)
Examples:
cc.xyw(1, 3, 7); cc.xyw(1, 3, 2);
From source file:jmemorize.gui.swing.panels.LearnSettingPanels.java
License:Open Source License
public JPanel buildSchedulePanel() { // prepare widgets m_schedulePresetsComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { onPresetScheduleSelected();//www. j a va 2s.c om } }); // build panel FormLayout layout = new FormLayout("p, 20dlu:grow, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, " + // columns //$NON-NLS-1$ "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p", //$NON-NLS-1$ "p, 15dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, " + // rows //$NON-NLS-1$ "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu"); //$NON-NLS-1$ CellConstraints cc = new CellConstraints(); DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.setDefaultDialogBorder(); builder.addLabel(Localization.get(LC.LEARN_SETTINGS_PRESETS), cc.xy(1, 1)); builder.add(m_schedulePresetsComboBox, cc.xyw(3, 1, 11)); for (int i = 0; i < LearnSettings.SCHEDULE_LEVELS; i++) { addScheduleRow(builder, cc, i); } return builder.getPanel(); }
From source file:jmemorize.gui.swing.panels.LearnSettingPanels.java
License:Open Source License
public JPanel buildFixedDueTimePanel() { Date date = new Date(); SpinnerDateModel model = new SpinnerDateModel(date, null, null, Calendar.HOUR); m_fixedExpirationTimeSpinner.setModel(model); String pattern = "h:mm a"; if (Localization.SHORT_TIME_FORMATER instanceof SimpleDateFormat) { SimpleDateFormat formatter = (SimpleDateFormat) Localization.SHORT_TIME_FORMATER; pattern = formatter.toPattern(); }//from ww w .j a v a 2s. c o m JSpinner.DateEditor de = new JSpinner.DateEditor(m_fixedExpirationTimeSpinner, pattern); m_fixedExpirationTimeSpinner.setEditor(de); m_fixedExpirationTimeCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateFixedDueTimeSpinner(); } }); // build panel FormLayout layout = new FormLayout("18dlu, 70dlu, left:d:grow", // columns //$NON-NLS-1$ "p, 3dlu, p"); // rows //$NON-NLS-1$ CellConstraints cc = new CellConstraints(); DefaultFormBuilder builder = new DefaultFormBuilder(layout); builder.setDefaultDialogBorder(); builder.add(m_fixedExpirationTimeCheckBox, cc.xyw(1, 1, 3)); builder.add(m_fixedExpirationTimeSpinner, cc.xyw(2, 3, 1)); return builder.getPanel(); }
From source file:knotifyplugin.KNotifySettingsTab.java
License:Open Source License
/** * Create the GUI/*from w w w .jav a 2s .c o m*/ * @return Panel */ public JPanel createSettingsPanel() { if (!mInitialized) { JPanel panel = new JPanel(new BorderLayout()); panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg("notinit", "Error, System not init")), BorderLayout.NORTH); return panel; } EnhancedPanelBuilder panel = new EnhancedPanelBuilder( FormFactory.RELATED_GAP_COLSPEC.encode() + ", pref:grow, " + FormFactory.RELATED_GAP_COLSPEC.encode() + "," + FormFactory.PREF_COLSPEC.encode()); CellConstraints cc = new CellConstraints(); panel.addRow(); panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg("help", "Help Text")), cc.xyw(2, panel.getRow(), 3)); panel.addParagraph(mLocalizer.msg("title", "Title")); mTitle = new ParamInputField(mSettings.getTitle()); panel.addGrowingRow(); panel.add(mTitle, cc.xyw(2, panel.getRow(), 3)); panel.addParagraph(mLocalizer.msg("description", "Description")); mDescription = new ParamInputField(mSettings.getDescription()); panel.addGrowingRow(); panel.add(mDescription, cc.xyw(2, panel.getRow(), 3)); JButton testGrowl = new JButton(mLocalizer.msg("testKNotify", "Test KNotify")); testGrowl.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mPlugin.sendToKNotify(mTitle.getText(), mDescription.getText(), Plugin.getPluginManager().getExampleProgram()); } }); panel.addRow(); panel.add(testGrowl, cc.xy(4, 12)); return panel.getPanel(); }
From source file:listviewplugin.ListViewDialog.java
License:Open Source License
/** * Creates the GUI/*from ww w .j a va2 s.c om*/ */ private void createGUI() { JPanel content = (JPanel) this.getContentPane(); content.setLayout(new BorderLayout()); content.setBorder(UiUtilities.DIALOG_BORDER); Vector<String> data = new Vector<String>(); data.add(TIMETEXT[0]); data.add(TIMETEXT[1]); data.add(TIMETEXT[2]); TimeFormatter formatter = new TimeFormatter(); for (int time : mTimes) { int h = time / 60; int m = time % 60; StringBuilder builder = new StringBuilder(); builder.append(mLocalizer.msg("at", "at")); builder.append(' '); builder.append(formatter.formatTime(h, m)); data.add(builder.toString()); } data.add(mLocalizer.msg("configureTimes", "Configure Times")); mBox = new JComboBox(data); mBox.addActionListener(new ActionListener() { private int lastSelected = 0; public void actionPerformed(ActionEvent e) { if (mBox.getSelectedIndex() == mBox.getItemCount() - 1) { mBox.setSelectedIndex(lastSelected); Plugin.getPluginManager().showSettings(SettingsItem.TIMEBUTTONS); } else { lastSelected = mDate.getSelectedIndex(); int time = calcTimeForSelection(mBox.getSelectedIndex()); generateList(new Date(), time); } } }); ButtonGroup group = new ButtonGroup(); group.add(mRuns); group.add(mOn); JPanel datetimeselect = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); Vector<Date> dates = new Vector<Date>(); Date currentDate = Date.getCurrentDate(); for (int i = 0; i < 14; i++) { dates.add(currentDate.addDays(i)); } mDate = new JComboBox(dates); datetimeselect.add(mDate); datetimeselect.add(new JLabel(" " + mLocalizer.msg("at", "at") + " ")); JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(mTimeSpinner, Settings.getTimePattern()); mTimeSpinner.setEditor(dateEditor); CaretPositionCorrector.createCorrector(dateEditor.getTextField(), new char[] { ':' }, -1); datetimeselect.add(mTimeSpinner); Vector<String> filters = new Vector<String>(); filters.add(mLocalizer.msg("filterAll", "all channels")); for (String filterName : FilterComponentList.getInstance().getChannelFilterNames()) { filters.add(filterName); } filters.add(mLocalizer.ellipsisMsg("filterDefine", "define filter")); mChannels = new JComboBox(filters); datetimeselect.add(new JLabel(" ")); datetimeselect.add(mChannels); // Event-Handler mRuns.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { refreshView(); } }); mOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { refreshView(); } }); mDate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { refreshView(); } }); mTimeSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { refreshView(); } }); mChannels.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // user defined selection if (mChannels.getSelectedIndex() == mChannels.getItemCount() - 1) { EditFilterComponentDlg dlg = new EditFilterComponentDlg(null, null, ChannelFilterComponent.class); FilterComponent rule = dlg.getFilterComponent(); if (rule == null) { return; } if (!(rule instanceof ChannelFilterComponent)) { return; } FilterComponentList.getInstance().add(rule); FilterComponentList.getInstance().store(); String filterName = rule.getName(); mChannels.removeAllItems(); mChannels.addItem(mLocalizer.msg("filterAll", "all channels")); for (String channel : FilterComponentList.getInstance().getChannelFilterNames()) { mChannels.addItem(channel); } mChannels.addItem(mLocalizer.ellipsisMsg("filterDefine", "define filter")); mChannels.setSelectedItem(filterName); } mModel.removeAllRows(); refreshView(); } }); mRuns.setSelected(true); mDate.setEnabled(false); mTimeSpinner.setEnabled(false); JLabel filterLabel = new JLabel("Filter:"); filterLabel.setHorizontalAlignment(SwingConstants.RIGHT); mFilterBox = new JComboBox(Plugin.getPluginManager().getFilterManager().getAvailableFilters()); mFilterBox.setSelectedItem(Plugin.getPluginManager().getFilterManager().getCurrentFilter()); mFilterBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { mCurrentFilter = (ProgramFilter) e.getItem(); refreshView(); } } }); // Upper Panel JPanel topPanel = new JPanel( new FormLayout("pref, 3dlu, pref, 15dlu, pref, 3dlu, pref, 3dlu, pref", "pref, 1dlu, pref, 3dlu")); CellConstraints cc = new CellConstraints(); topPanel.add(mRuns, cc.xy(1, 1)); topPanel.add(mBox, cc.xy(3, 1)); topPanel.add(mOn, cc.xy(5, 1)); topPanel.add(datetimeselect, cc.xy(7, 1)); topPanel.add(filterLabel, cc.xy(1, 3)); topPanel.add(mFilterBox, cc.xyw(3, 3, 5)); content.add(topPanel, BorderLayout.NORTH); // Rest of the GUI mProgramTable = new ListTable(mModel); mProgramTable.getTableHeader().setReorderingAllowed(false); mProgramTable.getTableHeader().setResizingAllowed(false); mProgramTable.setToolTipText(""); mProgramTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { if (evt.isPopupTrigger()) { showPopup(evt); } } @Override public void mouseReleased(MouseEvent evt) { if (evt.isPopupTrigger()) { showPopup(evt); } } @Override public void mouseClicked(MouseEvent e) { mouseClickedOnTable(e); } }); // Dispatch the KeyEvent to the RootPane for Closing the Dialog. // Needed for Java 1.4. mProgramTable.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { mProgramTable.getRootPane().dispatchEvent(e); } }); setTableColumProperties(); JScrollPane scroll = new JScrollPane(mProgramTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); content.add(scroll, BorderLayout.CENTER); JPanel buttonPn = new JPanel(new BorderLayout()); buttonPn.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); content.add(buttonPn, BorderLayout.SOUTH); JButton closeButton = new JButton(Localizer.getLocalization(Localizer.I18N_CLOSE)); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { dispose(); } }); JPanel p = new JPanel(new FormLayout("pref,5dlu,pref,5dlu,pref", "pref")); JButton settings = new JButton(TVBrowserIcons.preferences(TVBrowserIcons.SIZE_SMALL)); settings.setToolTipText(mLocalizer.msg("settings", "Open settings")); settings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { close(); Plugin.getPluginManager().showSettings(ListViewPlugin.getInstance()); } }); final JCheckBox showAtStartup = new JCheckBox(mLocalizer.msg("showAtStart", "Show at start")); showAtStartup.setSelected(mSettings.getProperty("showAtStartup", "false").equals("true")); showAtStartup.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (showAtStartup.isSelected()) { mSettings.setProperty("showAtStartup", "true"); } else { mSettings.setProperty("showAtStartup", "false"); } } }); p.add(settings, cc.xy(1, 1)); p.add(showAtStartup, cc.xy(3, 1)); buttonPn.add(p, BorderLayout.WEST); buttonPn.add(closeButton, BorderLayout.EAST); getRootPane().setDefaultButton(closeButton); }
From source file:loci.ome.editor.ExportDialog.java
License:Open Source License
/** Set up the GUI, etc. Can't directly instatiate this. */ private ExportDialog(Frame frame, Component locationComp, String labelText, String title, Object[] data, Object[] initialValue, String longValue) { super(frame, title, true); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); final JButton exportButton = new JButton("Export Selected"); exportButton.setActionCommand("Set"); exportButton.addActionListener(this); exportButton.setToolTipText("Export the selected note(s)."); final JButton exportAllButton = new JButton("Export All"); exportAllButton.setActionCommand("SetAll"); exportAllButton.addActionListener(this); exportAllButton.setToolTipText("Export all notes."); getRootPane().setDefaultButton(exportAllButton); list = new JList(data) { //Subclass JList to workaround bug 4832765, which can cause the //scroll pane to not let the user easily scroll up to the beginning //of the list. An alternative would be to set the unitIncrement //of the JScrollBar to a fixed value. You wouldn't get the nice //aligned scrolling, but it should work. public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { int row; if (orientation == SwingConstants.VERTICAL && direction < 0 && (row = getFirstVisibleIndex()) != -1) { Rectangle r = getCellBounds(row, row); if ((r.y == visibleRect.y) && (row != 0)) { Point loc = r.getLocation(); loc.y--;//from w w w .ja va 2 s. c om int prevIndex = locationToIndex(loc); Rectangle prevR = getCellBounds(prevIndex, prevIndex); if (prevR == null || prevR.y >= r.y) { return 0; } return prevR.height; } } return super.getScrollableUnitIncrement(visibleRect, orientation, direction); } }; list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); if (longValue != null) { list.setPrototypeCellValue(longValue); //get extra space } list.setLayoutOrientation(JList.VERTICAL); list.setVisibleRowCount(-1); JScrollPane listScroller = new JScrollPane(list); listScroller.setPreferredSize(new Dimension(300, 160)); listScroller.setAlignmentX(LEFT_ALIGNMENT); JPanel listPane = new JPanel(); FormLayout panelLayout = new FormLayout("5dlu, pref:grow:right, 5dlu, pref, 5dlu, pref, 5dlu", "5dlu, pref, 5dlu, pref, 5dlu, pref, 5dlu"); listPane.setLayout(panelLayout); CellConstraints cc = new CellConstraints(); listPane.setLayout(panelLayout); JLabel label = new JLabel(labelText); label.setLabelFor(list); listPane.add(label, cc.xyw(2, 2, 5)); listPane.add(listScroller, cc.xyw(2, 4, 5)); listPane.add(exportButton, cc.xy(2, 6)); listPane.add(exportAllButton, cc.xy(4, 6)); listPane.add(cancelButton, cc.xy(6, 6)); setContentPane(listPane); //Initialize values. setValue(initialValue); pack(); setLocationRelativeTo(locationComp); }
From source file:loci.ome.editor.NotePane.java
License:Open Source License
/** * Reset the TablePanel list acquired from MetadataPane, get * the NotePanels for these TablePanels, display them. *///w w w.j a va 2s. c o m public void setPanels(Vector tablePanels) { tPanels = tablePanels; String rowString = "pref"; for (int i = 0; i < tablePanels.size(); i++) { rowString = rowString + ", 5dlu, pref"; } ScrollablePanel contentPanel = new ScrollablePanel(); FormLayout panelLayout = new FormLayout("5dlu, pref:grow, 5dlu", rowString); contentPanel.setLayout(panelLayout); CellConstraints cc = new CellConstraints(); contentPanel.add(titlePanel, cc.xyw(1, 1, 3)); for (int i = 0; i < tablePanels.size(); i++) { MetadataPane.TablePanel tableP = (MetadataPane.TablePanel) tablePanels.get(i); tableP.tableName.setForeground(TEXT_COLOR); tableP.addButton.setVisible(false); tableP.delButton.setVisible(false); tableP.tHead.setVisible(false); tableP.table.setVisible(false); if (tableP.imageLabel != null) tableP.imageLabel.setVisible(false); contentPanel.add(tableP, cc.xy(2, (2 * i) + 3)); } setViewportView(contentPanel); }
From source file:loci.ome.editor.WiscScanPane.java
License:Open Source License
/** Construct a new WiscScanPane. */ public WiscScanPane() { setup = false;// w w w.j a v a 2 s .c o m ome = null; exrEle = null; exEle = null; prEle = null; desEle = null; tiEle = null; pmtEle = null; phEle = null; setPreferredSize(new Dimension(700, 500)); JPanel loginPanel = new JPanel(); JPanel experimentPanel = new ScrollablePanel(); JScrollPane jScroll = new JScrollPane(experimentPanel); addTab("WiscScan Login", (Icon) null, loginPanel, "Emulates the login screen of WiscScan."); addTab("Experiment Setup Information", (Icon) null, jScroll, "Emulates the Experiment Setup Information" + " screen of WiscScan."); //gui setup for login screen int w = 300, h = 20; JLabel firstLabel = new JLabel("First Name"); firstLabel.setPreferredSize(new Dimension(w, h)); firstField = new JTextField(); firstField.setPreferredSize(new Dimension(w, h)); firstField.getDocument().addDocumentListener(this); JLabel lastLabel = new JLabel("Last Name"); lastLabel.setPreferredSize(new Dimension(w, h)); lastField = new JTextField(); lastField.setPreferredSize(new Dimension(w, h)); lastField.getDocument().addDocumentListener(this); JLabel omeLabel = new JLabel("OME Name (not supported)"); omeLabel.setPreferredSize(new Dimension(w, h)); omeField = new JTextField(); omeField.setEnabled(false); omeField.setPreferredSize(new Dimension(w, h)); omeField.getDocument().addDocumentListener(this); JLabel passLabel = new JLabel("Password (not supported)"); passLabel.setPreferredSize(new Dimension(w, h)); passField = new JTextField(); passField.setEnabled(false); passField.setPreferredSize(new Dimension(w, h)); passField.getDocument().addDocumentListener(this); JLabel emailLabel = new JLabel("Email"); emailLabel.setPreferredSize(new Dimension(w, h)); emailField = new JTextField(); emailField.setPreferredSize(new Dimension(w, h)); emailField.getDocument().addDocumentListener(this); JLabel groupLabel = new JLabel("Group (not supported)"); groupLabel.setPreferredSize(new Dimension(w, h)); groupBox = new JComboBox(); groupBox.setPreferredSize(new Dimension(w, h)); groupBox.addActionListener(this); groupBox.setEnabled(false); JPanel subPanel = null; FormLayout layout = new FormLayout("5dlu,center:pref,5dlu", "5dlu,pref,5dlu,pref,5dlu,pref,5dlu,pref,5dlu,pref,5dlu,pref," + "5dlu,pref,5dlu,pref,5dlu,pref,5dlu,pref,5dlu,pref,5dlu,pref,5dlu"); PanelBuilder build = new PanelBuilder(layout); CellConstraints cc = new CellConstraints(); build.add(firstLabel, cc.xy(2, 2)); build.add(firstField, cc.xy(2, 4)); build.add(lastLabel, cc.xy(2, 6)); build.add(lastField, cc.xy(2, 8)); build.add(omeLabel, cc.xy(2, 10)); build.add(omeField, cc.xy(2, 12)); build.add(passLabel, cc.xy(2, 14)); build.add(passField, cc.xy(2, 16)); build.add(emailLabel, cc.xy(2, 18)); build.add(emailField, cc.xy(2, 20)); build.add(groupLabel, cc.xy(2, 22)); build.add(groupBox, cc.xy(2, 24)); subPanel = build.getPanel(); Border lineB = BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLACK); EmptyBorder emptyB = new EmptyBorder(5, 5, 5, 5); EmptyBorder empB = new EmptyBorder(5, 5, 5, 5); CompoundBorder tempB = new CompoundBorder(lineB, emptyB); CompoundBorder finalB = new CompoundBorder(empB, lineB); subPanel.setBorder(finalB); JPanel holderP = new JPanel(); holderP.add(subPanel); JLabel welcomeLabel = new JLabel("Welcome To WiscScan", JLabel.CENTER); // Font thisFont = welcomeLabel.getFont(); Font thisFont = new Font("Serif", Font.PLAIN, 64); welcomeLabel.setFont(thisFont); loginPanel.setLayout(new BorderLayout()); loginPanel.add(welcomeLabel, BorderLayout.NORTH); loginPanel.add(holderP, BorderLayout.CENTER); //gui setup for experiment setup screen Border etchB = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); TitledBorder infoB = BorderFactory.createTitledBorder(etchB, "Experiment Information"); TitledBorder filterB = BorderFactory.createTitledBorder(etchB, "Filter"); TitledBorder laserB = BorderFactory.createTitledBorder(etchB, "Laser"); TitledBorder detB = BorderFactory.createTitledBorder(etchB, "Detector"); JPanel infoP, filterP, laserP, detP; w = 250; JLabel exL = new JLabel("Experiment Type"); JLabel prL = new JLabel("Project Name"); JLabel desL = new JLabel("Description"); JLabel tempL = new JLabel("Temperature"); JLabel pocL = new JLabel("Pockel Cell"); JLabel tapL = new JLabel("Tap Settings"); JLabel wheeL = new JLabel("Wheel"); JLabel hoL = new JLabel("Holder"); prT = new JTextField(); prT.setPreferredSize(new Dimension(w, h)); prT.getDocument().addDocumentListener(this); tempT = new JTextField(); tempT.setPreferredSize(new Dimension(w, h)); tempT.setEnabled(false); pocT = new JTextField(); pocT.setPreferredSize(new Dimension(w, h)); pocT.setEnabled(false); tapT = new JTextField(); tapT.setPreferredSize(new Dimension(w, h)); tapT.setEnabled(false); tiT = new JTextField(); tiT.setPreferredSize(new Dimension(80, h)); tiT.setEnabled(false); pmtT = new JTextField(); pmtT.setPreferredSize(new Dimension(80, h)); pmtT.getDocument().addDocumentListener(this); desA = new JTextArea("", 4, 1); desA.setLineWrap(true); desA.setWrapStyleWord(true); desA.getDocument().addDocumentListener(this); JScrollPane desS = new JScrollPane(desA); desS.setPreferredSize(new Dimension(w, h * 4)); desS.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); exB = new JComboBox(EX_CHOICES); exB.setPreferredSize(new Dimension(w, h)); exB.addActionListener(this); wheeB = new JComboBox(WHEE_CHOICES); wheeB.setEnabled(false); hoB = new JComboBox(HO_CHOICES); hoB.setEnabled(false); tiC = new JCheckBox("Ti-Sapphire"); tiC.addItemListener(this); phC = new JCheckBox("Photodiode Bio-Rad 1024TLD"); phC.addItemListener(this); pmtC = new JCheckBox("PMT Hamamatsu H7422"); pmtC.addItemListener(this); FormLayout layoutF = new FormLayout("5dlu,pref,5dlu,pref:grow,5dlu", "5dlu,pref,5dlu,pref,5dlu"); PanelBuilder buildF = new PanelBuilder(layoutF); CellConstraints ccF = new CellConstraints(); buildF.add(wheeL, ccF.xy(2, 2)); buildF.add(wheeB, ccF.xy(4, 2)); buildF.add(hoL, ccF.xy(2, 4)); buildF.add(hoB, ccF.xy(4, 4)); filterP = buildF.getPanel(); filterP.setBorder(filterB); FormLayout layoutL = new FormLayout("5dlu,pref,5dlu,pref,pref:grow, 5dlu", "5dlu,pref,25dlu"); PanelBuilder buildL = new PanelBuilder(layoutL); CellConstraints ccL = new CellConstraints(); buildL.add(tiC, cc.xy(2, 2)); buildL.add(tiT, cc.xy(4, 2)); laserP = buildL.getPanel(); laserP.setBorder(laserB); FormLayout layoutD = new FormLayout("5dlu,pref,5dlu,pref,pref:grow, 5dlu", "5dlu,pref,5dlu,pref,20dlu"); PanelBuilder buildD = new PanelBuilder(layoutD); CellConstraints ccD = new CellConstraints(); buildD.add(phC, cc.xy(2, 2)); buildD.add(pmtC, cc.xy(2, 4)); buildD.add(pmtT, cc.xy(4, 4)); detP = buildD.getPanel(); detP.setBorder(detB); FormLayout layoutE = new FormLayout("5dlu,pref,5dlu,pref,5dlu,", "5dlu,pref,5dlu,pref,5dlu,top:pref,5dlu,pref,5dlu,pref," + "5dlu,pref,5dlu,pref,5dlu,pref,5dlu,pref,5dlu"); PanelBuilder buildE = new PanelBuilder(layoutE); CellConstraints ccE = new CellConstraints(); buildE.add(exL, cc.xy(2, 2)); buildE.add(exB, cc.xy(4, 2)); buildE.add(prL, cc.xy(2, 4)); buildE.add(prT, cc.xy(4, 4)); buildE.add(desL, cc.xy(2, 6)); buildE.add(desS, cc.xy(4, 6)); buildE.add(tempL, cc.xy(2, 8)); buildE.add(tempT, cc.xy(4, 8)); buildE.add(pocL, cc.xy(2, 10)); buildE.add(pocT, cc.xy(4, 10)); buildE.add(tapL, cc.xy(2, 12)); buildE.add(tapT, cc.xy(4, 12)); buildE.add(filterP, cc.xyw(2, 14, 3)); buildE.add(laserP, cc.xyw(2, 16, 3)); buildE.add(detP, cc.xyw(2, 18, 3)); infoP = buildE.getPanel(); infoP.setBorder(infoB); experimentPanel.add(infoP); }
From source file:loci.plugins.in.FilePatternDialog.java
License:Open Source License
private void rebuild(GenericDialog gd) { // rebuild dialog to organize things more nicely Vector checkboxes = gd.getCheckboxes(); Vector fields = gd.getStringFields(); final ArrayList<Label> labels = new ArrayList<Label>(); for (Component c : gd.getComponents()) { if (c instanceof Label) { labels.add((Label) c); }//from w w w.j a v a 2s . co m } final String cols = "pref, 3dlu, pref, 3dlu, pref"; final StringBuilder sb = new StringBuilder("pref, 3dlu, pref"); for (int s = 1; s < fields.size(); s++) { sb.append(", 3dlu, pref"); } final String rows = sb.toString(); final PanelBuilder builder = new PanelBuilder(new FormLayout(cols, rows)); final CellConstraints cc = new CellConstraints(); int row = 1; if (checkboxes.size() > 2 && fields.size() > 2) { builder.add((Component) labels.get(0), cc.xyw(1, row, 5)); row += 2; builder.add((Component) checkboxes.get(0), cc.xy(1, row)); for (int i = 0; i < fields.size() - 2; i++) { builder.add((Component) labels.get(i + 1), cc.xy(3, row)); builder.add((Component) fields.get(i), cc.xy(5, row)); row += 2; } } builder.add((Component) checkboxes.get(checkboxes.size() - 2), cc.xy(1, row)); builder.add((Component) labels.get(labels.size() - 2), cc.xy(3, row)); builder.add((Component) fields.get(fields.size() - 2), cc.xy(5, row)); row += 2; builder.add((Component) checkboxes.get(checkboxes.size() - 1), cc.xy(1, row)); builder.add((Component) labels.get(labels.size() - 1), cc.xy(3, row)); builder.add((Component) fields.get(fields.size() - 1), cc.xy(5, row)); row += 2; final JPanel masterPanel = builder.getPanel(); gd.removeAll(); GridBagLayout gdl = (GridBagLayout) gd.getLayout(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 3; gbc.gridheight = fields.size(); gdl.setConstraints(masterPanel, gbc); gd.add(masterPanel); gd.setBackground(Color.white); // HACK: workaround for JPanel in a Dialog }
From source file:loci.plugins.in.MainDialog.java
License:Open Source License
/** Fancies up the importer dialog to look much nicer. */ private void rebuildDialog(GenericDialog gd) { // extract GUI components from dialog and add listeners List<Checkbox> boxes = null; List<Choice> choices = null; List<Label> labels = null; Label colorModeLabel = null;/*from w ww . j a va2 s .c o m*/ Label stackFormatLabel = null; Label stackOrderLabel = null; Component[] c = gd.getComponents(); if (c != null) { boxes = new ArrayList<Checkbox>(); choices = new ArrayList<Choice>(); labels = new ArrayList<Label>(); for (int i = 0; i < c.length; i++) { if (c[i] instanceof Checkbox) { Checkbox item = (Checkbox) c[i]; item.addFocusListener(this); item.addItemListener(this); item.addMouseListener(this); boxes.add(item); } else if (c[i] instanceof Choice) { Choice item = (Choice) c[i]; item.addFocusListener(this); item.addItemListener(this); item.addMouseListener(this); choices.add(item); } else if (c[i] instanceof Label) labels.add((Label) c[i]); } int boxIndex = 0, choiceIndex = 0, labelIndex = 0; autoscaleBox = boxes.get(boxIndex++); colorModeChoice = choices.get(choiceIndex++); colorModeLabel = labels.get(labelIndex++); concatenateBox = boxes.get(boxIndex++); cropBox = boxes.get(boxIndex++); groupFilesBox = boxes.get(boxIndex++); ungroupFilesBox = boxes.get(boxIndex++); openAllSeriesBox = boxes.get(boxIndex++); boxIndex++; // quiet //recordBox = boxes.get(boxIndex++); showMetadataBox = boxes.get(boxIndex++); showOMEXMLBox = boxes.get(boxIndex++); showROIsBox = boxes.get(boxIndex++); specifyRangesBox = boxes.get(boxIndex++); splitZBox = boxes.get(boxIndex++); splitTBox = boxes.get(boxIndex++); splitCBox = boxes.get(boxIndex++); stackFormatChoice = choices.get(choiceIndex++); stackFormatLabel = labels.get(labelIndex++); stackOrderChoice = choices.get(choiceIndex++); stackOrderLabel = labels.get(labelIndex++); swapDimsBox = boxes.get(boxIndex++); virtualBox = boxes.get(boxIndex++); stitchTilesBox = boxes.get(boxIndex++); } verifyOptions(null); // TODO: The info table and focus logic could be split into // its own class, rather than being specific to this dialog. // associate information for each option infoTable = new HashMap<Component, String>(); infoTable.put(autoscaleBox, options.getAutoscaleInfo()); infoTable.put(colorModeChoice, options.getColorModeInfo()); infoTable.put(colorModeLabel, options.getColorModeInfo()); infoTable.put(concatenateBox, options.getConcatenateInfo()); infoTable.put(cropBox, options.getCropInfo()); infoTable.put(groupFilesBox, options.getGroupFilesInfo()); infoTable.put(ungroupFilesBox, options.getUngroupFilesInfo()); infoTable.put(openAllSeriesBox, options.getOpenAllSeriesInfo()); //infoTable.put(recordBox, options.getRecordInfo()); infoTable.put(showMetadataBox, options.getShowMetadataInfo()); infoTable.put(showOMEXMLBox, options.getShowOMEXMLInfo()); infoTable.put(showROIsBox, options.getShowROIsInfo()); infoTable.put(specifyRangesBox, options.getSpecifyRangesInfo()); infoTable.put(splitZBox, options.getSplitFocalPlanesInfo()); infoTable.put(splitTBox, options.getSplitTimepointsInfo()); infoTable.put(splitCBox, options.getSplitChannelsInfo()); infoTable.put(stackFormatChoice, options.getStackFormatInfo()); infoTable.put(stackFormatLabel, options.getStackFormatInfo()); infoTable.put(stackOrderChoice, options.getStackOrderInfo()); infoTable.put(stackOrderLabel, options.getStackOrderInfo()); infoTable.put(swapDimsBox, options.getSwapDimensionsInfo()); infoTable.put(virtualBox, options.getVirtualInfo()); infoTable.put(stitchTilesBox, options.getStitchTilesInfo()); // rebuild dialog using FormLayout to organize things more nicely String cols = // first column "pref, 3dlu, pref:grow, " + // second column "10dlu, pref, " + // third column "10dlu, fill:150dlu"; String rows = // Stack viewing | Metadata viewing "pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, " + // Dataset organization | Memory management "9dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, " + "3dlu, pref, " + // Color options | Split into separate windows "9dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref"; // TODO: Change "Use virtual stack" and "Record modifications to virtual // stack" checkboxes to "Stack type" choice with options: // "Normal", "Virtual" or "Smart virtual" PanelBuilder builder = new PanelBuilder(new FormLayout(cols, rows)); CellConstraints cc = new CellConstraints(); // populate 1st column int row = 1; builder.addSeparator("Stack viewing", cc.xyw(1, row, 3)); row += 2; builder.add(stackFormatLabel, cc.xy(1, row)); builder.add(stackFormatChoice, cc.xy(3, row)); row += 2; builder.add(stackOrderLabel, cc.xy(1, row)); builder.add(stackOrderChoice, cc.xy(3, row)); row += 4; builder.addSeparator("Dataset organization", cc.xyw(1, row, 3)); row += 2; builder.add(groupFilesBox, xyw(cc, 1, row, 3)); row += 2; builder.add(ungroupFilesBox, xyw(cc, 1, row, 3)); row += 2; builder.add(swapDimsBox, xyw(cc, 1, row, 3)); row += 2; builder.add(openAllSeriesBox, xyw(cc, 1, row, 3)); row += 2; builder.add(concatenateBox, xyw(cc, 1, row, 3)); row += 2; builder.add(stitchTilesBox, xyw(cc, 1, row, 3)); row += 2; builder.addSeparator("Color options", cc.xyw(1, row, 3)); row += 2; builder.add(colorModeLabel, cc.xy(1, row)); builder.add(colorModeChoice, cc.xy(3, row)); row += 2; builder.add(autoscaleBox, xyw(cc, 1, row, 3)); row += 2; // populate 2nd column row = 1; builder.addSeparator("Metadata viewing", cc.xy(5, row)); row += 2; builder.add(showMetadataBox, xyw(cc, 5, row, 1)); row += 2; builder.add(showOMEXMLBox, xyw(cc, 5, row, 1)); row += 2; builder.add(showROIsBox, xyw(cc, 5, row, 1)); row += 2; builder.addSeparator("Memory management", cc.xy(5, row)); row += 2; builder.add(virtualBox, xyw(cc, 5, row, 1)); row += 2; //builder.add(recordBox, xyw(cc, 5, row, 1)); //row += 2; builder.add(specifyRangesBox, xyw(cc, 5, row, 1)); row += 2; builder.add(cropBox, xyw(cc, 5, row, 1)); row += 4; builder.addSeparator("Split into separate windows", cc.xy(5, row)); row += 2; builder.add(splitCBox, xyw(cc, 5, row, 1)); row += 2; builder.add(splitZBox, xyw(cc, 5, row, 1)); row += 2; builder.add(splitTBox, xyw(cc, 5, row, 1)); //row += 4; // information section builder.addSeparator("Information", cc.xy(7, 1)); //row += 2; infoPane = new JEditorPane(); infoPane.setContentType("text/html"); infoPane.setEditable(false); infoPane.setText("<html>" + INFO_DEFAULT); builder.add(new JScrollPane(infoPane), cc.xywh(7, 3, 1, row)); //row += 2; gd.removeAll(); gd.add(builder.getPanel()); WindowTools.addScrollBars(gd); gd.setBackground(Color.white); // HACK: workaround for JPanel in a Dialog }
From source file:loci.plugins.util.DataBrowser.java
License:Open Source License
public DataBrowser(final ImagePlus imp, ImageCanvas ic, String[] channels, int[] cLengths, XMLWindow xmlWindow) {//ww w . ja va2 s .c o m super(imp, ic); if (channels == null || channels.length == 0) { channels = new String[] { "Channel" }; } if (cLengths == null || cLengths.length == 0) { cLengths = new int[] { imp.getNChannels() }; } this.cLengths = cLengths; cIndex = new int[cLengths.length]; // build metadata window metaWindow = xmlWindow; if (metaWindow == null) { metaWindow = new XMLWindow("OME Metadata - " + getTitle()); } // build fancy UI widgets while (getComponentCount() > 1) remove(1); Panel controls = new Panel() { @Override public Dimension getPreferredSize() { int minWidth = MIN_BROWSER_WIDTH; int w = imp.getCanvas().getWidth(); if (w < minWidth) w = minWidth; int h = super.getPreferredSize().height; return new Dimension(w, h); } }; String cols = "5dlu, right:pref, 3dlu, pref:grow, 5dlu, pref, 5dlu, pref, 5dlu"; // <-labels-> <------sliders------> <misc> String rows = "4dlu, pref, 3dlu, pref"; // <Z-> <T-> <C-> for (int i = 0; i < channels.length; i++) rows += ", 3dlu, pref"; rows += ", 6dlu"; controls.setLayout(new FormLayout(cols, rows)); controls.setBackground(Color.white); int c = imp.getNChannels(); int z = imp.getNSlices(); int t = imp.getNFrames(); boolean hasZ = z > 1; boolean hasC = c > 1; boolean hasT = t > 1; // remove everything except the image canvas Component[] comps = getComponents(); for (Component comp : comps) { if (!(comp instanceof ImageCanvas)) remove(comp); } ImageJ ij = IJ.getInstance(); if (hasC) { cScroll = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, c + 1); add(cScroll); if (ij != null) cScroll.addKeyListener(ij); cScroll.addAdjustmentListener(this); // prevents scroll bar from blinking on Windows cScroll.setFocusable(false); cScroll.setUnitIncrement(1); cScroll.setBlockIncrement(1); } if (hasZ) { zScroll = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, z + 1); add(zScroll); if (ij != null) zScroll.addKeyListener(ij); zScroll.addAdjustmentListener(this); zScroll.setFocusable(false); int blockIncrement = Math.max(z / 10, 1); zScroll.setUnitIncrement(1); zScroll.setBlockIncrement(blockIncrement); } if (hasT) { tScroll = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, t + 1); add(tScroll); if (ij != null) tScroll.addKeyListener(ij); tScroll.addAdjustmentListener(this); tScroll.setFocusable(false); int blockIncrement = Math.max(t / 10, 1); tScroll.setUnitIncrement(1); tScroll.setBlockIncrement(blockIncrement); } Label zLabel = new Label("Z-depth"); zLabel.setEnabled(hasZ); Label tLabel = new Label("Time"); tLabel.setEnabled(hasT); Label[] cLabels = new Label[channels.length]; for (int i = 0; i < channels.length; i++) { cLabels[i] = new Label(channels[i]); cLabels[i].setEnabled(hasC); } final Scrollbar zSlider = hasZ ? zScroll : makeDummySlider(); final Scrollbar tSlider = hasT ? tScroll : makeDummySlider(); cSliders = new Scrollbar[channels.length]; Panel[] cPanels = new Panel[channels.length]; for (int i = 0; i < channels.length; i++) { if (channels.length == 1) { cSliders[i] = hasC ? cScroll : makeDummySlider(); } else if (cLengths[i] == 1) { cSliders[i] = makeDummySlider(); } else { cSliders[i] = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, cLengths[i] + 1); cSliders[i].addAdjustmentListener(this); } cPanels[i] = makeHeavyPanel(cSliders[i]); } Panel zPanel = makeHeavyPanel(zSlider); Panel tPanel = makeHeavyPanel(tSlider); fpsSpin = new JSpinner(new SpinnerNumberModel(10, 1, 99, 1)); fpsSpin.setToolTipText("Animation rate in frames per second"); Label fpsLabel = new Label(" FPS"); Panel fpsPanel = new Panel(); fpsPanel.setLayout(new BorderLayout()); fpsPanel.add(fpsSpin, BorderLayout.CENTER); fpsPanel.add(fpsLabel, BorderLayout.EAST); ImageStack stack = imp.getStack(); if (stack instanceof BFVirtualStack) { BFVirtualStack bfvs = (BFVirtualStack) stack; Cache cache = bfvs.getCache(); if (hasZ) { CacheIndicator zCache = new CacheIndicator(cache, channels.length, zSlider, 10, 20); zPanel.add(zCache, BorderLayout.SOUTH); } if (hasT) { CacheIndicator tCache = new CacheIndicator(cache, channels.length + 1, tSlider, 10, 20); tPanel.add(tCache, BorderLayout.SOUTH); } for (int i = 0; i < channels.length; i++) { if (cLengths[i] > 1) { CacheIndicator cCache = new CacheIndicator(cache, i, cSliders[i], 10, 20); cPanels[i].add(cCache, BorderLayout.SOUTH); } } String[] axes = new String[channels.length + 2]; System.arraycopy(channels, 0, axes, 0, channels.length); axes[channels.length] = "Z"; axes[channels.length + 1] = "T"; optionsWindow = new BrowserOptionsWindow("Options - " + getTitle(), cache, axes); } animate = new Button("Animate"); animate.addActionListener(this); fpsSpin.setEnabled(hasT); fpsLabel.setEnabled(hasT); animate.setEnabled(hasT); options = new Button("Options"); options.addActionListener(this); options.setEnabled(optionsWindow != null); metadata = new Button("Metadata"); metadata.addActionListener(this); metadata.setEnabled(false); CellConstraints cc = new CellConstraints(); controls.add(zLabel, cc.xy(2, 2)); controls.add(zPanel, cc.xyw(4, 2, 3)); controls.add(fpsPanel, cc.xy(8, 2)); controls.add(tLabel, cc.xy(2, 4)); controls.add(tPanel, cc.xyw(4, 4, 3)); controls.add(animate, cc.xy(8, 4)); int row = 6; // place Options and Metadata buttons intelligently if (channels.length == 1) { controls.add(options, cc.xy(6, row)); controls.add(metadata, cc.xy(8, row)); controls.add(cLabels[0], cc.xy(2, row)); controls.add(cPanels[0], cc.xy(4, row)); } else { controls.add(options, cc.xy(8, row)); controls.add(metadata, cc.xy(8, row + 2)); for (int i = 0; i < channels.length; i++) { int w = i < 2 ? 3 : 5; controls.add(cLabels[i], cc.xy(2, row)); controls.add(cPanels[i], cc.xyw(4, row, w)); row += 2; } } add(controls, BorderLayout.SOUTH); FileInfo fi = imp.getOriginalFileInfo(); if (fi.description != null && fi.description.startsWith("<?xml")) { setXML(fi.description); } allowShow = true; pack(); setVisible(true); // start up animation thread if (hasT) { // NB: Cannot implement Runnable because one of the superclasses does so // for its SliceSelector thread, and overriding results in a conflict. new Thread("DataBrowser-Animation") { @Override public void run() { while (isVisible()) { int ms = 200; if (anim) { int c = imp.getChannel(); int z = imp.getSlice(); int t = imp.getFrame() + 1; int sizeT = tSlider.getMaximum() - 1; if (t > sizeT) t = 1; imp.setPosition(c, z, t); syncSliders(); int fps = ((Number) fpsSpin.getValue()).intValue(); ms = 1000 / fps; } try { Thread.sleep(ms); } catch (InterruptedException exc) { } } } }.start(); } }