List of usage examples for javax.swing JScrollPane setMaximumSize
@BeanProperty(description = "The maximum size of the component.") public void setMaximumSize(Dimension maximumSize)
From source file:org.gumtree.vis.awt.AbstractPlotEditor.java
private JPanel createHelpPanel() { JPanel wrap = new JPanel(new GridLayout(1, 1)); JPanel helpPanel = new JPanel(new GridLayout(1, 1)); helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // helpPanel.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Help Topics")); SpringLayout spring = new SpringLayout(); JPanel inner = new JPanel(spring); inner.setBorder(BorderFactory.createEmptyBorder()); final IHelpProvider provider = plot.getHelpProvider(); final JList list = new JList(provider.getHelpMap().keySet().toArray()); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane listPane1 = new JScrollPane(list); inner.add(listPane1);/* w w w. j a v a 2 s.c o m*/ listPane1.setMaximumSize(new Dimension(140, 0)); listPane1.setMinimumSize(new Dimension(70, 0)); // JPanel contentPanel = new JPanel(new GridLayout(2, 1)); // inner.add(list); final JTextField keyField = new JTextField(); keyField.setMaximumSize(new Dimension(400, 20)); keyField.setEditable(false); // keyField.setMaximumSize(); // keyArea.setLineWrap(true); // keyArea.setWrapStyleWord(true); // keyArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(keyField); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); final JTextArea helpArea = new JTextArea(); JScrollPane areaPane = new JScrollPane(helpArea); helpArea.setEditable(false); helpArea.setLineWrap(true); helpArea.setWrapStyleWord(true); // helpArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(areaPane); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); // inner.add(contentPanel); spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner); spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField); spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField); spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner); spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane); spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object[] selected = list.getSelectedValues(); if (selected.length >= 0) { HelpObject help = provider.getHelpMap().get(selected[0]); if (help != null) { keyField.setText(help.getKey()); helpArea.setText(help.getDiscription()); } } } }); helpPanel.add(inner, BorderLayout.NORTH); wrap.setName("Help"); wrap.add(helpPanel, BorderLayout.NORTH); return wrap; }
From source file:com.opendoorlogistics.components.geocode.postcodes.impl.SummaryPanel.java
public SummaryPanel() { setLayout(new BorderLayout()); text.setEditable(false);// w ww . ja v a 2 s .c o m JScrollPane scrollpane = new JScrollPane(text); scrollpane.setViewportView(text); add(scrollpane, BorderLayout.CENTER); Dimension size = new Dimension(350, 100); scrollpane.setMinimumSize(new Dimension(1, (int) size.getHeight())); scrollpane.setPreferredSize(size); scrollpane.setMaximumSize(new Dimension(2000, (int) size.getHeight())); text.setBackground(new Color(220, 220, 220)); text.setOpaque(true); }
From source file:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java
/** * Creates the UI panel containing all of the fields necessary to upload * the current session data to the web service *///from www . ja v a2s . c o m private void createSetupPane() { this.setupPanel = new JPanel(); this.setupPanel.setLayout(new BorderLayout()); this.setupPanel.setBackground(Color.white); try { String data = IOUtils.toString(LoginDialog.class.getResourceAsStream("/export2.html")); data = data.replace("{LIST}", formatWitnessList()); JLabel txt = new JLabel(data); this.setupPanel.add(txt, BorderLayout.NORTH); } catch (IOException e) { // dunno. not much that can be done! } // ugly layout code to follow. avert your eyes JPanel data = new JPanel(); data.setLayout(new BorderLayout()); data.setBackground(Color.white); JPanel names = new JPanel(); names.setLayout(new BoxLayout(names, BoxLayout.Y_AXIS)); names.setBackground(Color.white); JLabel l = new JLabel("Name:", SwingConstants.RIGHT); l.setPreferredSize(new Dimension(100, 20)); l.setMaximumSize(new Dimension(100, 20)); l.setAlignmentX(RIGHT_ALIGNMENT); names.add(l); names.add(Box.createVerticalStrut(5)); JLabel l2 = new JLabel("Description:", SwingConstants.RIGHT); l2.setPreferredSize(new Dimension(100, 20)); l2.setMaximumSize(new Dimension(100, 20)); l2.setAlignmentX(RIGHT_ALIGNMENT); names.add(l2); data.add(names, BorderLayout.WEST); JPanel edits = new JPanel(); edits.setBackground(Color.white); edits.setLayout(new BoxLayout(edits, BoxLayout.Y_AXIS)); this.nameEdit = new JTextField(); this.nameEdit.setPreferredSize(new Dimension(200, 22)); this.nameEdit.setMaximumSize(new Dimension(200, 22)); File saveFile = this.juxtaFrame.getSession().getSaveFile(); if (saveFile == null) { this.nameEdit.setText("new_session"); } else { String name = saveFile.getName(); this.nameEdit.setText(name.substring(0, name.lastIndexOf('.'))); } edits.add(this.nameEdit); this.descriptionEdit = new JTextArea(3, 0); this.descriptionEdit.setLineWrap(true); this.descriptionEdit.setWrapStyleWord(true); JScrollPane sp = new JScrollPane(this.descriptionEdit); sp.setPreferredSize(new Dimension(194, 60)); sp.setMaximumSize(new Dimension(194, 300)); edits.add(Box.createVerticalStrut(4)); edits.add(sp); data.add(edits, BorderLayout.CENTER); this.setupPanel.add(data, BorderLayout.SOUTH); }
From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java
/** * Displays help window/* w ww . j a v a 2s. c o m*/ */ private void help() { String msg = ""; MutableDataSet options = new MutableDataSet(); Parser parser = Parser.builder(options).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).build(); try { msg = IOUtils.toString(Main.getFile("Usage.md", this)); Node document = parser.parse(msg); msg = renderer.render(document); } catch (IOException e) { e.printStackTrace(); } JTextPane area = new JTextPane(); area.setContentType("text/html"); area.setText(msg); area.setCaretPosition(0); area.setEditable(false); JScrollPane scrollPane = new JScrollPane(area); scrollPane .setMaximumSize(new Dimension(GraphicsRunner.SCREEN_SIZE.width, GraphicsRunner.SCREEN_SIZE.height)); scrollPane.setPreferredSize( new Dimension(GraphicsRunner.SCREEN_SIZE.width - 10, GraphicsRunner.SCREEN_SIZE.height - 10)); scrollPane.scrollRectToVisible(new Rectangle()); JOptionPane.showMessageDialog(this, scrollPane, "Help", JOptionPane.PLAIN_MESSAGE); }
From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java
private JPanel createHelpPanel(JFreeChart chart) { JPanel wrap = new JPanel(new GridLayout(1, 1)); JPanel helpPanel = new JPanel(new GridLayout(1, 1)); helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // helpPanel.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Help Topics")); SpringLayout spring = new SpringLayout(); JPanel inner = new JPanel(spring); inner.setBorder(BorderFactory.createEmptyBorder()); final IHelpProvider provider = new Hist2DHelpProvider(); final JList list = new JList(provider.getHelpMap().keySet().toArray()); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane listPane1 = new JScrollPane(list); inner.add(listPane1);/*from w w w .j av a 2 s .c o m*/ listPane1.setMaximumSize(new Dimension(140, 0)); listPane1.setMinimumSize(new Dimension(70, 0)); // JPanel contentPanel = new JPanel(new GridLayout(2, 1)); // inner.add(list); final JTextField keyField = new JTextField(); keyField.setMaximumSize(new Dimension(400, 20)); keyField.setEditable(false); // keyField.setMaximumSize(); // keyArea.setLineWrap(true); // keyArea.setWrapStyleWord(true); // keyArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(keyField); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); final JTextArea helpArea = new JTextArea(); JScrollPane areaPane = new JScrollPane(helpArea); helpArea.setEditable(false); helpArea.setLineWrap(true); helpArea.setWrapStyleWord(true); // helpArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(areaPane); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); // inner.add(contentPanel); spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner); spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField); spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField); spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner); spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane); spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object[] selected = list.getSelectedValues(); if (selected.length >= 0) { HelpObject help = provider.getHelpMap().get(selected[0]); if (help != null) { keyField.setText(help.getKey()); helpArea.setText(help.getDiscription()); } } } }); helpPanel.add(inner, BorderLayout.NORTH); wrap.setName("Help"); wrap.add(helpPanel, BorderLayout.NORTH); return wrap; }
From source file:ca.phon.app.session.editor.view.segmentation.SegmentationEditorView.java
private void init() { segmentWindowField = new JTextField(); SegmentWindowDocument segDoc = new SegmentWindowDocument(); segmentWindowField.setDocument(segDoc); segmentWindowField.setText(DEFAULT_SEGMENT_WINDOW + ""); segDoc.addDocumentListener(new SegmentWindowListener()); segmentLabel = new SegmentLabel(); segmentLabel.setSegmentWindow(DEFAULT_SEGMENT_WINDOW); segmentLabel.setCurrentTime(0L);// w ww . ja v a 2 s. c o m segmentLabel.lockSegmentStartTime(-1L); modeBox = new JComboBox(SegmentationMode.values()); modeBox.setSelectedItem(SegmentationMode.INSERT_AFTER_CURRENT); JPanel topPanel = new JPanel(); FormLayout topLayout = new FormLayout("right:pref, 3dlu, fill:default:grow, pref", "pref, pref, pref, pref"); topPanel.setLayout(topLayout); CellConstraints cc = new CellConstraints(); topPanel.add(new JLabel("Segment Window"), cc.xy(1, 1)); topPanel.add(segmentWindowField, cc.xy(3, 1)); topPanel.add(new JLabel("ms"), cc.xy(4, 1)); JLabel infoLabel = new JLabel("Set to 0 for unlimited segment time"); infoLabel.setFont(infoLabel.getFont().deriveFont(10.0f)); topPanel.add(infoLabel, cc.xy(3, 2)); topPanel.add(new JLabel("Current Window"), cc.xy(1, 3)); topPanel.add(segmentLabel, cc.xy(3, 3)); topPanel.add(new JLabel("Mode"), cc.xy(1, 4)); topPanel.add(modeBox, cc.xyw(3, 4, 2)); setLayout(new BorderLayout()); add(topPanel, BorderLayout.NORTH); participantPanel = new JPanel(); participantPanel.setBackground(Color.white); participantPanel.setOpaque(true); JScrollPane participantScroller = new JScrollPane(participantPanel); Dimension prefSize = participantScroller.getPreferredSize(); prefSize.height = 150; participantScroller.setPreferredSize(prefSize); Dimension maxSize = participantScroller.getMaximumSize(); maxSize.height = 200; participantScroller.setMaximumSize(maxSize); Dimension minSize = participantScroller.getMinimumSize(); minSize.height = 100; participantScroller.setMinimumSize(minSize); participantScroller.setBorder(BorderFactory.createTitledBorder("Participants")); add(participantScroller, BorderLayout.CENTER); updateParticipantPanel(); setupEditorActions(); }
From source file:de.uka.aifb.com.systemDynamics.gui.ModelExecutionChartPanel.java
/** * Creates panel.// w ww . j a v a2 s .co m */ private void createPanel() { setLayout(new BorderLayout()); // CENTER: chart ChartPanel chartPanel = new ChartPanel(createChart()); // no context menu chartPanel.setPopupMenu(null); // not zoomable chartPanel.setMouseZoomable(false); add(chartPanel, BorderLayout.CENTER); // LINE_END: series table JPanel tablePanel = new JPanel(new GridBagLayout()); String[] columnNames = { messages.getString("ModelExecutionChartPanel.Table.ColumnNames.ExtraAxis"), messages.getString("ModelExecutionChartPanel.Table.ColumnNames.LevelNode") }; final MyTableModel tableModel = new MyTableModel(columnNames, xySeriesArray.length); for (int i = 0; i < xySeriesArray.length; i++) { tableModel.addEntry((String) xySeriesArray[i].getKey()); } JTable table = new JTable(tableModel); table.setRowSelectionAllowed(false); JScrollPane tableScrollPane = new JScrollPane(table); int width = (int) Math.min(300, table.getPreferredSize().getWidth()); int height = (int) Math.min(200, table.getPreferredSize().getHeight()); tableScrollPane.getViewport().setPreferredSize(new Dimension(width, height)); tableScrollPane.setMaximumSize(tableScrollPane.getViewport().getPreferredSize()); axesButton = new JButton(messages.getString("ModelExecutionChartPanel.AxesButton.Text")); axesButton.setToolTipText(messages.getString("ModelExecutionChartPanel.AxesButton.ToolTipText")); axesButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // create XYSeriesCollections (and renderer) XYSeriesCollection standardData = new XYSeriesCollection(); XYLineAndShapeRenderer standardRenderer = new XYLineAndShapeRenderer(true, false); LinkedList<XYSeriesCollection> extraDataList = new LinkedList<XYSeriesCollection>(); LinkedList<XYLineAndShapeRenderer> extraRendererList = new LinkedList<XYLineAndShapeRenderer>(); for (int i = 0; i < tableModel.getRowCount(); i++) { if (tableModel.getValueAt(i, 0).equals(Boolean.FALSE)) { standardData.addSeries(xySeriesArray[i]); standardRenderer.setSeriesPaint(standardData.getSeriesCount() - 1, DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length]); } else { // extra axis XYSeriesCollection extraData = new XYSeriesCollection(); extraData.addSeries(xySeriesArray[i]); extraDataList.add(extraData); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); extraRendererList.add(renderer); renderer.setSeriesPaint(0, DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length]); } } LinkedList<XYSeriesCollection> dataList = new LinkedList<XYSeriesCollection>(); LinkedList<XYLineAndShapeRenderer> rendererList = new LinkedList<XYLineAndShapeRenderer>(); if (!standardData.getSeries().isEmpty()) { dataList.add(standardData); rendererList.add(standardRenderer); } for (XYSeriesCollection data : extraDataList) { dataList.add(data); } for (XYLineAndShapeRenderer renderer : extraRendererList) { rendererList.add(renderer); } // creates axes LinkedList<NumberAxis> axesList = new LinkedList<NumberAxis>(); if (!standardData.getSeries().isEmpty()) { NumberAxis axis = new NumberAxis(messages.getString("ModelExecutionChartPanel.Value")); axis.setNumberFormatOverride(NumberFormat.getInstance(locale)); axesList.add(axis); } for (XYSeriesCollection data : extraDataList) { NumberAxis axis = new NumberAxis((String) data.getSeries(0).getKey()); axis.setNumberFormatOverride(NumberFormat.getInstance(locale)); axesList.add(axis); } // store data and axes in plot XYPlot plot = chart.getXYPlot(); plot.clearRangeAxes(); plot.setRangeAxes(axesList.toArray(new NumberAxis[0])); for (int i = 0; i < plot.getDatasetCount(); i++) { plot.setDataset(i, null); } int datasetIndex = 0; Iterator<XYSeriesCollection> datasetIterator = dataList.iterator(); Iterator<XYLineAndShapeRenderer> rendererIterator = rendererList.iterator(); while (datasetIterator.hasNext()) { plot.setDataset(datasetIndex, datasetIterator.next()); plot.setRenderer(datasetIndex, rendererIterator.next()); datasetIndex++; } for (int i = 0; i < plot.getDatasetCount(); i++) { plot.mapDatasetToRangeAxis(i, i); } } }); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 0; c.insets = new Insets(0, 0, 10, 0); tablePanel.add(tableScrollPane, c); c.gridx = 0; c.gridy = 1; tablePanel.add(axesButton, c); add(tablePanel, BorderLayout.LINE_END); // PAGE_END: number of rounds and execution button JPanel commandPanel = new JPanel(); commandPanel.add(new JLabel(messages.getString("ModelExecutionChartPanel.NumberRounds"))); final JTextField numberRoundsField = new JTextField("1", 5); numberRoundsField.addFocusListener(this); commandPanel.add(numberRoundsField); executionButton = new JButton(messages.getString("ModelExecutionChartPanel.ExecutionButton.Text")); executionButton.setToolTipText(messages.getString("ModelExecutionChartPanel.ExecutionButton.ToolTipText")); executionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int numberRounds = 0; boolean correctNumber = false; try { numberRounds = integerNumberFormatter.parse(numberRoundsField.getText()).intValue(); } catch (ParseException parseExcep) { // do nothing } if (numberRounds >= 1) { correctNumber = true; } if (correctNumber) { ModelExecutionThread executionThread = new ModelExecutionThread(numberRounds); executionThread.start(); } else { JOptionPane.showMessageDialog(null, messages.getString("ModelExecutionChartPanel.Error.Message"), messages.getString("ModelExecutionChartPanel.Error.Title"), JOptionPane.ERROR_MESSAGE); } } }); commandPanel.add(executionButton); add(commandPanel, BorderLayout.PAGE_END); }
From source file:org.gumtree.vis.plot1d.Plot1DChartEditor.java
private JPanel createHelpPanel(JFreeChart chart) { JPanel wrap = new JPanel(new GridLayout(1, 1)); JPanel helpPanel = new JPanel(new GridLayout(1, 1)); helpPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); // helpPanel.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Help Topics")); SpringLayout spring = new SpringLayout(); JPanel inner = new JPanel(spring); inner.setBorder(BorderFactory.createEmptyBorder()); final IHelpProvider provider = new Plot1DHelpProvider(); final JList list = new JList(provider.getHelpMap().keySet().toArray()); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // list.setBorder(BorderFactory.createEtchedBorder()); JScrollPane listPane1 = new JScrollPane(list); inner.add(listPane1);/* ww w. ja v a 2s. c o m*/ listPane1.setMaximumSize(new Dimension(140, 0)); listPane1.setMinimumSize(new Dimension(70, 0)); // JPanel contentPanel = new JPanel(new GridLayout(2, 1)); // inner.add(list); final JTextField keyField = new JTextField(); keyField.setMaximumSize(new Dimension(400, 20)); keyField.setEditable(false); // keyField.setMaximumSize(); // keyArea.setLineWrap(true); // keyArea.setWrapStyleWord(true); // keyArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(keyField); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); final JTextArea helpArea = new JTextArea(); JScrollPane areaPane = new JScrollPane(helpArea); helpArea.setEditable(false); helpArea.setLineWrap(true); helpArea.setWrapStyleWord(true); // helpArea.setBorder(BorderFactory.createEtchedBorder()); inner.add(areaPane); // contentPanel.add(new JLabel()); // contentPanel.add(new JLabel()); // inner.add(contentPanel); spring.putConstraint(SpringLayout.WEST, listPane1, 2, SpringLayout.WEST, inner); spring.putConstraint(SpringLayout.NORTH, listPane1, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.WEST, keyField, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, keyField, 2, SpringLayout.NORTH, inner); spring.putConstraint(SpringLayout.EAST, inner, 2, SpringLayout.EAST, keyField); spring.putConstraint(SpringLayout.WEST, areaPane, 4, SpringLayout.EAST, listPane1); spring.putConstraint(SpringLayout.NORTH, areaPane, 4, SpringLayout.SOUTH, keyField); spring.putConstraint(SpringLayout.EAST, areaPane, -2, SpringLayout.EAST, inner); spring.putConstraint(SpringLayout.SOUTH, inner, 2, SpringLayout.SOUTH, areaPane); spring.putConstraint(SpringLayout.SOUTH, listPane1, -2, SpringLayout.SOUTH, inner); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object[] selected = list.getSelectedValues(); if (selected.length >= 0) { HelpObject help = provider.getHelpMap().get(selected[0]); if (help != null) { keyField.setText(help.getKey()); helpArea.setText(help.getDiscription()); } } } }); helpPanel.add(inner, BorderLayout.NORTH); wrap.setName("Help"); wrap.add(helpPanel, BorderLayout.NORTH); return wrap; }
From source file:it.iit.genomics.cru.igb.bundles.mi.view.MIResultPanel.java
public MIResultPanel(IgbService service, String summary, List<MIResult> results, String label, MIQuery query) { setLayout(new BorderLayout()); this.label = label; igbLogger = IGBLogger.getInstance(label); colorer = TaxonColorer.getColorer(query.getTaxid()); Box menuBox = new Box(BoxLayout.X_AXIS); Box buttonBox = new Box(BoxLayout.Y_AXIS); Box buttonBox1 = new Box(BoxLayout.X_AXIS); Box buttonBox3 = new Box(BoxLayout.X_AXIS); buttonBox.add(buttonBox1);/*from w w w . j av a 2s .co m*/ buttonBox.add(buttonBox3); JTextPane querySummary = new JTextPane(); querySummary.setContentType("text/html"); querySummary.setEditable(false); querySummary.setText(summary); menuBox.add(querySummary); menuBox.add(buttonBox); final JFrame logFrame = new JFrame("MI Bundle Log"); logFrame.setVisible(false); Dimension preferredSize = new Dimension(800, 500); logFrame.setPreferredSize(preferredSize); logFrame.setMinimumSize(preferredSize); logFrame.add(new LogPanel(igbLogger)); JButton log = new JButton(); if (igbLogger.hasError()) { log.setBackground(Color.red); } log.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/console.png")); log.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logFrame.setVisible(true); } }); buttonBox1.add(log); JButton networkButton = new JButton(""); networkButton.setIcon(new ImageIcon(getClass().getResource("/network.jpg"))); networkButton.addActionListener(new DisplayNetworkActionListener()); buttonBox1.add(networkButton); buttonBox1.add(new JSeparator(JSeparator.VERTICAL)); buttonBox1.add(new JLabel("Save: ")); JButton exportButton = new JButton("text"); exportButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/save.png")); exportButton.addActionListener(new ExportActionListener()); if (false == MICommons.testVersion) { buttonBox1.add(exportButton); } JButton exportXgmmlButton = new JButton("xgmml"); exportXgmmlButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/save.png")); exportXgmmlButton.addActionListener(new ExportXgmmlActionListener()); if (false == MICommons.testVersion) { buttonBox1.add(exportXgmmlButton); } buttonBox1.add(new JSeparator(JSeparator.VERTICAL)); buttonBox1.add(new JLabel("View structure: ")); structures = new StructuresPanel(service, label); buttonBox1.add(structures.getJmolButton()); buttonBox1.add(structures.getLinkButton()); // Filters ButtonGroup scoreGroup = new ButtonGroup(); JRadioButton scoreButton0 = new JRadioButton("<html>" + HTML_SCORE_0 + "</html>"); JRadioButton scoreButton1 = new JRadioButton("<html>" + HTML_SCORE_1 + "</html>"); JRadioButton scoreButton2 = new JRadioButton("<html>" + HTML_SCORE_2 + "</html>"); JRadioButton scoreButton3 = new JRadioButton("<html>" + HTML_SCORE_3 + "</html>"); scoreButton0.setSelected(true); ScoreListener scoreListener = new ScoreListener(); scoreButton0.addActionListener(scoreListener); scoreButton1.addActionListener(scoreListener); scoreButton2.addActionListener(scoreListener); scoreButton3.addActionListener(scoreListener); scoreGroup.add(scoreButton0); scoreGroup.add(scoreButton1); scoreGroup.add(scoreButton2); scoreGroup.add(scoreButton3); buttonBox1.add(new JSeparator(JSeparator.VERTICAL)); buttonBox1.add(new JLabel("Score: ")); buttonBox1.add(scoreButton0); buttonBox1.add(scoreButton1); buttonBox1.add(scoreButton2); buttonBox1.add(scoreButton3); buttonBox3.add(new JLabel("Interaction type: ")); JCheckBox EvidencePhysicalButton = new JCheckBox(HTML_CHECKBOX_PHYSICAL); JCheckBox EvidenceAssociationButton = new JCheckBox(HTML_CHECKBOX_ASSOCIATION); JCheckBox EvidenceEnzymaticButton = new JCheckBox(HTML_CHECKBOX_ENZYMATIC); JCheckBox EvidenceOtherButton = new JCheckBox(HTML_CHECKBOX_OTHER); JCheckBox EvidenceUnspecifiedButton = new JCheckBox(HTML_CHECKBOX_UNSPECIFIED); JCheckBox EvidenceStructureButton = new JCheckBox(HTML_CHECKBOX_STRUCTURE); EvidencePhysicalButton.setSelected(true); EvidenceAssociationButton.setSelected(true); EvidenceEnzymaticButton.setSelected(true); EvidenceOtherButton.setSelected(true); EvidenceUnspecifiedButton.setSelected(true); EvidenceStructureButton.setSelected(true); buttonBox3.add(EvidencePhysicalButton); buttonBox3.add(EvidenceAssociationButton); buttonBox3.add(EvidenceEnzymaticButton); buttonBox3.add(EvidenceOtherButton); buttonBox3.add(EvidenceUnspecifiedButton); buttonBox3.add(EvidenceStructureButton); EvidenceTypeListener evidenceListener = new EvidenceTypeListener(); EvidencePhysicalButton.addActionListener(evidenceListener); EvidenceAssociationButton.addActionListener(evidenceListener); EvidenceEnzymaticButton.addActionListener(evidenceListener); EvidenceOtherButton.addActionListener(evidenceListener); EvidenceUnspecifiedButton.addActionListener(evidenceListener); EvidenceStructureButton.addActionListener(evidenceListener); Box tableBox = new Box(BoxLayout.Y_AXIS); MITableModel model = new MITableModel(results); miTable = new MITable(model, service, query); miTable.setFillsViewportHeight(true); miTable.setStructuresPanel(structures); tableBox.add(miTable.getTableHeader()); tableBox.add(miTable); JScrollPane tableScroll = new JScrollPane(tableBox); tableScroll.setMinimumSize(new Dimension(800, 50)); tableScroll.setPreferredSize(new Dimension(800, 50)); tableScroll.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); structures.setMinimumSize(new Dimension(200, 500)); structures.setPreferredSize(new Dimension(200, 500)); structures.setMaximumSize(new Dimension(200, Short.MAX_VALUE)); resultBox = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tableScroll, structures); resultBox.setOneTouchExpandable(true); add(menuBox, BorderLayout.NORTH); add(resultBox, BorderLayout.CENTER); }
From source file:cellularAutomata.analysis.PricingDistributionAnalysis.java
/** * Create the panel used to display the pricing statistics. *//*www . j a va 2 s. c o m*/ private void createDisplayPanel() { int displayWidth = CAFrame.tabbedPaneDimension.width; int displayHeight = 600 + (100 * numberOfStates); // create the display panel if (displayPanel == null) { displayPanel = new JPanel(new GridBagLayout()); displayPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); displayPanel.setPreferredSize(new Dimension(displayWidth, displayHeight)); } else { displayPanel.removeAll(); } if (isCompatibleRule && (numberOfStates <= MAX_NUMBER_OF_STATES)) { // create a panel that displays messages JPanel messagePanel = createMessagePanel(); // create the labels for the display createDataDisplayLabels(); JLabel generationLabel = new JLabel("Generation: "); JLabel stateLabel = new JLabel("State:"); JLabel numStateLabel = new JLabel("Number:"); JLabel percentOccupiedLabel = new JLabel("Kurtosis:"); // create boxes for each column of the display (a Box uses the // BoxLayout, so it is handy for laying out components) Box boxOfStateLabels = Box.createVerticalBox(); Box boxOfNumberLabels = Box.createVerticalBox(); Box boxOfPercentLabels = Box.createVerticalBox(); // the amount of vertical space to put between components int verticalSpace = 5; // add the states to the first vertical box boxOfStateLabels.add(stateLabel); boxOfStateLabels.add(Box.createVerticalStrut(verticalSpace)); for (int state = 0; state < numberOfStates; state++) { boxOfStateLabels.add(new JLabel("" + state)); boxOfStateLabels.add(Box.createVerticalStrut(verticalSpace)); } // add the numbers (in each state) to the second vertical box boxOfNumberLabels.add(numStateLabel); boxOfNumberLabels.add(Box.createVerticalStrut(verticalSpace)); for (int i = 0; i < numberOfStates; i++) { boxOfNumberLabels.add(numberOccupiedByStateDataLabel[i]); boxOfNumberLabels.add(Box.createVerticalStrut(verticalSpace)); } // add the percents (in each state) to the third vertical box boxOfPercentLabels.add(percentOccupiedLabel); boxOfPercentLabels.add(Box.createVerticalStrut(verticalSpace)); for (int i = 0; i < numberOfStates; i++) { boxOfPercentLabels.add(percentOccupiedByStateDataLabel[i]); boxOfPercentLabels.add(Box.createVerticalStrut(verticalSpace)); } // create another box that holds all of the label boxes Box boxOfLabels = Box.createHorizontalBox(); boxOfLabels.add(boxOfStateLabels); boxOfLabels.add(boxOfNumberLabels); boxOfLabels.add(boxOfPercentLabels); boxOfLabels.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7)); // put the boxOfLabels in a scrollPane -- with many states, will get // very large JScrollPane stateScroller = new JScrollPane(boxOfLabels); int scrollPaneWidth = (int) (displayWidth * 0.8); int scrollPaneHeight = displayHeight / 4; stateScroller.setPreferredSize(new Dimension(scrollPaneWidth, scrollPaneHeight)); stateScroller.setMinimumSize(new Dimension(scrollPaneWidth, scrollPaneHeight)); stateScroller.setMaximumSize(new Dimension(scrollPaneWidth, scrollPaneHeight)); stateScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); // create a "plot zero state" check box plotZeroStateCheckBox = new JCheckBox(PLOT_ZERO_STATE); plotZeroStateCheckBox.setSelected(true); plotZeroStateCheckBox.setToolTipText(PLOT_ZERO_STATE_TOOLTIP); plotZeroStateCheckBox.setActionCommand(PLOT_ZERO_STATE); plotZeroStateCheckBox.addActionListener(this); JPanel plotZeroStatePanel = new JPanel(new BorderLayout()); plotZeroStatePanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7)); plotZeroStatePanel.add(BorderLayout.CENTER, plotZeroStateCheckBox); // create a "save data" check box saveDataCheckBox = new JCheckBox(SAVE_DATA); saveDataCheckBox.setToolTipText(SAVE_DATA_TOOLTIP); saveDataCheckBox.setActionCommand(SAVE_DATA); saveDataCheckBox.addActionListener(this); JPanel saveDataPanel = new JPanel(new BorderLayout()); saveDataPanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7)); saveDataPanel.add(BorderLayout.CENTER, saveDataCheckBox); // create a panel that plots the data plot = new SimplePlot(); // add all the components to the panel int row = 0; displayPanel.add(messagePanel, new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH).setWeight(1.0, 1.0) .setAnchor(GBC.WEST).setInsets(1)); row++; displayPanel.add(plot, new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH).setWeight(10.0, 10.0) .setAnchor(GBC.WEST).setInsets(1)); row++; for (int i = 0; i < numberOfStates; i++) { timeSeriesPlot[i] = new SimplePlot(); displayPanel.add(timeSeriesPlot[i], new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH) .setWeight(10.0, 10.0).setAnchor(GBC.WEST).setInsets(1)); row++; } displayPanel.add(plotZeroStatePanel, new GBC(1, row).setSpan(4, 1).setFill(GBC.NONE).setWeight(1.0, 1.0) .setAnchor(GBC.CENTER).setInsets(1)); row++; displayPanel.add(generationLabel, new GBC(1, row).setSpan(1, 1).setFill(GBC.NONE).setWeight(1.0, 1.0) .setAnchor(GBC.EAST).setInsets(1)); displayPanel.add(generationDataLabel, new GBC(2, row).setSpan(1, 1).setFill(GBC.NONE) .setWeight(1.0, 1.0).setAnchor(GBC.WEST).setInsets(1)); row++; displayPanel.add(stateScroller, new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH).setWeight(1.0, 1.0) .setAnchor(GBC.WEST).setInsets(1)); row++; displayPanel.add(saveDataPanel, new GBC(1, row).setSpan(4, 1).setFill(GBC.NONE).setWeight(1.0, 1.0) .setAnchor(GBC.CENTER).setInsets(1)); } else { int row = 0; displayPanel.add(createWarningMessagePanel(), new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH) .setWeight(1.0, 1.0).setAnchor(GBC.WEST).setInsets(1)); } }