Search in sources :

Example 1 with LayerTableCellRenderer

use of org.pepsoft.worldpainter.layers.LayerTableCellRenderer in project WorldPainter by Captain-Chaos.

the class CombinedLayerEditor method configureTable.

private void configureTable() {
    tableLayers.setModel(tableModel);
    TableColumn layerColumn = tableLayers.getColumnModel().getColumn(COLUMN_LAYER);
    JComboBox layerCellEditor = new JComboBox(allLayers.toArray());
    layerCellEditor.setRenderer(new LayerListCellRenderer());
    layerColumn.setCellEditor(new DefaultCellEditor(layerCellEditor));
    layerColumn.setCellRenderer(new LayerTableCellRenderer());
    SpinnerModel factorSpinnerModel = new SpinnerNumberModel(100, 1, 1500, 1);
    tableLayers.getColumnModel().getColumn(COLUMN_FACTOR).setCellEditor(new JSpinnerTableCellEditor(factorSpinnerModel));
}
Also used : LayerListCellRenderer(org.pepsoft.worldpainter.LayerListCellRenderer) LayerTableCellRenderer(org.pepsoft.worldpainter.layers.LayerTableCellRenderer) TableColumn(javax.swing.table.TableColumn) JSpinnerTableCellEditor(org.pepsoft.worldpainter.themes.JSpinnerTableCellEditor)

Example 2 with LayerTableCellRenderer

use of org.pepsoft.worldpainter.layers.LayerTableCellRenderer 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)

Example 3 with LayerTableCellRenderer

use of org.pepsoft.worldpainter.layers.LayerTableCellRenderer in project WorldPainter by Captain-Chaos.

the class TunnelLayerDialog method loadSettings.

private void loadSettings() {
    programmaticChange = true;
    try {
        spinnerFloorLevel.setValue(layer.getFloorLevel());
        spinnerFloorMin.setValue(layer.getFloorMin());
        spinnerFloorMax.setValue(Math.min(layer.getFloorMax(), maxHeight - 1));
        mixedMaterialSelectorFloor.setMaterial(layer.getFloorMaterial());
        switch(layer.getFloorMode()) {
            case CONSTANT_DEPTH:
                radioButtonFloorFixedDepth.setSelected(true);
                break;
            case FIXED_HEIGHT:
                radioButtonFloorFixedLevel.setSelected(true);
                break;
            case INVERTED_DEPTH:
                radioButtonFloorInverse.setSelected(true);
                break;
        }
        NoiseSettings floorNoise = layer.getFloorNoise();
        if (floorNoise == null) {
            floorNoise = new NoiseSettings();
        }
        noiseSettingsEditorFloor.setNoiseSettings(floorNoise);
        spinnerRoofLevel.setValue(layer.getRoofLevel());
        spinnerRoofMin.setValue(layer.getRoofMin());
        spinnerRoofMax.setValue(Math.min(layer.getRoofMax(), maxHeight - 1));
        mixedMaterialSelectorRoof.setMaterial(layer.getRoofMaterial());
        switch(layer.getRoofMode()) {
            case CONSTANT_DEPTH:
                radioButtonRoofFixedDepth.setSelected(true);
                break;
            case FIXED_HEIGHT:
                radioButtonRoofFixedLevel.setSelected(true);
                break;
            case INVERTED_DEPTH:
                radioButtonRoofInverse.setSelected(true);
                break;
        }
        NoiseSettings roofNoise = layer.getRoofNoise();
        if (roofNoise == null) {
            roofNoise = new NoiseSettings();
        }
        noiseSettingsEditorRoof.setNoiseSettings(roofNoise);
        spinnerWallFloorDepth.setValue(layer.getFloorWallDepth());
        spinnerWallRoofDepth.setValue(layer.getRoofWallDepth());
        mixedMaterialSelectorWall.setMaterial(layer.getWallMaterial());
        textFieldName.setText(layer.getName());
        colourEditor1.setColour(layer.getColour());
        checkBoxRemoveWater.setSelected(layer.isRemoveWater());
        checkBoxFlood.setSelected(layer.getFloodLevel() > 0);
        spinnerFloodLevel.setValue((layer.getFloodLevel() > 0) ? layer.getFloodLevel() : waterLevel);
        checkBoxFloodWithLava.setSelected(layer.isFloodWithLava());
        Map<Layer, TunnelLayer.LayerSettings> floorLayers = layer.getFloorLayers();
        floorLayersTableModel = new TunnelFloorLayersTableModel(floorLayers, maxHeight);
        tableFloorLayers.setModel(floorLayersTableModel);
        tableFloorLayers.getColumnModel().getColumn(TunnelFloorLayersTableModel.COLUMN_NAME).setCellRenderer(new LayerTableCellRenderer());
    } finally {
        programmaticChange = false;
    }
    setControlStates();
}
Also used : NoiseSettings(org.pepsoft.worldpainter.NoiseSettings) LayerTableCellRenderer(org.pepsoft.worldpainter.layers.LayerTableCellRenderer) Bo2Layer(org.pepsoft.worldpainter.layers.Bo2Layer) CustomLayer(org.pepsoft.worldpainter.layers.CustomLayer) PlantLayer(org.pepsoft.worldpainter.layers.plants.PlantLayer) Layer(org.pepsoft.worldpainter.layers.Layer) GroundCoverLayer(org.pepsoft.worldpainter.layers.groundcover.GroundCoverLayer)

Aggregations

LayerTableCellRenderer (org.pepsoft.worldpainter.layers.LayerTableCellRenderer)3 JSpinnerTableCellEditor (org.pepsoft.worldpainter.themes.JSpinnerTableCellEditor)2 DefaultCellEditor (javax.swing.DefaultCellEditor)1 JComboBox (javax.swing.JComboBox)1 SpinnerNumberModel (javax.swing.SpinnerNumberModel)1 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)1 TableColumn (javax.swing.table.TableColumn)1 LayerListCellRenderer (org.pepsoft.worldpainter.LayerListCellRenderer)1 NoiseSettings (org.pepsoft.worldpainter.NoiseSettings)1 Bo2Layer (org.pepsoft.worldpainter.layers.Bo2Layer)1 CustomLayer (org.pepsoft.worldpainter.layers.CustomLayer)1 Layer (org.pepsoft.worldpainter.layers.Layer)1 GroundCoverLayer (org.pepsoft.worldpainter.layers.groundcover.GroundCoverLayer)1 PlantLayer (org.pepsoft.worldpainter.layers.plants.PlantLayer)1 JButtonTableCellEditor (org.pepsoft.worldpainter.themes.JButtonTableCellEditor)1 JButtonTableCellRenderer (org.pepsoft.worldpainter.themes.JButtonTableCellRenderer)1 TerrainListCellRenderer (org.pepsoft.worldpainter.themes.TerrainListCellRenderer)1 TerrainTableCellRenderer (org.pepsoft.worldpainter.themes.TerrainTableCellRenderer)1