@NotNull
  EditorWindow[] getOrderedWindows() {
    final List<EditorWindow> res = new ArrayList<EditorWindow>();

    // Collector for windows in tree ordering:
    class Inner {
      private void collect(final JPanel panel) {
        final Component comp = panel.getComponent(0);
        if (comp instanceof Splitter) {
          final Splitter splitter = (Splitter) comp;
          collect((JPanel) splitter.getFirstComponent());
          collect((JPanel) splitter.getSecondComponent());
        } else if (comp instanceof JPanel || comp instanceof JBTabs) {
          final EditorWindow window = findWindowWith(comp);
          if (window != null) {
            res.add(window);
          }
        }
      }
    }

    // get root component and traverse splitters tree:
    if (getComponentCount() != 0) {
      final Component comp = getComponent(0);
      LOG.assertTrue(comp instanceof JPanel);
      final JPanel panel = (JPanel) comp;
      if (panel.getComponentCount() != 0) {
        new Inner().collect(panel);
      }
    }

    LOG.assertTrue(res.size() == myWindows.size());
    return res.toArray(new EditorWindow[res.size()]);
  }
 private static int restorePanel(JPanel component, int i) {
   int removed = 0;
   while (component.getComponentCount() > i) {
     component.remove(component.getComponentCount() - 1);
     removed++;
   }
   return removed;
 }
 public JComponent getAdditionalColumn(String key, int index) {
   JPanel p = keyExtraComponentsMap.get(key)[index];
   if (p.getComponentCount() > 0) {
     return (JComponent) p.getComponent(0);
   }
   return null;
 }
示例#4
0
  public static void main(String[] args) {
    final JavaMixer sm = new JavaMixer();
    final JFrame jf = new JFrame("Mixer Test");
    final JPanel jp = new JPanel();
    jf.add(jp);
    jp.add(sm.getTree());
    jf.setSize(600, 500);
    jf.setVisible(true);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    sm.getTree()
        .addTreeSelectionListener(
            e -> {
              TreePath path = e.getPath();
              if (path.getLastPathComponent() instanceof ControlNode) {
                ControlNode controlNode = (ControlNode) path.getLastPathComponent();
                if (!(controlNode.getControl() instanceof CompoundControl)) {
                  if (jp.getComponentCount() > 1) jp.remove(1);
                  jp.add(controlNode.getComponent(), 1);
                  jp.repaint();
                }
              }
            });
    jp.add(sm.getPrefferedMasterVolume());
    jp.add(sm.getPrefferedMasterVolume());
    jp.add(sm.getPrefferedInputVolume());
    jp.repaint();
    sm.setMicrophoneInput();
    sm.setMuteForMicrophoneOutput();
  }
 public JComponent getComponent(String key) {
   JPanel valuePanel = keyValueComponentMap.get(key);
   if (valuePanel.getComponentCount() > 0) {
     return (JComponent) valuePanel.getComponent(0);
   }
   return null;
 }
  public Dimension getDocumentSize() {
    float pageViewWidth = 0;
    float pageViewHeight = 0;
    if (pagesPanel != null) {
      int currCompIndex = documentViewController.getCurrentPageIndex();
      int numComponents = pagesPanel.getComponentCount();
      if (currCompIndex >= 0 && currCompIndex < numComponents) {
        Component comp = pagesPanel.getComponent(currCompIndex);
        if (comp instanceof PageViewDecorator) {
          PageViewDecorator pvd = (PageViewDecorator) comp;
          Dimension dim = pvd.getPreferredSize();
          pageViewWidth = dim.width;
          pageViewHeight = dim.height;
        }
      }
    }
    // normalize the dimensions to a zoom level of zero.
    float currentZoom = documentViewModel.getViewZoom();
    pageViewWidth = Math.abs(pageViewWidth / currentZoom);
    pageViewHeight = Math.abs(pageViewHeight / currentZoom);

    // add any horizontal padding from layout manager
    pageViewWidth += AbstractDocumentView.horizontalSpace * 2;
    pageViewHeight += AbstractDocumentView.verticalSpace * 2;
    return new Dimension((int) pageViewWidth, (int) pageViewHeight);
  }
  private void setupPanels(@Nullable ProjectTemplate template) {

    restorePanel(myNamePathComponent, 4);
    restorePanel(myModulePanel, myWizardContext.isCreatingNewProject() ? 8 : 6);
    restorePanel(myExpertPanel, myWizardContext.isCreatingNewProject() ? 1 : 0);
    mySettingsStep = myModuleBuilder == null ? null : myModuleBuilder.modifySettingsStep(this);

    String description = null;
    if (template != null) {
      description = template.getDescription();
      if (StringUtil.isNotEmpty(description)) {
        StringBuilder sb = new StringBuilder("<html><body><font ");
        sb.append(SystemInfo.isMac ? "" : "face=\"Verdana\" size=\"-1\"").append('>');
        sb.append(description).append("</font></body></html>");
        description = sb.toString();
        myDescriptionPane.setText(description);
      }
    }

    myExpertPlaceholder.setVisible(
        !(myModuleBuilder instanceof TemplateModuleBuilder)
            && myExpertPanel.getComponentCount() > 0);
    for (int i = 0; i < 6; i++) {
      myModulePanel.getComponent(i).setVisible(!(myModuleBuilder instanceof EmptyModuleBuilder));
    }
    myDescriptionPanel.setVisible(StringUtil.isNotEmpty(description));

    mySettingsPanel.revalidate();
    mySettingsPanel.repaint();
  }
