FileDocCategorySizeDatePackage
TrackListRenderer.javaAPI Docmp4parser 1.0-RC-171082Wed Dec 19 20:10:21 GMT 2012com.coremedia.iso.gui

TrackListRenderer.java

package com.coremedia.iso.gui;

import com.coremedia.iso.boxes.TrackBox;
import com.coremedia.iso.boxes.fragment.TrackFragmentBox;

import javax.swing.*;
import java.awt.*;

/**
 *
 */
public class TrackListRenderer extends DefaultListCellRenderer {
    public Component getListCellRendererComponent(JList list,
                                                  Object value,
                                                  int index,
                                                  boolean isSelected,
                                                  boolean cellHasFocus) {
        final long trackId;
        if (value instanceof TrackBox) {
            TrackBox trackBox = ((TrackBox) value);
            trackId = trackBox.getTrackHeaderBox().getTrackId();
        } else {
            TrackFragmentBox traf = ((TrackFragmentBox) value);
            trackId = traf.getTrackFragmentHeaderBox().getTrackId();
        }
        value = "Track " + trackId;
        super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        return this;
    }
}