use of mudmap2.frontend.GUIElement.ColorChooserButton in project mudmap2 by Neop.
the class ExportImageDialog method createBackgroundPanel.
/**
* Creats backround (color, grid) panel
* @return panel
*/
JPanel createBackgroundPanel() {
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.insets = new Insets(2, 2, 2, 2);
constraints.gridx = constraints.gridy = 1;
JLabel label = new JLabel("Background:");
Font font = label.getFont();
label.setFont(font.deriveFont(Font.BOLD));
panel.add(label, constraints);
rbBackgroundTransparent = new JRadioButton("transparent");
rbBackgroundColor = new JRadioButton("color");
ButtonGroup bgBackground = new ButtonGroup();
bgBackground.add(rbBackgroundTransparent);
bgBackground.add(rbBackgroundColor);
rbBackgroundTransparent.setSelected(true);
constraints.gridx++;
panel.add(rbBackgroundTransparent, constraints);
constraints.gridx++;
panel.add(rbBackgroundColor, constraints);
constraints.gridx++;
constraints.weightx = 4;
ccbBackgroundColor = new ColorChooserButton(panel, Color.white);
panel.add(ccbBackgroundColor, constraints);
constraints.gridy++;
constraints.gridx = 1;
constraints.weightx = 0;
cbBackgroundGrid = new JCheckBox("Draw grid");
panel.add(cbBackgroundGrid, constraints);
return panel;
}
use of mudmap2.frontend.GUIElement.ColorChooserButton in project mudmap2 by Neop.
the class ExportImageDialog method createLegendPanel.
/**
* Creates legend panel
* @return panel
*/
JPanel createLegendPanel() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
JPanel pRow1 = new JPanel();
pRow1.setLayout(new GridBagLayout());
panel.add(pRow1);
GridBagConstraints constraints1 = new GridBagConstraints();
constraints1.fill = GridBagConstraints.HORIZONTAL;
constraints1.insets = new Insets(2, 2, 2, 2);
constraints1.weightx = 1;
constraints1.gridx = constraints1.gridy = 1;
JLabel label = new JLabel("Legend:");
Font font = label.getFont();
label.setFont(font.deriveFont(Font.BOLD));
pRow1.add(label, constraints1);
cbLegendPathColors = new JCheckBox("Path colors");
cbLegendPlaceGroups = new JCheckBox("Place groups");
cbLegendRiskLevels = new JCheckBox("Risk levels");
constraints1.gridx++;
pRow1.add(cbLegendPathColors, constraints1);
constraints1.gridx++;
pRow1.add(cbLegendPlaceGroups, constraints1);
constraints1.gridx++;
pRow1.add(cbLegendRiskLevels, constraints1);
cbLegendPathColors.addActionListener(new UpdateDialogListener());
cbLegendPlaceGroups.addActionListener(new UpdateDialogListener());
cbLegendRiskLevels.addActionListener(new UpdateDialogListener());
constraints1.gridy++;
constraints1.gridx = 1;
pRow1.add(new JLabel("Position:"), constraints1);
rbLegendPosBottom = new JRadioButton("Bottom");
rbLegendPosLeft = new JRadioButton("Left");
rbLegendPosRight = new JRadioButton("Right");
rbLegendPosTop = new JRadioButton("Top");
ButtonGroup bgLegendPos = new ButtonGroup();
bgLegendPos.add(rbLegendPosBottom);
bgLegendPos.add(rbLegendPosLeft);
bgLegendPos.add(rbLegendPosRight);
bgLegendPos.add(rbLegendPosTop);
rbLegendPosBottom.setSelected(true);
constraints1.gridx++;
pRow1.add(rbLegendPosTop, constraints1);
constraints1.gridx++;
pRow1.add(rbLegendPosBottom, constraints1);
constraints1.gridx++;
pRow1.add(rbLegendPosLeft, constraints1);
constraints1.gridx++;
pRow1.add(rbLegendPosRight, constraints1);
JPanel pRow2 = new JPanel();
pRow2.setLayout(new GridBagLayout());
panel.add(pRow2);
GridBagConstraints constraints2 = new GridBagConstraints();
constraints2.fill = GridBagConstraints.HORIZONTAL;
constraints2.insets = new Insets(2, 2, 2, 2);
constraints2.gridx = constraints1.gridy = 1;
pRow2.add(new JLabel("Background color:"), constraints2);
constraints2.gridx++;
constraints2.weightx = 2;
ccbLegendBackground = new ColorChooserButton(pRow2, Color.LIGHT_GRAY);
pRow2.add(ccbLegendBackground, constraints2);
return panel;
}
use of mudmap2.frontend.GUIElement.ColorChooserButton in project mudmap2 by Neop.
the class PlaceGroupDialog method create.
/**
* Creates the GUI
*/
@Override
void create() {
setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets(2, 2, 2, 2);
constraints.gridx = 0;
constraints.gridy = 0;
constraints.fill = GridBagConstraints.HORIZONTAL;
add(new JLabel("Name"), constraints);
constraints.gridx = 1;
constraints.gridwidth = 2;
if (placeGroup != null)
textfield_name = new JTextField(placeGroup.toString());
else
textfield_name = new JTextField();
add(textfield_name, constraints);
textfield_name.setColumns(20);
constraints.gridwidth = 1;
constraints.gridx = 0;
constraints.gridy++;
add(new JLabel("Color"), constraints);
constraints.weighty = 4.0;
constraints.gridx = 1;
constraints.fill = GridBagConstraints.BOTH;
constraints.gridwidth = 2;
if (placeGroup != null)
colorchooserbutton = new ColorChooserButton(getParent(), placeGroup.getColor());
else
colorchooserbutton = new ColorChooserButton(getParent());
add(colorchooserbutton, constraints);
constraints.weighty = 1.0;
constraints.gridwidth = 1;
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridx = 0;
constraints.gridy++;
JButton button_cancel = new JButton("Cancel");
add(button_cancel, constraints);
button_cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
dispose();
}
});
constraints.gridx++;
JButton button_new = new JButton("Add");
button_new.setToolTipText("Create a new place group");
add(button_new, constraints);
getRootPane().setDefaultButton(button_new);
button_new.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
new_group = true;
save();
dispose();
}
});
if (!new_group) {
// don't show edit button when creating a new place
constraints.gridx++;
JButton button_edit = new JButton("Edit");
button_edit.setToolTipText("Edit the current place group");
add(button_edit, constraints);
getRootPane().setDefaultButton(button_edit);
button_edit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
save();
dispose();
}
});
}
pack();
setResizable(false);
setLocation(getParent().getX() + (getParent().getWidth() - getWidth()) / 2, getParent().getY() + (getParent().getHeight() - getHeight()) / 2);
}
use of mudmap2.frontend.GUIElement.ColorChooserButton in project mudmap2 by Neop.
the class EditWorldDialog method create.
@Override
void create() {
setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
GridBagConstraints constraints_l = new GridBagConstraints();
GridBagConstraints constraints_r = new GridBagConstraints();
constraints.insets = constraints_l.insets = constraints_r.insets = new Insets(2, 2, 2, 2);
constraints_l.fill = GridBagConstraints.HORIZONTAL;
constraints_r.fill = GridBagConstraints.BOTH;
constraints_r.gridx = 1;
constraints_l.weightx = constraints_r.weightx = 1.0;
constraints_l.gridy = ++constraints_r.gridy;
add(new JLabel("World name"), constraints_l);
add(textfield_name = new JTextField(world.getName()), constraints_r);
textfield_name.setColumns(20);
constraints_l.gridy = ++constraints_r.gridy;
constraints.gridy = constraints_l.gridy = ++constraints_r.gridy;
constraints.gridwidth = 2;
constraints.fill = GridBagConstraints.HORIZONTAL;
add(new JSeparator(), constraints);
constraints.gridy = constraints_l.gridy = ++constraints_r.gridy;
add(new JLabel("Risk Levels"), constraints);
risklevel_colors = new HashMap<>();
for (RiskLevel rl : world.getRiskLevels()) {
constraints_l.gridy = ++constraints_r.gridy;
JTextField tf_rl_name = new JTextField(rl.getDescription());
add(tf_rl_name, constraints_l);
ColorChooserButton colorchooser = new ColorChooserButton(getParent(), rl.getColor());
add(colorchooser, constraints_r);
risklevel_colors.put(rl, new Pair<>(tf_rl_name, colorchooser));
}
constraints_l.gridy = ++constraints_r.gridy;
add(risklevel_new_name = new JTextField(), constraints_l);
add(risklevel_new_color = new ColorChooserButton(getParent()), constraints_r);
constraints_l.gridy = ++constraints_r.gridy;
add(new JLabel("Tile center color"), constraints_l);
add(tile_center_color = new ColorChooserButton(getParent(), world.getTileCenterColor()), constraints_r);
constraints.gridy = constraints_l.gridy = ++constraints_r.gridy;
add(new JSeparator(), constraints);
buttongroup_place_id = new ButtonGroup();
radiobutton_place_id_none = new JRadioButton("Don't show place ID on map");
radiobutton_place_id_unique = new JRadioButton("Show place ID if name isn't unique");
radiobutton_place_id_all = new JRadioButton("Always show place ID");
buttongroup_place_id.add(radiobutton_place_id_none);
buttongroup_place_id.add(radiobutton_place_id_unique);
buttongroup_place_id.add(radiobutton_place_id_all);
constraints_l.gridy = ++constraints_r.gridy;
add(radiobutton_place_id_none, constraints_l);
/*constraints_l.gridy = ++constraints_r.gridy; // feature (temporarily?) removed
add(radiobutton_place_id_unique, constraints_l);*/
constraints_l.gridy = ++constraints_r.gridy;
add(radiobutton_place_id_all, constraints_l);
switch(world.getShowPlaceId()) {
case NONE:
buttongroup_place_id.setSelected(radiobutton_place_id_none.getModel(), true);
break;
default:
case UNIQUE:
buttongroup_place_id.setSelected(radiobutton_place_id_unique.getModel(), true);
break;
case ALL:
buttongroup_place_id.setSelected(radiobutton_place_id_all.getModel(), true);
break;
}
constraints_l.insets = constraints_r.insets = new Insets(0, 2, 0, 2);
constraints_l.gridy = ++constraints_r.gridy;
JButton button_cancel = new JButton("Cancel");
add(button_cancel, constraints_l);
button_cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
dispose();
}
});
JButton button_ok = new JButton("Ok");
add(button_ok, constraints_r);
getRootPane().setDefaultButton(button_ok);
button_ok.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
try {
save();
} catch (Exception ex) {
Logger.getLogger(EditWorldDialog.class.getName()).log(Level.SEVERE, null, ex);
}
dispose();
}
});
pack();
setResizable(false);
setLocation(getParent().getX() + (getParent().getWidth() - getWidth()) / 2, getParent().getY() + (getParent().getHeight() - getHeight()) / 2);
}
use of mudmap2.frontend.GUIElement.ColorChooserButton in project mudmap2 by Neop.
the class EditWorldDialog method save.
/**
* Saves the changes
*/
private void save() throws Exception {
String name = textfield_name.getText();
// if textfield is not empty
if (!name.isEmpty()) {
world.setName(name);
}
// modify risk levels
for (Map.Entry<RiskLevel, Pair<JTextField, ColorChooserButton>> rl_color : risklevel_colors.entrySet()) {
String description = rl_color.getValue().first.getText();
if (description.isEmpty())
world.removeRiskLevel(rl_color.getKey());
else {
rl_color.getKey().setDescription(description);
rl_color.getKey().setColor(rl_color.getValue().second.getColor());
}
}
world.setTileCenterColor(tile_center_color.getColor());
// add new risk level, if name not empty
String name_new = risklevel_new_name.getText();
if (!name_new.isEmpty()) {
world.addRiskLevel(new RiskLevel(name_new, risklevel_new_color.getColor()));
}
ButtonModel selection = buttongroup_place_id.getSelection();
if (selection == radiobutton_place_id_none.getModel())
world.setShowPlaceID(World.ShowPlaceID.NONE);
else if (selection == radiobutton_place_id_all.getModel())
world.setShowPlaceID(World.ShowPlaceID.ALL);
else
world.setShowPlaceID(World.ShowPlaceID.UNIQUE);
getParent().repaint();
}
Aggregations