示例#8
0
  public void enableControlPanel() {
    boolean bVisible = false;

    int nmembers = buttonPane.getComponentCount();
    for (int k = 0; k < nmembers; k++) {
      Component comp = buttonPane.getComponent(k);
      if (comp != null) {
        if (comp.isVisible() || comp.isEnabled()) {
          bVisible = true;
          break;
        }
      }
    }

    if (bVisible && !buttonPane.isVisible()) {
      Dimension dim = getSize();
      Dimension dim1 = buttonPane.getPreferredSize();
      int w = dim.width;
      int h = dim.height + dim1.height;
      if (dim1.width > w) w = dim1.width;
      if (w < 300) w = 300;
      if (h < 200) h = 200;
      setSize(w, h);
    }
    buttonPane.setVisible(bVisible);
  }
示例#9
0
  void install() {
    Vector components = new Vector();
    Vector indicies = new Vector();
    int size = 0;

    JPanel comp = selectComponents.comp;
    Vector ids = selectComponents.filesets;

    for (int i = 0; i < comp.getComponentCount(); i++) {
      if (((JCheckBox) comp.getComponent(i)).getModel().isSelected()) {
        size += installer.getIntegerProperty("comp." + ids.elementAt(i) + ".real-size");
        components.addElement(installer.getProperty("comp." + ids.elementAt(i) + ".fileset"));
        indicies.addElement(new Integer(i));
      }
    }

    String installDir = chooseDirectory.installDir.getText();

    Map osTaskDirs = chooseDirectory.osTaskDirs;
    Iterator keys = osTaskDirs.keySet().iterator();
    while (keys.hasNext()) {
      OperatingSystem.OSTask osTask = (OperatingSystem.OSTask) keys.next();
      String dir = ((JTextField) osTaskDirs.get(osTask)).getText();
      if (dir != null && dir.length() != 0) {
        osTask.setEnabled(true);
        osTask.setDirectory(dir);
      } else osTask.setEnabled(false);
    }

    InstallThread thread =
        new InstallThread(installer, progress, installDir, osTasks, size, components, indicies);
    progress.setThread(thread);
    thread.start();
  }
