List of usage examples for javax.swing JScrollPane setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:org.p_vcd.ui.LicenseDialog.java
public LicenseDialog(String libName, String libHomepage, String licenseName, String licenseFilename) { setSize(680, 480);/*from www .ja va2s.c o m*/ setTitle(libName); getContentPane().setLayout(new BorderLayout()); { JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.NORTH); panel.setLayout(new MigLayout("", "[grow,trailing][grow]", "[20px][][]")); { JLabel lblSoft = new JLabel(libName); lblSoft.setFont(new Font("Tahoma", Font.BOLD, 16)); panel.add(lblSoft, "center,cell 0 0 2 1"); } { JLabel lblHomePage = new JLabel("Home page:"); lblHomePage.setFont(new Font("Tahoma", Font.BOLD, 14)); panel.add(lblHomePage, "cell 0 1"); } { JLabel lblHome = SwingUtil.createLink(libHomepage, libHomepage); lblHome.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(lblHome, "cell 1 1"); } { JLabel lblNewLabel = new JLabel("License:"); lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 14)); panel.add(lblNewLabel, "cell 0 2"); } { JLabel lblLicense = new JLabel(licenseName); lblLicense.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(lblLicense, "cell 1 2"); } } { JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.CENTER); panel.setLayout(new FlowLayout()); panel.setBorder(new EmptyBorder(5, 5, 5, 5)); JScrollPane scrollPane = new JScrollPane(); scrollPane.setPreferredSize(new Dimension(600, 300)); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); panel.add(scrollPane); { JTextArea txtLicense = new JTextArea(); txtLicense.setEditable(false); txtLicense.setFont(new Font("Monospaced", Font.PLAIN, 11)); txtLicense.setWrapStyleWord(true); txtLicense.setLineWrap(true); try { InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream("org/p_vcd/licenses/" + licenseFilename); String text = IOUtils.toString(is, "UTF-8"); IOUtils.closeQuietly(is); txtLicense.setText(text); txtLicense.setCaretPosition(0); } catch (Exception e) { e.printStackTrace(); } scrollPane.setViewportView(txtLicense); } } { JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.SOUTH); panel.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LicenseDialog.this.dispose(); } }); okButton.setActionCommand("OK"); panel.add(okButton); getRootPane().setDefaultButton(okButton); } }
From source file:org.rdv.ui.ConsoleDialog.java
public ConsoleDialog(JDialog owner) { super(owner); setName("consoleDialog"); setDefaultCloseOperation(AboutDialog.DISPOSE_ON_CLOSE); JPanel container = new JPanel(); container.setLayout(new BorderLayout()); container.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); setContentPane(container);/* w w w. j a v a 2 s .co m*/ InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = container.getActionMap(); Action disposeAction = new AbstractAction() { /** serialized version identifier */ private static final long serialVersionUID = 4380189911762232261L; public void actionPerformed(ActionEvent ae) { dispose(); } }; Action copyAction = new AbstractAction() { /** serialized version identifier */ private static final long serialVersionUID = 2596081241883913660L; public void actionPerformed(ActionEvent e) { textArea.selectAll(); textArea.copy(); } }; // Action scrollLockAction = new AbstractAction() { // /** serialized version identifier */ // private static final long serialVersionUID = -8089076016097529064L; // // public void actionPerformed(ActionEvent e) { // //toggle scroll lock // scrollLock_=!scrollLock_; // } // }; disposeAction.putValue(Action.NAME, "OK"); inputMap.put(KeyStroke.getKeyStroke("ENTER"), "dispose"); inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "dispose"); actionMap.put("dispose", disposeAction); copyAction.putValue(Action.NAME, "Copy"); actionMap.put("copy", copyAction); // actionMap.put("scroll lock", scrollLockAction); // scrollLockAction.putValue(Action.NAME, "Scroll Lock"); textArea = new JTextArea(); textArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); textArea.setBackground(Color.WHITE); textArea.setForeground(Color.BLACK); textArea.setEditable(false); textArea.setLineWrap(false); Iterator<String> msgIt = messageBuffer.getMessages().iterator(); //add all the messages in the buffer to this point while (msgIt.hasNext()) { addMessage(msgIt.next()); } JScrollPane scrollPane = new JScrollPane(textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.setPreferredSize(new Dimension(640, 480)); container.add(scrollPane, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BorderLayout()); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); JButton okButton = new JButton(disposeAction); buttonPanel.add(okButton, BorderLayout.EAST); JPanel leftBtnsPanel = new JPanel(); leftBtnsPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); buttonPanel.add(leftBtnsPanel, BorderLayout.WEST); JButton copyButton = new JButton(copyAction); leftBtnsPanel.add(copyButton); // JButton scrollLockButton = new JButton(scrollLockAction); // leftBtnsPanel.add(scrollLockButton); container.add(buttonPanel, BorderLayout.SOUTH); // inject resources from the properties for this component ResourceMap resourceMap = RDV.getInstance().getContext().getResourceMap(getClass()); resourceMap.injectComponents(this); pack(); okButton.requestFocusInWindow(); setLocationByPlatform(true); setVisible(true); messageBuffer.addObserver(this); }
From source file:org.rimudb.editor.DescriptorEditor.java
/** * Build the panel//from ww w. j a v a2 s . c o m */ private JPanel createColumnTablePanel() { JPanel columnPanel = new JPanel(); columnPanel.setLayout(new BoxLayout(columnPanel, BoxLayout.Y_AXIS)); // Create the property table panel propertyModel = new PropertyTableModel(); // Add a listener to set the changed state propertyModel.addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { markChanged(); if (e instanceof PropertyTableModelEvent) { PropertyTableModelEvent ptme = (PropertyTableModelEvent) e; // If the columnName column was changed then check it isn't // a PK if (ptme.getColumn() == 1) { String beforeColumnName = (String) ptme.getBeforeValue(); String afterColumnName = (String) ptme.getAfterValue(); // Is the field entry in the list of primary keys? for (int i = 0; i < pkListModel.getSize(); i++) { String pkColumnName = (String) pkListModel.get(i); // If it's found then remove it if (beforeColumnName.equals(pkColumnName)) { pkListModel.set(i, afterColumnName); break; } } } } } }); table = new ATable(getPropertyModel()); table.setName("ColumnTable"); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectedRowCount = table.getSelectedRowCount(); removeColumnBtn.setEnabled(selectedRowCount > 0); moveUpBtn.setEnabled(selectedRowCount > 0); moveDownBtn.setEnabled(selectedRowCount > 0); } }); table.setTransferHandler(new TransferHandler() { public int getSourceActions(JComponent c) { return COPY; } protected Transferable createTransferable(JComponent c) { ATable columnTable = (ATable) c; int row = columnTable.getSelectedRow(); String columnName = getPropertyModel().getRow(row).getColumnName(); return new StringSelection(columnName); } }); table.setDragEnabled(true); JScrollPane sp = new JScrollPane(table); sp.setMaximumSize(new Dimension(Short.MAX_VALUE, 325)); sp.setPreferredSize(new Dimension(Short.MAX_VALUE, 325)); sp.setMinimumSize(new Dimension(Short.MAX_VALUE, 325)); JComboBox typeCB = new JComboBox(DatabaseTypes.getAllTypes()); typeCB.setEditable(false); javax.swing.table.TableColumn typeColumn = table.getColumnModel().getColumn(2); typeColumn.setCellEditor(new DefaultCellEditor(typeCB)); // Create the popup menu and set it on the table propertyPopup = new TablePopupMenu(this, table); table.addMouseListener(propertyPopup); sp.addMouseListener(propertyPopup); sp.setAlignmentX(LEFT_ALIGNMENT); columnPanel.add(sp); columnPanel.add(Box.createVerticalStrut(10)); JLabel pkLabel = new JLabel("Primary Key Columns", SwingConstants.LEFT); pkLabel.setAlignmentX(LEFT_ALIGNMENT); columnPanel.add(pkLabel); pkListModel = new DefaultListModel(); pkListModel.addListDataListener(new ListDataListener() { public void intervalRemoved(ListDataEvent e) { markChanged(); } public void intervalAdded(ListDataEvent e) { markChanged(); } public void contentsChanged(ListDataEvent e) { markChanged(); } }); pkList = new JList(pkListModel); pkList.setName("pkList"); pkList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); pkList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectedRowCount = pkList.getSelectedIndex(); removePkBtn.setEnabled(selectedRowCount > -1); } }); pkList.setTransferHandler(new TransferHandler() { public boolean canImport(TransferHandler.TransferSupport info) { // we only import Strings if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { return false; } JList.DropLocation dl = (JList.DropLocation) info.getDropLocation(); if (dl.getIndex() == -1) { return false; } return true; } public boolean importData(TransferHandler.TransferSupport info) { if (!info.isDrop()) { return false; } // Check for String flavor if (!info.isDataFlavorSupported(DataFlavor.stringFlavor)) { displayDropLocation("List doesn't accept a drop of this type."); return false; } JList.DropLocation dl = (JList.DropLocation) info.getDropLocation(); DefaultListModel listModel = (DefaultListModel) pkList.getModel(); int index = dl.getIndex(); // Get the string that is being dropped. Transferable t = info.getTransferable(); String data; try { data = (String) t.getTransferData(DataFlavor.stringFlavor); } catch (Exception e) { return false; } // If this is a copy action then check we don't already have that String if (info.getDropAction() == COPY && listModel.indexOf(data) > -1) { displayDropLocation("The column " + data + " is already a primary key"); return false; } // Perform the actual import. if (dl.isInsert()) { int oldIndex = listModel.indexOf(data); if (oldIndex < index) { listModel.add(index, data); listModel.remove(oldIndex); } else { listModel.remove(oldIndex); listModel.add(index, data); } } else { // Don't handle replacements } return true; } public int getSourceActions(JComponent c) { return MOVE; } protected Transferable createTransferable(JComponent c) { JList list = (JList) c; Object[] values = list.getSelectedValues(); StringBuffer buff = new StringBuffer(); for (int i = 0; i < values.length; i++) { Object val = values[i]; buff.append(val == null ? "" : val.toString()); if (i != values.length - 1) { buff.append("\n"); } } return new StringSelection(buff.toString()); } }); pkList.setDropMode(DropMode.INSERT); pkList.setDragEnabled(true); JScrollPane pkScrollPanel = new JScrollPane(pkList); pkScrollPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 100)); pkScrollPanel.setAlignmentX(LEFT_ALIGNMENT); columnPanel.add(pkScrollPanel); return columnPanel; }
From source file:org.simmi.GeneSetHead.java
License:asdf
public void blastn(boolean show) { String dbname = null;/*from w w w .j a v a 2 s . c o m*/ final JTextArea ta = new JTextArea(); JScrollPane sp = new JScrollPane(ta); Dimension dim = new Dimension(400, 300); sp.setSize(dim); sp.setPreferredSize(dim); JTextField tf = new JTextField(); tf.setText("0.00001"); Object[] objs = new Object[] { sp, tf }; JOptionPane.showMessageDialog(GeneSetHead.this, objs); doBlastn(ta.getText(), tf.getText(), false, null, show); }
From source file:org.simmi.GeneSetHead.java
License:asdf
public void blast(boolean x) { //String dbname = null; /*try {/*from ww w. j a v a 2 s. c om*/ Map<String,String> env = new HashMap<String,String>(); Path path = zipfile.toPath(); String uristr = "jar:" + path.toUri(); geneset.zipuri = URI.create( uristr /*.replace("file://", "file:")* ); geneset.zipfilesystem = FileSystems.newFileSystem( geneset.zipuri, env ); final PathMatcher pm = geneset.zipfilesystem.getPathMatcher("*.p??"); for( Path p : zipfilesystem.getRootDirectories() ) { Files.walkFileTree( p, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if( pm.matches( file ) ) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] bb = new byte[1024]; int r = zipm.read( bb ); while( r > 0 ) { baos.write(bb, 0, r); r = zipm.read( bb ); } Files.write( new File("c:/"+file.getFileName().).toPath(), baos.toByteArray(), StandardOpenOption.CREATE); //unresolvedmap = loadunresolvedmap( new InputStreamReader( zipm ) ); dbname = zname.substring(0, zname.length()-4); } return null;* } }); }*/ //Path nf = zipfilesystem.getPath("/unresolved.blastout"); //unresolvedmap = loadunresolvedmap( new InputStreamReader( Files.newInputStream(nf, StandardOpenOption.READ) ) ); /*ZipInputStream zipm = new ZipInputStream( new ByteArrayInputStream( zipf ) ); ZipEntry ze = zipm.getNextEntry(); while( ze != null ) { String zname = ze.getName(); if( zname.endsWith(".phr") || zname.endsWith(".pin") || zname.endsWith(".psq") ) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] bb = new byte[1024]; int r = zipm.read( bb ); while( r > 0 ) { baos.write(bb, 0, r); r = zipm.read( bb ); } Files.write( new File("c:/"+zname).toPath(), baos.toByteArray(), StandardOpenOption.CREATE); //unresolvedmap = loadunresolvedmap( new InputStreamReader( zipm ) ); dbname = zname.substring(0, zname.length()-4); } ze = zipm.getNextEntry(); }* } catch (IOException e1) { e1.printStackTrace(); }*/ final JTextArea ta = new JTextArea(); JScrollPane sp = new JScrollPane(ta); Dimension dim = new Dimension(400, 300); sp.setSize(dim); sp.setPreferredSize(dim); JTextField tf = new JTextField(); tf.setText("0.00001"); Object[] objs = new Object[] { sp, tf }; JOptionPane.showMessageDialog(GeneSetHead.this, objs); doBlast(ta.getText(), tf.getText(), true, null, x); }
From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java
private AbstractWizardPage getPatientFieldsPage() { //setup page//from w w w. j a va2 s .c o m final DefaultWizardPage page = new DefaultWizardPage(PAGENAME_PATIENTS) { @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } }; page.addText("Add relevant fields for patients. "); JScrollPane scrollpane = new JScrollPane(); scrollpane.setPreferredSize(new Dimension(300, 250)); scrollpane.getViewport().setBackground(Color.white); final JTable table = new JTable() { @Override public Class<?> getColumnClass(int column) { if (column == 2) { return Boolean.class; } else { return String.class; } } }; patientFormatModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int col) { return row >= 8; } }; patientFormatModel.addColumn("Name"); patientFormatModel.addColumn("Type"); patientFormatModel.addColumn("Filterable"); patientFormatModel.addColumn("Alias"); patientFormatModel.addColumn("Description"); patientFormatModel.addRow(new Object[] { FAMILY_ID.getColumnName(), FAMILY_ID.getTypeString(), true, FAMILY_ID.getAlias(), "" }); patientFormatModel.addRow(new Object[] { HOSPITAL_ID.getColumnName(), HOSPITAL_ID.getTypeString(), true, HOSPITAL_ID.getAlias(), "" }); patientFormatModel.addRow( new Object[] { IDBIOMOM.getColumnName(), IDBIOMOM.getTypeString(), true, IDBIOMOM.getAlias(), "" }); patientFormatModel.addRow( new Object[] { IDBIODAD.getColumnName(), IDBIODAD.getTypeString(), true, IDBIODAD.getAlias(), "" }); patientFormatModel.addRow( new Object[] { GENDER.getColumnName(), GENDER.getTypeString(), true, GENDER.getAlias(), "" }); patientFormatModel.addRow( new Object[] { AFFECTED.getColumnName(), AFFECTED.getTypeString(), true, AFFECTED.getAlias(), "" }); patientFormatModel.addRow( new Object[] { DNA_IDS.getColumnName(), DNA_IDS.getTypeString(), true, DNA_IDS.getAlias(), "" }); patientFormatModel.addRow( new Object[] { BAM_URL.getColumnName(), BAM_URL.getTypeString(), true, BAM_URL.getAlias(), "" }); patientFormatModel.addRow(new Object[] { PHENOTYPES.getColumnName(), PHENOTYPES.getTypeString(), true, PHENOTYPES.getAlias(), "" }); if (modify) { for (CustomField f : customFields) { patientFormatModel.addRow(new Object[] { f.getColumnName(), f.getTypeString(), f.isFilterable(), f.getAlias(), f.getDescription() }); } } table.setModel(patientFormatModel); table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollpane.getViewport().add(table); page.addComponent(scrollpane); JButton addFieldButton = new JButton("Add Field"); addFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { patientFormatModel.addRow(new Object[5]); table.setModel(patientFormatModel); } }); page.addComponent(addFieldButton); JButton removeFieldButton = new JButton("Remove Field"); removeFieldButton.setEnabled(false); removeFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { int row = table.getSelectedRow(); // Minus one because patient_id isn't in the table. if (row >= BasicPatientColumns.REQUIRED_PATIENT_FIELDS.length - 1) { patientFormatModel.removeRow(row); } table.setModel(patientFormatModel); } }); table.getSelectionModel().addListSelectionListener( new RemovalEnabler(BasicPatientColumns.REQUIRED_PATIENT_FIELDS.length - 1, removeFieldButton)); page.addComponent(removeFieldButton); return page; }
From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java
private AbstractWizardPage getVCFFieldsPage() { //setup page/*from w ww . j a v a 2s .c om*/ final DefaultWizardPage page = new DefaultWizardPage(PAGENAME_VCF) { @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } }; page.addText("Add extra fields to parse from INFO text in VCF files. "); JScrollPane scrollpane = new JScrollPane(); scrollpane.setPreferredSize(new Dimension(300, 250)); scrollpane.getViewport().setBackground(Color.white); final JTable table = new JTable() { @Override public Class<?> getColumnClass(int column) { if (column == 2) { return Boolean.class; } else { return String.class; } } }; variantFormatModel = new DefaultTableModel(); variantFormatModel.addColumn("Key"); variantFormatModel.addColumn("Type"); variantFormatModel.addColumn("Filterable"); variantFormatModel.addColumn("Alias"); variantFormatModel.addColumn("Description"); if (modify) { try { int firstRef = manager.getReferenceIDsForProject(LoginController.getSessionID(), projectID)[0]; CustomField[] fields = manager.getCustomVariantFields(LoginController.getSessionID(), projectID, firstRef, manager.getNewestUpdateID(LoginController.getSessionID(), projectID, firstRef, false)); for (CustomField f : fields) { //casing of f.getColumnName should match database. variantFormatModel.addRow(new Object[] { f.getColumnName(), f.getTypeString(), f.isFilterable(), f.getAlias(), f.getDescription() }); } } catch (Exception ex) { LOG.error("Error getting reference IDs for project.", ex); } } else { variantFormatModel .addRow(new Object[] { AA.getColumnName(), AA.getTypeString(), true, AA.getAlias(), "" }); variantFormatModel .addRow(new Object[] { AC.getColumnName(), AC.getTypeString(), true, AC.getAlias(), "" }); variantFormatModel .addRow(new Object[] { AF.getColumnName(), AF.getTypeString(), true, AF.getAlias(), "" }); variantFormatModel .addRow(new Object[] { AN.getColumnName(), AN.getTypeString(), true, AN.getAlias(), "" }); variantFormatModel .addRow(new Object[] { BQ.getColumnName(), BQ.getTypeString(), true, BQ.getAlias(), "" }); variantFormatModel.addRow( new Object[] { CIGAR.getColumnName(), CIGAR.getTypeString(), true, CIGAR.getAlias(), "" }); variantFormatModel .addRow(new Object[] { DB.getColumnName(), DB.getTypeString(), true, DB.getAlias(), "" }); variantFormatModel .addRow(new Object[] { DP.getColumnName(), DP.getTypeString(), true, DP.getAlias(), "" }); //variantFormatModel.addRow(new Object[]{END.getColumnName(), END.getTypeString(), true, END.getAlias(), ""}); variantFormatModel .addRow(new Object[] { H2.getColumnName(), H2.getTypeString(), true, H2.getAlias(), "" }); variantFormatModel .addRow(new Object[] { MQ.getColumnName(), MQ.getTypeString(), true, MQ.getAlias(), "" }); variantFormatModel .addRow(new Object[] { MQ0.getColumnName(), MQ0.getTypeString(), true, MQ0.getAlias(), "" }); variantFormatModel .addRow(new Object[] { NS.getColumnName(), NS.getTypeString(), true, NS.getAlias(), "" }); variantFormatModel .addRow(new Object[] { SB.getColumnName(), SB.getTypeString(), true, SB.getAlias(), "" }); variantFormatModel.addRow(new Object[] { SOMATIC.getColumnName(), SOMATIC.getTypeString(), true, SOMATIC.getAlias(), "" }); variantFormatModel.addRow(new Object[] { VALIDATED.getColumnName(), VALIDATED.getTypeString(), true, VALIDATED.getAlias(), "" }); variantFormatModel .addRow(new Object[] { JANNOVAR_EFFECT.getColumnName(), JANNOVAR_EFFECT.getTypeString(), JANNOVAR_EFFECT.isFilterable(), JANNOVAR_EFFECT.getAlias(), "" }); variantFormatModel .addRow(new Object[] { JANNOVAR_SYMBOL.getColumnName(), JANNOVAR_SYMBOL.getTypeString(), JANNOVAR_SYMBOL.isFilterable(), JANNOVAR_SYMBOL.getAlias(), "" }); variantFormatModel.addRow(new Object[] { FORMAT.getColumnName(), FORMAT.getTypeString(), FORMAT.isFilterable(), FORMAT.getAlias(), "" }); variantFormatModel.addRow(new Object[] { SAMPLE_INFO.getColumnName(), SAMPLE_INFO.getTypeString(), SAMPLE_INFO.isFilterable(), SAMPLE_INFO.getAlias(), "" }); } table.setModel(variantFormatModel); table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollpane.getViewport().add(table); page.addComponent(scrollpane); table.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { variantFieldsChanged = true; } @Override public void keyPressed(KeyEvent e) { variantFieldsChanged = true; } @Override public void keyReleased(KeyEvent e) { variantFieldsChanged = true; } }); JButton addFieldButton = new JButton("Add Field"); addFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { variantFormatModel.addRow(new Object[2]); table.setModel(variantFormatModel); variantFieldsChanged = true; } }); page.addComponent(addFieldButton); JButton removeFieldButton = new JButton("Remove Field"); removeFieldButton.setEnabled(false); removeFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { int row = table.getSelectedRow(); if (row >= 0) { variantFormatModel.removeRow(row); table.setModel(variantFormatModel); variantFieldsChanged = true; } } }); table.getSelectionModel().addListSelectionListener(new RemovalEnabler(0, removeFieldButton)); page.addComponent(removeFieldButton); return page; }
From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java
private AbstractWizardPage getReferencePage() throws SQLException, RemoteException { //setup page/*from w w w .ja v a 2s .com*/ final DefaultWizardPage page = new DefaultWizardPage(PAGENAME_REF) { @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } }; page.addText("Choose reference genome(s) to add to this project, along\n" + "with corresponding annotations. Annotations will be\n" + "applied to all variants added to these tables."); //setup list JScrollPane scrollpane = new JScrollPane(); scrollpane.setPreferredSize(new Dimension(300, 220)); scrollpane.getViewport().setBackground(Color.white); final JPanel p = new JPanel(); p.setBackground(Color.white); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); refreshReferencePanel(p); scrollpane.getViewport().add(p); page.addComponent(scrollpane); JButton addRefButton = new JButton("New Reference"); addRefButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { try { new NewReferenceDialog().setVisible(true); refreshReferencePanel(p); } catch (Exception ex) { ClientMiscUtils.reportError("Unable to retrieve references and annotations: %s", ex); } } }); page.addComponent(addRefButton); return page; }
From source file:org.ut.biolab.medsavant.client.view.genetics.charts.SummaryChart.java
private synchronized void drawScatterChart(ScatterChartMap entries) { Chart chart = new Chart(new Dimension(200, 200)); Legend legend = new Legend(chart); //Create x axis int max = 0;//w ww. j a v a2 s. c o m CategoryRange<String> range = new CategoryRange<String>(); for (int i = 0; i < entries.getNumX(); i++) { range.add(new ChartCategory(entries.getXValueAt(i))); } //create models DefaultChartModel[] models = new DefaultChartModel[entries.getNumY()]; for (int i = 0; i < entries.getNumY(); i++) { models[i] = new DefaultChartModel(); } for (int i = 0; i < entries.getNumX(); i++) { //ScatterChartEntry[] x = entries[i]; for (int j = 0; j < entries.getNumY(); j++) { ScatterChartEntry entry = entries.getValueAt(i, j); if (entry != null) { max = Math.max(max, entry.getFrequency()); models[j].addPoint(new ChartPoint(range.getCategoryValues().get(i), entry.getFrequency())); models[j].setName(entry.getYRange()); } else { models[j].addPoint(new ChartPoint(range.getCategoryValues().get(i), 0)); } } } //add models for (int i = 0; i < models.length; i++) { Color translucentGreen = ViewUtil.getColor(i, models.length); ChartStyle style = new ChartStyle(translucentGreen, PointShape.DISC); style.setPointSize(10); chart.addModel(models[i], style); } //add axes CategoryAxis xaxis = new CategoryAxis(range, mapGenerator.getName()); chart.setXAxis(xaxis); chart.setYAxis(new Axis(new NumericRange(0, max * 1.1), "Frequency")); //add chart add(chart, c, JLayeredPane.DEFAULT_LAYER); //add legend in scrollpane JScrollPane scroll = new JScrollPane(legend); scroll.setPreferredSize(new Dimension(150, 100)); c.gridx = 1; c.weightx = 0; add(scroll, c, JLayeredPane.DEFAULT_LAYER); c.weightx = 1; c.gridx = 0; }
From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.OtherIndividualsSubInspector.java
protected final void init(VariantFrequencyAggregatePane ap) { this.aggregatePane = ap; ap.setSplitScreenPanel(splitScreenPanel); infoPanel = new JPanel(); infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.Y_AXIS)); innerPanel = new JPanel(); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS)); initHierarchicalTable();//from w ww .j ava 2s. c om JScrollPane jsp = new JScrollPane(hTable); jsp.setPreferredSize(PREFERRED_SIZE); innerPanel.add(jsp); innerPanel.setPreferredSize(PREFERRED_SIZE); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS)); JButton cohortButton = new JButton("? " + aggregatePane.getTitle("Cohort")); cohortButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { openAggregatePane("Cohort"); } }); JButton familyButton = new JButton( "? " + aggregatePane.getTitle(BasicPatientColumns.FAMILY_ID.getAlias())); familyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { openAggregatePane(BasicPatientColumns.FAMILY_ID.getAlias()); } }); buttonPanel.add(cohortButton); buttonPanel.add(familyButton); innerPanel.add(buttonPanel); firstCol = "Cohort"; }