public List<IDataset> getSelectionData(GalleryItem[] items) {

    final List<IDataset> ys = new ArrayList<IDataset>(11);
    for (GalleryItem item : items) {
      final ImageItem ii = new ImageItem();
      ii.setIndex(item.getItemCount());
      ii.setItem(item);
      try {
        IDataset slice = info.getData(true, ii);
        slice.setName(selectionDataLabel + " " + info.getItemName(item.getItemCount(), false));
        ys.add(slice);
      } catch (Exception e) {
        logger.error("Cannot slice ", e);
        continue;
      }
    }
    return ys;
  }
  @SuppressWarnings("unchecked")
  public static String getTitle(
      final IDataset xIn,
      final List<? extends IDataset> ysIn,
      final boolean isFileName,
      final String rootName) {

    final IDataset x;
    final List<IDataset> ys;
    if (ysIn == null) {
      ys = new ArrayList<IDataset>(1);
      ys.add(xIn);
      x = DatasetFactory.createRange(DoubleDataset.class, ys.get(0).getSize());
      x.setName("Index of " + xIn.getName());
    } else {
      x = xIn;
      ys = (List<IDataset>) ysIn;
    }

    final StringBuilder buf = new StringBuilder();
    buf.append("Plot of ");
    final Set<String> used = new HashSet<String>(7);
    int i = 0;
    int dataSetSize = ys.size();
    for (IDataset dataSet : ys) {
      String name = getName(dataSet, rootName);

      if (isFileName && name != null) {
        // Strip off file name
        final Matcher matcher = Pattern.compile("(.*) \\(.*\\)").matcher(name);
        if (matcher.matches()) name = matcher.group(1);
      }

      if (used.contains(name)) continue;
      if (i == 0) buf.append(name);
      if (ys.size() < 2) break;
      if (i == 1 && 1 == dataSetSize - 1) buf.append("," + name);
      if (i == dataSetSize - 1 && dataSetSize - 1 != 1) buf.append("..." + name);
      i++;
    }
    buf.append(" against ");
    buf.append(x.getName());
    return buf.toString();
  }