示例#10
0
  /**
   * Spusti se pri zmacknuti tlacitka. Pokud je pod mysi obraz figury, zjisti, zda se muze pohnout
   * (pokud ano, upravi ho pro tahnuti, nastavi ho do figLabel) a zobrazi kontextovou napovedu.
   */
  private void eCatcherMousePressed(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_eCatcherMousePressed
    if (figLabel != null || finished) {
      return;
    }
    BoardSquare bsquare = (BoardSquare) eCatcher.getComponentAt(evt.getPoint());

    JPanel fsquare = (JPanel) figurePan.getComponent(bsquare.getIndex());
    sourceBSquare = bsquare;
    Point defLocation = fsquare.getLocation();
    xAdjustment = (int) defLocation.getX() - evt.getX();
    yAdjustment = (int) defLocation.getY() - evt.getY();
    if (fsquare.getComponentCount() == 0) {
      return;
    }
    figLabel = (JLabel) fsquare.getComponent(0);

    setFocus(gui.getFocus(bsquare.getColumn(), bsquare.getRow()));
    if (!gui.canMove(bsquare.getColumn(), bsquare.getRow())) {
      figLabel = null;
      return;
    }
    fsquare.remove(figLabel);
    boardPane.add(figLabel, 0);
    figLabel.setLocation(evt.getX() + xAdjustment, evt.getY() + yAdjustment);
    figLabel.setSize(figLabel.getWidth(), figLabel.getHeight());
  } // GEN-LAST:event_eCatcherMousePressed
    public void createColorPanel() {
      JPanel colorPanel = new JPanel(new GridLayout(0, 1));
      int curRow = 0;
      for (int i = 0; i < colorString.length / 5; i++) {
        JPanel row = new JPanel(new GridLayout(1, 0, 2, 1));
        row.setBorder(new EmptyBorder(2, 2, 2, 2));

        for (int j = curRow; j < curRow + 5; j++) {
          final JLabel colorLabel =
              new JLabel(null, new ColoredIcon(color[j], 14, 14), JLabel.CENTER);
          colorLabel.setOpaque(true);
          final Border emb = BorderFactory.createEmptyBorder(2, 1, 2, 1);
          final Border lnb = BorderFactory.createLineBorder(Color.black);
          final Border cmb = BorderFactory.createCompoundBorder(lnb, emb);
          colorLabel.setBorder(emb);
          colorLabel.addMouseListener(
              new MouseAdapter() {

                public void mouseClicked(MouseEvent e) {
                  JButton btn = (JButton) getTarget();
                  Color selColor = ((ColoredIcon) colorLabel.getIcon()).getCurrentColor();
                  btn.setIcon(new ColoredIcon(selColor));
                  setVisible(false);
                  btn.doClick();
                  oldLabel.setBackground(null);
                  colorLabel.setBackground(new Color(150, 150, 200));
                  colorLabel.setBorder(emb);
                  oldLabel = colorLabel;
                }

                public void mouseEntered(MouseEvent e) {
                  colorLabel.setBorder(cmb);
                  colorLabel.setBackground(new Color(150, 150, 200));
                }

                public void mouseExited(MouseEvent e) {
                  colorLabel.setBorder(emb);
                  colorLabel.setBackground(null);
                }
              });
          row.add(colorLabel);
        }
        colorPanel.add(row);
        curRow += row.getComponentCount();
        // System.out.println(curRow);
      }

      add(colorPanel, BorderLayout.CENTER);

      // More Colors Button
      moreColors = new JButton(new ColorChooserAction((JButton) target));
      moreColors.setText("More Colors...");
      moreColors.setIcon(null);
      moreColors.setFont(new Font("Verdana", Font.PLAIN, 10));
      //
      JPanel c = new JPanel(new FlowLayout(FlowLayout.CENTER));
      c.add(moreColors);
      add(c, BorderLayout.SOUTH);
    }
 public void writeExternal(final Element element) {
   if (getComponentCount() != 0) {
     final Component comp = getComponent(0);
     LOG.assertTrue(comp instanceof JPanel);
     final JPanel panel = (JPanel) comp;
     if (panel.getComponentCount() != 0) {
       element.addContent(writePanel(panel));
     }
   }
 }
示例#13
0
 public void stateChanged(ChangeEvent e) {
   int value = slider.getValue();
   TitledBorder tb = (TitledBorder) slider.getBorder();
   tb.setTitle("Anim delay = " + String.valueOf(value) + " ms");
   int index = Java2Demo.tabbedPane.getSelectedIndex() - 1;
   DemoGroup dg = Java2Demo.group[index];
   JPanel p = dg.getPanel();
   for (int i = 0; i < p.getComponentCount(); i++) {
     DemoPanel dp = (DemoPanel) p.getComponent(i);
     if (dp.tools != null && dp.tools.slider != null) {
       dp.tools.slider.setValue(value);
     }
   }
   slider.repaint();
 }
