/** Description of the Method */ public void init() { // super.init(); size = new Dimension(570, 570); contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(borderLayout1); Dimension d = messagePanel.getSize(); d.height += 20; messagePanel.setPreferredSize(d); contentPane.add(messagePanel, BorderLayout.SOUTH); contentPane.setOpaque(true); userPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(2, 2, 2, 2); messagePanel.setLayout(borderLayout5); contentPane.setOpaque(true); contentPane.setBackground(Color.white); this.setSize(size); messagePanel.add(labelMessage, BorderLayout.NORTH); // Logg.logg("MhClient: Före XttTree-skapande", 6); this.mhTable = new MhTable(root, false, this.labelMessage); // Logg.logg("MhClient: mhTable-skapande klart", 6); this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER); }
/** * @param filenames * @exception Exception if internal error */ public ChestImageViewer(String filenames[]) throws Exception { DisplayDeviceArea[] displayDeviceAreas = getPresentationAndImageDeviceAreas(); if (displayDeviceAreas == null) { System.err.println("Cannot determine device display areas"); } else { System.err.println("Found " + displayDeviceAreas.length + " device display areas"); for (int i = 0; i < displayDeviceAreas.length; ++i) { System.err.println("[" + i + "] = " + displayDeviceAreas[i]); displayDeviceAreas[i].getFrame().setBackground(Color.black); displayDeviceAreas[i].getFrame().setVisible(true); } { // Need to actually add something to the unused left display frame, else background will not // be set to black on Windows JPanel backgroundPanel = new JPanel(); backgroundPanel.setBackground(Color.black); displayDeviceAreas[0].getFrame().getContentPane().add(backgroundPanel); displayDeviceAreas[0].getFrame().validate(); } frame = displayDeviceAreas[1].getFrame(); Container content = frame.getContentPane(); content.setLayout(new GridLayout(1, 1)); multiPanel = new JPanel(); // multiPanel.setBackground(Color.black); frameWidth = (int) frame.getWidth(); frameHeight = (int) frame.getHeight(); Dimension d = new Dimension(frameWidth, frameHeight); // multiPanel.setSize(d); multiPanel.setPreferredSize(d); multiPanel.setBackground(Color.black); content.add(multiPanel); // frame.pack(); content.validate(); loadMultiPanelFromSpecifiedFiles(filenames); } }
static void buildGUI() { // Need this size to balance axes. frame.setSize(520, 690); frame.setTitle("DrawTool"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container cPane = frame.getContentPane(); // Status label on top. Unused for now. statusLabel.setOpaque(true); statusLabel.setBackground(Color.white); cPane.add(statusLabel, BorderLayout.NORTH); // Build the input/output elements at the bottom. JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createLineBorder(Color.black)); panel.setBackground(inputPanelColor); panel.setLayout(new GridLayout(2, 1)); panel.add(outputLabel); JPanel bottomPanel = new JPanel(); bottomPanel.setBackground(inputPanelColor); bottomPanel.add(inputField); bottomPanel.add(new JLabel(" ")); JButton enterButton = new JButton("Enter"); enterButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent a) { hasEntered = true; } }); bottomPanel.add(enterButton); panel.add(bottomPanel); if (!sequencingOn) { cPane.add(panel, BorderLayout.SOUTH); } // Drawing in the center. drawArea = new DrawTool(); if (sequencingOn) { frame.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent e) { handleKeyTyped(e); } }); } cPane.add(drawArea, BorderLayout.CENTER); drawArea.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { handleMouseClick(e); } public void mouseReleased(MouseEvent e) { handleMouseReleased(e); } }); drawArea.addMouseMotionListener( new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { handleMouseDragged(e); } }); }
/** * @param filenames * @exception Exception if internal error */ public void loadMultiPanelFromSpecifiedFiles(String filenames[]) throws Exception { int nFiles = filenames.length; SingleImagePanel imagePanels[] = new SingleImagePanel[nFiles]; String orientations[][] = new String[nFiles][]; String views[] = new String[nFiles]; String lateralityViewAndModifiers[] = new String[nFiles]; String lateralities[] = new String[nFiles]; int widths[] = new int[nFiles]; int heights[] = new int[nFiles]; PixelSpacing spacing[] = new PixelSpacing[nFiles]; String rowOrientations[] = new String[nFiles]; String columnOrientations[] = new String[nFiles]; HashMap eventContexts = new HashMap(); double maximumHorizontalExtentInMm = 0; double maximumVerticalExtentInMm = 0; StructuredReport sr[] = new StructuredReport[nFiles]; int nImages = 0; int nCAD = 0; ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); for (int f = 0; f < nFiles; ++f) { try { String filename = filenames[f]; DicomInputStream distream = null; InputStream in = classLoader.getResourceAsStream(filename); if (in != null) { distream = new DicomInputStream(in); } else { distream = new DicomInputStream(new File(filename)); } AttributeList list = new AttributeList(); list.read(distream); if (list.isImage()) { int i = nImages++; System.err.println("IMAGE [" + i + "] is file " + f + " (" + filenames[f] + ")"); orientations[i] = getPatientOrientation(list); // System.err.println("IMAGE ["+i+"] orientation="+(orientations[i] == null && // orientations[i].length == 2 ? "" : (orientations[i][0] + " " + orientations[i][1]))); views[i] = getView(list); // System.err.println("IMAGE ["+i+"] view="+views[i]); lateralityViewAndModifiers[i] = getImageLateralityViewModifierAndViewModifier(list); // System.err.println("IMAGE ["+i+"] // lateralityViewAndModifiers="+lateralityViewAndModifiers[i]); // System.err.println("File "+filenames[f]+": "+lateralityViewAndModifiers[i]); lateralities[i] = getLaterality(list); // System.err.println("IMAGE ["+i+"] laterality="+lateralities[i]); spacing[i] = new PixelSpacing(list); // System.err.println("IMAGE ["+i+"] spacing="+spacing[i]); SourceImage sImg = new SourceImage(list); BufferedImage img = sImg.getBufferedImage(); widths[i] = sImg.getWidth(); heights[i] = sImg.getHeight(); boolean shareVOIEventsInStudy = false; // does not seem to work anyway, since adding VOITransform to panel constructor // :( EventContext eventContext = new EventContext(Integer.toString(i)); SingleImagePanel imagePanel = makeNewImagePanel(sImg, eventContext); imagePanel.setDemographicAndTechniqueAnnotations( new DemographicAndTechniqueAnnotations(list), "SansSerif", Font.PLAIN, 10, Color.pink); imagePanel.setOrientationAnnotations( new OrientationAnnotations(rowOrientations[i], columnOrientations[i]), "SansSerif", Font.PLAIN, 20, Color.pink); imagePanel.setPixelSpacingInSourceImage( spacing[i].getSpacing(), spacing[i].getDescription()); if (Attribute.getSingleStringValueOrEmptyString(list, TagFromName.VOILUTFunction) .equals("SIGMOID")) { imagePanel.setVOIFunctionToLogistic(); } imagePanels[i] = imagePanel; } else { throw new DicomException("Unsupported SOP Class in file " + filenames[f]); } } catch (Exception e) { // FileNotFoundException,IOException,DicomException e.printStackTrace(System.err); } } // int imagesPerRow = nImages; // i.e., 1 -> 1, 2 -> 1, 4 -> 4, 5 -> 4, 8 -> 4 // int imagesPerCol = 1; int imagesPerRow = nImages >= 8 ? 8 : nImages; // i.e., 1 -> 1, 2 -> 1, 4 -> 4, 5 -> 4, 8 -> 4 int imagesPerCol = (nImages - 1) / imagesPerRow + 1; // i.e., 1 -> 1, 2 -> 2, 4 -> 1, 5 -> 2, 8 -> 2 int singleWidth = frameWidth / imagesPerRow; int singleHeight = frameHeight / imagesPerCol; if (nImages == 1 && singleWidth > singleHeight) { singleWidth = singleWidth / 2; // use only half the screen for a single view and a landscape monitor } for (int i = 0; i < nImages; ++i) { DisplayedAreaSelection displayedAreaSelection = null; displayedAreaSelection = new DisplayedAreaSelection( widths[i], heights[i], 0, 0, widths[i], heights[i], true, // in case spacing was not supplied 0, 0, 0, 0, 0, false /*crop*/); imagePanels[i].setDisplayedAreaSelection(displayedAreaSelection); imagePanels[i].setPreTransformImageRelativeCoordinates(null); } SingleImagePanel.deconstructAllSingleImagePanelsInContainer(multiPanel); multiPanel.removeAll(); multiPanel.setLayout(new GridLayout(imagesPerCol, imagesPerRow)); multiPanel.setBackground(Color.black); for (int x = 0; x < imagesPerCol; ++x) { for (int y = 0; y < imagesPerRow; ++y) { int i = x * imagesPerRow + y; if (i < nImages) { imagePanels[i].setPreferredSize(new Dimension(singleWidth, singleHeight)); multiPanel.add(imagePanels[i]); } } } frame.getContentPane().validate(); frame.getContentPane().repaint(); }