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);
}
}
Aggregations