示例#14
0
  protected void doSysValidation() {
    int nComps = m_pnlDisplay.getComponentCount();
    JTextArea txaMsg = null;

    for (int i = 0; i < nComps; i++) {
      Component comp = m_pnlDisplay.getComponent(i);
      if (comp instanceof JTextArea) txaMsg = (JTextArea) comp;
    }

    if (txaMsg != null) {
      txaMsg.append("VALIDATING SYSTEM FILES...\n");
      txaMsg.append("\n");
    }
    runScripts(txaMsg);
  }
示例#15
0
  @Nullable
  public Condition getCondition() {
    Condition condition = null;
    ConditionTemplate template = (ConditionTemplate) conditionType.getSelectedItem();
    if (template != null) {
      int count = parameterPanels.getComponentCount();
      Object[] parameters = new Object[count];
      for (int i = 0; i < count; ++i) {
        ParameterPanel p = (ParameterPanel) parameterPanels.getComponent(i);
        parameters[i] = p.getParameter();
      }

      condition = new Condition(template.getName(), parameters);
    }
    return condition;
  }
示例#16
0
  public int getOpenCount() {
    int num = tabbedToolPanel.getComponentCount();
    if (num != 1) return num;
    Component comp = tabbedToolPanel.getComponent(0);
    if (comp instanceof JTabbedPane) {
      JTabbedPane tp = (JTabbedPane) comp;
      num = tp.getTabCount();
      if (num != 1) return num;
      comp = tp.getComponentAt(0);
    }
    if (comp instanceof VToolPanel) num = ((VToolPanel) comp).getOpenCount();
    else if (comp instanceof PushpinIF) {
      if (!((PushpinIF) comp).isOpen()) num = 0;
    }

    return num;
  }
示例#17
0
  private Component getSelectedObj() {
    if (tabbedToolPanel.getComponentCount() < 1) return null;
    Component comp = tabbedToolPanel.getComponent(0);
    if (comp instanceof JTabbedPane) {
      JTabbedPane tp = (JTabbedPane) comp;
      if (tp.getTabCount() == 1) {
        comp = tp.getComponentAt(0);
      } else if (tp.getTabCount() > 1) {
        comp = tp.getSelectedComponent();
      }
    }
    if (comp instanceof VToolPanel) return comp;

    if (!(comp instanceof XMLToolPanel)) {
      if (comp instanceof PushpinIF) comp = ((PushpinIF) comp).getPinObj();
    }
    return comp;
  }
示例#18
0
  private boolean containTool(JComponent obj) {
    int k, num;

    if (obj == null) return false;
    Component src = (Component) obj;
    Component comp;
    if (tabbedPane != null) {
      num = tabbedPane.getTabCount();
      for (k = 0; k < num; k++) {
        comp = tabbedPane.getComponentAt(k);
        if (src == comp) return true;
      }
    }
    if (tabbedToolPanel != null) {
      num = tabbedToolPanel.getComponentCount();
      for (k = 0; k < num; k++) {
        comp = tabbedToolPanel.getComponent(k);
        if (src == comp) return true;
      }
    }
    return false;
  }
