List of usage examples for javax.swing JPanel setMinimumSize
@BeanProperty(description = "The minimum size of the component.") public void setMinimumSize(Dimension minimumSize)
From source file:com.sshtools.shift.FileTransferDialog.java
private void jbInit() throws Exception { getContentPane().setLayout(new BorderLayout()); progressbar.setToolTipText(""); progressbar.setValue(0);//w ww.jav a2s. co m try { Method m = progressbar.getClass().getMethod("setIndeterminate", new Class[] { boolean.class }); Object[] args = new Object[] { new Boolean(true) }; m.invoke(progressbar, args); } catch (Throwable ex) { } //progressbar.setIndeterminate(true); progressbar.setBounds(new Rectangle(8, 45, 336, 22)); lblEstimatedTime.setText("Estimated time left: "); lblEstimatedTime.setBounds(new Rectangle(8, 74, 114, 17)); lblTimeLeftValue.setText(""); lblTimeLeftValue.setBounds(new Rectangle(109, 74, 235, 17)); lblTargetAction.setText("Downloading to:"); lblTargetAction.setBounds(new Rectangle(8, 92, 96, 17)); lblTargetValue.setText(""); lblTargetValue.setBounds(new Rectangle(109, 92, 235, 17)); lblTransferRate.setText("Transfer rate: "); lblTransferRate.setBounds(new Rectangle(8, 110, 96, 17)); lblTransferRateValue.setText(""); lblTransferRateValue.setBounds(new Rectangle(109, 110, 235, 17)); btnCancel.setText("Cancel"); btnCancel.addActionListener(new FileTransferDialog_cancel_actionAdapter( this)); chkClose.setText("Close this window when the transfer completes"); chkClose.setBounds(new Rectangle(8, 132, 307, 18)); chkClose.setSelected(true); JPanel p = new JPanel(null); lblAction.setBounds(new Rectangle(9, 5, 334, 21)); lblPathValue.setText(""); lblPathValue.setBounds(new Rectangle(10, 22, 329, 22)); p.add(progressbar); p.add(lblEstimatedTime); p.add(lblTimeLeftValue); p.add(lblTargetAction); p.add(lblTransferRate); p.add(lblTransferRateValue); p.add(lblTargetValue); p.add(lblAction); p.add(lblPathValue); p.add(chkClose); JPanel b = new JPanel(new FlowLayout(FlowLayout.RIGHT)); b.add(btnCancel); p.setMaximumSize(new Dimension(350, 185)); p.setMinimumSize(new Dimension(350, 185)); p.setPreferredSize(new Dimension(350, 185)); getContentPane().add(p, BorderLayout.CENTER); getContentPane().add(b, BorderLayout.SOUTH); elaspedTime = 0; formatMb.setMaximumFractionDigits(2); formatKb.setMaximumFractionDigits(0); formatKb1.setMaximumFractionDigits(1); setResizable(true); setSize(new Dimension(350, 184)); UIUtil.positionComponent(UIUtil.CENTER, this); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.DataImportDialog.java
/** * Creates the UI panel for a xls import * //from w ww .j av a 2 s .com * @return * JPanel */ private JPanel createConfigPanelForXLS() { //JPanel configPanel = new FormDebugPanel(); JPanel configPanel = new JPanel(); CellConstraints cc = new CellConstraints(); PanelBuilder builder = new PanelBuilder(new FormLayout("5px, 15px, p, 30px, p:g, 15px", // columns "5px," + //padding "p,3px, " + //file info separator "p,3px, " + //file info lable "p,10px, " + //row header "p, 3px," + //previe separator "f:p:g,5px," + //tablePreview "30px,3px," + //data import status error panel "p,10px" //buttongs ), configPanel);// rows JLabel fileInfo = createLabel(getResourceString("FILE_PREVIEW") + " " + fileName); JPanel buttonpanel = buildButtons(); containsHeaders = createCheckBox(getResourceString("COLUMN_HEAD")); containsHeaders.setSelected(true); containsHeaders.addItemListener(new CheckboxItemListener()); builder.addSeparator(getResourceString("FILE_IMPORT"), cc.xyw(2, 2, 4)); builder.add(fileInfo, cc.xyw(3, 4, 4)); builder.add(containsHeaders, cc.xyw(3, 6, 3)); builder.addSeparator(getResourceString("DATA_PREVIEW"), cc.xyw(2, 8, 4)); myDisplayTable = setXLSTableData(myDisplayTable); if (myDisplayTable == null) { return null; } builder.add(addtoScroll(myDisplayTable), cc.xyw(3, 10, 3)); builder.add(errorPanel, cc.xyw(3, 12, 4)); builder.add(buttonpanel, cc.xyw(2, 14, 4)); configPanel.setMinimumSize(buttonpanel.getMinimumSize()); return configPanel; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.DataImportDialog.java
/** * Creates the UI panel for a csv import, displays config opionts. * //from ww w .j a va 2 s.c o m * @return * JPanel - the panel to be displayed */ private JPanel createConfigPanelForCSV() { //JPanel configPanel = new FormDebugPanel(); JPanel configPanel = new JPanel(); CellConstraints cc = new CellConstraints(); PanelBuilder builder = new PanelBuilder(new FormLayout("5px, 15px, p, 30px, p:g, 15px", // columns "5px," + //padding "p,3px, " + //separator "p,10px, " + //delim panel "p,3px, " + //file info separator "p,3px, " + //file info lable "p,10px, " + //row header "p, 3px," + //preview separator "f:p:g,5px," + //tablePreview "30px,3px," + //data import status error panel "p,10px" //buttongs ), configPanel);// rows JLabel fileInfo = createLabel(getResourceString("FILE_PREVIEW") + " " + fileName); JPanel buttonpanel = buildButtons(); containsHeaders = createCheckBox(getResourceString("COLUMN_HEAD")); containsHeaders.setSelected(true); containsHeaders.addItemListener(new CheckboxItemListener()); builder.addSeparator(getResourceString("DATA_IMPORT_OPS"), cc.xyw(2, 2, 4)); builder.add(createDelimiterPanel(), cc.xy(3, 4)); builder.add(createOtherControlsForCSVPanel(), cc.xy(5, 4)); builder.addSeparator(getResourceString("FILE_IMPORT"), cc.xyw(2, 6, 4)); builder.add(fileInfo, cc.xyw(3, 8, 4)); builder.add(containsHeaders, cc.xyw(3, 10, 3)); builder.addSeparator(getResourceString("DATA_PREVIEW"), cc.xyw(2, 12, 4)); myDisplayTable = setCSVTableData(myDisplayTable); builder.add(addtoScroll(myDisplayTable), cc.xyw(3, 14, 3)); builder.add(errorPanel, cc.xyw(3, 16, 4)); builder.add(buttonpanel, cc.xyw(2, 18, 4)); configPanel.setMinimumSize(buttonpanel.getMinimumSize()); return configPanel; }
From source file:au.org.ala.delta.intkey.Intkey.java
@Override public void addToolbarSpace() { JPanel spacerPanel = new JPanel(); spacerPanel.setMinimumSize(new Dimension(20, 1)); _pnlDynamicButtons.add(spacerPanel); _rootPanel.revalidate();//from w ww .j a v a 2 s . co m }
From source file:jp.massbank.spectrumsearch.SearchPage.java
/** * ?//from w w w .j a v a2 s . c o m */ private void createWindow() { // ?? ToolTipManager ttm = ToolTipManager.sharedInstance(); ttm.setInitialDelay(50); ttm.setDismissDelay(8000); // Search? JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); Border border = BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(), new EmptyBorder(1, 1, 1, 1)); mainPanel.setBorder(border); // ********************************************************************* // User File Query // ********************************************************************* DefaultTableModel fileDm = new DefaultTableModel(); fileSorter = new TableSorter(fileDm, TABLE_QUERY_FILE); queryFileTable = new JTable(fileSorter) { @Override public boolean isCellEditable(int row, int column) { // super.isCellEditable(row, column); // ?????? return false; } }; queryFileTable.addMouseListener(new TblMouseListener()); fileSorter.setTableHeader(queryFileTable.getTableHeader()); queryFileTable.setRowSelectionAllowed(true); queryFileTable.setColumnSelectionAllowed(false); queryFileTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); String[] col = { COL_LABEL_NO, COL_LABEL_NAME, COL_LABEL_ID }; ((DefaultTableModel) fileSorter.getTableModel()).setColumnIdentifiers(col); (queryFileTable.getColumn(queryFileTable.getColumnName(0))).setPreferredWidth(44); (queryFileTable.getColumn(queryFileTable.getColumnName(1))).setPreferredWidth(LEFT_PANEL_WIDTH - 44); (queryFileTable.getColumn(queryFileTable.getColumnName(2))).setPreferredWidth(70); ListSelectionModel lm = queryFileTable.getSelectionModel(); lm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lm.addListSelectionListener(new LmFileListener()); queryFilePane = new JScrollPane(queryFileTable); queryFilePane.addMouseListener(new PaneMouseListener()); queryFilePane.setPreferredSize(new Dimension(300, 300)); // ********************************************************************* // Result // ********************************************************************* DefaultTableModel resultDm = new DefaultTableModel(); resultSorter = new TableSorter(resultDm, TABLE_RESULT); resultTable = new JTable(resultSorter) { @Override public String getToolTipText(MouseEvent me) { // super.getToolTipText(me); // ????? Point pt = me.getPoint(); int row = rowAtPoint(pt); if (row < 0) { return null; } else { int nameCol = getColumnModel().getColumnIndex(COL_LABEL_NAME); return " " + getValueAt(row, nameCol) + " "; } } @Override public boolean isCellEditable(int row, int column) { // super.isCellEditable(row, column); // ?????? return false; } }; resultTable.addMouseListener(new TblMouseListener()); resultSorter.setTableHeader(resultTable.getTableHeader()); JPanel dbPanel = new JPanel(); dbPanel.setLayout(new BorderLayout()); resultPane = new JScrollPane(resultTable); resultPane.addMouseListener(new PaneMouseListener()); resultTable.setRowSelectionAllowed(true); resultTable.setColumnSelectionAllowed(false); resultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); String[] col2 = { COL_LABEL_NAME, COL_LABEL_SCORE, COL_LABEL_HIT, COL_LABEL_ID, COL_LABEL_ION, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO }; resultDm.setColumnIdentifiers(col2); (resultTable.getColumn(resultTable.getColumnName(0))).setPreferredWidth(LEFT_PANEL_WIDTH - 180); (resultTable.getColumn(resultTable.getColumnName(1))).setPreferredWidth(70); (resultTable.getColumn(resultTable.getColumnName(2))).setPreferredWidth(20); (resultTable.getColumn(resultTable.getColumnName(3))).setPreferredWidth(70); (resultTable.getColumn(resultTable.getColumnName(4))).setPreferredWidth(20); (resultTable.getColumn(resultTable.getColumnName(5))).setPreferredWidth(70); (resultTable.getColumn(resultTable.getColumnName(6))).setPreferredWidth(50); ListSelectionModel lm2 = resultTable.getSelectionModel(); lm2.addListSelectionListener(new LmResultListener()); resultPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, 200)); dbPanel.add(resultPane, BorderLayout.CENTER); // ********************************************************************* // DB Query // ********************************************************************* DefaultTableModel dbDm = new DefaultTableModel(); querySorter = new TableSorter(dbDm, TABLE_QUERY_DB); queryDbTable = new JTable(querySorter) { @Override public boolean isCellEditable(int row, int column) { // super.isCellEditable(row, column); // ?????? return false; } }; queryDbTable.addMouseListener(new TblMouseListener()); querySorter.setTableHeader(queryDbTable.getTableHeader()); queryDbPane = new JScrollPane(queryDbTable); queryDbPane.addMouseListener(new PaneMouseListener()); int h = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); queryDbPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, h)); queryDbTable.setRowSelectionAllowed(true); queryDbTable.setColumnSelectionAllowed(false); queryDbTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); String[] col3 = { COL_LABEL_ID, COL_LABEL_NAME, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO }; DefaultTableModel model = (DefaultTableModel) querySorter.getTableModel(); model.setColumnIdentifiers(col3); // queryDbTable.getColumn(queryDbTable.getColumnName(0)).setPreferredWidth(70); queryDbTable.getColumn(queryDbTable.getColumnName(1)).setPreferredWidth(LEFT_PANEL_WIDTH - 70); queryDbTable.getColumn(queryDbTable.getColumnName(2)).setPreferredWidth(70); queryDbTable.getColumn(queryDbTable.getColumnName(3)).setPreferredWidth(50); ListSelectionModel lm3 = queryDbTable.getSelectionModel(); lm3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lm3.addListSelectionListener(new LmQueryDbListener()); // ? JPanel btnPanel = new JPanel(); btnName.addActionListener(new BtnSearchNameListener()); btnAll.addActionListener(new BtnAllListener()); btnPanel.add(btnName); btnPanel.add(btnAll); parentPanel2 = new JPanel(); parentPanel2.setLayout(new BoxLayout(parentPanel2, BoxLayout.PAGE_AXIS)); parentPanel2.add(btnPanel); parentPanel2.add(queryDbPane); // ? JPanel dispModePanel = new JPanel(); isDispSelected = dispSelected.isSelected(); isDispRelated = dispRelated.isSelected(); if (isDispSelected) { resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } else if (isDispRelated) { resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } Object[] retRadio = new Object[] { dispSelected, dispRelated }; for (int i = 0; i < retRadio.length; i++) { ((JRadioButton) retRadio[i]).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (isDispSelected != dispSelected.isSelected() || isDispRelated != dispRelated.isSelected()) { isDispSelected = dispSelected.isSelected(); isDispRelated = dispRelated.isSelected(); // ?? resultTable.clearSelection(); resultPlot.clear(); compPlot.setPeaks(null, 1); resultPlot.setPeaks(null, 0); setAllPlotAreaRange(); pkgView.initResultRecInfo(); if (isDispSelected) { resultTable.getSelectionModel() .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } else if (isDispRelated) { resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } } } }); } ButtonGroup disGroup = new ButtonGroup(); disGroup.add(dispSelected); disGroup.add(dispRelated); dispModePanel.add(lbl2); dispModePanel.add(dispSelected); dispModePanel.add(dispRelated); JPanel paramPanel = new JPanel(); paramPanel.add(etcPropertyButton); etcPropertyButton.setMargin(new Insets(0, 10, 0, 10)); etcPropertyButton.addActionListener(new ActionListener() { private ParameterSetWindow ps = null; public void actionPerformed(ActionEvent e) { // ?????????? if (!isSubWindow) { ps = new ParameterSetWindow(getParentFrame()); } else { ps.requestFocus(); } } }); JPanel optionPanel = new JPanel(); optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS)); optionPanel.add(dispModePanel); optionPanel.add(paramPanel); // PackageView????? pkgView = new PackageViewPanel(); pkgView.initAllRecInfo(); queryTabPane.addTab("DB", parentPanel2); queryTabPane.setToolTipTextAt(TAB_ORDER_DB, "Query from DB."); queryTabPane.addTab("File", queryFilePane); queryTabPane.setToolTipTextAt(TAB_ORDER_FILE, "Query from user file."); queryTabPane.setSelectedIndex(TAB_ORDER_DB); queryTabPane.setFocusable(false); queryTabPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // ? queryPlot.clear(); compPlot.clear(); resultPlot.clear(); queryPlot.setPeaks(null, 0); compPlot.setPeaks(null, 1); resultPlot.setPeaks(null, 0); // PackageView? pkgView.initAllRecInfo(); // DB Hit? if (resultTabPane.getTabCount() > 0) { resultTabPane.setSelectedIndex(0); } DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel(); dataModel.setRowCount(0); hitLabel.setText(" "); // DB?User File?????? queryTabPane.update(queryTabPane.getGraphics()); if (queryTabPane.getSelectedIndex() == TAB_ORDER_DB) { parentPanel2.update(parentPanel2.getGraphics()); updateSelectQueryTable(queryDbTable); } else if (queryTabPane.getSelectedIndex() == TAB_ORDER_FILE) { queryFilePane.update(queryFilePane.getGraphics()); updateSelectQueryTable(queryFileTable); } } }); // JPanel queryPanel = new JPanel(); queryPanel.setLayout(new BorderLayout()); queryPanel.add(queryTabPane, BorderLayout.CENTER); queryPanel.add(optionPanel, BorderLayout.SOUTH); queryPanel.setMinimumSize(new Dimension(0, 170)); JPanel jtp2Panel = new JPanel(); jtp2Panel.setLayout(new BorderLayout()); jtp2Panel.add(dbPanel, BorderLayout.CENTER); jtp2Panel.add(hitLabel, BorderLayout.SOUTH); jtp2Panel.setMinimumSize(new Dimension(0, 70)); Color colorGreen = new Color(0, 128, 0); hitLabel.setForeground(colorGreen); resultTabPane.addTab("Result", jtp2Panel); resultTabPane.setToolTipTextAt(TAB_RESULT_DB, "Result of DB hit."); resultTabPane.setFocusable(false); queryPlot.setMinimumSize(new Dimension(0, 100)); compPlot.setMinimumSize(new Dimension(0, 120)); resultPlot.setMinimumSize(new Dimension(0, 100)); int height = initAppletHight / 3; JSplitPane jsp_cmp2db = new JSplitPane(JSplitPane.VERTICAL_SPLIT, compPlot, resultPlot); JSplitPane jsp_qry2cmp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPlot, jsp_cmp2db); jsp_cmp2db.setDividerLocation(height); jsp_qry2cmp.setDividerLocation(height - 25); jsp_qry2cmp.setMinimumSize(new Dimension(190, 0)); viewTabPane.addTab("Compare View", jsp_qry2cmp); viewTabPane.addTab("Package View", pkgView); viewTabPane.setToolTipTextAt(TAB_VIEW_COMPARE, "Comparison of query and result spectrum."); viewTabPane.setToolTipTextAt(TAB_VIEW_PACKAGE, "Package comparison of query and result spectrum."); viewTabPane.setSelectedIndex(TAB_VIEW_COMPARE); viewTabPane.setFocusable(false); JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPanel, resultTabPane); jsp.setDividerLocation(310); jsp.setMinimumSize(new Dimension(180, 0)); jsp.setOneTouchExpandable(true); JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jsp, viewTabPane); int divideSize = (int) (initAppletWidth * 0.4); divideSize = (divideSize >= 180) ? divideSize : 180; jsp2.setDividerLocation(divideSize); jsp2.setOneTouchExpandable(true); mainPanel.add(jsp2, BorderLayout.CENTER); add(mainPanel); queryPlot.setSearchPage(this); compPlot.setSearchPage(this); resultPlot.setSearchPage(this); setJMenuBar(MenuBarGenerator.generateMenuBar(this)); }
From source file:flexflux.analyses.result.PP2DResult.java
public void plot() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); // one chart by group Map<Integer, Integer> correspGroup = new HashMap<Integer, Integer>(); XYSeriesCollection dataset = new XYSeriesCollection(); int index = 0; XYSeries series = new XYSeries(""); for (double point : fluxValues) { series.add(point, resultValues.get(point)); correspGroup.put(index, pointIndex.get(point)); index++;/*from ww w . j a v a 2s . co m*/ } dataset.addSeries(series); if (!expValues.isEmpty()) { XYSeries expSeries = new XYSeries("Experimental values"); if (!expValues.isEmpty()) { for (Double d : expValues.keySet()) { for (Double d2 : expValues.get(d)) { expSeries.add(d, d2); } } } dataset.addSeries(expSeries); } final JFreeChart chart = ChartFactory.createXYLineChart("", // chart // title reacName, // domain axis label objName, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.GRAY); plot.setDomainGridlinePaint(Color.GRAY); XYLineAndShapeRenderer renderer = new MyRenderer(true, false, correspGroup); plot.setRenderer(0, renderer); if (!expValues.isEmpty()) { renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesPaint(1, Color.BLUE); } ChartPanel chartPanel = new ChartPanel(chart); panel.add(chartPanel); JPanel fvaPanel = new JPanel(); fvaPanel.setLayout(new BoxLayout(fvaPanel, BoxLayout.PAGE_AXIS)); for (int i = 1; i <= groupIndex.size(); i++) { Color color = COLORLIST[i % COLORLIST.length]; JPanel groupPanel = new JPanel(); groupPanel.setLayout(new BoxLayout(groupPanel, BoxLayout.PAGE_AXIS)); List<BioEntity> newEssentialReactions = comparator.getNewEssentialEntities().get(i); List<BioEntity> noLongerEssentialReactions = comparator.getNoLongerEssentialEntities().get(i); JPanel colorPanel = new JPanel(); colorPanel.setBackground(color); groupPanel.add(colorPanel); groupPanel.add(new JLabel( "Phenotypic phase " + i + ", " + newEssentialReactions.size() + " new essential reactions")); fvaPanel.add(groupPanel); if (newEssentialReactions.size() > 0) { fvaPanel.add(new JScrollPane(comparator.getNewEssentialEntitiesPanel().get(i))); } fvaPanel.add(new JLabel("Phenotypic phase " + i + ", " + noLongerEssentialReactions.size() + " no longer essential reactions")); if (noLongerEssentialReactions.size() > 0) { fvaPanel.add(fvaPanel.add(new JScrollPane(comparator.getNoLongerEssentialEntitiesPanel().get(i)))); } } JScrollPane fvaScrollPane = new JScrollPane(fvaPanel); JFrame frame = new JFrame("Phenotypic phase analysis results"); if (expValues.size() > 0) { frame.setTitle("Pareto analysis two dimensions results"); } if (groupIndex.size() > 0) { JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panel, fvaScrollPane); frame.setContentPane(splitPane); frame.setSize(600, 1000); } else { frame.setContentPane(panel); frame.setSize(600, 600); } panel.setPreferredSize(new Dimension(600, 600)); panel.setMinimumSize(new Dimension(600, 600)); RefineryUtilities.centerFrameOnScreen(frame); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:sim.util.media.chart.ChartGenerator.java
/** Generates a new ChartGenerator with a blank chart. Before anything else, buildChart() is called. */ public ChartGenerator() { // create the chart buildChart();/*from w w w .j a v a 2s .co m*/ chart.getPlot().setBackgroundPaint(Color.WHITE); chart.setAntiAlias(true); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true); split.setBorder(new EmptyBorder(0, 0, 0, 0)); JScrollPane scroll = new JScrollPane(); JPanel b = new JPanel(); b.setLayout(new BorderLayout()); b.add(seriesAttributes, BorderLayout.NORTH); b.add(new JPanel(), BorderLayout.CENTER); scroll.getViewport().setView(b); scroll.setBackground(getBackground()); scroll.getViewport().setBackground(getBackground()); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); LabelledList list = new LabelledList("Chart Properties"); DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list); globalAttributes.add(pan1); JLabel j = new JLabel("Right-Click or Control-Click"); j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC)); list.add(j); j = new JLabel("on Chart for More Options"); j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC)); list.add(j); titleField = new PropertyField() { public String newValue(String newValue) { setTitle(newValue); getChartPanel().repaint(); return newValue; } }; titleField.setValue(chart.getTitle().getText()); list.add(new JLabel("Title"), titleField); buildGlobalAttributes(list); final JCheckBox legendCheck = new JCheckBox(); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LegendTitle title = new LegendTitle(chart.getPlot()); title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4)); chart.addLegend(title); } else { chart.removeLegend(); } } }; legendCheck.addItemListener(il); list.add(new JLabel("Legend"), legendCheck); legendCheck.setSelected(true); /* final JCheckBox aliasCheck = new JCheckBox(); aliasCheck.setSelected(chart.getAntiAlias()); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED ); } }; aliasCheck.addItemListener(il); list.add(new JLabel("Antialias"), aliasCheck); */ JPanel pdfButtonPanel = new JPanel(); pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output")); DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel); pdfButtonPanel.setLayout(new BorderLayout()); Box pdfbox = new Box(BoxLayout.Y_AXIS); pdfButtonPanel.add(pdfbox, BorderLayout.WEST); JButton pdfButton = new JButton("Save as PDF"); pdfbox.add(pdfButton); pdfButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE); fd.setFile(chart.getTitle().getText() + ".pdf"); fd.setVisible(true); String fileName = fd.getFile(); if (fileName != null) { Dimension dim = chartPanel.getPreferredSize(); PDFEncoder.generatePDF(chart, dim.width, dim.height, new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf"))); } } }); movieButton = new JButton("Create a Movie"); pdfbox.add(movieButton); pdfbox.add(Box.createGlue()); movieButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (movieMaker == null) startMovie(); else stopMovie(); } }); globalAttributes.add(pan2); // we add into an outer box so we can later on add more global seriesAttributes // as the user instructs and still have glue be last Box outerAttributes = Box.createVerticalBox(); outerAttributes.add(globalAttributes); outerAttributes.add(Box.createGlue()); p.add(outerAttributes, BorderLayout.NORTH); p.add(scroll, BorderLayout.CENTER); p.setMinimumSize(new Dimension(0, 0)); p.setPreferredSize(new Dimension(200, 0)); split.setLeftComponent(p); // Add scale and proportion fields Box header = Box.createHorizontalBox(); final double MAXIMUM_SCALE = 8; fixBox = new JCheckBox("Fill"); fixBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setFixed(fixBox.isSelected()); } }); header.add(fixBox); fixBox.setSelected(true); // add the scale field scaleField = new NumberTextField(" Scale: ", 1.0, true) { public double newValue(double newValue) { if (newValue <= 0.0) newValue = currentValue; if (newValue > MAXIMUM_SCALE) newValue = currentValue; scale = newValue; resizeChart(); return newValue; } }; scaleField.setToolTipText("Zoom in and out"); scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); scaleField.setEnabled(false); scaleField.setText(""); header.add(scaleField); // add the proportion field proportionField = new NumberTextField(" Proportion: ", 1.5, true) { public double newValue(double newValue) { if (newValue <= 0.0) newValue = currentValue; proportion = newValue; resizeChart(); return newValue; } }; proportionField.setToolTipText("Change the chart proportions (ratio of width to height)"); proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); header.add(proportionField); chartHolder.setMinimumSize(new Dimension(0, 0)); chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); chartHolder.getViewport().setBackground(Color.gray); JPanel p2 = new JPanel(); p2.setLayout(new BorderLayout()); p2.add(chartHolder, BorderLayout.CENTER); p2.add(header, BorderLayout.NORTH); split.setRightComponent(p2); setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); // set the default to be white, which looks good when printed chart.setBackgroundPaint(Color.WHITE); // JFreeChart has a hillariously broken way of handling font scaling. // It allows fonts to scale independently in X and Y. We hack a workaround here. chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT); chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT); chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion)); chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion)); chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION), (int) (DEFAULT_CHART_HEIGHT))); }
From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java
/** Generates a new ChartGenerator with a blank chart. Before anything else, buildChart() is called. */ public ChartGenerator() { // create the chart buildChart();/*from www .j a v a 2 s . c om*/ chart.getPlot().setBackgroundPaint(Color.WHITE); chart.setAntiAlias(true); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true); split.setBorder(new EmptyBorder(0, 0, 0, 0)); JScrollPane scroll = new JScrollPane(); JPanel b = new JPanel(); b.setLayout(new BorderLayout()); b.add(seriesAttributes, BorderLayout.NORTH); b.add(new JPanel(), BorderLayout.CENTER); scroll.getViewport().setView(b); scroll.setBackground(getBackground()); scroll.getViewport().setBackground(getBackground()); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); LabelledList list = new LabelledList("Chart Properties"); DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list); globalAttributes.add(pan1); JLabel j = new JLabel("Right-Click or Control-Click"); j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC)); list.add(j); j = new JLabel("on Chart for More Options"); j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC)); list.add(j); titleField = new PropertyField() { public String newValue(String newValue) { setTitle(newValue); getChartPanel().repaint(); return newValue; } }; titleField.setValue(chart.getTitle().getText()); list.add(new JLabel("Title"), titleField); buildGlobalAttributes(list); final JCheckBox legendCheck = new JCheckBox(); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LegendTitle title = new LegendTitle(chart.getPlot()); title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4)); chart.addLegend(title); } else { chart.removeLegend(); } } }; legendCheck.addItemListener(il); list.add(new JLabel("Legend"), legendCheck); legendCheck.setSelected(true); /* final JCheckBox aliasCheck = new JCheckBox(); aliasCheck.setSelected(chart.getAntiAlias()); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED ); } }; aliasCheck.addItemListener(il); list.add(new JLabel("Antialias"), aliasCheck); */ JPanel pdfButtonPanel = new JPanel(); pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output")); DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel); pdfButtonPanel.setLayout(new BorderLayout()); Box pdfbox = new Box(BoxLayout.Y_AXIS); pdfButtonPanel.add(pdfbox, BorderLayout.WEST); JButton pdfButton = new JButton("Save as PDF"); pdfbox.add(pdfButton); pdfButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE); fd.setFile(chart.getTitle().getText() + ".pdf"); fd.setVisible(true); String fileName = fd.getFile(); if (fileName != null) { Dimension dim = chartPanel.getPreferredSize(); PDFEncoder.generatePDF(chart, dim.width, dim.height, new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf"))); } } }); movieButton = new JButton("Create a Movie"); pdfbox.add(movieButton); pdfbox.add(Box.createGlue()); movieButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (movieMaker == null) { startMovie(); } else { stopMovie(); } } }); globalAttributes.add(pan2); // we add into an outer box so we can later on add more global seriesAttributes // as the user instructs and still have glue be last Box outerAttributes = Box.createVerticalBox(); outerAttributes.add(globalAttributes); outerAttributes.add(Box.createGlue()); p.add(outerAttributes, BorderLayout.NORTH); p.add(scroll, BorderLayout.CENTER); p.setMinimumSize(new Dimension(0, 0)); p.setPreferredSize(new Dimension(200, 0)); split.setLeftComponent(p); // Add scale and proportion fields Box header = Box.createHorizontalBox(); final double MAXIMUM_SCALE = 8; fixBox = new JCheckBox("Fill"); fixBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setFixed(fixBox.isSelected()); } }); header.add(fixBox); fixBox.setSelected(true); // add the scale field scaleField = new NumberTextField(" Scale: ", 1.0, true) { public double newValue(double newValue) { if (newValue <= 0.0) { newValue = currentValue; } if (newValue > MAXIMUM_SCALE) { newValue = currentValue; } scale = newValue; resizeChart(); return newValue; } }; scaleField.setToolTipText("Zoom in and out"); scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); scaleField.setEnabled(false); scaleField.setText(""); header.add(scaleField); // add the proportion field proportionField = new NumberTextField(" Proportion: ", 1.5, true) { public double newValue(double newValue) { if (newValue <= 0.0) { newValue = currentValue; } proportion = newValue; resizeChart(); return newValue; } }; proportionField.setToolTipText("Change the chart proportions (ratio of width to height)"); proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); header.add(proportionField); chartHolder.setMinimumSize(new Dimension(0, 0)); chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); chartHolder.getViewport().setBackground(Color.gray); JPanel p2 = new JPanel(); p2.setLayout(new BorderLayout()); p2.add(chartHolder, BorderLayout.CENTER); p2.add(header, BorderLayout.NORTH); split.setRightComponent(p2); setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); // set the default to be white, which looks good when printed chart.setBackgroundPaint(Color.WHITE); // JFreeChart has a hillariously broken way of handling font scaling. // It allows fonts to scale independently in X and Y. We hack a workaround here. chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT); chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT); chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion)); chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion)); chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION), (int) (DEFAULT_CHART_HEIGHT))); }
From source file:fxts.stations.util.preferences.EditAction.java
public void actionPerformed(ActionEvent aEvent) { JButton okButton = UIManager.getInst().createButton(); JButton cancelButton = UIManager.getInst().createButton(); final JDialog dialog = new JDialog(mEditorPanel.getParentDialog()); dialog.setTitle(mEditorPanel.getTitle()); JPanel editPanel = new JPanel(); JPanel buttonPanel = new JPanel(); JPanel mainPanel = new JPanel(); mainPanel.setLayout(UIFrontEnd.getInstance().getSideLayout()); //mainPanel.setLayout(new SideLayout()); //sets button panel buttonPanel.setLayout(UIFrontEnd.getInstance().getSideLayout()); okButton.setText(mResMan.getString("IDS_OK_BUTTON")); //okButton.setPreferredSize(new Dimension(80, 27)); GridBagConstraints sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.insets = new Insets(10, 10, 10, 10); sideConstraints.gridx = 0;//ww w . j a va2 s . c o m sideConstraints.gridy = 0; ResizeParameterWrapper resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.5, 0.0, 0.5, 0.0); resizeParameter.setToConstraints(sideConstraints); buttonPanel.add(okButton, sideConstraints); cancelButton.setText(mResMan.getString("IDS_CANCEL_BUTTON")); //cancelButton.setPreferredSize(new Dimension(80, 27)); sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.insets = new Insets(10, 10, 10, 10); sideConstraints.gridx = 1; sideConstraints.gridy = 0; resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.5, 0.0, 0.5, 0.0); resizeParameter.setToConstraints(sideConstraints); buttonPanel.add(cancelButton, sideConstraints); //adds button panel sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.insets = new Insets(10, 10, 10, 10); sideConstraints.gridx = 0; sideConstraints.gridy = 1; resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.0, 1.0, 1.0, 1.0); resizeParameter.setToConstraints(sideConstraints); mainPanel.add(buttonPanel, sideConstraints); //sets edit panel final IEditor editor = mType.getEditor(); editor.setValue(mValue); editPanel.setLayout(UIFrontEnd.getInstance().getSideLayout()); sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.0, 0.0, 1.0, 1.0); resizeParameter.setToConstraints(sideConstraints); Component editComp = editor.getComponent(); //Mar 25 2004 - kav: added for right tab order at Font Chooser at java 1.4. if (editComp instanceof FontChooser) { FontChooser fc = (FontChooser) editComp; fc.setNextFocusedComp(okButton); } editPanel.add(editComp, sideConstraints); //adds editor panel sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.gridx = 0; sideConstraints.gridy = 0; resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.0, 0.0, 1.0, 1.0); resizeParameter.setToConstraints(sideConstraints); mainPanel.add(editPanel, sideConstraints); //adds main panel dialog.getContentPane().setLayout(UIFrontEnd.getInstance().getSideLayout()); //dialog.getContentPane().setLayout(new SideLayout()); sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.fill = GridBagConstraints.BOTH; resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.0, 0.0, 1.0, 1.0); resizeParameter.setToConstraints(sideConstraints); dialog.getContentPane().add(mainPanel, sideConstraints); //adds listeners to buttons okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent aEvent) { if (editor.getValue().equals(mValue)) { // } else { mValue = editor.getValue(); mEditorPanel.setValue(mValue); mEditorPanel.refreshControls(); mEditorPanel.setValueChanged(true); } dialog.setVisible(false); dialog.dispose(); } }); okButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "ExitAction"); okButton.getActionMap().put("ExitAction", new AbstractAction() { /** * Invoked when an action occurs. */ public void actionPerformed(ActionEvent aEvent) { editor.setValue(mValue); dialog.setVisible(false); dialog.dispose(); } }); okButton.requestFocus(); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent aEvent) { editor.setValue(mValue); dialog.setVisible(false); dialog.dispose(); } }); //dialog.setResizable(false); dialog.setModal(true); dialog.pack(); //sets minimal sizes for components Dimension dim = mainPanel.getSize(); mainPanel.setMinimumSize(dim); mainPanel.setPreferredSize(dim); //sets size of buttons Dimension dimOkButton = okButton.getSize(); Dimension dimCancelButton = cancelButton.getSize(); int nMaxWidth = dimOkButton.getWidth() > dimCancelButton.getWidth() ? (int) dimOkButton.getWidth() : (int) dimCancelButton.getWidth(); okButton.setPreferredSize(new Dimension(nMaxWidth, (int) dimOkButton.getHeight())); okButton.setSize(new Dimension(nMaxWidth, (int) dimOkButton.getHeight())); cancelButton.setPreferredSize(new Dimension(nMaxWidth, (int) dimCancelButton.getHeight())); cancelButton.setSize(new Dimension(nMaxWidth, (int) dimCancelButton.getHeight())); dialog.setLocationRelativeTo(dialog.getOwner()); dialog.setVisible(true); }
From source file:org.esa.beam.visat.toolviews.stat.StatisticsPanel.java
private JPanel getRightPanel() { computePanel = new MultipleRoiComputePanel(this, getRaster()); final JPanel rightPanel = GridBagUtils.createPanel(); final JPanel mainPane = GridBagUtils.createPanel(); // GridBagConstraints extendedOptionsPanelConstraints = GridBagUtils.createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1,insets.right=-2"); GridBagConstraints extendedOptionsPanelConstraints = GridBagUtils .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1"); GridBagUtils.addToPanel(rightPanel, computePanel, extendedOptionsPanelConstraints, "gridy=0,fill=NONE,weighty=1,weightx=1"); // GridBagUtils.addToPanel(rightPanel, statisticsCriteriaPanel.getCriteriaFormattingTabbedPane(), extendedOptionsPanelConstraints, "gridy=1,fill=BOTH,weighty=0, insets.top=10"); computePanel.getCriteriaPanel().setBorder(UIUtils.createGroupBorder("")); GridBagUtils.addToPanel(computePanel.getCriteriaPanel(), statisticsCriteriaPanel.getCriteriaPanel(), extendedOptionsPanelConstraints, "insets.top=10, insets.left=5, insets.right=5"); JButton resetToDefaultsButton = new JButton("Reset"); resetToDefaultsButton.addActionListener(new ActionListener() { @Override//from ww w .jav a2s . c o m public void actionPerformed(ActionEvent e) { statisticsCriteriaPanel.reset(); } }); runButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { computePanel.run(); } }); runButton.setEnabled(getRaster() != null); exportButton = getExportButton(); exportButton.setToolTipText("Export: This only exports the binning portion of the statistics"); exportButton.setVisible(exportButtonVisible); final JPanel exportAndHelpPanel = GridBagUtils.createPanel(); GridBagConstraints helpPanelConstraints = GridBagUtils .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1,ipadx=0"); GridBagUtils.addToPanel(exportAndHelpPanel, new JSeparator(), helpPanelConstraints, "fill=HORIZONTAL,gridwidth=4,insets.left=5,insets.right=5"); GridBagUtils.addToPanel(exportAndHelpPanel, exportButton, helpPanelConstraints, "gridy=1,anchor=WEST,fill=NONE, gridwidth=1"); GridBagUtils.addToPanel(exportAndHelpPanel, runButton, helpPanelConstraints, "gridx=1, gridy=1,anchor=WEST,fill=NONE"); GridBagUtils.addToPanel(exportAndHelpPanel, resetToDefaultsButton, helpPanelConstraints, "gridx=2, gridy=1,anchor=CENTER,fill=NONE"); GridBagUtils.addToPanel(exportAndHelpPanel, getHelpButton(), helpPanelConstraints, "gridx=3,gridy=1,anchor=EAST,fill=NONE"); GridBagUtils.addToPanel(rightPanel, exportAndHelpPanel, extendedOptionsPanelConstraints, "gridy=2,anchor=SOUTHWEST,fill=HORIZONTAL,weighty=0,insets.top=0"); rightPanel.setMinimumSize(rightPanel.getPreferredSize()); return rightPanel; }