class CSIndexed
{
    private final PDIndexed indexed;
    private JPanel panel;
    private final int colorCount;

    /**
     * Constructor.
     * 
     * @param array COSArray instance for Indexed color space.
     * @throws IOException if the instance could not be created
     */
    public CSIndexed(COSArray array) throws IOException
    {
        indexed = new PDIndexed(array);
        colorCount = getHival(array) + 1;
        initUI(getColorantData());
    }

    /**
     * Parses the colorant data from the array and return.
     *
     * @return
     */
    private IndexedColorant[] getColorantData()
    {
        IndexedColorant[] colorants = new IndexedColorant[colorCount];
        for (int i = 0; i < colorCount; i++)
        {
            IndexedColorant colorant = new IndexedColorant();
            colorant.setIndex(i);

            float[] rgbValues = indexed.toRGB(new float[]{i});
            colorant.setRgbValues(rgbValues);
            colorants[i] = colorant;
        }
        return colorants;
    }

    private void initUI(IndexedColorant[] colorants)
    {<FILL_FUNCTION_BODY>}

    /**
     * return the main panel that hold all the UI elements.
     *
     * @return JPanel instance
     */
    public Component getPanel()
    {
        return panel;
    }

    private int getHival(COSArray array)
    {
        int hival = ((COSNumber) array.getObject(2).getCOSObject()).intValue();
        return Math.min(hival, 255);
    }
}

        panel = new JPanel();
        panel.setLayout(new GridBagLayout());
        panel.setPreferredSize(new Dimension(300, 500));

        JLabel colorSpaceLabel = new JLabel("Indexed colorspace");
        colorSpaceLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
        colorSpaceLabel.setFont(new Font(Font.MONOSPACED, Font.BOLD, 30));
        JPanel colorspaceLabelPanel = new JPanel();
        colorspaceLabelPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
        colorspaceLabelPanel.add(colorSpaceLabel);

        JLabel colorCountLabel = new JLabel(" Total Color Count: " + colorCount);
        colorCountLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
        colorCountLabel.setFont(new Font(Font.MONOSPACED, Font.BOLD, 20));

        IndexedTableModel tableModel = new IndexedTableModel(colorants);
        JTable table = new JTable(tableModel);
        table.setDefaultRenderer(Color.class, new ColorBarCellRenderer());
        table.setRowHeight(40);
        table.getColumnModel().getColumn(0).setMinWidth(30);
        table.getColumnModel().getColumn(0).setMaxWidth(50);
        table.getColumnModel().getColumn(1).setMinWidth(100);
        table.getColumnModel().getColumn(1).setMaxWidth(100);

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setViewportView(table);
        scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);

        Box box = Box.createVerticalBox();
        box.add(colorCountLabel);
        box.add(scrollPane);
        box.setAlignmentX(Component.LEFT_ALIGNMENT);

        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weighty = 0.05;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.anchor = GridBagConstraints.PAGE_START;

        panel.add(colorspaceLabelPanel, gbc);

        gbc.gridy = 2;
        gbc.weighty=0.9;
        gbc.weightx = 1;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.anchor = GridBagConstraints.BELOW_BASELINE;

        panel.add(box, gbc);
    
<no_super_class>