use of org.pepsoft.worldpainter.threedeeview.ThreeDeeFrame in project WorldPainter by Captain-Chaos.
the class App method createViewMenu.
private JMenu createViewMenu() {
JMenuItem menuItem = new JMenuItem(ACTION_ZOOM_IN);
menuItem.setMnemonic('i');
JMenu menu = new JMenu(strings.getString("view"));
menu.setMnemonic('v');
menu.add(menuItem);
menuItem = new JMenuItem(ACTION_ZOOM_OUT);
menuItem.setMnemonic('o');
menu.add(menuItem);
menuItem = new JMenuItem(ACTION_ZOOM_RESET);
menuItem.setMnemonic('r');
menu.add(menuItem);
menu.addSeparator();
viewSurfaceMenuItem = new JCheckBoxMenuItem(strings.getString("view.surface"), true);
viewSurfaceMenuItem.addActionListener(e -> viewDimension(DIM_NORMAL));
viewSurfaceMenuItem.setMnemonic('s');
viewSurfaceMenuItem.setAccelerator(KeyStroke.getKeyStroke(VK_U, PLATFORM_COMMAND_MASK));
viewSurfaceMenuItem.setEnabled(false);
menu.add(viewSurfaceMenuItem);
viewSurfaceCeilingMenuItem = new JCheckBoxMenuItem("View Surface Ceiling", false);
viewSurfaceCeilingMenuItem.addActionListener(e -> viewDimension(DIM_NORMAL_CEILING));
viewSurfaceCeilingMenuItem.setEnabled(false);
menu.add(viewSurfaceCeilingMenuItem);
viewNetherMenuItem = new JCheckBoxMenuItem(strings.getString("view.nether"), false);
viewNetherMenuItem.addActionListener(e -> viewDimension(DIM_NETHER));
viewNetherMenuItem.setMnemonic('n');
viewNetherMenuItem.setAccelerator(KeyStroke.getKeyStroke(VK_H, PLATFORM_COMMAND_MASK));
viewNetherMenuItem.setEnabled(false);
menu.add(viewNetherMenuItem);
viewNetherCeilingMenuItem = new JCheckBoxMenuItem("View Nether Ceiling", false);
viewNetherCeilingMenuItem.addActionListener(e -> viewDimension(DIM_NETHER_CEILING));
viewNetherCeilingMenuItem.setEnabled(false);
menu.add(viewNetherCeilingMenuItem);
viewEndMenuItem = new JCheckBoxMenuItem(strings.getString("view.end"), false);
viewEndMenuItem.addActionListener(e -> viewDimension(DIM_END));
viewEndMenuItem.setMnemonic('e');
viewEndMenuItem.setAccelerator(KeyStroke.getKeyStroke(VK_D, PLATFORM_COMMAND_MASK));
viewEndMenuItem.setEnabled(false);
menu.add(viewEndMenuItem);
viewEndCeilingMenuItem = new JCheckBoxMenuItem("View End Ceiling", false);
viewEndCeilingMenuItem.addActionListener(e -> viewDimension(DIM_END_CEILING));
viewEndCeilingMenuItem.setEnabled(false);
menu.add(viewEndCeilingMenuItem);
menu.add(ACTION_SWITCH_TO_FROM_CEILING);
menu.addSeparator();
JMenu colourSchemeMenu = new JMenu(strings.getString("change.colour.scheme"));
String[] colourSchemeNames = { strings.getString("default"), "Flames", "Ovocean", "Sk89q", "DokuDark", "DokuHigh", "DokuLight", "Misa", "Sphax" };
Set<String> deprecatedColourSchemes = new HashSet<>(Arrays.asList("Flames", "Ovocean", "Sk89q"));
final int schemeCount = colourSchemeNames.length;
final JCheckBoxMenuItem[] schemeMenuItems = new JCheckBoxMenuItem[schemeCount];
Configuration config = Configuration.getInstance();
for (int i = 0; i < colourSchemeNames.length; i++) {
final int index = i;
schemeMenuItems[index] = new JCheckBoxMenuItem(colourSchemeNames[index]);
if (config.getColourschemeIndex() == index) {
schemeMenuItems[index].setSelected(true);
}
schemeMenuItems[index].addActionListener(e -> {
for (int i1 = 0; i1 < schemeCount; i1++) {
if ((i1 != index) && schemeMenuItems[i1].isSelected()) {
schemeMenuItems[i1].setSelected(false);
}
}
selectedColourScheme = colourSchemes[index];
view.setColourScheme(selectedColourScheme);
config.setColourschemeIndex(index);
});
if (!deprecatedColourSchemes.contains(colourSchemeNames[i])) {
colourSchemeMenu.add(schemeMenuItems[index]);
}
}
colourSchemeMenu.addSeparator();
colourSchemeMenu.add(new JLabel("Deprecated:"));
for (int i = 0; i < colourSchemeNames.length; i++) {
if (deprecatedColourSchemes.contains(colourSchemeNames[i])) {
colourSchemeMenu.add(schemeMenuItems[i]);
}
}
menu.add(colourSchemeMenu);
menuItem = new JMenuItem(strings.getString("configure.view") + "...");
menuItem.addActionListener(e -> {
ConfigureViewDialog dialog = new ConfigureViewDialog(App.this, dimension, view);
dialog.setVisible(true);
ACTION_GRID.setSelected(view.isPaintGrid());
ACTION_CONTOURS.setSelected(view.isDrawContours());
ACTION_OVERLAY.setSelected(view.isDrawOverlay());
});
menuItem.setMnemonic('c');
menuItem.setAccelerator(KeyStroke.getKeyStroke(VK_V, PLATFORM_COMMAND_MASK));
menu.add(menuItem);
menu.addSeparator();
JMenu workspaceLayoutMenu = new JMenu("Workspace layout");
menuItem = new JMenuItem(ACTION_RESET_DOCKS);
menuItem.setMnemonic('r');
workspaceLayoutMenu.add(menuItem);
menuItem = new JMenuItem(ACTION_RESET_ALL_DOCKS);
menuItem.setMnemonic('a');
workspaceLayoutMenu.add(menuItem);
ACTION_LOAD_LAYOUT.setEnabled(config.getDefaultJideLayoutData() != null);
menuItem = new JMenuItem(ACTION_LOAD_LAYOUT);
menuItem.setMnemonic('l');
workspaceLayoutMenu.add(menuItem);
menuItem = new JMenuItem(ACTION_SAVE_LAYOUT);
menuItem.setMnemonic('s');
workspaceLayoutMenu.add(menuItem);
menu.add(workspaceLayoutMenu);
menu.addSeparator();
menuItem = new JMenuItem(strings.getString("show.3d.view") + "...");
menuItem.addActionListener(e -> {
Point focusPoint = view.getViewCentreInWorldCoords();
if (threeDeeFrame != null) {
threeDeeFrame.requestFocus();
threeDeeFrame.moveTo(focusPoint);
} else {
logger.info("Opening 3D view");
threeDeeFrame = new ThreeDeeFrame(dimension, view.getColourScheme(), customBiomeManager, focusPoint);
threeDeeFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
threeDeeFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
// was
if (threeDeeFrame != null) {
threeDeeFrame.dispose();
threeDeeFrame = null;
}
}
});
threeDeeFrame.setLocationRelativeTo(App.this);
threeDeeFrame.setVisible(true);
}
});
menuItem.setMnemonic('3');
menuItem.setAccelerator(KeyStroke.getKeyStroke(VK_3, PLATFORM_COMMAND_MASK));
menu.add(menuItem);
menu.addSeparator();
menuItem = new JMenuItem("View world history...");
menuItem.addActionListener(e -> {
if (world != null) {
WorldHistoryDialog dialog = new WorldHistoryDialog(this, world);
dialog.setVisible(true);
}
});
menu.add(menuItem);
menu.putClientProperty(HELP_KEY_KEY, "Menu/View");
return menu;
}
Aggregations