}
public JPopupMenu setGUI(JPopupMenu popup) {
//////// Line Cap
JMenu capMenu = new JMenu(i18n.get(BasicStrokeEditorMenu.class, "Cap_Decoration", "Cap Decoration"));
ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String command = ae.getActionCommand();
try {
setEndCaps(Integer.parseInt(command));
resetStroke();
} catch (NumberFormatException e) {
}
}
};
ButtonGroup group = new ButtonGroup();
JRadioButtonMenuItem button = new JRadioButtonMenuItem(i18n.get(BasicStrokeEditorMenu.class, "Butt", "Butt"), endCaps == BasicStroke.CAP_BUTT);
button.setActionCommand(String.valueOf(BasicStroke.CAP_BUTT));
group.add(button);
button.addActionListener(listener);
capMenu.add(button);
button = new JRadioButtonMenuItem(i18n.get(BasicStrokeEditorMenu.class, "Round", "Round"), endCaps == BasicStroke.CAP_ROUND);
button.setActionCommand(String.valueOf(BasicStroke.CAP_ROUND));
group.add(button);
button.addActionListener(listener);
capMenu.add(button);
button = new JRadioButtonMenuItem(i18n.get(BasicStrokeEditorMenu.class, "Square", "Square"), endCaps == BasicStroke.CAP_SQUARE);
button.setActionCommand(String.valueOf(BasicStroke.CAP_SQUARE));
group.add(button);
button.addActionListener(listener);
capMenu.add(button);
//////// Line Joins
JMenu joinMenu = new JMenu(i18n.get(BasicStrokeEditorMenu.class, "Joint_Decoration", "Joint Decoration"));
listener = new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String command = ae.getActionCommand();
try {
setLineJoins(Integer.parseInt(command));
resetStroke();
} catch (NumberFormatException e) {
}
}
};
group = new ButtonGroup();
button = new JRadioButtonMenuItem(i18n.get(BasicStrokeEditorMenu.class, "Miter", "Miter"), lineJoins == BasicStroke.JOIN_MITER);
button.setActionCommand(String.valueOf(BasicStroke.JOIN_MITER));
group.add(button);
button.addActionListener(listener);
joinMenu.add(button);
button = new JRadioButtonMenuItem(i18n.get(BasicStrokeEditorMenu.class, "Round", "Round"), lineJoins == BasicStroke.JOIN_ROUND);
button.setActionCommand(String.valueOf(BasicStroke.JOIN_ROUND));
group.add(button);
button.addActionListener(listener);
joinMenu.add(button);
button = new JRadioButtonMenuItem(i18n.get(BasicStrokeEditorMenu.class, "Bevel", "Bevel"), lineJoins == BasicStroke.JOIN_BEVEL);
button.setActionCommand(String.valueOf(BasicStroke.JOIN_BEVEL));
group.add(button);
button.addActionListener(listener);
joinMenu.add(button);
//////// Line Width
JMenu widthMenu = new JMenu(i18n.get(BasicStrokeEditorMenu.class, "Line_Width", "Line_Width"));
listener = new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String command = ae.getActionCommand();
try {
setStrokeWidth((float) Integer.parseInt(command));
resetStroke();
} catch (NumberFormatException e) {
}
}
};
group = new ButtonGroup();
ImageIcon ii;
int i;
for (i = 1; i < 13; i++) {
ii = createIcon(new BasicStroke(i), 50, 20, true);
button = new JRadioButtonMenuItem(" ", ii, (int) width == i);//without the space as a parameter these instances look strange with some Look&Feel
button.setActionCommand(String.valueOf(i));
group.add(button);
button.addActionListener(listener);
button.setMargin( new java.awt.Insets(0,10,0,10));
button.setPreferredSize(new java.awt.Dimension(70,20));
widthMenu.add(button);
}
//////// Dash Pattern
JMenu dashMenu = new JMenu(i18n.get(BasicStrokeEditorMenu.class, "Dash_Pattern", "Dash Pattern"));
listener = new ActionListener() {
public void actionPerformed(ActionEvent ae) {
String command = ae.getActionCommand();
try {
setDash(stringToDashArray(command));
resetStroke();
} catch (NumberFormatException e) {
}
}
};
group = new ButtonGroup();
String[] patterns = new String[] { NONE, "1.0 3.0", "3.0 3.0", "12.0 10.0",
"12.0 10.0 6.0 10.0", "20.0 10.0", "20.0 10.0 6.0 10.0", "20.0 10.0 6.0 10.0 6.0 10.0" };
String currentDash = dashArrayToString(getDash());
for (i = 0; i < patterns.length; i++) {
BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, stringToDashArray(patterns[i]), 0.0f);
ii = createIcon(dashStroke, 90, 10, true);
button = new JRadioButtonMenuItem(" ", ii, currentDash.equals(patterns[i]));
button.setActionCommand(patterns[i]);
group.add(button);
button.addActionListener(listener);
button.setMargin( new java.awt.Insets(0,10,0,10));
button.setPreferredSize(new java.awt.Dimension(110,20));
dashMenu.add(button);
}
popup.add(widthMenu);
popup.add(dashMenu);
popup.add(capMenu);