Search in sources :

Example 1 with TerrainTableCellRenderer

use of org.pepsoft.worldpainter.themes.TerrainTableCellRenderer in project WorldPainter by Captain-Chaos.

the class SimpleThemeEditor method setTheme.

public void setTheme(SimpleTheme theme) {
    this.theme = theme;
    if (theme != null) {
        terrainTableModel = new TerrainRangesTableModel(theme.getTerrainRanges());
        terrainTableModel.setChangeListener(this);
        tableTerrain.setModel(terrainTableModel);
        tableTerrain.setDefaultRenderer(Integer.class, new DefaultTableCellRenderer());
        tableTerrain.setDefaultRenderer(Terrain.class, new TerrainTableCellRenderer(colourScheme));
        tableTerrain.setDefaultRenderer(JButton.class, new JButtonTableCellRenderer());
        tableTerrain.setDefaultEditor(Integer.class, new JSpinnerTableCellEditor(new SpinnerNumberModel(1, 1, theme.getMaxHeight() - 1, 1)));
        JComboBox terrainEditor = new JComboBox(Terrain.getConfiguredValues());
        terrainEditor.setRenderer(new TerrainListCellRenderer(colourScheme));
        tableTerrain.setDefaultEditor(Terrain.class, new DefaultCellEditor(terrainEditor));
        tableTerrain.setDefaultEditor(JButton.class, new JButtonTableCellEditor(this));
        checkBoxBeaches.setSelected(theme.isBeaches());
        spinnerWaterLevel.setModel(new SpinnerNumberModel(theme.getWaterHeight(), 0, theme.getMaxHeight() - 1, 1));
        spinnerWaterLevel.setEnabled(checkBoxBeaches.isSelected());
        checkBoxRandomise.setSelected(theme.isRandomise());
        layerTableModel = new LayerRangesTableModel(theme.getMaxHeight(), theme.getLayerMap());
        tableLayers.setModel(layerTableModel);
        tableLayers.setDefaultRenderer(Layer.class, new LayerTableCellRenderer());
        tableLayers.setDefaultRenderer(JButton.class, new JButtonTableCellRenderer());
        tableLayers.setDefaultEditor(Integer.class, new JSpinnerTableCellEditor(new SpinnerNumberModel(1, 1, theme.getMaxHeight() - 1, 1)));
        tableLayers.setDefaultEditor(JButton.class, new JButtonTableCellEditor(this));
    }
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JComboBox(javax.swing.JComboBox) JButtonTableCellRenderer(org.pepsoft.worldpainter.themes.JButtonTableCellRenderer) JButtonTableCellEditor(org.pepsoft.worldpainter.themes.JButtonTableCellEditor) TerrainTableCellRenderer(org.pepsoft.worldpainter.themes.TerrainTableCellRenderer) LayerTableCellRenderer(org.pepsoft.worldpainter.layers.LayerTableCellRenderer) JSpinnerTableCellEditor(org.pepsoft.worldpainter.themes.JSpinnerTableCellEditor) TerrainListCellRenderer(org.pepsoft.worldpainter.themes.TerrainListCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) DefaultCellEditor(javax.swing.DefaultCellEditor)

Aggregations

DefaultCellEditor (javax.swing.DefaultCellEditor)1 JComboBox (javax.swing.JComboBox)1 SpinnerNumberModel (javax.swing.SpinnerNumberModel)1 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)1 LayerTableCellRenderer (org.pepsoft.worldpainter.layers.LayerTableCellRenderer)1 JButtonTableCellEditor (org.pepsoft.worldpainter.themes.JButtonTableCellEditor)1 JButtonTableCellRenderer (org.pepsoft.worldpainter.themes.JButtonTableCellRenderer)1 JSpinnerTableCellEditor (org.pepsoft.worldpainter.themes.JSpinnerTableCellEditor)1 TerrainListCellRenderer (org.pepsoft.worldpainter.themes.TerrainListCellRenderer)1 TerrainTableCellRenderer (org.pepsoft.worldpainter.themes.TerrainTableCellRenderer)1