List of usage examples for javax.swing ListSelectionModel SINGLE_SELECTION
int SINGLE_SELECTION
To view the source code for javax.swing ListSelectionModel SINGLE_SELECTION.
Click Source Link
From source file:org.adamkrajcik.gui.MainForm.java
public MainForm() { DataSource bds = new EmbeddedDatabaseBuilder().setType(DERBY).addScript("classpath:createTables.sql") .addScript("classpath:testData.sql").build(); dataSource = bds;/*from w w w . j a v a 2 s . c o m*/ /*config = ResourceBundle.getBundle("org/adamkrajcik/gui/resources/config"); BasicDataSource bds = new BasicDataSource(); bds.setUrl(config.getString("url")); bds.setUsername(config.getString("user")); bds.setPassword(config.getString("password")); bds.setDriverClassName("org.apache.derby.jdbc.ClientDriver"); dataSource = bds; */ try { langResource = ResourceBundle.getBundle("org/adamkrajcik/gui/resources/lang", getLocale()); } catch (Exception ex) { langResource = ResourceBundle.getBundle("org/adamkrajcik/gui/resources/lang"); log.debug("Error local language bundle doesnt exist.", ex); JOptionPane.showMessageDialog(rootPane, "This application isn't yet translated to your language. Default language was set. ", "Warning", JOptionPane.WARNING_MESSAGE); } WineManagerImpl wmi = new WineManagerImpl(); wmi.setDataSource(dataSource); wineManager = wmi; CellarManagerImpl cmi = new CellarManagerImpl(); cmi.setDataSource(dataSource); cellarManager = cmi; WineCellarsManagerImpl wcmi = new WineCellarsManagerImpl(); wcmi.setDataSource(dataSource); wineCellarManager = wcmi; wineTableModel = new WineTableModel(wineManager, wineCellarManager, langResource); cellarTableModel = new CellarTableModel(cellarManager, wineCellarManager, langResource); new LoadAllCellarsSwingWorker().execute(); new LoadAllWinesSwingWorker().execute(); initComponents(); wineFilterPanel.setVisible(false); WineTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); }
From source file:org.angnysa.yaba.swing.BudgetFrame.java
private void buildTransactionTable() { transactionModel = new TransactionTableModel(service); transactionTable = new JTable(transactionModel); transactionTable.setRowHeight((int) (transactionTable.getRowHeight() * 1.2)); transactionTable.getColumnModel().getColumn(TransactionTableModel.COL_END) .setCellEditor(new CustomCellEditor( new JFormattedTextField(new OptionalValueFormatter(new JodaLocalDateFormat())))); transactionTable.setDefaultEditor(LocalDate.class, new CustomCellEditor(new JFormattedTextField(new JodaLocalDateFormat()))); transactionTable.setDefaultEditor(ReadablePeriod.class, new CustomCellEditor(new JFormattedTextField(new OptionalValueFormatter(new JodaPeriodFormat())))); transactionTable.setDefaultEditor(Double.class, new CustomCellEditor(new JFormattedTextField(NumberFormat.getNumberInstance()))); transactionTable.setDefaultRenderer(LocalDate.class, new FormattedTableCellRenderer(new JodaLocalDateFormat())); transactionTable.setDefaultRenderer(ReadablePeriod.class, new FormattedTableCellRenderer(new JodaPeriodFormat())); transactionTable.setDefaultRenderer(Double.class, new FormattedTableCellRenderer(TransactionAmountFormatFactory.getFormat())); transactionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); transactionTable.setAutoCreateRowSorter(true); transactionTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "delete"); //$NON-NLS-1$ transactionTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) .put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "delete"); //$NON-NLS-1$ transactionTable.getActionMap().put("delete", new AbstractAction() { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override//from w w w. j av a 2 s .co m public void actionPerformed(ActionEvent e) { int row = transactionTable.getSelectedRow(); if (row >= 0) { row = transactionTable.getRowSorter().convertRowIndexToModel(row); transactionModel.deleteRow(row); } } }); }
From source file:simx.profiler.info.actor.ActorInstanceInfoTopComponent.java
/** * This constructor initializes the top component. It configures the * tales creates the visulizations.//w w w .j av a2s. c om */ public ActorInstanceInfoTopComponent() { initComponents(); setName(Bundle.CTL_ActorInstanceInfoTopComponent()); setToolTipText(Bundle.HINT_ActorInstanceInfoTopComponent()); this.content = new InstanceContent(); this.associateLookup(new AbstractLookup(this.content)); ListSelectionModel listSelectionModel = this.messageSentTable.getSelectionModel(); listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listSelectionModel.addListSelectionListener((ListSelectionEvent e) -> { if (messageSentTable.getSelectedRow() != -1) { messagesReceivedTable.clearSelection(); messageProcessedTable.clearSelection(); if (selectedMessageType != null) content.remove(selectedMessageType); selectedMessageType = sentMessages.get(messageSentTable.getSelectedRow()).getKey(); content.add(selectedMessageType); } }); listSelectionModel = this.messagesReceivedTable.getSelectionModel(); listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listSelectionModel.addListSelectionListener((ListSelectionEvent e) -> { if (messagesReceivedTable.getSelectedRow() != -1) { messageSentTable.clearSelection(); messageProcessedTable.clearSelection(); if (selectedMessageType != null) content.remove(selectedMessageType); selectedMessageType = receivedMessages.get(messagesReceivedTable.getSelectedRow()).getKey(); content.add(selectedMessageType); } }); listSelectionModel = this.messageProcessedTable.getSelectionModel(); listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listSelectionModel.addListSelectionListener((ListSelectionEvent e) -> { if (messageProcessedTable.getSelectedRow() != -1) { messageSentTable.clearSelection(); messagesReceivedTable.clearSelection(); if (selectedMessageType != null) content.remove(selectedMessageType); selectedMessageType = processedMessages.get(messageProcessedTable.getSelectedRow()).getKey(); content.add(selectedMessageType); } }); this.messagesSentDataSet = new DefaultPieDataset(); this.messagesReceivedDataSet = new DefaultPieDataset(); this.messagesProcessedDataSet = new DefaultPieDataset(); this.createPieChart(this.messagesSentDataSet, this.messagesSentPanel); this.createPieChart(this.messagesReceivedDataSet, this.messagesReceivedPanel); this.createPieChart(this.messagesProcessedDataSet, this.messagesProcessedPanel); this.frequencyPlotData = new XYSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart("", "", "", this.frequencyPlotData); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(261, 157)); this.frequencyPanel.setLayout(new BorderLayout()); this.frequencyPanel.add(chartPanel, BorderLayout.CENTER); }
From source file:SplitPaneDemo2.java
public SplitPaneDemo() { //Read image names from a properties file. ResourceBundle imageResource; try {/* w ww . j a v a 2s .c o m*/ imageResource = ResourceBundle.getBundle("imagenames"); String imageNamesString = imageResource.getString("images"); imageNames = parseList(imageNamesString); } catch (MissingResourceException e) { handleMissingResource(e); } //Create the list of images and put it in a scroll pane. list = new JList(imageNames); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener(this); JScrollPane listScrollPane = new JScrollPane(list); //Set up the picture label and put it in a scroll pane. ImageIcon firstImage = createImageIcon("images/" + (String) imageNames.firstElement()); if (firstImage != null) { picture = new JLabel(firstImage); } else { picture = new JLabel((String) imageNames.firstElement()); } JScrollPane pictureScrollPane = new JScrollPane(picture); //Create a split pane with the two scroll panes in it. splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listScrollPane, pictureScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(150); //Provide minimum sizes for the two components in the split pane. Dimension minimumSize = new Dimension(100, 50); listScrollPane.setMinimumSize(minimumSize); pictureScrollPane.setMinimumSize(minimumSize); //Provide a preferred size for the split pane. splitPane.setPreferredSize(new Dimension(400, 200)); }
From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java
public COSMOSACDialog() { super("JCOSMO Simple"); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new BorderLayout()); db = COSMOSACDataBase.getInstance(); COSMOSAC models[] = new COSMOSAC[5]; models[0] = new COSMOSAC(); models[1] = new COSMOPAC(); models[2] = new COSMOSAC_SVP(); models[3] = new COSMOSAC_G(); models[4] = new PCMSAC(); modelBox = new JComboBox(models); modelBox.addActionListener(this); JPanel north = new JPanel(new GridLayout(0, 2)); add(north, BorderLayout.NORTH); JPanel northAba1 = new JPanel(new GridLayout(0, 4)); JPanel northAba2 = new JPanel(new GridLayout(0, 2)); //Where the GUI is created: JMenuBar menuBar;/*from w ww . j av a 2s.com*/ JMenu file, help; JMenuItem menuItem; //Create the menu bar. menuBar = new JMenuBar(); // the file menu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); menuBar.add(file); menuItem = new JMenuItem("Quit", KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)); menuItem.setActionCommand(QUIT); menuItem.addActionListener(this); file.add(menuItem); // the help menu help = new JMenu("Help"); file.setMnemonic(KeyEvent.VK_H); menuBar.add(help); menuItem = new JMenuItem("About", KeyEvent.VK_A); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); menuItem.setActionCommand(ABOUT); menuItem.addActionListener(this); help.add(menuItem); setJMenuBar(menuBar); listModel = new DefaultListModel(); list = new JList(listModel); list.setBorder(BorderFactory.createTitledBorder("compounds")); list.setVisibleRowCount(2); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane listScrollPane = new JScrollPane(list); JButton addButton = new JButton("Add"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AddCompoundDialog(COSMOSACDialog.this); } }); removeButton = new JButton("Remove"); removeButton.addActionListener(this); visibRemove(false); JButton calcButton = new JButton("Calculate"); calcButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rebuildChart(); rebuildSigmaProfiles(); } }); JButton refreshButton = new JButton("Refresh"); refreshButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rebuildSigmaProfiles(); } }); ignoreSGButton = new JCheckBox("Ignore SG"); ignoreSGButton.setToolTipText("Toogles the ignore flag for the Staverman-Guggenheim term"); ignoreSGButton.addActionListener(this); JPanel but = new JPanel(new GridLayout(0, 1)); but.add(addButton, BorderLayout.EAST); but.add(removeButton, BorderLayout.EAST); but.add(modelBox); north.add(listScrollPane); north.add(but); northAba1.add(new JLabel("Temperature [K]")); northAba1.add(temperature = new JTextField(10)); temperature.setText("298"); northAba1.add(new JLabel("Sigma HB")); northAba1.add(sigmaHB = new JTextField(10)); northAba1.add(new JLabel("Sigma HB2")); northAba1.add(sigmaHB2 = new JTextField(10)); northAba1.add(new JLabel("Sigma HB3")); northAba1.add(sigmaHB3 = new JTextField(10)); northAba1.add(new JLabel("Charge HB")); northAba1.add(chargeHB = new JTextField(10)); northAba1.add(new JLabel("Sigma Disp")); northAba1.add(sigmaDisp = new JTextField(10)); northAba1.add(new JLabel("Charge Disp")); northAba1.add(chargeDisp = new JTextField(10)); northAba1.add(new JLabel("Beta")); northAba1.add(beta = new JTextField(10)); northAba1.add(new JLabel("fpol")); northAba1.add(fpol = new JTextField(10)); northAba1.add(new JLabel("Anorm")); northAba1.add(anorm = new JTextField(10)); northAba1.add(ignoreSGButton); northAba1.add(calcButton); northAba2.add(new JLabel("")); northAba2.add(refreshButton); // chart = new JLineChart(); // add(chart, BorderLayout.CENTER); // chart.setTitle("Gamma Plot"); // chart.setSubtitle(""); // chart.setXAxisLabel("Mole Fraction, x_1"); // chart.setYAxisLabel("ln gamma, gE/RT"); // chart.setSource(getTitle()); // chart.setLegendPosition(LegendPosition.BOTTOM); // chart.setShapesVisible(true); JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction, x_1", "ln gamma, gE/RT", null, PlotOrientation.VERTICAL, true, true, false); plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setAutoRange(false); plot.getDomainAxis().setRange(new Range(0.0, 1.0)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); r.setUseFillPaint(true); r.setBaseFillPaint(Color.white); r.setBaseShapesVisible(true); JFreeChart sigmaProfileChart = ChartFactory.createXYLineChart(null, "sigma", "P^x", null, PlotOrientation.VERTICAL, true, true, false); sigmaProfilePlot = sigmaProfileChart.getXYPlot(); sigmaProfilePlot.getDomainAxis().setAutoRange(false); sigmaProfilePlot.getDomainAxis().setRange(new Range(-0.025, 0.025)); // sigmaProfilePlot.setBackgroundPaint(Color.lightGray); // sigmaProfilePlot.setDomainGridlinePaint(Color.white); // sigmaProfilePlot.setRangeGridlinePaint(Color.white); JFreeChart chartSegGamma = ChartFactory.createXYLineChart(null, "sigma", "Segment Gamma", null, PlotOrientation.VERTICAL, true, true, false); plotSegGamma = (XYPlot) chartSegGamma.getPlot(); JPanel south = new JPanel(); south.setLayout(new FlowLayout()); south.add(new JLabel("<html>ln γ<sup>∞</sup><sub>1</sub>:</html>")); south.add(lnGammaInf1Label = new JLabel()); south.add(new JLabel("<html>ln γ<sup>∞</sup><sub>2</sub>:</html>")); south.add(lnGammaInf2Label = new JLabel()); south.add(Box.createHorizontalStrut(20)); south.add(new JLabel("<html>γ<sup>∞</sup><sub>1</sub>:</html>")); south.add(gammaInf1Label = new JLabel()); south.add(new JLabel("<html>γ<sup>∞</sup><sub>2</sub>:</html>")); south.add(gammaInf2Label = new JLabel()); JPanel aba1 = new JPanel(new BorderLayout()); aba1.add(northAba1, BorderLayout.NORTH); JPanel chartsPanel = new JPanel(new GridLayout(0, 2)); aba1.add(chartsPanel, BorderLayout.CENTER); chartsPanel.add(new ChartPanel(chart)); chartsPanel.add(new ChartPanel(chartSegGamma)); aba1.add(south, BorderLayout.SOUTH); JPanel aba2 = new JPanel(new BorderLayout()); aba2.add(northAba2, BorderLayout.NORTH); aba2.add(chartPanel = new ChartPanel(sigmaProfileChart), BorderLayout.CENTER); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("gamma", aba1); tabbedPane.addTab("sigma", aba2); add(tabbedPane, BorderLayout.CENTER); // cosmosac.setAEffPrime(6.596176570595075); // cosmosac.setCoord(11.614599507917934); // cosmosac.setVnorm(56.36966406129967); // cosmosac.setAnorm(41.56058649432742); // cosmosac.setCHB(65330.19484947528); // cosmosac.setSigmaHB(0.008292411048046008); //Display the window. setSize(800, 600); setLocationRelativeTo(null); modelBox.setSelectedIndex(0); setVisible(true); // test for a mixture // addList("WATER"); // addList("H3O+1"); // addList("OH-1"); // addList("CL-1"); // addList("OXYGEN"); // addList("sec-butylamine"); // addList("hydrogen-fluoride"); // addList("ACETONE"); // addList("METHANOL"); // addList("ACETONE.opt"); // addList("METHANOL.opt"); // addList("METHYL-ETHYL-KETONE"); // addList("ETHANOL"); // addList("N-HEPTANE"); // addList("PROPIONIC-ACID"); // addList("EMIM"); // addList("NTF2"); // addList("DCA"); // addList("N-OCTANE"); addList("ETHYLENE CARBONATE"); addList("BENZENE"); addList("TOLUENE"); removeButton.setEnabled(true); }
From source file:simx.profiler.info.application.ActorsInfoTopComponent.java
public ActorsInfoTopComponent() { initComponents();/* w w w .j a va 2 s. c o m*/ setName(Bundle.CTL_ActorsInfoTopComponent()); setToolTipText(Bundle.HINT_ActorsInfoTopComponent()); this.content = new InstanceContent(); this.associateLookup(new AbstractLookup(this.content)); this.profilingData = ProfilingData.getLoadedProfilingData(); final Map<MessageType, Integer> applicationCommunicationDataLocal = new HashMap<>(); this.profilingData.getMessageTypes().stream().forEach((messageType) -> { applicationCommunicationDataLocal.put(messageType, messageType.getTimesSent()); }); this.applicationCommunicationData = new CommunicationData(new ImmutableTupel<>(null, null), applicationCommunicationDataLocal); this.content.set(Collections.singleton(this.applicationCommunicationData), null); this.actorTypes = this.profilingData.getActorTypes(); this.actorTypeInformationTable.setModel(new ActorTypeInformationTableModel(this.profilingData)); ListSelectionModel listSelectionModel = this.actorTypeInformationTable.getSelectionModel(); listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listSelectionModel.addListSelectionListener((final ListSelectionEvent e) -> { setSelectedActorType(actorTypes.get(actorTypeInformationTable.getSelectedRow())); }); this.actorInstances = profilingData.getActorInstances(); listSelectionModel = this.actorInstanceInformationTable.getSelectionModel(); listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listSelectionModel.addListSelectionListener((ListSelectionEvent e) -> { final ActorInstance actorInstance = actorInstances.get(actorInstanceInformationTable.getSelectedRow()); setSelectedActorInstance(actorInstance); }); this.actorInstanceInformationTable.setModel(new ActorInstanceInformationTableModel(this.profilingData)); long minProcessingTime = Long.MAX_VALUE; long maxProcessingTime = Long.MIN_VALUE; for (final ActorType type : this.actorTypes) { if (type.getOverallProcessingTime() < minProcessingTime) minProcessingTime = type.getOverallProcessingTime(); if (type.getOverallProcessingTime() > maxProcessingTime) maxProcessingTime = type.getOverallProcessingTime(); } final Map<ImmutableTupel<ActorType, ActorType>, Integer> typeCommunicationScaleFactors = new HashMap<>(); int minMessagesCount = Integer.MAX_VALUE; int maxMessagesCount = Integer.MIN_VALUE; for (final ActorType actorType : this.actorTypes) { final Map<ActorType, Map<MessageType, Integer>> s = actorType.getReceiverStatistics(); for (final Map.Entry<ActorType, Map<MessageType, Integer>> e : s.entrySet()) { int count = 0; count = e.getValue().entrySet().stream().map((d) -> d.getValue()).reduce(count, Integer::sum); typeCommunicationScaleFactors.put(new ImmutableTupel<>(actorType, e.getKey()), count); if (count < minMessagesCount) minMessagesCount = count; if (count > maxMessagesCount) maxMessagesCount = count; } } int messagesSpan = maxMessagesCount - minMessagesCount; for (final Map.Entry<ImmutableTupel<ActorType, ActorType>, Integer> e : typeCommunicationScaleFactors .entrySet()) { final int factor = (((e.getValue() - minMessagesCount) * 4) / messagesSpan) + 1; typeCommunicationScaleFactors.put(e.getKey(), factor); } double timeSpan = maxProcessingTime - minProcessingTime; final Map<ActorType, Double> typeComputationScaleFactors = new HashMap<>(); for (final ActorType type : this.actorTypes) { typeComputationScaleFactors.put(type, ((double) (type.getOverallProcessingTime() - minProcessingTime) * 0.4 / timeSpan) + 0.6); } final ActorTypeGraphScene actorTypeGraphScene = new ActorTypeGraphScene(this, typeComputationScaleFactors, typeCommunicationScaleFactors); actorTypeGraphScene.addObjectSceneListener(new ObjectSceneListener() { @Override public void objectAdded(final ObjectSceneEvent ose, final Object o) { } @Override public void objectRemoved(final ObjectSceneEvent ose, final Object o) { } @Override public void objectStateChanged(final ObjectSceneEvent ose, final Object o, final ObjectState os, final ObjectState os1) { } @Override public void selectionChanged(final ObjectSceneEvent ose, final Set<Object> oldSelection, final Set<Object> newSelection) { boolean communicationDataSet = false; for (final Object o : newSelection) { if (o instanceof ActorType) setSelectedActorType((ActorType) o); if (o instanceof CommunicationData) { setSelectedCommunicationData((CommunicationData) o); communicationDataSet = true; } } if (!communicationDataSet) setSelectedCommunicationData(null); } @Override public void highlightingChanged(final ObjectSceneEvent ose, final Set<Object> set, final Set<Object> set1) { } @Override public void hoverChanged(final ObjectSceneEvent ose, final Object o, final Object o1) { } @Override public void focusChanged(final ObjectSceneEvent ose, final Object o, final Object o1) { } }, ObjectSceneEventType.OBJECT_SELECTION_CHANGED); this.typeScrollPane.setViewportView(actorTypeGraphScene.createView()); this.actorTypes.stream().forEach((actorType) -> { actorTypeGraphScene.addNode(actorType); }); this.actorTypes.stream().forEach((actorType) -> { final Map<ActorType, Map<MessageType, Integer>> s = actorType.getReceiverStatistics(); s.entrySet().stream().forEach((e) -> { final CommunicationData edge = new CommunicationData(new ImmutableTupel<>(actorType, e.getKey()), e.getValue()); actorTypeGraphScene.addEdge(edge); actorTypeGraphScene.setEdgeSource(edge, actorType); actorTypeGraphScene.setEdgeTarget(edge, e.getKey()); }); }); minProcessingTime = Long.MAX_VALUE; maxProcessingTime = Long.MIN_VALUE; for (final ActorInstance instance : this.actorInstances) { if (instance.getOverallProcessingTime() < minProcessingTime) minProcessingTime = instance.getOverallProcessingTime(); if (instance.getOverallProcessingTime() > maxProcessingTime) maxProcessingTime = instance.getOverallProcessingTime(); } timeSpan = maxProcessingTime - minProcessingTime; final Map<ImmutableTupel<ActorInstance, ActorInstance>, Integer> instanceCommunicationScaleFactors = new HashMap<>(); minMessagesCount = Integer.MAX_VALUE; maxMessagesCount = Integer.MIN_VALUE; for (final ActorInstance instance : this.actorInstances) { final Map<ActorInstance, Map<MessageType, Integer>> s = instance.getReceiverStatistics(); for (final Map.Entry<ActorInstance, Map<MessageType, Integer>> e : s.entrySet()) { int count = 0; count = e.getValue().entrySet().stream().map((d) -> d.getValue()).reduce(count, Integer::sum); instanceCommunicationScaleFactors.put(new ImmutableTupel<>(instance, e.getKey()), count); if (count < minMessagesCount) minMessagesCount = count; if (count > maxMessagesCount) maxMessagesCount = count; } } messagesSpan = maxMessagesCount - minMessagesCount; for (final Map.Entry<ImmutableTupel<ActorInstance, ActorInstance>, Integer> e : instanceCommunicationScaleFactors .entrySet()) { final int factor = (((e.getValue() - minMessagesCount) * 4) / messagesSpan) + 1; instanceCommunicationScaleFactors.put(e.getKey(), factor); } final Map<ActorInstance, Double> instanceComputationScaleFactors = new HashMap<>(); for (final ActorInstance instance : this.actorInstances) { instanceComputationScaleFactors.put(instance, ((double) (instance.getOverallProcessingTime() - minProcessingTime) * 0.4 / timeSpan) + 0.6); } final ActorInstanceGraphScene actorInstanceGraphScene = new ActorInstanceGraphScene(this, instanceComputationScaleFactors, instanceCommunicationScaleFactors); actorInstanceGraphScene.addObjectSceneListener(new ObjectSceneListener() { @Override public void objectAdded(final ObjectSceneEvent ose, final Object o) { } @Override public void objectRemoved(final ObjectSceneEvent ose, final Object o) { } @Override public void objectStateChanged(final ObjectSceneEvent ose, final Object o, final ObjectState os, final ObjectState os1) { } @Override public void selectionChanged(final ObjectSceneEvent ose, final Set<Object> oldSelection, final Set<Object> newSelection) { boolean communicationDataSet = false; for (final Object o : newSelection) { if (o instanceof ActorInstance) setSelectedActorInstance((ActorInstance) o); if (o instanceof CommunicationData) { setSelectedCommunicationData((CommunicationData) o); communicationDataSet = true; } } if (!communicationDataSet) setSelectedCommunicationData(null); } @Override public void highlightingChanged(final ObjectSceneEvent ose, final Set<Object> set, final Set<Object> set1) { } @Override public void hoverChanged(final ObjectSceneEvent ose, final Object o, final Object o1) { } @Override public void focusChanged(final ObjectSceneEvent ose, final Object o, final Object o1) { } }, ObjectSceneEventType.OBJECT_SELECTION_CHANGED); this.instancesScrollPane.setViewportView(actorInstanceGraphScene.createView()); this.actorInstances.stream().forEach((actorInstance) -> { actorInstanceGraphScene.addNode(actorInstance); }); this.actorInstances.stream().forEach((actorInstance) -> { final Map<ActorInstance, Map<MessageType, Integer>> s = actorInstance.getReceiverStatistics(); s.entrySet().stream().forEach((e) -> { final CommunicationData edge = new CommunicationData( new ImmutableTupel<>(actorInstance, e.getKey()), e.getValue()); actorInstanceGraphScene.addEdge(edge); actorInstanceGraphScene.setEdgeSource(edge, actorInstance); actorInstanceGraphScene.setEdgeTarget(edge, e.getKey()); }); }); this.dopPlotData = new XYSeriesCollection(); JFreeChart dopChart = ChartFactory.createXYLineChart("", "", "", this.dopPlotData); final ChartPanel dopChartPanel = new ChartPanel(dopChart); dopChartPanel.setPreferredSize(new java.awt.Dimension(261, 157)); this.dopPanel.setLayout(new BorderLayout()); this.dopPanel.add(dopChartPanel, BorderLayout.CENTER); final XYSeries plotData = new XYSeries("Degree of Parallelism"); final List<ParallelismEvent> parallelismEvents = this.profilingData.getParallelismEvents(); Collections.sort(parallelismEvents); int parallelismLevel = 1; long lastTimeStamp = parallelismEvents.get(0).timestamp; final long firstTimeStamp = lastTimeStamp; final Map<Integer, Long> histogramData = new HashMap<>(); plotData.add(0, 1); for (int i = 1; i < parallelismEvents.size(); ++i) { if (histogramData.containsKey(parallelismLevel)) { final long old = histogramData.get(parallelismLevel); histogramData.put(parallelismLevel, parallelismEvents.get(i).timestamp - lastTimeStamp + old); } else { histogramData.put(parallelismLevel, parallelismEvents.get(i).timestamp - lastTimeStamp); } lastTimeStamp = parallelismEvents.get(i).timestamp; if (parallelismEvents.get(i).eventType == ParallelismEvent.ParallelimEventTypes.PROCESSING_START) { ++parallelismLevel; } else { --parallelismLevel; } plotData.add((double) (lastTimeStamp - firstTimeStamp) / 1000000000.0, parallelismLevel); } this.dopPlotData.addSeries(plotData); this.parallelismHistogramDataSet = new DefaultCategoryDataset(); double avgParallelism1 = 0.0; double avgParallelism2 = 0.0; long t = 0; for (int i = 1; i < histogramData.size(); ++i) { t += histogramData.get(i); } for (int i = 0; i < histogramData.size(); ++i) { parallelismHistogramDataSet.addValue((double) histogramData.get(i) / 1000000.0, "", i == 0 ? "Idle" : "" + i); avgParallelism1 += i * ((double) histogramData.get(i) / this.profilingData.applicationRunTime()); avgParallelism2 += i * ((double) histogramData.get(i) / t); } final JFreeChart chart = ChartFactory.createBarChart("", "Parallelism", "ms", this.parallelismHistogramDataSet, PlotOrientation.VERTICAL, false, true, false); final ChartPanel chartPanel = new ChartPanel(chart); this.parallelismHistogramPanel.setLayout(new BorderLayout()); this.parallelismHistogramPanel.add(chartPanel, BorderLayout.CENTER); this.runtimeTextField.setText("" + (this.profilingData.applicationRunTime() / 1000000.0)); this.computationTimeMsTextField.setText("" + (this.profilingData.getOverallProcessingTime() / 1000000.0)); this.computationTimePercentTextField.setText("" + (this.profilingData.getOverallProcessingTime() * 100.0 / this.profilingData.applicationRunTime())); this.actorInstancesTextField.setText("" + this.actorInstances.size()); this.messagesSentTextField.setText("" + this.profilingData.getMessagesSentCount()); this.messagesSentPerSecondTextField.setText("" + ((double) this.profilingData.getMessagesSentCount() * 1000000000.0 / this.profilingData.applicationRunTime())); this.messagesProcessedTextField.setText("" + this.profilingData.getMessagesProcessedCount()); this.messagesProcessedPerSecondTextField .setText("" + ((double) this.profilingData.getMessagesProcessedCount() * 1000000000.0 / this.profilingData.applicationRunTime())); this.averageTimeInMailboxTextField.setText("" + (this.profilingData.getAverageTimeInMailbox() / 1000000.0)); this.avgParallelismWithIdleTimeTextField.setText("" + avgParallelism1); this.avgParallelismWithouIdleTimeTextField.setText("" + avgParallelism2); final SpawnTreeGraphScene spawnTreeGraphScene = new SpawnTreeGraphScene(this); this.spawnTreeScrollPane.setViewportView(spawnTreeGraphScene.createView()); this.actorInstances.stream().forEach((actorInstance) -> { spawnTreeGraphScene.addNode(actorInstance); }); for (final ActorInstance actorInstance : this.actorInstances) { if (actorInstance.supervisor != null) { final ImmutableTupel<ActorInstance, ActorInstance> edge = new ImmutableTupel( actorInstance.supervisor, actorInstance); spawnTreeGraphScene.addEdge(edge); spawnTreeGraphScene.setEdgeSource(edge, actorInstance.supervisor); spawnTreeGraphScene.setEdgeTarget(edge, actorInstance); } } }
From source file:ca.phon.app.session.RecordFilterPanel.java
private void init() { FormLayout layout = new FormLayout("0px, fill:pref:grow", "pref, 1dlu, pref, pref, 1dlu, pref, pref, 1dlu, pref, pref"); CellConstraints cc = new CellConstraints(); setLayout(layout);// w w w.j a va2 s . c om radioGrp = new ButtonGroup(); ButtonAction bAct = new ButtonAction(); allBtn = new JRadioButton("All records"); allBtn.setSelected(true); allBtn.addActionListener(bAct); radioGrp.add(allBtn); rangeBtn = new JRadioButton("Specific records"); rangeBtn.addActionListener(bAct); radioGrp.add(rangeBtn); speakerBtn = new JRadioButton("Records for participant(s)"); speakerBtn.addActionListener(bAct); radioGrp.add(speakerBtn); searchBtn = new JRadioButton("Records from search results"); searchBtn.addActionListener(bAct); radioGrp.add(searchBtn); rangeField = new JTextField(); rangeField.setText("1.." + t.getRecordCount()); rangeField.setInputVerifier(new RangeVerifier()); rangeField.setEnabled(false); speakerTbl = new JXTable(new ParticipantsTableModel()); speakerTbl.setVisibleRowCount(2); speakerTbl.setEnabled(false); searchTbl = new JXTable(new SearchTableModel()); searchTbl.setVisibleRowCount(4); searchTbl.setEnabled(false); searchTbl.getColumn(0).setCellRenderer(new QueryNameCellRenderer()); searchTbl.getColumn(1).setCellRenderer(new DateCellRenderer()); searchTbl.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); searchTbl.getSelectionModel().addListSelectionListener(new SearchListener()); if (searchTbl.getModel().getRowCount() > 0) { searchTbl.getSelectionModel().setSelectionInterval(0, 0); } searchTbl.setSortOrder(1, SortOrder.DESCENDING); // add components add(allBtn, cc.xyw(1, 1, 2)); add(rangeBtn, cc.xyw(1, 3, 2)); add(rangeField, cc.xy(2, 4)); add(speakerBtn, cc.xyw(1, 6, 2)); add(new JScrollPane(speakerTbl), cc.xy(2, 7)); add(searchBtn, cc.xyw(1, 9, 2)); add(new JScrollPane(searchTbl), cc.xy(2, 10)); }
From source file:gui.DownloadPanel.java
public DownloadPanel(JFrame parent, String databasePath, int connectionTimeout, int readTimeout) { this.parent = parent; setLayout(new BorderLayout()); this.connectionTimeout = connectionTimeout; this.readTimeout = readTimeout; downloadDialogs = new ArrayList<>(); String connectionUrl = "jdbc:sqlite:" + databasePath + File.separator + "cheetah.db"; databaseController = new DatabaseControllerImpl("org.sqlite.JDBC", connectionUrl, 0, "", ""); try {/*from www .j a v a2 s . c o m*/ databaseController.createTablesIfNotExist(); } catch (SQLException e) { e.printStackTrace(); } // Set up Downloads table. downloadsTableModel = new DownloadsTableModel(); downloadTable = new JTable(downloadsTableModel); popup = initPopupMenu(); downloadTable.getSelectionModel().addListSelectionListener(e -> { tableSelectionChanged(); if (downloadPanelListener != null) downloadPanelListener.downloadSelected(selectedDownload); }); // Allow only one row at a time to be selected. downloadTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Set up ProgressBar as renderer for progress column. ProgressRenderer renderer = new ProgressRenderer(0, 100); renderer.setStringPainted(true); // show progress text downloadTable.setDefaultRenderer(JProgressBar.class, renderer); // Set table's row height large enough to fit JProgressBar. downloadTable.setRowHeight((int) renderer.getPreferredSize().getHeight()); downloadTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { super.mousePressed(e); int row = downloadTable.rowAtPoint(e.getPoint()); downloadTable.getSelectionModel().setSelectionInterval(row, row); DownloadDialog downloadDialog = getDownloadDialogByDownload(selectedDownload); if (e.getButton() == MouseEvent.BUTTON3) { // TODO right click popup.show(downloadTable, e.getX(), e.getY()); } else if (e.getClickCount() == 2) { // double click if (!downloadDialog.isVisible()) { downloadDialog.setVisible(true); } } } }); JScrollPane scrollPane = new JScrollPane(downloadTable); scrollPane.getViewport().setBackground(Color.WHITE); add(scrollPane, BorderLayout.CENTER); try { downloadList = databaseController.load(); } catch (Exception e) { e.printStackTrace(); } DownloadDialog downloadDialog; for (Download download : downloadList) { calculateDownloaded(download); download.setDownloadInfoListener(this); download.addDownloadStatusListener(this); downloadDialog = new DownloadDialog(parent, download); downloadDialog.setDownloadInfoListener(this); downloadDialogs.add(downloadDialog); downloadsTableModel.addDownload(download); downloadDialog.setDownloadRanges(download.getDownloadRangeList()); } setColumnWidths(); }
From source file:edu.clemson.cs.nestbed.client.gui.MoteDetailFrame.java
public MoteDetailFrame(int configID, MoteTestbedAssignment mtba, Mote mote, MoteType moteType, Program program) throws RemoteException, NotBoundException, MalformedURLException, ClassNotFoundException { super("Mote " + mtba.getMoteAddress() + " - (" + mote.getMoteSerialID() + ")"); this.mtba = mtba; this.mote = mote; this.moteType = moteType; this.program = program; lookupRemoteManagers();//from w ww . j a v a 2 s. com profilingSymbols = profSymManager.getProgramProfilingSymbols(configID, program.getID()); progProfMsgSymbols = progProfMsgSymManager.getProgramProfilingMessageSymbols(configID, program.getID()); programSymbols = new HashMap<Integer, ProgramSymbol>(); List<ProgramSymbol> ps = programSymbolManager.getProgramSymbols(program.getID()); for (ProgramSymbol i : ps) { programSymbols.put(i.getID(), i); } programMessageSymbols = new HashMap<Integer, ProgramMessageSymbol>(); List<ProgramMessageSymbol> pms = progMsgSymManager.getProgramMessageSymbols(program.getID()); for (ProgramMessageSymbol i : pms) { programMessageSymbols.put(i.getID(), i); } symbolTable.addMouseListener(new ProfilingTableMouseListener()); symbolTable.setModel(new ProfilingTableModel()); symbolTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); messageTable.addMouseListener(new MessageTableMouseListener()); messageTable.setModel(new MessageTableModel()); messageTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setSize(WINDOW_WIDTH, WINDOW_HEIGHT); setJMenuBar(buildMenuBar()); Container c = this.getContentPane(); c.setLayout(new BorderLayout()); c.add(buildMotePanel(), BorderLayout.NORTH); c.add(buildBottomPane(), BorderLayout.CENTER); }
From source file:it.iit.genomics.cru.igb.bundles.mi.view.StructuresPanel.java
public StructuresPanel(IgbService service, String label) { super("MI Structures", "MI Structures", "Display structure", true); igbLogger = IGBLogger.getInstance(label); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // Create hidden JmolFrame jmolFrame = new JFrame(); jmolPanel = new JmolPanel(); jmolPanel.setPreferredSize(new Dimension(500, 500)); Box jmolBox = new Box(BoxLayout.Y_AXIS); Box jmolButtonBox = new Box(BoxLayout.X_AXIS); jmolFrame.add(jmolBox);//www . j a v a 2s . c om jmolBox.add(jmolPanel); jmolBox.add(jmolButtonBox); jmolButtonBox.add(new JLabel("Display type:")); ButtonGroup displayGroup = new ButtonGroup(); JRadioButton cartoonButton = new JRadioButton(JMOL_DISPLAY_CARTOON); JRadioButton ballAndSticksButton = new JRadioButton(JMOL_DISPLAY_BALL_AND_STICK); JmolDisplayListener listener = new JmolDisplayListener(); cartoonButton.addActionListener(listener); ballAndSticksButton.addActionListener(listener); displayGroup.add(cartoonButton); displayGroup.add(ballAndSticksButton); jmolButtonBox.add(cartoonButton); jmolButtonBox.add(ballAndSticksButton); ballAndSticksButton.setSelected(true); jmolFrame.pack(); jmolFrame.setVisible(false); jmolButton.addActionListener(new JmolActionListener()); jmolButton.setIcon(new ImageIcon(getClass().getResource("/jmol.jpg"))); linkButton.addActionListener(new ExternalLinkActionListener()); linkButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/searchweb.png")); StructureTableModel model = new StructureTableModel(new ArrayList<StructureItem>(0)); structureList = new StructureTable(model, service); structureList.setTableHeader(null); structureList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane structureListPane = new JScrollPane(structureList); add(structureListPane); }