use of javax.swing.JRadioButtonMenuItem in project energy3d by concord-consortium.
the class MainFrame method getScaleToFitRadioButtonMenuItem.
private JRadioButtonMenuItem getScaleToFitRadioButtonMenuItem() {
if (scaleToFitRadioButtonMenuItem == null) {
scaleToFitRadioButtonMenuItem = new JRadioButtonMenuItem("Scale To Fit Paper");
scaleToFitRadioButtonMenuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
PrintController.getInstance().setScaleToFit(true);
}
});
printSizeOptionBbuttonGroup.add(scaleToFitRadioButtonMenuItem);
scaleToFitRadioButtonMenuItem.setSelected(true);
}
return scaleToFitRadioButtonMenuItem;
}
use of javax.swing.JRadioButtonMenuItem in project energy3d by concord-consortium.
the class MainFrame method getTextureMenu.
private JMenu getTextureMenu() {
if (textureMenu == null) {
textureMenu = new JMenu("Texture");
final JMenuItem removeBuildingTextureMenuItem = new JMenuItem("Remove Building Texture");
removeBuildingTextureMenuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
final ChangeBuildingTextureCommand c = new ChangeBuildingTextureCommand();
Scene.getInstance().setTextureMode(TextureMode.None);
Scene.getInstance().setEdited(true);
if (MainPanel.getInstance().getEnergyButton().isSelected()) {
MainPanel.getInstance().getEnergyButton().setSelected(false);
}
SceneManager.getInstance().getUndoManager().addEdit(c);
}
});
textureMenu.add(removeBuildingTextureMenuItem);
final JMenuItem outlineBuildingTextureMenuItem = new JMenuItem("Use Outline Building Texture");
outlineBuildingTextureMenuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
final ChangeBuildingTextureCommand c = new ChangeBuildingTextureCommand();
Scene.getInstance().setTextureMode(TextureMode.Simple);
Scene.getInstance().setEdited(true);
if (MainPanel.getInstance().getEnergyButton().isSelected()) {
MainPanel.getInstance().getEnergyButton().setSelected(false);
}
SceneManager.getInstance().getUndoManager().addEdit(c);
}
});
textureMenu.add(outlineBuildingTextureMenuItem);
textureMenu.addSeparator();
final JMenu wallTextureMenu = new JMenu("Walls");
textureMenu.add(wallTextureMenu);
final JRadioButtonMenuItem wallTexture01MenuItem = createWallTextureMenuItem(Wall.TEXTURE_01, "icons/wall_01.png");
final JRadioButtonMenuItem wallTexture02MenuItem = createWallTextureMenuItem(Wall.TEXTURE_02, "icons/wall_02.png");
final JRadioButtonMenuItem wallTexture03MenuItem = createWallTextureMenuItem(Wall.TEXTURE_03, "icons/wall_03.png");
final JRadioButtonMenuItem wallTexture04MenuItem = createWallTextureMenuItem(Wall.TEXTURE_04, "icons/wall_04.png");
final JRadioButtonMenuItem wallTexture05MenuItem = createWallTextureMenuItem(Wall.TEXTURE_05, "icons/wall_05.png");
final JRadioButtonMenuItem wallTexture06MenuItem = createWallTextureMenuItem(Wall.TEXTURE_06, "icons/wall_06.png");
final ButtonGroup wallTextureButtonGroup = new ButtonGroup();
wallTextureButtonGroup.add(wallTexture01MenuItem);
wallTextureButtonGroup.add(wallTexture02MenuItem);
wallTextureButtonGroup.add(wallTexture03MenuItem);
wallTextureButtonGroup.add(wallTexture04MenuItem);
wallTextureButtonGroup.add(wallTexture05MenuItem);
wallTextureButtonGroup.add(wallTexture06MenuItem);
wallTextureMenu.add(wallTexture01MenuItem);
wallTextureMenu.add(wallTexture02MenuItem);
wallTextureMenu.add(wallTexture03MenuItem);
wallTextureMenu.add(wallTexture04MenuItem);
wallTextureMenu.add(wallTexture05MenuItem);
wallTextureMenu.add(wallTexture06MenuItem);
wallTextureMenu.addMenuListener(new MenuListener() {
@Override
public void menuCanceled(final MenuEvent e) {
}
@Override
public void menuDeselected(final MenuEvent e) {
SceneManager.getInstance().refresh();
}
@Override
public void menuSelected(final MenuEvent e) {
if (Scene.getInstance().getTextureMode() == TextureMode.Full) {
switch(Scene.getInstance().getWallTextureType()) {
case Wall.TEXTURE_01:
Util.selectSilently(wallTexture01MenuItem, true);
break;
case Wall.TEXTURE_02:
Util.selectSilently(wallTexture02MenuItem, true);
break;
case Wall.TEXTURE_03:
Util.selectSilently(wallTexture03MenuItem, true);
break;
case Wall.TEXTURE_04:
Util.selectSilently(wallTexture04MenuItem, true);
break;
case Wall.TEXTURE_05:
Util.selectSilently(wallTexture05MenuItem, true);
break;
case Wall.TEXTURE_06:
Util.selectSilently(wallTexture06MenuItem, true);
break;
}
}
}
});
final JMenu roofTextureMenu = new JMenu("Roofs");
textureMenu.add(roofTextureMenu);
final JRadioButtonMenuItem roofTexture01MenuItem = createRoofTextureMenuItem(Wall.TEXTURE_01, "icons/roof_01.png");
final JRadioButtonMenuItem roofTexture02MenuItem = createRoofTextureMenuItem(Wall.TEXTURE_02, "icons/roof_02.png");
final JRadioButtonMenuItem roofTexture03MenuItem = createRoofTextureMenuItem(Wall.TEXTURE_03, "icons/roof_03.png");
final JRadioButtonMenuItem roofTexture04MenuItem = createRoofTextureMenuItem(Wall.TEXTURE_04, "icons/roof_04.png");
final JRadioButtonMenuItem roofTexture05MenuItem = createRoofTextureMenuItem(Wall.TEXTURE_05, "icons/roof_05.png");
final JRadioButtonMenuItem roofTexture06MenuItem = createRoofTextureMenuItem(Wall.TEXTURE_06, "icons/roof_06.png");
final ButtonGroup roofTextureButtonGroup = new ButtonGroup();
roofTextureButtonGroup.add(roofTexture01MenuItem);
roofTextureButtonGroup.add(roofTexture02MenuItem);
roofTextureButtonGroup.add(roofTexture03MenuItem);
roofTextureButtonGroup.add(roofTexture04MenuItem);
roofTextureButtonGroup.add(roofTexture05MenuItem);
roofTextureButtonGroup.add(roofTexture06MenuItem);
roofTextureMenu.add(roofTexture01MenuItem);
roofTextureMenu.add(roofTexture02MenuItem);
roofTextureMenu.add(roofTexture03MenuItem);
roofTextureMenu.add(roofTexture04MenuItem);
roofTextureMenu.add(roofTexture05MenuItem);
roofTextureMenu.add(roofTexture06MenuItem);
roofTextureMenu.addMenuListener(new MenuListener() {
@Override
public void menuCanceled(final MenuEvent e) {
}
@Override
public void menuDeselected(final MenuEvent e) {
SceneManager.getInstance().refresh();
}
@Override
public void menuSelected(final MenuEvent e) {
if (Scene.getInstance().getTextureMode() == TextureMode.Full) {
switch(Scene.getInstance().getRoofTextureType()) {
case Roof.TEXTURE_01:
Util.selectSilently(roofTexture01MenuItem, true);
break;
case Roof.TEXTURE_02:
Util.selectSilently(roofTexture02MenuItem, true);
break;
case Roof.TEXTURE_03:
Util.selectSilently(roofTexture03MenuItem, true);
break;
case Roof.TEXTURE_04:
Util.selectSilently(roofTexture04MenuItem, true);
break;
case Roof.TEXTURE_05:
Util.selectSilently(roofTexture05MenuItem, true);
break;
case Roof.TEXTURE_06:
Util.selectSilently(roofTexture06MenuItem, true);
break;
}
}
}
});
textureMenu.addSeparator();
final JMenu heliostatTextureMenu = new JMenu("Heliostats");
textureMenu.add(heliostatTextureMenu);
final ButtonGroup heliostatTextureButtonGroup = new ButtonGroup();
final JRadioButtonMenuItem heliostat1MirrorTextureMenuItem = new JRadioButtonMenuItem("Whole Mirror");
heliostat1MirrorTextureMenuItem.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
final ChangeHeliostatTextureCommand c = new ChangeHeliostatTextureCommand();
Scene.getInstance().setHeliostatTextureType(Mirror.TEXTURE_ONE_MIRROR);
Scene.getInstance().setEdited(true);
if (MainPanel.getInstance().getEnergyButton().isSelected()) {
MainPanel.getInstance().getEnergyButton().setSelected(false);
}
Scene.getInstance().redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
}
}
});
heliostatTextureButtonGroup.add(heliostat1MirrorTextureMenuItem);
final JRadioButtonMenuItem heliostat2X1MirrorsTextureMenuItem = new JRadioButtonMenuItem("2 \u00D7 1 Mirrors");
heliostat2X1MirrorsTextureMenuItem.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
final ChangeHeliostatTextureCommand c = new ChangeHeliostatTextureCommand();
Scene.getInstance().setHeliostatTextureType(Mirror.TEXTURE_2X1_MIRRORS);
Scene.getInstance().setEdited(true);
if (MainPanel.getInstance().getEnergyButton().isSelected()) {
MainPanel.getInstance().getEnergyButton().setSelected(false);
}
Scene.getInstance().redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
}
}
});
heliostatTextureButtonGroup.add(heliostat2X1MirrorsTextureMenuItem);
final JRadioButtonMenuItem heliostat1X2MirrorsTextureMenuItem = new JRadioButtonMenuItem("1 \u00D7 2 Mirrors");
heliostat1X2MirrorsTextureMenuItem.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
final ChangeHeliostatTextureCommand c = new ChangeHeliostatTextureCommand();
Scene.getInstance().setHeliostatTextureType(Mirror.TEXTURE_1X2_MIRRORS);
Scene.getInstance().setEdited(true);
if (MainPanel.getInstance().getEnergyButton().isSelected()) {
MainPanel.getInstance().getEnergyButton().setSelected(false);
}
Scene.getInstance().redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
}
}
});
heliostatTextureButtonGroup.add(heliostat1X2MirrorsTextureMenuItem);
final JRadioButtonMenuItem heliostat7X5MirrorsTextureMenuItem = new JRadioButtonMenuItem("7 \u00D7 5 Mirrors");
heliostat7X5MirrorsTextureMenuItem.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
final ChangeHeliostatTextureCommand c = new ChangeHeliostatTextureCommand();
Scene.getInstance().setHeliostatTextureType(Mirror.TEXTURE_7X5_MIRRORS);
Scene.getInstance().setEdited(true);
if (MainPanel.getInstance().getEnergyButton().isSelected()) {
MainPanel.getInstance().getEnergyButton().setSelected(false);
}
Scene.getInstance().redrawAll();
SceneManager.getInstance().getUndoManager().addEdit(c);
}
}
});
heliostatTextureButtonGroup.add(heliostat7X5MirrorsTextureMenuItem);
heliostatTextureMenu.add(heliostat1MirrorTextureMenuItem);
heliostatTextureMenu.add(heliostat2X1MirrorsTextureMenuItem);
heliostatTextureMenu.add(heliostat1X2MirrorsTextureMenuItem);
heliostatTextureMenu.add(heliostat7X5MirrorsTextureMenuItem);
heliostatTextureMenu.addMenuListener(new MenuListener() {
@Override
public void menuCanceled(final MenuEvent e) {
}
@Override
public void menuDeselected(final MenuEvent e) {
SceneManager.getInstance().refresh();
}
@Override
public void menuSelected(final MenuEvent e) {
switch(Scene.getInstance().getHeliostatTextureType()) {
default:
Util.selectSilently(heliostat1MirrorTextureMenuItem, true);
break;
case Mirror.TEXTURE_2X1_MIRRORS:
Util.selectSilently(heliostat2X1MirrorsTextureMenuItem, true);
break;
case Mirror.TEXTURE_1X2_MIRRORS:
Util.selectSilently(heliostat1X2MirrorsTextureMenuItem, true);
break;
case Mirror.TEXTURE_7X5_MIRRORS:
Util.selectSilently(heliostat7X5MirrorsTextureMenuItem, true);
break;
}
}
});
}
return textureMenu;
}
use of javax.swing.JRadioButtonMenuItem in project energy3d by concord-consortium.
the class MainFrame method createWallTextureMenuItem.
JRadioButtonMenuItem createWallTextureMenuItem(final int type, final String imageFile) {
final JRadioButtonMenuItem m = new JRadioButtonMenuItem(new ImageIcon(MainPanel.class.getResource(imageFile)));
m.setText("Texture #" + (type + 1));
m.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
final ChangeWallTextureCommand c = new ChangeWallTextureCommand();
Scene.getInstance().setTextureMode(TextureMode.Full);
Scene.getInstance().setWallTextureType(type);
Scene.getInstance().setEdited(true);
if (MainPanel.getInstance().getEnergyButton().isSelected()) {
MainPanel.getInstance().getEnergyButton().setSelected(false);
}
SceneManager.getInstance().getUndoManager().addEdit(c);
}
}
});
return m;
}
use of javax.swing.JRadioButtonMenuItem in project energy3d by concord-consortium.
the class MainFrame method getOrbitMenuItem.
private JRadioButtonMenuItem getOrbitMenuItem() {
if (orbitMenuItem == null) {
orbitMenuItem = new JRadioButtonMenuItem();
orbitMenuItem.setText("Orbit");
orbitMenuItem.setSelected(true);
orbitMenuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
SceneManager.getInstance().setCameraControl(CameraMode.ORBIT);
}
});
}
return orbitMenuItem;
}
use of javax.swing.JRadioButtonMenuItem in project energy3d by concord-consortium.
the class MainFrame method getGrasslandMenuItem.
private JRadioButtonMenuItem getGrasslandMenuItem() {
if (grasslandMenuItem == null) {
grasslandMenuItem = new JRadioButtonMenuItem("Grassland");
grasslandMenuItem.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
final ChangeThemeCommand c = new ChangeThemeCommand();
Scene.getInstance().setTheme(Scene.GRASSLAND_THEME);
Scene.getInstance().setEdited(true);
SceneManager.getInstance().getUndoManager().addEdit(c);
}
}
});
themeButtonGroup.add(grasslandMenuItem);
}
return grasslandMenuItem;
}
Aggregations