def __init__(self, imgData): n = imgData.size() win = JFrame("Point Marker Panel") win.setPreferredSize(Dimension(350, 590)) win.setSize(win.getPreferredSize()) pan = JPanel() pan.setLayout(BoxLayout(pan, BoxLayout.Y_AXIS)) win.getContentPane().add(pan) progressPanel = JPanel() progressPanel.setLayout(BoxLayout(progressPanel, BoxLayout.Y_AXIS)) positionBar = JProgressBar() positionBar.setMinimum(0) positionBar.setMaximum(n) positionBar.setStringPainted(True) progressPanel.add(Box.createGlue()) progressPanel.add(positionBar) progressBar = JProgressBar() progressBar.setMinimum(0) progressBar.setMaximum(n) progressBar.setStringPainted(True) progressPanel.add(progressBar) progressPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)) pan.add(progressPanel) pan.add(Box.createRigidArea(Dimension(5, 5))) savePanel = JPanel() savePanel.setLayout(BoxLayout(savePanel, BoxLayout.Y_AXIS)) saveMessageLabel = JLabel("<html><u>Save Often</u></html>") savePanel.add(saveMessageLabel) savePanel.setAlignmentX(Component.CENTER_ALIGNMENT) savePanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)) pan.add(savePanel) # pan.add(saveMessageLabel) pan.add(Box.createRigidArea(Dimension(5, 5))) calPanel = JPanel() calPanel.setLayout(BoxLayout(calPanel, BoxLayout.Y_AXIS)) calPanelIn = JPanel() calPanelIn.setLayout(BoxLayout(calPanelIn, BoxLayout.X_AXIS)) pixelSizeText = JTextField(12) pixelSizeText.setHorizontalAlignment(JTextField.RIGHT) # pixelSizeText.setMaximumSize(pixelSizeText.getPreferredSize()) unitText = JTextField(10) # unitText.setMaximumSize(unitText.getPreferredSize()) pixelSizeText.setText("Enter Pixel Size Here") calPanelIn.add(pixelSizeText) unitText.setText("Unit") calPanelIn.add(unitText) calPanelIn.setAlignmentX(Component.CENTER_ALIGNMENT) calPanelIn.setBorder( BorderFactory.createTitledBorder("Custom Calibration")) calPanel.add(calPanelIn) calPanelIn.setAlignmentX(Component.CENTER_ALIGNMENT) calPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)) pan.add(calPanel) pan.add(Box.createRigidArea(Dimension(5, 5))) helpPanel = JPanel() helpPanel.setLayout(BoxLayout(helpPanel, BoxLayout.Y_AXIS)) helpLable = JLabel("<html><ul>\ <li>Focus on Image Window</li>\ <li>Select multi-point Tool</li>\ <li>Click to Draw Points</li>\ <li>Drag to Move Points</li>\ <li>\"Alt\" + Click to Erase Points</li>\ <li>Optional: Customize Calibration Above\ and Refresh Images\ (won't be written to files)</li>\ </html>") helpLable.setBorder(BorderFactory.createTitledBorder("Usage")) keyTagOpen = "<span style=\"background-color: #FFFFFF\"><b><kbd>" keyTagClose = "</kbd></b></span>" keyLable = JLabel("<html><ul>\ <li>Next Image --- " + keyTagOpen + "<" + \ keyTagClose + "</li>\ <li>Previous Image --- " + keyTagOpen + ">" + \ keyTagClose + "</li>\ <li>Save --- " + keyTagOpen + "`" + keyTagClose + \ " (upper-left to TAB key)</li>\ <li>Next Unmarked Image --- " + keyTagOpen + \ "TAB" + keyTagClose + "</li></ul>\ </html>" ) keyLable.setBorder( BorderFactory.createTitledBorder("Keyboard Shortcuts")) helpPanel.add(helpLable) helpPanel.add(keyLable) helpPanel.setAlignmentX(Component.CENTER_ALIGNMENT) helpPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)) pan.add(helpPanel) # pan.add(Box.createRigidArea(Dimension(0, 10))) infoPanel = JPanel() infoPanel.setLayout(BoxLayout(infoPanel, BoxLayout.Y_AXIS)) infoLabel = JLabel() infoLabel.setBorder(BorderFactory.createTitledBorder("Project Info")) infoPanel.add(infoLabel) infoPanel.setAlignmentX(Component.CENTER_ALIGNMENT) infoPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)) pan.add(infoPanel) win.setVisible(True) self.imgData = imgData self.win = win # self.progressPanel = progressPanel self.positionBar = positionBar self.progressBar = progressBar self.saveMessageLabel = saveMessageLabel self.infoLabel = infoLabel self.pixelSizeText = pixelSizeText self.unitText = unitText self.update()
def __init__(self, imgData): n = imgData.size() win = JFrame("Point Marker Panel") win.setPreferredSize(Dimension(350, 590)) win.setSize(win.getPreferredSize()) pan = JPanel() pan.setLayout(BoxLayout(pan, BoxLayout.Y_AXIS)) win.getContentPane().add(pan) progressPanel = JPanel() progressPanel.setLayout(BoxLayout(progressPanel, BoxLayout.Y_AXIS)) positionBar = JProgressBar() positionBar.setMinimum(0) positionBar.setMaximum(n) positionBar.setStringPainted(True) progressPanel.add(Box.createGlue()) progressPanel.add(positionBar) progressBar = JProgressBar() progressBar.setMinimum(0) progressBar.setMaximum(n) progressBar.setStringPainted(True) progressPanel.add(progressBar) progressPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10)) pan.add(progressPanel) pan.add(Box.createRigidArea(Dimension(5,5))) savePanel = JPanel() savePanel.setLayout(BoxLayout(savePanel, BoxLayout.Y_AXIS)) saveMessageLabel = JLabel("<html><u>Save Often</u></html>") savePanel.add(saveMessageLabel) savePanel.setAlignmentX(Component.CENTER_ALIGNMENT) savePanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10)) pan.add(savePanel) # pan.add(saveMessageLabel) pan.add(Box.createRigidArea(Dimension(5,5))) calPanel = JPanel() calPanel.setLayout(BoxLayout(calPanel, BoxLayout.Y_AXIS)) calPanelIn = JPanel() calPanelIn.setLayout(BoxLayout(calPanelIn, BoxLayout.X_AXIS)) pixelSizeText = JTextField(12) pixelSizeText.setHorizontalAlignment(JTextField.RIGHT) # pixelSizeText.setMaximumSize(pixelSizeText.getPreferredSize()) unitText = JTextField(10) # unitText.setMaximumSize(unitText.getPreferredSize()) pixelSizeText.setText("Enter Pixel Size Here") calPanelIn.add(pixelSizeText) unitText.setText("Unit") calPanelIn.add(unitText) calPanelIn.setAlignmentX(Component.CENTER_ALIGNMENT) calPanelIn.setBorder(BorderFactory.createTitledBorder("Custom Calibration")) calPanel.add(calPanelIn) calPanelIn.setAlignmentX(Component.CENTER_ALIGNMENT) calPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10)) pan.add(calPanel) pan.add(Box.createRigidArea(Dimension(5,5))) helpPanel = JPanel() helpPanel.setLayout(BoxLayout(helpPanel, BoxLayout.Y_AXIS)) helpLable = JLabel("<html><ul>\ <li>Focus on Image Window</li>\ <li>Select multi-point Tool</li>\ <li>Click to Draw Points</li>\ <li>Drag to Move Points</li>\ <li>\"Alt\" + Click to Erase Points</li>\ <li>Optional: Customize Calibration Above\ and Refresh Images\ (won't be written to files)</li>\ </html>") helpLable.setBorder(BorderFactory.createTitledBorder("Usage")) keyTagOpen = "<span style=\"background-color: #FFFFFF\"><b><kbd>" keyTagClose = "</kbd></b></span>" keyLable = JLabel("<html><ul>\ <li>Next Image --- " + keyTagOpen + "<" + \ keyTagClose + "</li>\ <li>Previous Image --- " + keyTagOpen + ">" + \ keyTagClose + "</li>\ <li>Save --- " + keyTagOpen + "`" + keyTagClose + \ " (upper-left to TAB key)</li>\ <li>Next Unmarked Image --- " + keyTagOpen + \ "TAB" + keyTagClose + "</li></ul>\ </html>") keyLable.setBorder(BorderFactory.createTitledBorder("Keyboard Shortcuts")) helpPanel.add(helpLable) helpPanel.add(keyLable) helpPanel.setAlignmentX(Component.CENTER_ALIGNMENT) helpPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10)) pan.add(helpPanel) # pan.add(Box.createRigidArea(Dimension(0, 10))) infoPanel = JPanel() infoPanel.setLayout(BoxLayout(infoPanel, BoxLayout.Y_AXIS)) infoLabel = JLabel() infoLabel.setBorder(BorderFactory.createTitledBorder("Project Info")) infoPanel.add(infoLabel) infoPanel.setAlignmentX(Component.CENTER_ALIGNMENT) infoPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10)) pan.add(infoPanel) win.setVisible(True) self.imgData = imgData self.win = win # self.progressPanel = progressPanel self.positionBar = positionBar self.progressBar = progressBar self.saveMessageLabel = saveMessageLabel self.infoLabel = infoLabel self.pixelSizeText = pixelSizeText self.unitText = unitText self.update()