code: public void select(Segment segment, boolean addToSelection) {
      // abort if segment represents pairs inNone. Would select all segments...
      if(segment.isNone()) {
        return;
      }
      if(!addToSelection) {
        deselectAllSegments();
      }
  
      // get selected segments
      if(segment.isUnpaired()) {
        // check if all segments are selected
        if(addToSelection) {
          boolean allSegmentsSelected = true;
          for(Segment other : segments.getPairedSegments(segment)) {
            if(!isSelected(other)) {
              allSegmentsSelected = false;
              break;
            }
          }
  
          // if all are selected, deselect all
          if(allSegmentsSelected) {
            deselectSegment(segment);
            return;
          }
        }
        if(isSelected(segment)) {
          deselectSegment(segment);
        }
        else {
          selectSegment(segment);
        }
      }
      else {
        // an object segment was selected
        if(isSelected(segment)) {
          deselectSegment(segment);
        }
        else {
          selectSegment(segment);
        }
      }
    }
docs: Adds or removes the given segment to the selection. Depending on the
  clustering and cluster selected and the addToSelection option given, the
  current selection will be modified. This method is called by clicking on a
  segment and ring and the CTRL-button status.
  
  Adding selections does only work on the same clustering and cluster, else a
  new selection will be added.
  
  @param segment the selected element representing a segment ring (specific
  clustering)
  @param addToSelection flag for adding segment to current selection