List of usage examples for javax.swing BoxLayout X_AXIS
int X_AXIS
To view the source code for javax.swing BoxLayout X_AXIS.
Click Source Link
From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewer.java
private void initComponents() { setLayout(new BorderLayout()); // create button panel JPanel topPanel = new JPanel(); btnTreeView = new JRadioButton("Tree"); btnTreeView.putClientProperty("cv.cardName", TREEPANEL); btnTableView = new JRadioButton("Table"); btnTableView.putClientProperty("cv.cardName", TABLEPANEL); ActionListener btnListener = new ActionListener() { public void actionPerformed(ActionEvent e) { // show the right layout panel String v = (String) ((AbstractButton) e.getSource()).getClientProperty("cv.cardName"); if (v != null) ((CardLayout) contentPanel.getLayout()).show(contentPanel, v); }//from w w w. j a va 2 s . c o m }; btnTableView.addActionListener(btnListener); btnTreeView.addActionListener(btnListener); // connect buttons ButtonGroup group = new ButtonGroup(); group.add(btnTreeView); group.add(btnTableView); topPanel.setLayout(new MigLayout("", "[64px][55px][62px][grow]", "[][23px]")); lblViewAllThe = new JLabel( "<html>View all the component series that combine to create the current series. Series can be viewed as:"); topPanel.add(lblViewAllThe, "cell 0 0 4 1"); JRadioButton btnTree2View = new JRadioButton("Flow chart"); btnTree2View.putClientProperty("cv.cardName", TREE2PANEL); btnTree2View.addActionListener(btnListener); group.add(btnTree2View); topPanel.add(btnTree2View, "cell 0 1,alignx left,aligny center"); topPanel.add(btnTreeView, "cell 1 1,alignx left,aligny center"); topPanel.add(btnTableView, "cell 2 1,alignx left,aligny center"); topPanel.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8)); add(topPanel, BorderLayout.NORTH); // create status bar JPanel status = new JPanel(); status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS)); txtStatus = new JLabel(""); pbStatus = new JProgressBar(); pbStatus.setVisible(false); status.add(txtStatus); status.add(Box.createHorizontalStrut(8)); status.add(pbStatus); status.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); add(status, BorderLayout.SOUTH); contentPanel = new JPanel(new CardLayout()); add(contentPanel, BorderLayout.CENTER); tablePanel = new JPanel(new BorderLayout()); setupTable(); tablePanel.add(new JScrollPane(table), BorderLayout.CENTER); treePanel = new JPanel(new BorderLayout()); setupTree(); treePanel.add(new JScrollPane(tree), BorderLayout.CENTER); tree2Panel = new JPanel(new BorderLayout()); setupTreeGUI(); contentPanel.add(tablePanel, TABLEPANEL); contentPanel.add(treePanel, TREEPANEL); contentPanel.add(tree2Panel, TREE2PANEL); }
From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewerOld.java
private void initComponents() { JLabel label;//from w w w . j a va2 s. c o m setLayout(new BorderLayout()); // create button panel JPanel topPanel = new JPanel(); label = new JLabel("View as: "); btnTreeView = new JRadioButton("tree"); btnTreeView.putClientProperty("cv.cardName", TREEPANEL); btnTableView = new JRadioButton("table"); btnTableView.putClientProperty("cv.cardName", TABLEPANEL); ActionListener btnListener = new ActionListener() { public void actionPerformed(ActionEvent e) { // show the right layout panel String v = (String) ((AbstractButton) e.getSource()).getClientProperty("cv.cardName"); if (v != null) ((CardLayout) contentPanel.getLayout()).show(contentPanel, v); } }; btnTableView.addActionListener(btnListener); btnTreeView.addActionListener(btnListener); // connect buttons ButtonGroup group = new ButtonGroup(); group.add(btnTreeView); group.add(btnTableView); topPanel.setLayout(new MigLayout("", "[64px][55px][62px][63px][][]", "[23px]")); // add it all to a panel topPanel.add(label, "cell 0 0,alignx left,aligny center"); topPanel.add(btnTreeView, "cell 1 0,alignx left,aligny center"); topPanel.add(btnTableView, "cell 2 0,alignx left,aligny center"); topPanel.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8)); add(topPanel, BorderLayout.NORTH); JButton btnOrder = new JButton("Order"); btnOrder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { } }); topPanel.add(btnOrder, "cell 5 0"); // create status bar JPanel status = new JPanel(); status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS)); txtStatus = new JLabel(""); pbStatus = new JProgressBar(); pbStatus.setVisible(false); status.add(txtStatus); status.add(Box.createHorizontalStrut(8)); status.add(pbStatus); status.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); add(status, BorderLayout.SOUTH); contentPanel = new JPanel(new CardLayout()); add(contentPanel, BorderLayout.CENTER); tablePanel = new JPanel(new BorderLayout()); setupTable(); tablePanel.add(new JScrollPane(table), BorderLayout.CENTER); treePanel = new JPanel(new BorderLayout()); setupTree(); treePanel.add(new JScrollPane(tree), BorderLayout.CENTER); tree2Panel = new JPanel(new BorderLayout()); createTree(); //setupTreeGUI(); contentPanel.add(tablePanel, TABLEPANEL); contentPanel.add(treePanel, TREEPANEL); contentPanel.add(tree2Panel, TREE2PANEL); }
From source file:org.trianacode.gui.hci.ApplicationFrame.java
/** * Initialises the panels in the main window */// www . j a v a2s .co m private void initLayout() { GUIEnv.setApplicationFrame(this); ColorManager.setDefaultColorModel(new TrianaColorModel()); ColorManager.registerColorModel(ScriptConstants.SCRIPT_RENDERING_HINT, new ScriptColorModel()); // do this after all other color loading ColorTable.instance().loadUserPrefs(); TaskGraphView defaultview = new TaskGraphView("Default View"); TrianaComponentModel compmodel = new TrianaComponentModel(tools, this, this); defaultview.setDefaultToolModel(compmodel); defaultview.setDefaultOpenGroupModel(compmodel); defaultview.registerToolModel(ScriptConstants.SCRIPT_RENDERING_HINT, new ScriptComponentModel()); defaultview.registerToolModel(TextToolConstants.TEXT_TOOL_RENDERING_HINT, new TextToolComponentModel()); defaultview.registerToolModel(HiddenToolConstants.HIDDEN_RENDERING_HINT, new HiddenComponentModel()); TaskGraphView mapview = new TaskGraphView("Map View", defaultview); mapview.registerOpenGroupModel(MapConstants.MAP_RENDERING_HINT, new MapComponentModel()); mapview.registerToolModel(MapConstants.MAP_LOCATION_RENDERING_HINT, new MapLocationComponentModel()); TaskGraphViewManager.setDefaultTaskGraphView(defaultview); TaskGraphViewManager.registerTaskGraphView(MapConstants.MAP_RENDERING_HINT, mapview); taskGraphFileHandler = new TaskGraphFileHandler(); trianaMenuBar = new TrianaMainMenu(this, tools); this.setJMenuBar(trianaMenuBar); TrianaShutdownHook shutDownHook = new TrianaShutdownHook(); Runtime.getRuntime().addShutdownHook(shutDownHook); getDesktopViewManager().addDesktopViewListener(this); this.workspace.add(getDesktopViewManager().getWorkspace(), BorderLayout.CENTER); ((TrianaMainMenu) trianaMenuBar).addHelp(); ToolTreeModel treemodel = new ToolTreeModel(tools); toolboxTree = new JTree(treemodel); toolboxTree.addFocusListener(this); toolboxTree.setCellRenderer(new TrianaTreeRenderer()); toolmonitor.setTree(toolboxTree); treemodel.addTreeModelListener(this); ToolTipManager.sharedInstance().registerComponent(toolboxTree); ToolTipManager.sharedInstance().setInitialDelay(TOOL_TIP_SHOW_DELAY); ToolTipManager.sharedInstance().setDismissDelay(TOOL_TIP_HIDE_DELAY); //set up key maps MainTrianaKeyMapFactory keymaps = new MainTrianaKeyMapFactory(this, ActionDisplayOptions.DISPLAY_NAME); InputMap inputMap = keymaps.getInputMap(); inputMap.setParent(this.getRootPane().getInputMap()); this.getRootPane().setInputMap(JComponent.WHEN_FOCUSED, inputMap); ActionMap actMap = keymaps.getActionMap(); actMap.setParent(this.getRootPane().getActionMap()); this.getRootPane().setActionMap(actMap); leaflistener = new LeafListener(toolboxTree, this, tools); keymaps = new MainTrianaKeyMapFactory(leaflistener, ActionDisplayOptions.DISPLAY_NAME); inputMap = keymaps.getInputMap(); inputMap.setParent(toolboxTree.getInputMap()); toolboxTree.setInputMap(JComponent.WHEN_FOCUSED, inputMap); actMap = keymaps.getActionMap(); actMap.setParent(toolboxTree.getActionMap()); toolboxTree.setActionMap(actMap); toolboxTree.addMouseListener(leaflistener); toolboxTree.addMouseMotionListener(leaflistener); //toolboxTree.setRootVisible(false); JPanel toolPanel = new JPanel(new BorderLayout()); SearchToolBar searchtoolbar = new SearchToolBar("Search", toolboxTree, treemodel); searchtoolbar.setFloatable(false); toolPanel.add(searchtoolbar, BorderLayout.NORTH); JScrollPane scroll = new JScrollPane(toolboxTree); toolPanel.add(scroll, BorderLayout.CENTER); JSplitPane verticalSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, toolPanel, workspace); TrianaToolBar toolbar = new TrianaToolBar("Main ToolBar", this); TrianaUnitToolBar unitToolbar = new TrianaUnitToolBar("Unit ToolBar"); toolbar.setRollover(true); unitToolbar.setRollover(true); JPanel innerpanel = new JPanel(); innerpanel.setLayout(new BoxLayout(innerpanel, BoxLayout.X_AXIS)); innerpanel.add(toolbar); innerpanel.add(Box.createHorizontalStrut(10)); innerpanel.add(unitToolbar); innerpanel.add(Box.createHorizontalGlue()); JPanel outerpanel = new JPanel(new BorderLayout()); outerpanel.add(innerpanel, BorderLayout.NORTH); outerpanel.add(verticalSplit, BorderLayout.CENTER); getContentPane().add(outerpanel); }
From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java
private AbstractWizardPage getCompletionPage() { final ProgressWheel pw = new ProgressWheel(); final JPanel p = new JPanel(); p.setOpaque(false);//from w w w . j a va2s . c o m p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); final CompletionWizardPage page = new CompletionWizardPage(PAGENAME_COMPLETE) { @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.NEXT); if (modify) { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.FINISH); } else { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); new SwingWorker() { @Override protected Object doInBackground() throws Exception { try { createNewProject(); } catch (Exception e) { DialogUtils.displayException("Error", "Error trying to create project", e); LOG.error(e); e.printStackTrace(); } return null; } @Override protected void done() { pw.setComplete(); p.setVisible(true); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.FINISH); revalidate(); repaint(); } }.execute(); } } }; if (modify) { page.addText("You have completed the project modification process."); } else { page.addText("Creating project..."); page.addComponent(pw); p.add(new JLabel("Complete.")); p.add(Box.createHorizontalGlue()); page.addComponent(p); p.setVisible(false); /*p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.add(pw, Box.createHorizontalGlue()); p.add(pw, BorderLayout.CENTER); p.add(pw, Box.createHorizontalGlue()); page.addComponent(p);*/ } return page; }
From source file:org.ut.biolab.medsavant.client.query.view.NumberSearchConditionEditorView.java
@Override public void loadViewFromSearchConditionParameters(String encoding) throws ConditionRestorationException { double[] selectedValues; if (encoding == null) { selectedValues = null;/* w w w . j ava 2 s . c o m*/ } else { selectedValues = NumericConditionEncoder.unencodeConditions(encoding); } final double[] extremeValues = generator.getExtremeNumericValues(); this.removeAll(); if (extremeValues == null || (extremeValues[0] == 0 && extremeValues[1] == 0)) { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.add(Box.createHorizontalGlue()); p.add(new JLabel("<html>All values are blank for this condition.</html>")); p.add(Box.createHorizontalGlue()); this.add(p); return; } setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel p = ViewUtil.getClearPanel(); ViewUtil.applyVerticalBoxLayout(p); JPanel labelPanel = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(labelPanel); labelPanel.add(Box.createHorizontalGlue()); labelPanel.add(new JLabel("Filtering variants where " + item.getName() + ": ")); labelPanel.add(Box.createHorizontalGlue()); ButtonGroup group = new ButtonGroup(); //JRadioButton isButton = new JRadioButton("is within the following range:"); //JRadioButton nullButton = new JRadioButton("is missing"); //group.add(isButton); //group.add(nullButton); final JCheckBox nullButton = new JCheckBox("include missing values"); JPanel bp = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(bp); p.add(labelPanel); p.add(bp); add(p); final DecimalRangeSlider slider = new DecimalRangeSlider(); slider.setMajorTickSpacing(5); slider.setMinorTickSpacing(1); final JTextField fromBox = new JTextField(); final JTextField toBox = new JTextField(); nullButton.setSelected(NumericConditionEncoder.encodesNull(encoding)); nullButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { encodeValue(ViewUtil.parseDoubleFromFormattedString(fromBox.getText()), ViewUtil.parseDoubleFromFormattedString(toBox.getText()), extremeValues[0], extremeValues[1], nullButton.isSelected()); } }); fromBox.setMaximumSize(new Dimension(10000, 24)); toBox.setMaximumSize(new Dimension(10000, 24)); fromBox.setPreferredSize(new Dimension(FROM_TO_WIDTH, 24)); toBox.setPreferredSize(new Dimension(FROM_TO_WIDTH, 24)); fromBox.setMinimumSize(new Dimension(FROM_TO_WIDTH, 24)); toBox.setMinimumSize(new Dimension(FROM_TO_WIDTH, 24)); fromBox.setHorizontalAlignment(JTextField.RIGHT); toBox.setHorizontalAlignment(JTextField.RIGHT); final JLabel fromLabel = new JLabel(); final JLabel toLabel = new JLabel(); ViewUtil.makeMini(fromLabel); ViewUtil.makeMini(toLabel); JPanel fromToContainer = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(fromToContainer); fromToContainer.add(Box.createHorizontalGlue()); fromToContainer.add(fromBox); fromToContainer.add(new JLabel(" - ")); fromToContainer.add(toBox); fromToContainer.add(Box.createHorizontalGlue()); JPanel minMaxContainer = ViewUtil.getClearPanel(); minMaxContainer.setLayout(new BoxLayout(minMaxContainer, BoxLayout.X_AXIS)); JPanel sliderContainer = ViewUtil.getClearPanel(); sliderContainer.setLayout(new BoxLayout(sliderContainer, BoxLayout.Y_AXIS)); sliderContainer.add(slider); JPanel nullValueContainer = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(nullValueContainer); nullValueContainer.add(Box.createHorizontalGlue()); nullValueContainer.add(nullButton); nullButton.setBackground(nullValueContainer.getBackground()); //fixes a windows issue. nullValueContainer.add(Box.createHorizontalGlue()); JPanel labelContainer = ViewUtil.getClearPanel(); labelContainer.setLayout(new BoxLayout(labelContainer, BoxLayout.X_AXIS)); labelContainer.add(fromLabel); labelContainer.add(Box.createHorizontalGlue()); labelContainer.add(toLabel); sliderContainer.add(labelContainer); minMaxContainer.add(Box.createHorizontalGlue()); minMaxContainer.add(sliderContainer); minMaxContainer.add(Box.createHorizontalGlue()); add(fromToContainer); add(minMaxContainer); add(nullValueContainer); add(Box.createVerticalBox()); slider.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (slider.isEnabled()) { fromBox.setText(ViewUtil.numToString(slider.getLow())); toBox.setText(ViewUtil.numToString(slider.getHigh())); encodeValue(ViewUtil.parseDoubleFromFormattedString(fromBox.getText()), ViewUtil.parseDoubleFromFormattedString(toBox.getText()), extremeValues[0], extremeValues[1], nullButton.isSelected()); } } }); final KeyListener keyListener = new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER) { Range selectedRage = new Range(getNumber(fromBox.getText()), getNumber(toBox.getText())); setSelectedValues(slider, fromBox, toBox, selectedRage); } } private double getNumber(String s) { try { return Double.parseDouble(s.replaceAll(",", "")); } catch (NumberFormatException ignored) { return 0; } } }; CaretListener caretListener = new CaretListener() { @Override public void caretUpdate(CaretEvent ce) { if (!isAdjustingSlider) { try { encodeValue(ViewUtil.parseDoubleFromFormattedString(fromBox.getText()), ViewUtil.parseDoubleFromFormattedString(toBox.getText()), extremeValues[0], extremeValues[1], nullButton.isSelected()); } catch (Exception e) { } } } }; fromBox.addKeyListener(keyListener); toBox.addKeyListener(keyListener); fromBox.addCaretListener(caretListener); toBox.addCaretListener(caretListener); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { isAdjustingSlider = true; fromBox.setText(ViewUtil.numToString(slider.getLow())); toBox.setText(ViewUtil.numToString(slider.getHigh())); isAdjustingSlider = false; } }); JPanel bottomContainer = new JPanel(); bottomContainer.setLayout(new BoxLayout(bottomContainer, BoxLayout.X_AXIS)); bottomContainer.add(Box.createHorizontalGlue()); add(bottomContainer); setExtremeValues(slider, fromLabel, toLabel, fromBox, toBox, 0, new Range(extremeValues[0], extremeValues[1])); if (encoding != null) { double[] d = NumericConditionEncoder.unencodeConditions(encoding); setSelectedValues(slider, fromBox, toBox, new Range(d[0], d[1])); } }
From source file:org.ut.biolab.medsavant.client.region.RegionWizard.java
private AbstractWizardPage getGenesPage() { return new DefaultWizardPage(PAGENAME_GENES) { private static final int GENE_SELECTION_PANE_WIDTH = 350; private JPanel leftSide; private GeneSelectionPanel geneManiaResultsPanel; private Set<String> geneManiaGeneNames = null; {//from w ww . j a va 2 s . c o m selectedGenesPanel = new GeneSelectionPanel(true, true); sourceGenesPanel = new GeneSelectionPanel(true, true); geneManiaResultsPanel = new GeneSelectionPanel(true, true) { @Override protected void dragAndDropAddGenes(Set<Gene> geneSet) { Set<Object> genesToMoveToGeneManiaPanel = new HashSet<Object>(geneManiaGeneNames); genesToMoveToGeneManiaPanel.retainAll(selectedGenesPanel.getSelectedKeys()); selectedGenesPanel.copyItems(geneManiaResultsPanel, genesToMoveToGeneManiaPanel); selectedGenesPanel.moveSelectedItems(sourceGenesPanel); } @Override protected void dragAndDropRemoveKeys(Set<Object> keySet) { Set<Object> keys = geneManiaResultsPanel.getSelectedKeys(); geneManiaResultsPanel.removeRows(keys); sourceGenesPanel.removeRows(keys); } }; geneManiaResultsPanel.setOddRowColor(new Color(242, 249, 245)); runGeneManiaButton = new JButton("Run GeneMANIA"); runGeneManiaButton.setEnabled(!DirectorySettings.isGeneManiaInstalled()); ListSelectionListener selectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent lse) { int numSel = sourceGenesPanel.getNumSelected() + selectedGenesPanel.getNumSelected(); if (geneManiaGeneNames != null) { numSel += geneManiaResultsPanel.getNumSelected(); } if (GenemaniaInfoRetriever.isGeneManiaDownloading()) { runGeneManiaButton.setEnabled(false); } else { runGeneManiaButton.setEnabled(numSel > 0 || !DirectorySettings.isGeneManiaInstalled()); } } }; sourceGenesPanel.getTable().getSelectionModel().addListSelectionListener(selectionListener); selectedGenesPanel.getTable().getSelectionModel().addListSelectionListener(selectionListener); selectedGenesPanel.getTable().getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent tme) { if (selectedGenesPanel.getData().length > 0) { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } else { fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } } }); selectedGenesPanel.setPreferredSize( new Dimension(GENE_SELECTION_PANE_WIDTH, selectedGenesPanel.getPreferredSize().height)); final JPanel outerLeftSide = new JPanel(); outerLeftSide.setLayout(new BoxLayout(outerLeftSide, BoxLayout.X_AXIS)); leftSide = new JPanel(); leftSide.setLayout(new BoxLayout(leftSide, BoxLayout.Y_AXIS)); leftSide.add(sourceGenesPanel); outerLeftSide.add(leftSide); final JPanel bg = new JPanel(); bg.setLayout(new BoxLayout(bg, BoxLayout.Y_AXIS)); JButton addButton = new JButton("Add "); JButton removeButton = new JButton("? Remove"); sourceGenesPanel.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { sourceGenesPanel.moveSelectedItems(selectedGenesPanel); } } }); selectedGenesPanel.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { if (geneManiaGeneNames != null) { Set<Object> genesToMoveToGeneManiaPanel = new HashSet<Object>(geneManiaGeneNames); genesToMoveToGeneManiaPanel.retainAll(selectedGenesPanel.getSelectedKeys()); selectedGenesPanel.copyItems(geneManiaResultsPanel, genesToMoveToGeneManiaPanel); } selectedGenesPanel.moveSelectedItems(sourceGenesPanel); } } }); geneManiaResultsPanel.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { Set<Object> keys = geneManiaResultsPanel.getSelectedKeys(); geneManiaResultsPanel.moveSelectedItems(selectedGenesPanel); sourceGenesPanel.moveItems(selectedGenesPanel, keys); } } }); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (geneManiaGeneNames != null) { Set<Object> keys = geneManiaResultsPanel.getSelectedKeys(); geneManiaResultsPanel.moveSelectedItems(selectedGenesPanel); sourceGenesPanel.moveItems(selectedGenesPanel, keys); } else { sourceGenesPanel.moveSelectedItems(selectedGenesPanel); } } }); removeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (geneManiaGeneNames != null) { Set<Object> genesToMoveToGeneManiaPanel = new HashSet<Object>(geneManiaGeneNames); genesToMoveToGeneManiaPanel.retainAll(selectedGenesPanel.getSelectedKeys()); selectedGenesPanel.copyItems(geneManiaResultsPanel, genesToMoveToGeneManiaPanel); } selectedGenesPanel.moveSelectedItems(sourceGenesPanel); } }); bg.add(Box.createVerticalGlue()); bg.add(addButton); bg.add(removeButton); bg.add(Box.createVerticalGlue()); outerLeftSide.add(bg); JPanel rightSide = new JPanel(); rightSide.setLayout(new BoxLayout(rightSide, BoxLayout.Y_AXIS)); rightSide.add(selectedGenesPanel); rightSide.add(runGeneManiaButton); final JSplitPane hsplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, outerLeftSide, rightSide); hsplitPane.setResizeWeight(1); addComponent(hsplitPane, true); if (!DirectorySettings.isGeneManiaInstalled()) { runGeneManiaButton.setText("Download GeneMANIA"); if (GenemaniaInfoRetriever.isGeneManiaDownloading()) { runGeneManiaButton.setEnabled(false); registerDownloadListener(); } } runGeneManiaButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (!DirectorySettings.isGeneManiaInstalled()) { int response = DialogUtils.askYesNo("Download GeneMANIA?", "GeneMANIA is not yet installed. Do you want to download and install it now?"); try { if (response == DialogUtils.OK) { runGeneManiaButton.setText("Run GeneMANIA"); runGeneManiaButton.setEnabled(false); registerDownloadListener(); /* DownloadTask dt = GenemaniaInfoRetriever.getGeneManiaDownloadTask(); dt.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("downloadState")) { DownloadTask.DownloadState ds = (DownloadTask.DownloadState) evt.getNewValue(); if (ds == DownloadTask.DownloadState.CANCELLED || ds == DownloadTask.DownloadState.FINISHED) { runGeneManiaButton.setEnabled( (selectedGenesPanel.getNumSelected() + sourceGenesPanel.getNumSelected()) > 0); } } } }); */ GenemaniaInfoRetriever.getGeneManiaDownloadTask().execute(); } } catch (IOException e) { DialogUtils.displayMessage("Error downloading GeneMANIA files"); LOG.error(e); } } else { final List<String> selectedGenes = new LinkedList<String>(); for (Gene g : selectedGenesPanel.getSelectedGenes()) { selectedGenes.add(g.getName()); } for (Gene g : sourceGenesPanel.getSelectedGenes()) { selectedGenes.add(g.getName()); } if (geneManiaGeneNames != null) { for (Gene g : geneManiaResultsPanel.getSelectedGenes()) { selectedGenes.add(g.getName()); } } final JButton closeGeneManiaButton = new JButton("? Close GeneMANIA results"); closeGeneManiaButton.setEnabled(false); final JPanel geneManiaContainingPanel = new JPanel(); geneManiaContainingPanel .setLayout(new BoxLayout(geneManiaContainingPanel, BoxLayout.Y_AXIS)); final SwingWorker geneManiaWorker = new SwingWorker() { private List<Object[]> results; @Override public void done() { Object[][] newdata = new Object[results.size()][4]; results.toArray(newdata); geneManiaResultsPanel.updateData(newdata); geneManiaResultsPanel.updateView(); geneManiaContainingPanel.removeAll(); geneManiaContainingPanel.add(geneManiaResultsPanel); geneManiaContainingPanel.revalidate(); geneManiaContainingPanel.repaint(); closeGeneManiaButton.setEnabled(true); } @Override public Object doInBackground() { try { GenemaniaInfoRetriever genemania = new GenemaniaInfoRetriever(); genemania.setGenes(selectedGenes); List<String> geneNameList = genemania.getRelatedGeneNamesByScore(); geneManiaGeneNames = new HashSet<String>(); geneManiaGeneNames.addAll(geneNameList); LOG.debug("Found " + geneNameList.size() + " related genes"); results = new ArrayList<Object[]>(geneNameList.size()); int i = 0; for (String gene : geneNameList) { if (isCancelled()) { return null; } Gene g = GeneSetFetcher.getInstance().getGeneDictionary().get(gene); if (g == null) { LOG.warn("No gene found for " + gene); } else if (!selectedGenesPanel.hasKey(g.getName())) { results.add(new Object[] { g.getName(), g.getChrom(), g.getStart(), g.getEnd() }); } } } catch (IOException e) { LOG.error(e); } catch (ApplicationException e) { LOG.error(e); } catch (DataStoreException e) { LOG.error(e); } catch (NoRelatedGenesInfoException e) { LOG.error(e); } return null; } }; leftSide.removeAll(); closeGeneManiaButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { geneManiaWorker.cancel(true); } catch (Exception e) { //genemania throws exceptions when cancelled } leftSide.removeAll(); leftSide.add(sourceGenesPanel); leftSide.validate(); leftSide.repaint(); geneManiaGeneNames = null; } }); JPanel closeButtonPanel = new JPanel(); closeButtonPanel.setLayout(new BoxLayout(closeButtonPanel, BoxLayout.X_AXIS)); closeButtonPanel.add(closeGeneManiaButton); closeButtonPanel.add(Box.createHorizontalGlue()); leftSide.add(closeButtonPanel); geneManiaContainingPanel.add(new WaitPanel("Querying GeneMANIA for related genes")); leftSide.add(geneManiaContainingPanel); leftSide.validate(); leftSide.repaint(); geneManiaWorker.execute(); } //end else }//end actionPerformed });//end ActionListener } @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); if (selectedGenesPanel.getNumSelected() > 0) { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } else { fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } } }; }
From source file:org.ut.biolab.medsavant.client.view.component.SearchableTablePanel.java
public SearchableTablePanel(String pageName, String[] columnNames, Class[] columnClasses, int[] hiddenColumns, boolean allowSearch, boolean allowSort, int defaultRows, boolean allowPages, TableSelectionType selectionType, int defaultRowsRetrieved, DataRetriever<Object[]> retriever) { this.pageName = pageName; this.rowsPerPageX = defaultRows; this.defaultRowsRetrieved = defaultRowsRetrieved; this.retriever = retriever; this.hiddenColumns = hiddenColumns; table = new SortableTable() { @Override//from ww w .j a v a2s .c o m public Component prepareRenderer(TableCellRenderer renderer, int row, int col) { synchronized (SearchableTablePanel.this) { JComponent comp = (JComponent) super.prepareRenderer(renderer, row, col); // Even index, selected or not selected if (isRowToggled(TableModelWrapperUtils.getActualRowAt(this.getSortableTableModel(), row))) { //this.getActualRowAt(this.getSortedRowAt(row)))) { comp.setBackground(new Color(178, 225, 92)); } else if (isCellSelected(row, col)) { //comp.setBackground(new Color(75, 149, 229)); comp.setBackground(SELECTED_COLOUR); } else if (selectedRows != null && selectedRows.contains(TableModelWrapperUtils.getActualRowAt(getModel(), row))) { //comp.setBackground(SELECTED_COLOUR); } else if (row % 2 == 0 && !isCellSelected(row, col)) { comp.setBackground(Color.WHITE); } else { comp.setBackground(DARK_COLOUR); } comp.setBorder(BorderFactory.createEmptyBorder(0, 7, 0, 7)); return comp; } } @Override public String getToolTipText(MouseEvent e) { return getToolTip( TableModelWrapperUtils.getActualRowAt(table.getModel(), table.rowAtPoint(e.getPoint()))); } }; table.setToolTipText(""); //necessary to force check for tooltip text table.setClearSelectionOnTableDataChanges(true); table.setOptimized(true); table.setColumnAutoResizable(true); table.setAutoResort(false); table.setRowHeight(20); table.setSortable(allowSort); table.setSortingEnabled(allowSort); table.setFocusable(selectionType != TableSelectionType.DISABLED); //table.setCellSelectionEnabled(allowSelection); table.setCellSelectionEnabled(selectionType == TableSelectionType.CELL); table.setRowSelectionAllowed(selectionType == TableSelectionType.ROW); table.setAutoResizeMode(SortableTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); //column chooser TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(table); installer.addTableHeaderPopupMenuCustomizer(new AutoResizePopupMenuCustomizer()); columnChooser = new ColumnChooser(table); installer.addTableHeaderPopupMenuCustomizer(columnChooser); AutoFilterTableHeader header = new AutoFilterTableHeader(table); header.setAutoFilterEnabled(true); header.setShowFilterIcon(true); header.setShowFilterName(true); table.setTableHeader(header); filterField = new QuickTableFilterField(model); if (allowPages) { filterField.setHintText("Search for anything on the page"); } else { filterField.setHintText("Search for anything"); } setLayout(new BorderLayout(3, 3)); fieldPanel = ViewUtil.getClearPanel(); if (allowSearch) { fieldPanel.add(filterField); } chooseColumnButton = new JButton("Columns"); chooseColumnButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { columnChooser.showDialog(); } }); helpButton = ViewUtil.getHelpButton("About Variant List", "Variants are sorted first by DNA ID, then by position. The list of variants within each page can be sorted by various fields by clicking the corresponding column name, but note that this will only sort the current page."); exportButton = new JButton("Export"); exportButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { try { ExportTable.exportTable(table); } catch (Exception ex) { LOG.error("Error while exporting.", ex); DialogUtils.displayException("MedSavant", "<HTML>A problem occurred while exporting.<BR>Make sure the output file is not already in use.</HTML>", ex); } } }); fieldPanel.add(helpButton); fieldPanel.add(chooseColumnButton); fieldPanel.add(exportButton); bottomPanel = ViewUtil.getClearPanel(); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS)); gotoFirst = niceButton(); gotoPrevious = niceButton(); gotoNext = niceButton(); gotoLast = niceButton(); gotoFirst.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.FIRST)); gotoPrevious.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.PREVIOUS)); gotoNext.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.NEXT)); gotoLast.setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.LAST)); gotoFirst.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToFirstPage(); } }); gotoPrevious.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToPreviousPage(); } }); gotoNext.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToNextPage(); } }); gotoLast.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { goToLastPage(); } }); pageText = new JTextField(); ViewUtil.makeSmall(pageText); pageText.setColumns(5); pageText.setMaximumSize(new Dimension(50, 20)); pageText.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER) { try { setPageNumber(Integer.parseInt(pageText.getText())); } catch (NumberFormatException ex) { setPageNumber(0); } } } }); amountLabel = new JLabel(); ViewUtil.makeSmall(amountLabel); bottomPanel.add(amountLabel); pageLabel1 = new JLabel("Page "); ViewUtil.makeSmall(pageLabel1); pageLabel2 = new JLabel(); ViewUtil.makeSmall(pageLabel2); bottomPanel.add(Box.createHorizontalGlue()); bottomPanel.add(gotoFirst); bottomPanel.add(gotoPrevious); strut(bottomPanel); bottomPanel.add(pageLabel1); bottomPanel.add(pageText); bottomPanel.add(pageLabel2); strut(bottomPanel); bottomPanel.add(gotoNext); bottomPanel.add(gotoLast); bottomPanel.add(Box.createHorizontalGlue()); strut(bottomPanel); JLabel perpageL = new JLabel("Per page:"); ViewUtil.makeSmall(perpageL); bottomPanel.add(perpageL); strut(bottomPanel); boolean hasDefaultRowsPerPage = true; if (rowsPerPageX == ROWSPERPAGE_1 || rowsPerPageX == ROWSPERPAGE_2 || rowsPerPageX == ROWSPERPAGE_3) { hasDefaultRowsPerPage = false; } ArrayList<Integer> rowsList = new ArrayList<Integer>(); rowsList.add(ROWSPERPAGE_1); rowsList.add(ROWSPERPAGE_2); rowsList.add(ROWSPERPAGE_3); Integer[] finalList = new Integer[3]; if (hasDefaultRowsPerPage) { rowsList.add(rowsPerPageX); Collections.sort(rowsList); } finalList = rowsList.toArray(finalList); rowsPerPageDropdown = new JComboBox(finalList); ViewUtil.makeSmall(rowsPerPageDropdown); rowsPerPageDropdown.setPrototypeDisplayValue(ROWSPERPAGE_3); if (hasDefaultRowsPerPage) { rowsPerPageDropdown.setSelectedIndex(rowsList.indexOf(rowsPerPageX)); } else { rowsPerPageDropdown.setSelectedIndex(1); } rowsPerPageDropdown.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JComboBox cb = (JComboBox) e.getSource(); int rowsPerPage = (Integer) cb.getSelectedItem(); setNumRowsPerPage(rowsPerPage); } }); rowsPerPageDropdown.setPreferredSize(new Dimension(100, 25)); rowsPerPageDropdown.setMaximumSize(new Dimension(100, 25)); bottomPanel.add(rowsPerPageDropdown); setTableModel(data, columnNames, columnClasses); JPanel tablePanel = new JPanel(new BorderLayout(3, 3)); JScrollPane jsp = new JScrollPane(table); jsp.setBorder(null); tablePanel.add(jsp); if (allowSort) { add(fieldPanel, BorderLayout.NORTH); } if (allowPages) { add(bottomPanel, BorderLayout.SOUTH); } add(tablePanel, BorderLayout.CENTER); initEmpty(); }
From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.OtherIndividualsGeneSubInspector.java
@Override protected JPanel getIndividualSummaryPanel(String dnaID) { JPanel outerPanel = new JPanel(); outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS)); //dnaIDVariantMap.get(DNAId) -- all variants within gene corresponding to individual Set<VariantRecord> variantRecords = getVariantRecords(dnaID); Map<Long, Set<VariantRecord>> positionVariantMap = new TreeMap<Long, Set<VariantRecord>>(); for (VariantRecord variantRecord : variantRecords) { //Get all variants at that overlap at that position, regardless of individual. Set<VariantRecord> variantsAtPosition = positionVariantMap.get(variantRecord.getStartPosition()); if (variantsAtPosition == null) { variantsAtPosition = new HashSet<VariantRecord>(); }//ww w . java 2 s . c o m variantsAtPosition.add(variantRecord); positionVariantMap.put(variantRecord.getStartPosition(), variantsAtPosition); } for (Map.Entry<Long, Set<VariantRecord>> e : positionVariantMap.entrySet()) { Long pos = e.getKey(); Set<VariantRecord> variantsAtPosition = e.getValue(); for (final VariantRecord variantRecord : variantsAtPosition) { final JPanel rowContainer = new JPanel(); rowContainer.setLayout(new BoxLayout(rowContainer, BoxLayout.Y_AXIS)); final JPanel row = new JPanel(); row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS)); row.setBorder(new EmptyBorder(0, MIDDLE_LEVEL_INDENT, 0, 0)); final JLabel showDetailsButton = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND)); String posStr = NumberFormat.getNumberInstance().format(pos); JLabel rowTitle = new JLabel( " " + variantRecord.getZygosity().name() + " " + variantRecord.getType() + " @ " + posStr); row.add(showDetailsButton); row.add(rowTitle); row.add(Box.createHorizontalGlue()); rowContainer.add(row); outerPanel.add(rowContainer); showDetailsButton.addMouseListener(new MouseAdapter() { private boolean expanded = true; @Override public void mousePressed(MouseEvent me) { if (expanded) { showDetailsButton .setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.COLLAPSE)); int last_level_indent = MIDDLE_LEVEL_INDENT + IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND) .getIconWidth() + rowContainer.getFontMetrics(rowContainer.getFont()).charWidth(' '); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.setBorder(new EmptyBorder(0, last_level_indent, 0, 0)); JPanel textPanel = new JPanel(); textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS)); textPanel.add(new JLabel("Ref: " + variantRecord.getRef())); textPanel.add(Box.createHorizontalGlue()); p.add(textPanel); textPanel = new JPanel(); textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS)); textPanel.add(new JLabel("Alt: " + variantRecord.getAlt())); textPanel.add(Box.createHorizontalGlue()); p.add(textPanel); rowContainer.add(p); } else { showDetailsButton .setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND)); rowContainer.removeAll(); rowContainer.add(row); } rowContainer.revalidate(); rowContainer.repaint(); expanded = !expanded; } }); } } return outerPanel; }
From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.VariantFrequencyAggregatePane.java
public void setVariantRecords(Set<VariantRecord> records) { innerPanel.removeAll();//from w w w. j av a 2 s.c o m //This function executes quickly, no need for waitPanel. //innerPanel.add(new WaitPanel("Loading DNA Ids...")); tableModel.setValues(records); aggregateTable = new AggregateTable(tableModel) { @Override //Necessary to enable buttons within the table. public boolean isCellEditable(int rowIndex, int colIndex) { return colIndex == buttonIndex; } //"Disables" selection within the aggregateTable. @Override public TableCellRenderer getCellRenderer(final int rowIndex, final int columnIndex) { final TableCellRenderer renderer = super.getCellRenderer(rowIndex, columnIndex); return new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable jtable, final Object o, boolean bln, boolean bln1, int i, int i1) { return renderer.getTableCellRendererComponent(jtable, o, false, false, i, i1); } }; } //This overridden method, together with the custom mouse listener on the //AggregateTable header, disallows moving the first column, and columns //>= dnaIDIndex @Override protected AggregateTable.DraggingHandler createDraggingColumnPropertyChangeListener() { return new AggregateTable.DraggingHandler() { @Override public void columnMoved(TableColumnModelEvent e) { if (fromColumnIndex == -1) { fromColumnIndex = e.getFromIndex(); } toColumnIndex = e.getToIndex(); } }; } }; header = new AggregateTableHeader(aggregateTable); header.addMouseListener(new MouseAdapter() { //Disable moving the first column, or columns with index //>=dnaIDIndex @Override public void mouseReleased(MouseEvent e) { if (toColumnIndex != -1 && ((toColumnIndex == 0 || fromColumnIndex == 0) || (toColumnIndex >= dnaIDIndex || fromColumnIndex >= dnaIDIndex))) { aggregateTable.moveColumn(toColumnIndex, fromColumnIndex); String msg = "This column cannot be moved."; DialogUtils.displayMessage(msg); } else { for (int columnHeaderIndex = 0; columnHeaderIndex < header.getColumnModel().getColumnCount() - 2; columnHeaderIndex++) { String columnTitle = (String) header.getColumnModel().getColumn(columnHeaderIndex) .getHeaderValue(); aggregateColumns[columnHeaderIndex] = columnTitle; } reaggregate(); } //aggregateTable.aggregate(this.aggregateColumns); fromColumnIndex = -1; toColumnIndex = -1; //expandAllButLast(); } }); header.setAutoFilterEnabled(false); header.setReorderingAllowed(true); header.setFont(TABLE_FONT_LARGE); aggregateTable.setTableHeader(header); aggregateTable.setAutoResizeMode(AggregateTable.AUTO_RESIZE_ALL_COLUMNS); aggregateTable.setFont(TABLE_FONT_LARGE); //Setup a custom "summary". This is what calculates frequencies when cells are //collapsed PivotField f = aggregateTable.getAggregateTableModel().getField(BasicVariantColumns.DNA_ID.getAlias()); f.setSummaryType(PivotConstants.SUMMARY_RESERVED_MAX + 1); aggregateTable.getAggregateTableModel().setSummaryCalculator(new SummaryCalculator() { private Set<String> collapsedDNAIDs = new HashSet<String>(); private Values lastRowValues; private int valueCount = 0; private final int SUMMARY_FREQ = PivotConstants.SUMMARY_RESERVED_MAX + 1; @Override public void addValue(PivotValueProvider dataModel, PivotField field, Values rowValues, Values columnValues, Object object) { //this gets called multiple times for all the cells that disappear when //something is collapsed. // row[0] is the value of the corresponding first column: e.g. a Cohort or Family. // columnValues can be ignored (blank) // Object is the value of the item in the cell that disappeared. (i.e. those cells which are being summarized) // field.getName() is the column name corresponding to Object // Useful Debugging code: //if(field.getName().equals(BasicVariantColumns.DNA_ID.getAlias())){ /* System.out.println("=========="); System.out.println("Field : " + field.getName()); System.out.println("Row values: "); for (int i = 0; i < rowValues.getCount(); ++i) { System.out.println("\trow[" + i + "] = " + rowValues.getValueAt(i).getValue()); } System.out.println("Column values: "); for (int i = 0; i < columnValues.getCount(); ++i) { System.out.println("\tcol[" + i + "] = " + columnValues.getValueAt(i).getValue()); } System.out.println("Object: "); System.out.println("\t" + object); System.out.println("=========="); */ // } if (field.getName().equals(BasicVariantColumns.DNA_ID.getAlias())) { collapsedDNAIDs.add((String) object); lastRowValues = rowValues; } else { lastRowValues = null; } valueCount++; } //Should never be called @Override public void addValue(Object o) { LOG.error("Unexpected method invocation in OtherIndividualsSubInspector (1)"); } //Should never be called @Override public void addValue(IPivotDataModel ipdm, PivotField pf, int i, int i1, Object o) { LOG.error("Unexpected method invocation in OtherIndividualsSubInspector (2)"); } //Should never be called @Override public void addValue(PivotValueProvider pvp, PivotField pf, Object o) { LOG.error("Unexpected method invocation in OtherIndividualsSubInspector (3)"); } @Override public void clear() { collapsedDNAIDs.clear(); valueCount = 0; lastRowValues = null; } @Override public Object getSummaryResult(int type) { //if null, then we're not in the DNAId column. Return null //to show a blank in this cell if (lastRowValues == null) { return null; } int numIndividuals = getNumberOfIndividualsInGroup(lastRowValues.getValueAt(0)); return new Frequency(collapsedDNAIDs.size(), numIndividuals); } private int getNumberOfIndividualsInGroup(Value v) { if (aggregateColumns[0].equals("Cohort")) { //LOG.debug("Getting number of individuals in group " + v.getValue()); Set<String> dnaIds = cohortDNAIDMap.get((Cohort) v.getValue()); //for (String id : dnaIds) { //LOG.debug("\tGot id " + id); //} return cohortDNAIDMap.get((Cohort) v.getValue()).size(); } else if (aggregateColumns[0].equals(BasicPatientColumns.FAMILY_ID.getAlias())) { return familyIDdnaIDMap.get((String) v.getValue()).size(); } else { LOG.error("Invalid first column"); return -1; } } @Override public long getCount() { return valueCount; } @Override public int getNumberOfSummaries() { return 1; } @Override public String getSummaryName(Locale locale, int i) { return "Frequency"; } @Override public int[] getAllowedSummaries(Class<?> type) { return new int[] { SUMMARY_FREQ }; } @Override public int[] getAllowedSummaries(Class<?> type, ConverterContext cc) { return new int[] { SUMMARY_FREQ }; } }); //Sets up the context menu for clicking column headers. This will probably not be used //frequently. Limit the available operations to collapsing, expanding, and grouping. TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(aggregateTable); installer.addTableHeaderPopupMenuCustomizer(new AggregateTablePopupMenuCustomizer() { @Override public void customizePopupMenu(JTableHeader header, JPopupMenu popup, int clickingColumn) { super.customizePopupMenu(header, popup, clickingColumn); for (int i = 0; i < popup.getComponentCount(); i++) { String menuItemName = popup.getComponent(i).getName(); if (!(CONTEXT_MENU_COLLAPSE.equals(menuItemName) || CONTEXT_MENU_COLLAPSE_ALL.equals(menuItemName) || CONTEXT_MENU_EXPAND.equals(menuItemName) || CONTEXT_MENU_EXPAND_ALL.equals(menuItemName) || CONTEXT_MENU_GROUP.equals(menuItemName) || CONTEXT_MENU_UNGROUP.equals(menuItemName))) { popup.remove(popup.getComponent(i)); } } } }); aggregateTable.getAggregateTableModel().setSummaryMode(true); aggregateTable.aggregate(aggregateColumns); aggregateTable.setShowContextMenu(false); expandAllButLast(); setupButtonColumn(); JScrollPane jsp = new JScrollPane(aggregateTable); jsp.setPreferredSize(PREFERRED_SIZE); JPanel bp = new JPanel(); bp.setLayout(new BoxLayout(bp, BoxLayout.X_AXIS)); JButton closeButton = new JButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.CLOSE)); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { unsplitScreen(); } }); bp.add(Box.createHorizontalGlue()); bp.add(title); bp.add(Box.createHorizontalGlue()); bp.add(closeButton); innerPanel.add(bp); innerPanel.add(jsp); reaggregate(); innerPanel.revalidate(); innerPanel.repaint(); }
From source file:org.ut.biolab.medsavant.client.view.Menu.java
public Menu(JPanel panel) { resetMap();/* w w w . j a v a2 s . c o m*/ setLayout(new BorderLayout()); primaryMenuButtons = new ButtonGroup(); primaryMenu = ViewUtil.getPrimaryBannerPanel(); secondaryMenu = new JPanel(); secondaryMenu.setBackground(ViewUtil.getSecondaryMenuColor()); tertiaryMenu = new JPanel(); tertiaryMenu.setBorder(ViewUtil.getBottomLineBorder()); tertiaryMenu.setBackground(Color.white); // tertiaryMenu.setBorder(ViewUtil.getMediumBorder()); ViewUtil.applyHorizontalBoxLayout(tertiaryMenu); //tertiaryMenu.setMinimumSize(new Dimension(9999, 30)); ViewUtil.applyHorizontalBoxLayout(tertiaryMenu); int padding = 5; primaryMenu.setLayout(new BoxLayout(primaryMenu, BoxLayout.X_AXIS)); primaryMenu.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(150, 150, 150)), BorderFactory.createEmptyBorder(padding, padding, padding, padding))); primaryMenuSectionButtonContainer = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(primaryMenuSectionButtonContainer); NotificationsPanel n = NotificationsPanel.getNotifyPanel(NotificationsPanel.JOBS_PANEL_NAME); JPanel appStorePanel = ViewUtil.getClearPanel(); JButton appStoreButton = ViewUtil .getIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.MENU_STORE)); ViewUtil.applyHorizontalBoxLayout(appStorePanel); appStorePanel.add(ViewUtil.subTextComponent(appStoreButton, "App Store")); appStoreButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { MedSavantFrame.getInstance().showAppStore(); } }); int componentpadding = 10; primaryMenu.add(Box.createHorizontalStrut(componentpadding)); primaryMenu.add(primaryMenuSectionButtonContainer); primaryMenu.add(Box.createHorizontalGlue()); FlowLayout fl = new FlowLayout(FlowLayout.RIGHT, componentpadding, 1); JPanel rightSidePanel = ViewUtil.getClearPanel(); rightSidePanel.setLayout(fl); rightSidePanel.add(updatesPanel); rightSidePanel.add(n); rightSidePanel.add(appStorePanel); rightSidePanel.add(getLoginMenuItem()); primaryMenu.add(rightSidePanel); /* primaryMenu.add(updatesPanel); primaryMenu.add(ViewUtil.getMediumSeparator()); primaryMenu.add(n); primaryMenu.add(ViewUtil.getMediumSeparator()); primaryMenu.add(appStorePanel); primaryMenu.add(ViewUtil.getMediumSeparator()); primaryMenu.add(getLoginMenuItem()); */ add(primaryMenu, BorderLayout.NORTH); secondaryMenu.setLayout(new BoxLayout(secondaryMenu, BoxLayout.Y_AXIS)); //secondaryMenu.setBorder(ViewUtil.getRightLineBorder()); secondaryMenu.setPreferredSize(new Dimension(150, 100)); contentContainer = panel; ReferenceController.getInstance().addListener(new Listener<ReferenceEvent>() { @Override public void handleEvent(ReferenceEvent event) { if (event.getType() == ReferenceEvent.Type.CHANGED) { updateSections(); } } }); ProjectController.getInstance().addListener(new Listener<ProjectEvent>() { @Override public void handleEvent(ProjectEvent evt) { if (!GeneticsSection.isInitialized && evt.getType() == ProjectEvent.Type.CHANGED) { //once this section is initialized, referencecombobox fires //referencechanged event on every project change updateSections(); } } }); LoginController.getInstance().addListener(new Listener<LoginEvent>() { @Override public void handleEvent(LoginEvent evt) { if (evt.getType() == LoginEvent.Type.LOGGED_OUT) { contentContainer.removeAll(); ViewController.getInstance().changeSubSectionTo(null); currentView = null; resetMap(); } } }); tertiaryMenuPanelVisibilityContainer = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(tertiaryMenuPanelVisibilityContainer); tertiaryMenuPanelAccessoryContainer = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(tertiaryMenuPanelAccessoryContainer); clearMenu(); }