@Override public void valueChanged(TreeSelectionEvent e) { if (e.getSource() == colors && !locked) { TreeSelectionModel tsm = colors.getSelectionModel(); TreePath tp[] = tsm.getSelectionPaths(); if (tp == null) return; Vector<ClassedItem> tmp = new Vector<ClassedItem>(); for (TreePath element : tp) { try { Object[] path = element.getPath(); ClassedItem ci = new ClassedItem(path[1].toString(), path[2].toString()); tmp.add(ci); } catch (Exception exp) { // User did not select a leafnode } } if (sceneElement instanceof NenyaImageSceneElement) { ((NenyaImageSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0])); } if (sceneElement instanceof NenyaTileSceneElement) { ((NenyaTileSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0])); } if (sceneElement instanceof NenyaComponentSceneElement) { ((NenyaComponentSceneElement) sceneElement) .getComponents()[itemList.getSelectedIndex()].setColorList( tmp.toArray(new ClassedItem[0])); } submitElement(sceneElement, null); } else { super.valueChanged(e); } }
public static Image createImage(final JTree tree) { final TreeSelectionModel model = tree.getSelectionModel(); final TreePath[] paths = model.getSelectionPaths(); int count = 0; final List<ChangesBrowserNode> nodes = new ArrayList<ChangesBrowserNode>(); for (final TreePath path : paths) { final ChangesBrowserNode node = (ChangesBrowserNode) path.getLastPathComponent(); if (!node.isLeaf()) { nodes.add(node); count += node.getCount(); } } for (TreePath path : paths) { final ChangesBrowserNode element = (ChangesBrowserNode) path.getLastPathComponent(); boolean child = false; for (final ChangesBrowserNode node : nodes) { if (node.isNodeChild(element)) { child = true; break; } } if (!child) { if (element.isLeaf()) count++; } else if (!element.isLeaf()) { count -= element.getCount(); } } final JLabel label = new JLabel(VcsBundle.message("changes.view.dnd.label", count)); label.setOpaque(true); label.setForeground(tree.getForeground()); label.setBackground(tree.getBackground()); label.setFont(tree.getFont()); label.setSize(label.getPreferredSize()); final BufferedImage image = new BufferedImage(label.getWidth(), label.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = (Graphics2D) image.getGraphics(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f)); label.paint(g2); g2.dispose(); return image; }
public void actionPerformed(ActionEvent e) { // Spawn thread to handle the results and loading... if (e.getSource() == openAsComboBox) { String selection = (String) openAsComboBox.getSelectedItem(); if ("Raw images".equals(selection)) { imageWidthTextField.setEnabled(true); imageHeightTextField.setEnabled(true); bitsAllocatedTextField.setEnabled(true); bitsStoredTextField.setEnabled(true); fileOffsetTextField.setEnabled(true); numImagesTextField.setEnabled(true); imageWidthLabel.setEnabled(true); imageHeightLabel.setEnabled(true); bitsAllocatedLabel.setEnabled(true); bitsStoredLabel.setEnabled(true); fileOffsetLabel.setEnabled(true); numImagesLabel.setEnabled(true); } else { imageWidthTextField.setEnabled(false); imageHeightTextField.setEnabled(false); bitsAllocatedTextField.setEnabled(false); bitsStoredTextField.setEnabled(false); fileOffsetTextField.setEnabled(false); numImagesTextField.setEnabled(false); imageWidthLabel.setEnabled(false); imageHeightLabel.setEnabled(false); bitsAllocatedLabel.setEnabled(false); bitsStoredLabel.setEnabled(false); fileOffsetLabel.setEnabled(false); numImagesLabel.setEnabled(false); } } else if ("open".equals(e.getActionCommand())) { if (e.getSource() == openArchiveButton) { TreeSelectionModel tsm = treeTable.getTreeSelectionModel(); TreePath[] selectPaths = tsm.getSelectionPaths(); StudyListTreeTableModel slttm = (StudyListTreeTableModel) treeTable.getTreeTableModel(); // If it's a local archive, we don't need to do a move; // otherwise we execute a move thread and once that's // complete, invoke the openDialogArchive thread. if (!localSelectionModel.isSelectionEmpty()) { OpenDialogArchiveThread odat = new OpenDialogArchiveThread( slttm.computeSeries(selectPaths), false); // openStudyCheckBox.isSelected()); odat.start(); } else { ImageServerNodeDescription isnd = (ImageServerNodeDescription) networkList.getSelectedValue(); OpenDialogArchiveMoveThread odamt = ((isnd.getSupportedMoveScope() == Scope.SERIES) || (isnd.getSupportedMoveScope() == Scope.INSTANCE)) ? new OpenDialogArchiveMoveThread( isnd, slttm.computeSeries(selectPaths), false, transferOnlyCheckBox.isSelected()) : // openStudyCheckBox.isSelected()); new OpenDialogArchiveMoveThread( isnd, slttm.computeStudies(selectPaths), false, transferOnlyCheckBox.isSelected()); // openStudyCheckBox.isSelected()); odamt.start(); } } else { TreeSelectionModel tsm = dirTreeTable.getTreeSelectionModel(); TreePath[] selectPaths = tsm.getSelectionPaths(); File[] selectedFiles = new File[selectPaths.length]; for (int loop = 0; loop < selectPaths.length; loop++) selectedFiles[loop] = ((FileNode) (selectPaths[loop].getLastPathComponent())).getFile(); // Ultimately need to make this part dependent or specific to // a given image reader... ArrayList<Integer> paramList = new ArrayList<Integer>(); if (imageWidthTextField.isEnabled()) paramList.add(Integer.parseInt(imageWidthTextField.getText())); if (imageHeightTextField.isEnabled()) paramList.add(Integer.parseInt(imageHeightTextField.getText())); if (bitsAllocatedTextField.isEnabled()) paramList.add(Integer.parseInt(bitsAllocatedTextField.getText())); if (bitsStoredTextField.isEnabled()) paramList.add(Integer.parseInt(bitsStoredTextField.getText())); if (fileOffsetTextField.isEnabled()) paramList.add(Integer.parseInt(fileOffsetTextField.getText())); if (numImagesTextField.isEnabled()) paramList.add(Integer.parseInt(numImagesTextField.getText())); OpenDialogFileThread odft = new OpenDialogFileThread( selectedFiles, (String) openAsComboBox.getSelectedItem(), recurseCheckBox.isSelected(), false, paramList); // openStudyCheckBox.isSelected()); odft.start(); } if (closeOnOpenCheckBox.isSelected()) doClose(); } else if ("search".equals(e.getActionCommand())) { if ((networkList.isSelectionEmpty()) && (localList.isSelectionEmpty())) return; try { String patientID = patientIDField.getText(); String modality = modalityField.getText(); Date startDate = startDatePicker.getDate(); Date endDate = endDatePicker.getDate(); ImageServerFindDescription isfd = new ImageServerFindDescription(patientID); if (startDate != null) isfd.setStartDate(startDate); if (endDate != null) isfd.setEndDate(endDate); isfd.setModality(modality); isfd.setResultScope(Scope.SERIES); String s = (String) localList.getSelectedValue(); boolean isLocal = ((s != null) && ("local archive".equalsIgnoreCase(s))); if (!isLocal) { isfd.setNodeDescription((ImageServerNodeDescription) networkList.getSelectedValue()); Boolean b = (Boolean) ApplicationContext.getContext() .getProperty(ApplicationContext.USE_XML_COMPRESSION); if ((b != null) && (b.booleanValue())) isfd.setCompression(Compression.GZIP); } treeTable.setEnabled(false); treeTable.setVisible( false); // Hack because the cleared treetable doesn't update the display correctly and // has leftovers studyList.clear(); searchButton.setEnabled(false); clearFieldButton.setEnabled(false); OpenDialogFindThread odft = new OpenDialogFindThread( isfd, treeTable, searchButton, clearFieldButton, resultsLabel, isLocal); odft.start(); } catch (Exception exc) { exc.printStackTrace(); } } else if ("refreshNetwork".equals(e.getActionCommand())) { boolean networkStatus = ImageViewerClientNode.getInstance().connect(); if (networkStatus) { List<ImageServerNodeDescription> nodes = ImageViewerClientNode.getInstance().getQueryableNodes(); if (nodes != null) networkList.setListData(nodes.toArray()); } } else if ("clear".equals(e.getActionCommand())) { clearFields(); } else if ("close".equals(e.getActionCommand())) { doClose(); } }