use of org.pepsoft.worldpainter.layers.CustomLayer in project WorldPainter by Captain-Chaos.
the class CustomLayersTableModel method swap.
/**
* Swap two layers.
*
* @param rowIndex1 The index of the first layer.
* @param rowIndex2 The index of the second layer.
*/
public void swap(int rowIndex1, int rowIndex2) {
if (isHeaderRow(rowIndex1) || isHeaderRow(rowIndex2)) {
throw new IllegalStateException("Cannot swap with header rows");
}
CustomLayer layer = customLayers.get(rowIndex1);
customLayers.set(rowIndex1, customLayers.get(rowIndex2));
customLayers.set(rowIndex2, layer);
orderPristine = false;
TableModelEvent event = new TableModelEvent(this, Math.min(rowIndex1, rowIndex2), Math.max(rowIndex1, rowIndex2));
for (TableModelListener listener : listeners) {
listener.tableChanged(event);
}
}
use of org.pepsoft.worldpainter.layers.CustomLayer in project WorldPainter by Captain-Chaos.
the class TunnelLayerDialog method setControlStates.
private void setControlStates() {
spinnerFloorMin.setEnabled(!radioButtonFloorFixedLevel.isSelected());
spinnerFloorMax.setEnabled(!radioButtonFloorFixedLevel.isSelected());
spinnerRoofMin.setEnabled(!radioButtonRoofFixedLevel.isSelected());
spinnerRoofMax.setEnabled(!radioButtonRoofFixedLevel.isSelected());
spinnerFloodLevel.setEnabled(checkBoxFlood.isSelected());
checkBoxFloodWithLava.setEnabled(checkBoxFlood.isSelected());
int selectedFloorRow = tableFloorLayers.getSelectedRow();
if (selectedFloorRow != -1) {
buttonRemoveFloorLayer.setEnabled(tableFloorLayers.getSelectedRowCount() > 0);
Layer selectedLayer = floorLayersTableModel.getLayer(selectedFloorRow);
buttonEditFloorLayer.setEnabled(selectedLayer instanceof CustomLayer);
} else {
buttonRemoveFloorLayer.setEnabled(false);
buttonEditFloorLayer.setEnabled(false);
}
}
use of org.pepsoft.worldpainter.layers.CustomLayer in project WorldPainter by Captain-Chaos.
the class TunnelLayerDialog method addFloorLayer.
private void addFloorLayer() {
JPopupMenu popupMenu = new JPopupMenu();
LayerManager.getInstance().getLayers().stream().filter(l -> l.getExporter() instanceof IncidentalLayerExporter).forEach(l -> {
JMenuItem menuItem = new JMenuItem(l.getName(), new ImageIcon(l.getIcon()));
menuItem.addActionListener(e -> floorLayersTableModel.addLayer(l));
popupMenu.add(menuItem);
});
App app = App.getInstance();
Set<CustomLayer> customLayers = app.getCustomLayers().stream().filter(l -> l.getExporter() instanceof IncidentalLayerExporter).collect(Collectors.toSet());
if (customLayers.size() > 15) {
// If there are fifteen or more custom layers, split them by palette
// and move them to separate submenus to try and conserve screen
// space
app.getCustomLayersByPalette().entrySet().stream().map((entry) -> {
String palette = entry.getKey();
JMenu paletteMenu = new JMenu(palette != null ? palette : "Hidden Layers");
entry.getValue().stream().filter(l -> l.getExporter() instanceof IncidentalLayerExporter).forEach(l -> {
JMenuItem menuItem = new JMenuItem(l.getName(), new ImageIcon(l.getIcon()));
menuItem.addActionListener(e -> floorLayersTableModel.addLayer(l));
paletteMenu.add(menuItem);
});
return paletteMenu;
}).filter((paletteMenu) -> (paletteMenu.getItemCount() > 0)).forEach((paletteMenu) -> {
popupMenu.add(paletteMenu);
});
} else {
customLayers.forEach(l -> {
JMenuItem menuItem = new JMenuItem(l.getName(), new ImageIcon(l.getIcon()));
menuItem.addActionListener(e -> floorLayersTableModel.addLayer(l));
popupMenu.add(menuItem);
});
}
popupMenu.show(buttonAddFloorLayer, buttonAddFloorLayer.getWidth(), 0);
}
Aggregations