List of usage examples for javax.swing JDialog setSize
public void setSize(int width, int height)
The width and height values are automatically enlarged if either is less than the minimum size as specified by previous call to setMinimumSize .
From source file:org.fhcrc.cpl.viewer.ms2.Fractionation2DUtilities.java
public static void showHeatMapChart(FractionatedAMTDatabaseStructure amtDatabaseStructure, double[] dataForChart, String chartName, boolean showLegend) { int chartWidth = 1000; int chartHeight = 1000; double globalMinValue = Double.MAX_VALUE; double globalMaxValue = Double.MIN_VALUE; for (double value : dataForChart) { if (value < globalMinValue) globalMinValue = value;/*from w w w. ja va 2 s.c o m*/ if (value > globalMaxValue) globalMaxValue = value; } _log.debug("showHeatMapChart: experiment structures:"); List<double[][]> amtPeptidesInExperiments = new ArrayList<double[][]>(); for (int i = 0; i < amtDatabaseStructure.getNumExperiments(); i++) { int experimentWidth = amtDatabaseStructure.getExperimentStructure(i).columns; int experimentHeight = amtDatabaseStructure.getExperimentStructure(i).rows; _log.debug("\t" + amtDatabaseStructure.getExperimentStructure(i)); amtPeptidesInExperiments.add(new double[experimentWidth][experimentHeight]); } for (int i = 0; i < dataForChart.length; i++) { Pair<Integer, int[]> positionInExperiments = amtDatabaseStructure.calculateExperimentAndPosition(i); int xpos = positionInExperiments.second[0]; int ypos = positionInExperiments.second[1]; int experimentIndex = positionInExperiments.first; //System.err.println("i, xpos, ypos: " + i + ", " + xpos + ", " + ypos); amtPeptidesInExperiments.get(experimentIndex)[xpos][ypos] = dataForChart[i]; } JDialog cd = new JDialog(ApplicationContext.getFrame(), "Heat Map(s)"); cd.setSize(chartWidth, chartHeight); cd.setPreferredSize(new Dimension(chartWidth, chartHeight)); cd.setLayout(new FlowLayout()); int nextPerfectSquareRoot = 0; while (true) { nextPerfectSquareRoot++; if ((nextPerfectSquareRoot * nextPerfectSquareRoot) >= amtPeptidesInExperiments.size()) { break; } } int plotWidth = (int) ((double) (chartWidth - 20) / (double) nextPerfectSquareRoot); int plotHeight = (int) ((double) (chartHeight - 20) / (double) nextPerfectSquareRoot); _log.debug("Rescaled chart dimensions: " + plotWidth + "x" + plotHeight); LookupPaintScale paintScale = PanelWithHeatMap.createPaintScale(globalMinValue, globalMaxValue, Color.BLUE, Color.RED); for (int i = 0; i < amtPeptidesInExperiments.size(); i++) { PanelWithHeatMap pwhm = new PanelWithHeatMap(amtPeptidesInExperiments.get(i), "Experiment " + (i + 1)); // pwhm.setPalette(PanelWithHeatMap.PALETTE_BLUE_RED); pwhm.setPaintScale(paintScale); pwhm.setPreferredSize(new Dimension(plotWidth, plotHeight)); pwhm.setAxisLabels("AX Fraction", "RP Fraction"); if (!showLegend) pwhm.getChart().removeLegend(); cd.add(pwhm); } cd.setTitle(chartName); cd.setVisible(true); }
From source file:org.nekorp.workflow.desktop.view.resource.imp.EvidenciaViewDialogFactory.java
@Override public JDialog createDialog(Frame frame, boolean modal) { JDialog dialog = new JDialog(mainFrame, true); dialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); dialog.setTitle("Evidencia"); evidenciaView.iniciaVista();/*from w w w .j ava 2s.c o m*/ dialog.add(evidenciaView); dialog.setSize(980, 640);//hardcode para que no cresca en medida de imagenes en el preview dialog.validate(); //dialog.pack(); dialog.setLocationRelativeTo(mainFrame); return dialog; }
From source file:kenh.xscript.elements.Debug.java
/** * a dialog use to debug./* ww w .j a v a 2 s . co m*/ */ public void process() { JDialog dialog = new JDialog((Frame) null, true); dialog.setTitle("Debugger"); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setSize(750, 200); initial(dialog.getContentPane()); dialog.setVisible(true); this.result = null; }
From source file:com.aw.swing.mvp.JDialogView.java
public void hide() { JDialog dlg = (JDialog) parentContainer; size = dlg.getSize(); dlg.setSize(0, 0); }
From source file:edu.ucla.stat.SOCR.motionchart.MotionMouseListener.java
/** * Callback method for receiving notification of a mouse click on a chart. * * @param event information about the event. *//*w w w . ja v a 2s .c o m*/ public void chartMouseClicked(ChartMouseEvent event) { if (event.getTrigger().getClickCount() > 1) { if (event.getEntity() instanceof XYItemEntity) { XYItemEntity item = (XYItemEntity) event.getEntity(); Component c = event.getTrigger().getComponent(); final JDialog dialog = new JDialog(JOptionPane.getFrameForComponent(c), "Item Data", false); dialog.setSize(400, 300); dialog.setLocation(getDialogLocation(dialog, c)); dialog.add(getItemPanel(dialog, item, event)); dialog.setVisible(true); } else { XYItemEntity item = (XYItemEntity) event.getEntity(); Component c = event.getTrigger().getComponent(); final JDialog dialog = new JDialog(JOptionPane.getFrameForComponent(c), "Item Data", false); dialog.setSize(400, 300); dialog.setLocation(getDialogLocation(dialog, c)); dialog.add(getSeriesPanel(dialog, event)); dialog.setVisible(true); } } else { if (!(event.getChart().getXYPlot().getRenderer() instanceof MotionBubbleRenderer)) { return; } MotionBubbleRenderer renderer = (MotionBubbleRenderer) event.getChart().getXYPlot().getRenderer(); MotionDataSet dataset = (MotionDataSet) event.getChart().getXYPlot().getDataset(); if (event.getEntity() instanceof XYItemEntity) { boolean selected; XYItemEntity entity = (XYItemEntity) event.getEntity(); int series = entity.getSeriesIndex(); int item = entity.getItem(); Object category = dataset.getCategory(series, item); if (category == null) { selected = !renderer.isSelectedItem(series, item); renderer.setSelectedItem(series, item, selected); } else { selected = !renderer.isSelectedCategory(category); renderer.setSelectedCategory(category, selected); } } } }
From source file:biomine.bmvis2.pipeline.sources.QueryGraphSource.java
@Override public BMGraph getBMGraph() throws GraphOperationException { try {// w ww .j av a 2 s . c o m if (fetch == null) { fetch = new CrawlerFetch(query, neighborhood, database); } if (ret == null) { final JDialog dial = new JDialog((JFrame) null); dial.setTitle("BMVIS II - Query to database"); dial.setSize(400, 200); dial.setMinimumSize(new Dimension(400, 200)); dial.setResizable(false); final JTextArea text = new JTextArea(); text.setEditable(false); dial.add(text); text.setText("..."); class Z { Exception runExc = null; } final Z z = new Z(); Runnable fetchThread = new Runnable() { public void run() { try { long startTime = System.currentTimeMillis(); while (!fetch.isDone()) { fetch.update(); Thread.sleep(500); long time = System.currentTimeMillis(); long elapsed = time - startTime; if (elapsed > 30000) { throw new GraphOperationException("Timeout while querying " + query); } final String newText = fetch.getState() + ":\n" + fetch.getMessages(); SwingUtilities.invokeLater(new Runnable() { public void run() { text.setText(newText); } }); } SwingUtilities.invokeAndWait(new Runnable() { public void run() { dial.setVisible(false); } }); } catch (Exception e) { z.runExc = e; } } }; new Thread(fetchThread).start(); dial.setModalityType(ModalityType.APPLICATION_MODAL); dial.setVisible(true); ret = fetch.getBMGraph(); if (ret == null) throw new GraphOperationException(fetch.getMessages()); if (z.runExc != null) { if (z.runExc instanceof GraphOperationException) throw (GraphOperationException) z.runExc; else throw new GraphOperationException(z.runExc); } } } catch (IOException e) { throw new GraphOperationException(e); } updateInfo(); return ret; }
From source file:net.lmxm.ute.gui.validation.AbstractInputValidator.java
/** * Display messages dialog./*from w ww .j a v a 2s. c o m*/ * * @param component the component * @param messages the messages */ private void displayMessagesDialog(final JComponent component, final List<String> messages) { final JDialog dialog = getMessagesDialog(); // Load dialog with messages. getMessagesLabel().setText(StringUtils.join(messages, "\n")); // Relocate dialog relative to the input component dialog.setSize(0, 0); dialog.setLocationRelativeTo(component); final Point location = dialog.getLocation(); final Dimension componentSize = component.getSize(); dialog.setLocation(location.x - (int) componentSize.getWidth() / 2, location.y + (int) componentSize.getHeight() / 2); dialog.pack(); dialog.setVisible(true); }
From source file:biomine.bmvis2.pipeline.sources.QueryGraphSource.java
public static QueryGraphSource createFromDialog(Collection<VisualNode> start, String database) { final CrawlSuggestionList sel = new CrawlSuggestionList(); final JDialog dial = new JDialog(); if (database != null) sel.setDatabase(database);//from w w w .j a v a2s.c o m for (VisualNode vn : start) { if (vn.getBMNode() != null) sel.addNode(vn); } dial.setModalityType(ModalityType.APPLICATION_MODAL); final CrawlQuery q = new CrawlQuery(); // Helper class to pass back data from anonymous inner classes to this method class Z { boolean okPressed = false; } final Z z = new Z(); JButton okButton = new JButton(new AbstractAction("OK") { public void actionPerformed(ActionEvent arg0) { dial.setVisible(false); q.addAll(sel.getQueryTerms()); z.okPressed = true; } }); JPanel pane = new JPanel(); pane.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weightx = 1; c.weighty = 1; c.fill = c.BOTH; c.gridwidth = 2; c.gridx = 0; c.gridy = 0; pane.add(sel, c); c.weighty = 0; c.gridy++; c.fill = c.HORIZONTAL; c.gridwidth = 1; pane.add(okButton, c); dial.setContentPane(pane); dial.setSize(600, 500); dial.setVisible(true);//this will hopefully block if (z.okPressed) { if (q.size() == 0) { JOptionPane.showMessageDialog(dial, "At least 1 edge must be selected: no queries added"); return null; } return new QueryGraphSource(q, sel.getDatabase()); } return null; }
From source file:net.phyloviz.project.action.LoadDataSetAction.java
private JDialog createLoadingDialog() { JDialog d = new JDialog(WindowManager.getDefault().getMainWindow(), null, true); d.setLayout(new GridBagLayout()); JPanel panel = new JPanel(); JLabel jlabel = new JLabel("Loading DataSet....."); jlabel.setFont(new Font("Verdana", 1, 14)); panel.add(jlabel);//from ww w . j a v a 2 s .com d.add(panel, new GridBagConstraints()); d.setSize(200, 50); d.setLocationRelativeTo(null); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); return d; }
From source file:com.stonelion.zooviewer.ui.JZVNodePanel.java
/** * Returns the 'Add child' action./*from w w w . ja va 2 s . c o m*/ * * @return the action */ @SuppressWarnings("serial") private Action getAddChildAction() { if (addChildAction == null) { String actionCommand = bundle.getString(ADD_CHILD_NODE_KEY); String actionKey = bundle.getString(ADD_CHILD_NODE_KEY + ".action"); addChildAction = new AbstractAction(actionCommand, Icons.ADD) { @Override public void actionPerformed(ActionEvent e) { System.out.println("actionPerformed(): action = " + e.getActionCommand()); if (checkAction()) { model.addNode(StringUtils.removeEnd(nodes[0].getPath(), "/") + "/" + childName, childText.getBytes()); } childName = childText = ""; } private boolean checkAction() { JDialog dlg = createAddChildDialog(); dlg.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dlg.setSize(800, 600); dlg.setLocationRelativeTo(null); dlg.setVisible(true); boolean nameIsEmpty = childName == null || childName.isEmpty(); boolean dataIsEmpty = childText == null; return !nameIsEmpty && !dataIsEmpty; } }; addChildAction.putValue(Action.ACTION_COMMAND_KEY, actionKey); } return this.addChildAction; }