示例#19
0
  /**
   * Updates displayed month date buttons.
   *
   * @param monthDays panel to update
   */
  protected void updateMonth(final JPanel monthDays) {
    monthDays.removeAll();
    lastSelectedDayButton = null;

    monthDays.add(new WebSeparator(WebSeparator.VERTICAL), "1,0,1,5");
    monthDays.add(new WebSeparator(WebSeparator.VERTICAL), "3,0,3,5");
    monthDays.add(new WebSeparator(WebSeparator.VERTICAL), "5,0,5,5");
    monthDays.add(new WebSeparator(WebSeparator.VERTICAL), "7,0,7,5");
    monthDays.add(new WebSeparator(WebSeparator.VERTICAL), "9,0,9,5");
    monthDays.add(new WebSeparator(WebSeparator.VERTICAL), "11,0,11,5");

    final ButtonGroup dates = new ButtonGroup();

    final Calendar calendar = Calendar.getInstance();
    calendar.setTime(shownDate);
    calendar.set(Calendar.DAY_OF_MONTH, 1);

    int col = 0;
    int row = 0;

    // Month before
    final int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
    final int shift;
    switch (dayOfWeek) {
      case Calendar.MONDAY:
        shift = startWeekFromSunday ? 1 : 7;
        break;
      case Calendar.TUESDAY:
        shift = startWeekFromSunday ? 2 : 1;
        break;
      case Calendar.WEDNESDAY:
        shift = startWeekFromSunday ? 3 : 2;
        break;
      case Calendar.THURSDAY:
        shift = startWeekFromSunday ? 4 : 3;
        break;
      case Calendar.FRIDAY:
        shift = startWeekFromSunday ? 5 : 4;
        break;
      case Calendar.SATURDAY:
        shift = startWeekFromSunday ? 6 : 5;
        break;
      case Calendar.SUNDAY:
        shift = startWeekFromSunday ? 7 : 6;
        break;
      default:
        shift = 0;
        break;
    }
    TimeUtils.changeByDays(calendar, -shift);
    while (calendar.get(Calendar.DAY_OF_MONTH) > 1) {
      final Date thisDate = calendar.getTime();
      final WebToggleButton day = new WebToggleButton();
      day.setForeground(otherMonthForeground);
      day.setText("" + calendar.get(Calendar.DAY_OF_MONTH));
      day.setRolloverDecoratedOnly(true);
      day.setHorizontalAlignment(WebButton.RIGHT);
      day.setRound(StyleConstants.smallRound);
      day.setFocusable(false);
      day.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(final ItemEvent e) {
              final WebToggleButton dayButton = (WebToggleButton) e.getSource();
              if (dayButton.isSelected()) {
                setDateImpl(thisDate);
              }
            }
          });
      if (dateCustomizer != null) {
        dateCustomizer.customize(day, thisDate);
      }
      monthDays.add(day, col * 2 + "," + row);
      dates.add(day);

      TimeUtils.increaseByDay(calendar);

      col++;
      if (col > 6) {
        col = 0;
        row++;
      }
    }

    // Current month
    do {
      final boolean weekend =
          calendar.get(Calendar.DAY_OF_WEEK) == 1 || calendar.get(Calendar.DAY_OF_WEEK) == 7;
      final boolean selected = date != null && TimeUtils.isSameDay(calendar, date.getTime());

      final Date thisDate = calendar.getTime();
      final WebToggleButton day = new WebToggleButton();
      day.setForeground(weekend ? weekendsForeground : currentMonthForeground);
      day.setText("" + calendar.get(Calendar.DAY_OF_MONTH));
      day.setSelected(selected);
      day.setRolloverDecoratedOnly(true);
      day.setHorizontalAlignment(WebButton.RIGHT);
      day.setRound(StyleConstants.smallRound);
      day.setFocusable(false);
      day.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
              lastSelectedDayButton = (WebToggleButton) e.getSource();
              setDateImpl(thisDate);
            }
          });
      if (dateCustomizer != null) {
        dateCustomizer.customize(day, thisDate);
      }
      monthDays.add(day, col * 2 + "," + row);
      dates.add(day);

      if (selected) {
        lastSelectedDayButton = day;
      }

      TimeUtils.increaseByDay(calendar);

      col++;
      if (col > 6) {
        col = 0;
        row++;
      }
    } while (calendar.get(Calendar.DAY_OF_MONTH) > 1);

    // Month after
    final int left = 6 * 7 - (monthDays.getComponentCount() - 6);
    for (int i = 1; i <= left; i++) {
      final Date thisDate = calendar.getTime();
      final WebToggleButton day = new WebToggleButton();
      day.setForeground(otherMonthForeground);
      day.setText("" + calendar.get(Calendar.DAY_OF_MONTH));
      day.setRolloverDecoratedOnly(true);
      day.setHorizontalAlignment(WebButton.RIGHT);
      day.setRound(StyleConstants.smallRound);
      day.setFocusable(false);
      day.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(final ItemEvent e) {
              final WebToggleButton dayButton = (WebToggleButton) e.getSource();
              if (dayButton.isSelected()) {
                setDateImpl(thisDate);
              }
            }
          });
      if (dateCustomizer != null) {
        dateCustomizer.customize(day, thisDate);
      }
      monthDays.add(day, col * 2 + "," + row);
      dates.add(day);

      TimeUtils.increaseByDay(calendar);

      col++;
      if (col > 6) {
        col = 0;
        row++;
      }
    }

    monthDays.revalidate();
  }
