コード例 #1
0
 /** {@inheritDoc} */
 @Override
 public void loadAdditionalSettingsFrom(
     final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
   IntensityBins bins = null;
   try {
     bins = new IntensityBins(settings.getNodeSettings(IntensityBinnerNodeModel.KEY_BIN_SETTINGS));
   } catch (InvalidSettingsException e) {
     // TODO
     throw new NotConfigurableException(e.getMessage(), e);
   }
   m_intervalPanel.removeAllIntervalItems();
   for (int i = 0; i < bins.getNumBins(); i++) {
     double binValue = bins.getBinValue(i);
     boolean leftOpen = bins.isLeftOpen(i);
     double left = bins.getLeftValue(i);
     boolean rightOpen = bins.isRightOpen(i);
     double right = bins.getRightValue(i);
     IntervalItemPanel item =
         new IntervalItemPanel(
             m_intervalPanel, leftOpen, left, rightOpen, right, binValue, DoubleCell.TYPE);
     m_intervalPanel.addIntervalItem(item);
   }
   updateInfo();
   getPanel().validate();
   getPanel().repaint();
 }
コード例 #2
0
 /**
  * Helper method to create the {@link IntensityBins}-object from the IntervalPanel.
  *
  * @return
  */
 private IntensityBins createPixelBins() {
   IntensityBins bins = new IntensityBins(m_intervalPanel.getNumIntervals());
   for (int j = 0; j < m_intervalPanel.getNumIntervals(); j++) {
     IntervalItemPanel p = m_intervalPanel.getInterval(j);
     bins.setBinAtIndex(
         j,
         p.getBinValue(),
         p.isLeftOpen(),
         p.getLeftValue(false),
         p.isRightOpen(),
         p.getRightValue(false));
   }
   return bins;
 }
コード例 #3
0
 /**
  * Checks the current, previous, and next interval for consistency; and updates the intervals if
  * necessary.
  */
 public void updateInterval() {
   IntervalItemPanel prev = m_parent.getPrevious(this);
   IntervalItemPanel next = m_parent.getNext(this);
   if (prev == null && next == null) {
     this.setLeftValue(null);
     this.setRightValue(null);
     this.setLeftOpen(true);
     this.setRightOpen(true);
   } else {
     repairPrev(getLeftValue(true));
     repairNext(getRightValue(true));
   }
   myRepaint();
 }
コード例 #4
0
 /** Helper method that determines the result pixel type and updates the info label. */
 private void updateInfo() {
   if (m_intervalPanel.getNumIntervals() > 0) {
     // determine the result pixel type
     // and update the info label
     m_info.setText(createPixelBins().getPixelType().getClass().getSimpleName());
   } else {
     m_info.setText("No bins specified.");
   }
 }
コード例 #5
0
 /** {@inheritDoc} */
 @Override
 public void saveAdditionalSettingsTo(final NodeSettingsWO settings)
     throws InvalidSettingsException {
   if (m_intervalPanel.getNumIntervals() == 0) {
     throw new InvalidSettingsException("No pixel bins have been specified.");
   }
   createPixelBins()
       .saveToSettings(settings.addNodeSettings(IntensityBinnerNodeModel.KEY_BIN_SETTINGS));
 }
コード例 #6
0
  /** Creates a new binner dialog. */
  public IntensityBinnerNodeDialog() {
    super(true);

    // panel in tab
    final JPanel intervalTabPanel = new JPanel(new BorderLayout());
    m_intervalPanel = new IntervalPanel(intervalTabPanel, DoubleCell.TYPE);

    // numeric column intervals
    m_intervalPanel.setBorder(BorderFactory.createTitledBorder("Intervals"));
    m_intervalPanel.setMinimumSize(new Dimension(350, 300));
    m_intervalPanel.setPreferredSize(new Dimension(350, 300));
    intervalTabPanel.add(m_intervalPanel, BorderLayout.CENTER);

    final JPanel infoPanel = new JPanel();
    infoPanel.setBorder(BorderFactory.createTitledBorder("Result Pixel Type"));
    m_info = new JLabel("");
    infoPanel.add(m_info);
    intervalTabPanel.add(infoPanel, BorderLayout.SOUTH);

    super.addTab(" Intervals ", intervalTabPanel);
    super.buildDialog();
  }
コード例 #7
0
 private void repairNext(final double value) {
   IntervalItemPanel next = m_parent.getNext(this);
   if (next != null) {
     if (next.getLeftValue(false) != value) {
       next.setLeftValue(value);
       if (next.getRightValue(false) < value) {
         next.setRightValue(value);
       }
     }
     if (next.isLeftOpen() == isRightOpen()) {
       next.setLeftOpen(!isRightOpen());
     }
   } else {
     setRightValue(null);
     setRightOpen(true);
   }
 }
コード例 #8
0
 private void repairPrev(final double value) {
   IntervalItemPanel prev = m_parent.getPrevious(this);
   if (prev != null) {
     if (prev.getRightValue(false) != value) {
       prev.setRightValue(value);
       if (prev.getLeftValue(false) > value) {
         prev.setLeftValue(value);
       }
     }
     if (prev.isRightOpen() == isLeftOpen()) {
       prev.setRightOpen(!isLeftOpen());
     }
   } else {
     setLeftValue(null);
     setLeftOpen(true);
   }
 }