use of org.pepsoft.worldpainter.layers.Bo2Layer in project WorldPainter by Captain-Chaos.
the class Bo2LayerEditor method saveSettings.
private Bo2Layer saveSettings(Bo2Layer layer) {
String name = fieldName.getText();
List<WPObject> objects = new ArrayList<>(listModel.getSize());
for (int i = 0; i < listModel.getSize(); i++) {
objects.add((WPObject) listModel.getElementAt(i));
}
Bo2ObjectProvider objectProvider = new Bo2ObjectTube(name, objects);
if (layer == null) {
layer = new Bo2Layer(objectProvider, "Custom (e.g. bo2, bo3 and/or schematic) objects", selectedColour);
} else {
layer.setObjectProvider(objectProvider);
layer.setColour(selectedColour);
}
layer.setDensity((Integer) spinnerBlocksPerAttempt.getValue());
return layer;
}
use of org.pepsoft.worldpainter.layers.Bo2Layer in project WorldPainter by Captain-Chaos.
the class TunnelLayerDialog method newFloorLayer.
private void newFloorLayer() {
JPopupMenu popupMenu = new JPopupMenu();
JMenuItem item = new JMenuItem("Custom Objects Layer");
item.addActionListener(e -> {
EditLayerDialog<Bo2Layer> dialog = new EditLayerDialog(TunnelLayerDialog.this, Bo2Layer.class);
dialog.setVisible(true);
if (!dialog.isCancelled()) {
Bo2Layer newLayer = dialog.getLayer();
newLayer.setHide(true);
floorLayersTableModel.addLayer(newLayer);
}
});
popupMenu.add(item);
item = new JMenuItem("Custom Ground Cover Layer");
item.addActionListener(e -> {
EditLayerDialog<GroundCoverLayer> dialog = new EditLayerDialog(TunnelLayerDialog.this, GroundCoverLayer.class);
dialog.setVisible(true);
if (!dialog.isCancelled()) {
GroundCoverLayer newLayer = dialog.getLayer();
newLayer.setHide(true);
floorLayersTableModel.addLayer(newLayer);
}
});
popupMenu.add(item);
item = new JMenuItem("Custom Plants Layer");
item.addActionListener(e -> {
EditLayerDialog<PlantLayer> dialog = new EditLayerDialog(TunnelLayerDialog.this, PlantLayer.class);
dialog.setVisible(true);
if (!dialog.isCancelled()) {
PlantLayer newLayer = dialog.getLayer();
newLayer.setHide(true);
floorLayersTableModel.addLayer(newLayer);
}
});
popupMenu.add(item);
popupMenu.show(buttonNewFloorLayer, buttonNewFloorLayer.getWidth(), 0);
}
Aggregations