示例#20
0
  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);
  }
 private void makeCompactGrid(JPanel panel) {
   SpringUtilities.makeCompactGrid(panel, panel.getComponentCount() / 2, 2, 12, 12, 5, 5);
 }
 public boolean isConsoleEditorEnabled() {
   return myPanel.getComponentCount() > 1;
 }
 public void testFieldReference() throws Exception {
   Class cls = loadAndPatchClass("TestFieldReference.form", "FieldReferenceTest");
   JPanel instance = (JPanel) cls.newInstance();
   assertEquals(1, instance.getComponentCount());
 }
示例#24
0
  // new TemplatesGroup selected
  public void projectTypeChanged() {
    TemplatesGroup group = getSelectedGroup();
    if (group == null || group == myLastSelectedGroup) return;
    myLastSelectedGroup = group;
    PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_GROUP, group.getId());
    ModuleBuilder groupModuleBuilder = group.getModuleBuilder();

    mySettingsStep = null;
    myHeaderPanel.removeAll();
    if (groupModuleBuilder != null && groupModuleBuilder.getModuleType() != null) {
      mySettingsStep = groupModuleBuilder.modifyProjectTypeStep(this);
    }

    if (groupModuleBuilder == null || groupModuleBuilder.isTemplateBased()) {
      showTemplates(group);
    } else if (!showCustomOptions(groupModuleBuilder)) {
      List<FrameworkSupportInModuleProvider> providers =
          FrameworkSupportUtil.getProviders(groupModuleBuilder);
      final ProjectCategory category = group.getProjectCategory();
      if (category != null) {
        List<FrameworkSupportInModuleProvider> filtered =
            ContainerUtil.filter(
                providers,
                new Condition<FrameworkSupportInModuleProvider>() {
                  @Override
                  public boolean value(FrameworkSupportInModuleProvider provider) {
                    return matchFramework(category, provider);
                  }
                });
        // add associated
        Map<String, FrameworkSupportInModuleProvider> map =
            ContainerUtil.newMapFromValues(providers.iterator(), PROVIDER_STRING_CONVERTOR);
        Set<FrameworkSupportInModuleProvider> set =
            new HashSet<FrameworkSupportInModuleProvider>(filtered);
        for (FrameworkSupportInModuleProvider provider : filtered) {
          for (FrameworkSupportInModuleProvider.FrameworkDependency depId :
              provider.getDependenciesFrameworkIds()) {
            FrameworkSupportInModuleProvider dependency = map.get(depId.getFrameworkId());
            set.add(dependency);
          }
        }

        myFrameworksPanel.setProviders(
            new ArrayList<FrameworkSupportInModuleProvider>(set),
            new HashSet<String>(Arrays.asList(category.getAssociatedFrameworkIds())),
            new HashSet<String>(Arrays.asList(category.getPreselectedFrameworkIds())));
      } else {
        myFrameworksPanel.setProviders(providers);
      }
      getSelectedBuilder().addModuleConfigurationUpdater(myConfigurationUpdater);

      showCard(FRAMEWORKS_CARD);
    }

    myHeaderPanel.setVisible(myHeaderPanel.getComponentCount() > 0);
    // align header labels
    List<JLabel> labels = UIUtil.findComponentsOfType(myHeaderPanel, JLabel.class);
    int width = 0;
    for (JLabel label : labels) {
      int width1 = label.getPreferredSize().width;
      width = Math.max(width, width1);
    }
    for (JLabel label : labels) {
      label.setPreferredSize(new Dimension(width, label.getPreferredSize().height));
    }
    myHeaderPanel.revalidate();
    myHeaderPanel.repaint();

    updateSelection();
  }