public void updateTrackPanel(boolean hasTracks) { trackLabelPanel.updateLabels(); if (hasTracks) { if (!trackPanelX.isVisible()) { trackPanelX.setVisible(true); trackLabelPanel.setVisible(true); } if (!trackPanelY.isVisible()) { trackPanelY.setVisible(true); } } else { if (trackPanelX.isVisible()) { trackPanelX.setVisible(false); trackLabelPanel.setVisible(false); } if (trackPanelY.isVisible()) { trackPanelY.setVisible(false); } } trackPanelX.invalidate(); trackLabelPanel.invalidate(); trackPanelY.invalidate(); }
public void initializeMainView( final SuperAdapter superAdapter, Container contentPane, Dimension bigPanelDim, Dimension panelDim) { contentPane.setLayout(new BorderLayout()); final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); contentPane.add(mainPanel, BorderLayout.CENTER); mainPanel.setBackground(Color.white); final JPanel toolbarPanel = new JPanel(); toolbarPanel.setBorder(null); toolbarPanel.setLayout(new GridBagLayout()); mainPanel.add(toolbarPanel, BorderLayout.NORTH); JPanel bigPanel = new JPanel(); bigPanel.setLayout(new BorderLayout()); bigPanel.setBackground(Color.white); bigPanel.setPreferredSize(new Dimension(bigPanelDim)); bigPanel.setMaximumSize(new Dimension(bigPanelDim)); bigPanel.setMinimumSize(new Dimension(bigPanelDim)); JPanel bottomPanel = new JPanel(); bottomPanel.setBackground(Color.white); JMenuBar menuBar = null; try { menuBar = superAdapter.createMenuBar(); } catch (Exception e) { e.printStackTrace(); } assert menuBar != null; contentPane.add(menuBar, BorderLayout.NORTH); GridBagConstraints toolbarConstraints = new GridBagConstraints(); toolbarConstraints.anchor = GridBagConstraints.LINE_START; toolbarConstraints.fill = GridBagConstraints.HORIZONTAL; toolbarConstraints.gridx = 0; toolbarConstraints.gridy = 0; toolbarConstraints.weightx = 0.1; // --- Chromosome panel --- JPanel chrSelectionPanel = new JPanel(); toolbarPanel.add(chrSelectionPanel, toolbarConstraints); chrSelectionPanel.setBorder(LineBorder.createGrayLineBorder()); chrSelectionPanel.setLayout(new BorderLayout()); JPanel chrLabelPanel = new JPanel(); JLabel chrLabel = new JLabel("Chromosomes"); chrLabel.setHorizontalAlignment(SwingConstants.CENTER); chrLabelPanel.setBackground(HiCGlobals.backgroundColor); chrLabelPanel.setLayout(new BorderLayout()); chrLabelPanel.add(chrLabel, BorderLayout.CENTER); chrSelectionPanel.add(chrLabelPanel, BorderLayout.PAGE_START); JPanel chrButtonPanel = new JPanel(); chrButtonPanel.setBackground(new Color(238, 238, 238)); chrButtonPanel.setLayout(new BoxLayout(chrButtonPanel, BoxLayout.X_AXIS)); // ---- chrBox1 ---- chrBox1 = new JComboBox<Chromosome>(); chrBox1.setModel( new DefaultComboBoxModel<Chromosome>(new Chromosome[] {new Chromosome(0, "All", 0)})); chrBox1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { chrBox1ActionPerformed(e); } }); chrBox1.setPreferredSize(new Dimension(95, 70)); chrButtonPanel.add(chrBox1); // ---- chrBox2 ---- chrBox2 = new JComboBox<Chromosome>(); chrBox2.setModel( new DefaultComboBoxModel<Chromosome>(new Chromosome[] {new Chromosome(0, "All", 0)})); chrBox2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { chrBox2ActionPerformed(e); } }); chrBox2.setPreferredSize(new Dimension(95, 70)); chrButtonPanel.add(chrBox2); // ---- refreshButton ---- refreshButton = new JideButton(); refreshButton.setIcon( new ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Refresh24.gif"))); refreshButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { superAdapter.safeRefreshButtonActionPerformed(); } }); refreshButton.setPreferredSize(new Dimension(24, 24)); chrButtonPanel.add(refreshButton); chrBox1.setEnabled(false); chrBox2.setEnabled(false); refreshButton.setEnabled(false); chrSelectionPanel.add(chrButtonPanel, BorderLayout.CENTER); chrSelectionPanel.setMinimumSize(new Dimension(200, 70)); chrSelectionPanel.setPreferredSize(new Dimension(210, 70)); // ======== Display Option Panel ======== JPanel displayOptionPanel = new JPanel(); displayOptionPanel.setBackground(new Color(238, 238, 238)); displayOptionPanel.setBorder(LineBorder.createGrayLineBorder()); displayOptionPanel.setLayout(new BorderLayout()); JPanel displayOptionLabelPanel = new JPanel(); displayOptionLabelPanel.setBackground(HiCGlobals.backgroundColor); displayOptionLabelPanel.setLayout(new BorderLayout()); JLabel displayOptionLabel = new JLabel("Show"); displayOptionLabel.setHorizontalAlignment(SwingConstants.CENTER); displayOptionLabelPanel.add(displayOptionLabel, BorderLayout.CENTER); displayOptionPanel.add(displayOptionLabelPanel, BorderLayout.PAGE_START); JPanel displayOptionButtonPanel = new JPanel(); displayOptionButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 10)); displayOptionButtonPanel.setLayout(new GridLayout(1, 0, 20, 0)); displayOptionComboBox = new JComboBox<MatrixType>(); displayOptionComboBox.setModel( new DefaultComboBoxModel<MatrixType>(new MatrixType[] {MatrixType.OBSERVED})); displayOptionComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { superAdapter.safeDisplayOptionComboBoxActionPerformed(); normalizationComboBox.setEnabled(!isWholeGenome()); } }); displayOptionButtonPanel.add(displayOptionComboBox); displayOptionPanel.add(displayOptionButtonPanel, BorderLayout.CENTER); displayOptionPanel.setMinimumSize(new Dimension(140, 70)); displayOptionPanel.setPreferredSize(new Dimension(140, 70)); displayOptionPanel.setMaximumSize(new Dimension(140, 70)); toolbarConstraints.gridx = 1; toolbarConstraints.weightx = 0.1; toolbarPanel.add(displayOptionPanel, toolbarConstraints); displayOptionComboBox.setEnabled(false); // ======== Normalization Panel ======== JPanel normalizationPanel = new JPanel(); normalizationPanel.setBackground(new Color(238, 238, 238)); normalizationPanel.setBorder(LineBorder.createGrayLineBorder()); normalizationPanel.setLayout(new BorderLayout()); JPanel normalizationLabelPanel = new JPanel(); normalizationLabelPanel.setBackground(HiCGlobals.backgroundColor); normalizationLabelPanel.setLayout(new BorderLayout()); JLabel normalizationLabel = new JLabel("Normalization"); normalizationLabel.setHorizontalAlignment(SwingConstants.CENTER); normalizationLabelPanel.add(normalizationLabel, BorderLayout.CENTER); normalizationPanel.add(normalizationLabelPanel, BorderLayout.PAGE_START); JPanel normalizationButtonPanel = new JPanel(); normalizationButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 10)); normalizationButtonPanel.setLayout(new GridLayout(1, 0, 20, 0)); normalizationComboBox = new JComboBox<String>(); normalizationComboBox.setModel( new DefaultComboBoxModel<String>(new String[] {NormalizationType.NONE.getLabel()})); normalizationComboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { superAdapter.safeNormalizationComboBoxActionPerformed(e); } }); normalizationButtonPanel.add(normalizationComboBox); normalizationPanel.add(normalizationButtonPanel, BorderLayout.CENTER); normalizationPanel.setPreferredSize(new Dimension(180, 70)); normalizationPanel.setMinimumSize(new Dimension(140, 70)); toolbarConstraints.gridx = 2; toolbarConstraints.weightx = 0.1; toolbarPanel.add(normalizationPanel, toolbarConstraints); normalizationComboBox.setEnabled(false); // ======== Resolution Panel ======== hiCPanel = new JPanel(); hiCPanel.setBackground(Color.white); hiCPanel.setLayout(new HiCLayout()); bigPanel.add(hiCPanel, BorderLayout.CENTER); JPanel wrapGapPanel = new JPanel(); wrapGapPanel.setBackground(Color.white); wrapGapPanel.setMaximumSize(new Dimension(5, 5)); wrapGapPanel.setMinimumSize(new Dimension(5, 5)); wrapGapPanel.setPreferredSize(new Dimension(5, 5)); wrapGapPanel.setBorder(LineBorder.createBlackLineBorder()); bigPanel.add(wrapGapPanel, BorderLayout.EAST); // splitPanel.insertPane(hiCPanel, 0); // splitPanel.setBackground(Color.white); // ---- rulerPanel2 ---- JPanel topPanel = new JPanel(); topPanel.setBackground(Color.green); topPanel.setLayout(new BorderLayout()); hiCPanel.add(topPanel, BorderLayout.NORTH); trackLabelPanel = new TrackLabelPanel(superAdapter.getHiC()); trackLabelPanel.setBackground(Color.white); hiCPanel.add(trackLabelPanel, HiCLayout.NORTH_WEST); trackPanelX = new TrackPanel(superAdapter, superAdapter.getHiC(), TrackPanel.Orientation.X); trackPanelX.setMaximumSize(new Dimension(4000, 50)); trackPanelX.setPreferredSize(new Dimension(1, 50)); trackPanelX.setMinimumSize(new Dimension(1, 50)); trackPanelX.setVisible(false); topPanel.add(trackPanelX, BorderLayout.NORTH); rulerPanelX = new HiCRulerPanel(superAdapter.getHiC()); rulerPanelX.setMaximumSize(new Dimension(4000, 50)); rulerPanelX.setMinimumSize(new Dimension(1, 50)); rulerPanelX.setPreferredSize(new Dimension(1, 50)); rulerPanelX.setBorder(null); topPanel.add(rulerPanelX, BorderLayout.SOUTH); // ---- rulerPanel1 ---- JPanel leftPanel = new JPanel(); leftPanel.setBackground(Color.white); leftPanel.setLayout(new BorderLayout()); hiCPanel.add(leftPanel, BorderLayout.WEST); trackPanelY = new TrackPanel(superAdapter, superAdapter.getHiC(), TrackPanel.Orientation.Y); trackPanelY.setMaximumSize(new Dimension(50, 4000)); trackPanelY.setPreferredSize(new Dimension(50, 1)); trackPanelY.setMinimumSize(new Dimension(50, 1)); trackPanelY.setVisible(false); leftPanel.add(trackPanelY, BorderLayout.WEST); rulerPanelY = new HiCRulerPanel(superAdapter.getHiC()); rulerPanelY.setMaximumSize(new Dimension(50, 4000)); rulerPanelY.setPreferredSize(new Dimension(50, 800)); rulerPanelY.setBorder(null); rulerPanelY.setMinimumSize(new Dimension(50, 1)); leftPanel.add(rulerPanelY, BorderLayout.EAST); // ---- heatmapPanel ---- // Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); // int panelSize = screenDimension.height - 210; int panelWidth = (int) panelDim.getWidth(); int panelHeight = (int) panelDim.getHeight(); System.err.println("Window W: " + panelWidth + " H" + panelHeight); JPanel wrapHeatmapPanel = new JPanel(new BorderLayout()); wrapHeatmapPanel.setMaximumSize(new Dimension(panelDim)); wrapHeatmapPanel.setMinimumSize(new Dimension(panelDim)); wrapHeatmapPanel.setPreferredSize(new Dimension(panelDim)); wrapHeatmapPanel.setBackground(Color.BLUE); wrapHeatmapPanel.setVisible(true); heatmapPanel = new HeatmapPanel(superAdapter); heatmapPanel.setMaximumSize(new Dimension(panelWidth - 5, panelHeight - 5)); heatmapPanel.setMinimumSize(new Dimension(panelWidth - 5, panelHeight - 5)); heatmapPanel.setPreferredSize(new Dimension(panelWidth - 5, panelHeight - 5)); heatmapPanel.setBackground(Color.white); wrapHeatmapPanel.add(heatmapPanel, BorderLayout.CENTER); // hiCPanel.setMaximumSize(new Dimension(panelWidth, panelHeight)); // hiCPanel.setMinimumSize(new Dimension(panelWidth, panelHeight)); // hiCPanel.setPreferredSize(new Dimension(panelWidth, panelHeight)); hiCPanel.add(wrapHeatmapPanel, BorderLayout.CENTER); // ======== Resolution Slider Panel ======== // Resolution panel resolutionSlider = new ResolutionControl(superAdapter); resolutionSlider.setPreferredSize(new Dimension(200, 70)); resolutionSlider.setMinimumSize(new Dimension(150, 70)); toolbarConstraints.gridx = 3; toolbarConstraints.weightx = 0.1; toolbarPanel.add(resolutionSlider, toolbarConstraints); // ======== Color Range Panel ======== colorRangePanel = new JColorRangePanel(superAdapter, heatmapPanel, preDefMapColor); toolbarConstraints.gridx = 4; toolbarConstraints.weightx = 0.5; toolbarPanel.add(colorRangePanel, toolbarConstraints); goPanel = new GoToPanel(superAdapter); toolbarConstraints.gridx = 5; toolbarConstraints.weightx = 0.25; toolbarPanel.add(goPanel, toolbarConstraints); // not sure this is working // toolbarPanel.setPreferredSize(new Dimension(panelHeight,100)); toolbarPanel.setEnabled(false); // ======== Right side panel ======== JPanel rightSidePanel = new JPanel(new BorderLayout()); // (new BorderLayout()); rightSidePanel.setBackground(Color.white); rightSidePanel.setPreferredSize(new Dimension(210, 1000)); rightSidePanel.setMaximumSize(new Dimension(10000, 10000)); // ======== Bird's view mini map ======== JPanel thumbPanel = new JPanel(); thumbPanel.setLayout(new BorderLayout()); // ---- thumbnailPanel ---- thumbnailPanel = new ThumbnailPanel(superAdapter); thumbnailPanel.setBackground(Color.white); thumbnailPanel.setMaximumSize(new Dimension(210, 210)); thumbnailPanel.setMinimumSize(new Dimension(210, 210)); thumbnailPanel.setPreferredSize(new Dimension(210, 210)); // JPanel gapPanel = new JPanel(); // gapPanel.setMaximumSize(new Dimension(1, 1)); // rightSidePanel.add(gapPanel,BorderLayout.WEST); thumbPanel.add(thumbnailPanel, BorderLayout.CENTER); thumbPanel.setBackground(Color.white); rightSidePanel.add(thumbPanel, BorderLayout.NORTH); // ========= mouse hover text ====== JPanel tooltipPanel = new JPanel(new BorderLayout()); tooltipPanel.setBackground(Color.white); tooltipPanel.setPreferredSize(new Dimension(210, 490)); mouseHoverTextPanel = new JEditorPane(); mouseHoverTextPanel.setEditable(false); mouseHoverTextPanel.setContentType("text/html"); mouseHoverTextPanel.setFont(new Font("sans-serif", 0, 20)); mouseHoverTextPanel.setBackground(Color.white); mouseHoverTextPanel.setBorder(null); int mouseTextY = rightSidePanel.getBounds().y + rightSidePanel.getBounds().height; // *Dimension prefSize = new Dimension(210, 490); Dimension prefSize = new Dimension(210, 390); mouseHoverTextPanel.setPreferredSize(prefSize); JScrollPane tooltipScroller = new JScrollPane(mouseHoverTextPanel); tooltipScroller.setBackground(Color.white); tooltipScroller.setBorder(null); tooltipPanel.setPreferredSize(new Dimension(210, 500)); tooltipPanel.add(tooltipScroller); tooltipPanel.setBounds(new Rectangle(new Point(0, mouseTextY), prefSize)); tooltipPanel.setBackground(Color.white); tooltipPanel.setBorder(null); rightSidePanel.add(tooltipPanel, BorderLayout.CENTER); // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < rightSidePanel.getComponentCount(); i++) { Rectangle bounds = rightSidePanel.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = rightSidePanel.getInsets(); preferredSize.width += insets.right + 20; preferredSize.height += insets.bottom; rightSidePanel.setMinimumSize(preferredSize); rightSidePanel.setPreferredSize(preferredSize); mainPanel.add(bigPanel, BorderLayout.CENTER); mainPanel.add(rightSidePanel, BorderLayout.EAST); }
public void repaintTrackPanels() { trackPanelX.repaint(); trackPanelY.repaint(); }