Search in sources :

Example 1 with Palette

use of org.gephi.appearance.plugin.palette.Palette in project gephi by gephi.

the class PaletteGeneratorPanel method generate.

private void generate() {
    int colorCount = Integer.parseInt(colorCountLabel.getText());
    int paletteCount = colorCount;
    if (limitColorsCheckbox.isSelected()) {
        paletteCount = ((Number) limitColorSpinner.getValue()).intValue();
    }
    selectedPalette = PaletteManager.getInstance().generatePalette(paletteCount, selectedPreset);
    if (paletteCount < colorCount) {
        Color[] cols = Arrays.copyOf(selectedPalette.getColors(), colorCount);
        for (int i = paletteCount; i < cols.length; i++) {
            cols[i] = Color.LIGHT_GRAY;
        }
        selectedPalette = new Palette(cols);
    }
    String[] columnNames = new String[] { "Color" };
    DefaultTableModel model = new DefaultTableModel(columnNames, colorCount) {

        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };
    colorTable.setModel(model);
    TableColumn colorCol = colorTable.getColumnModel().getColumn(0);
    colorCol.setCellRenderer(new ColorCellRenderer());
    int row = 0;
    for (Color c : selectedPalette.getColors()) {
        model.setValueAt(c, row++, 0);
    }
}
Also used : Palette(org.gephi.appearance.plugin.palette.Palette) Color(java.awt.Color) DefaultTableModel(javax.swing.table.DefaultTableModel) TableColumn(javax.swing.table.TableColumn)

Aggregations

Color (java.awt.Color)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1 TableColumn (javax.swing.table.TableColumn)1 Palette (org.gephi.appearance.plugin.palette.Palette)1