private JPopupMenu getPalettePopupMenu() {
JPopupMenu popupMenu = new JPopupMenu();
JMenu defaultMenu = new JMenu(NbBundle.getMessage(RankingColorTransformerPanel.class, "PalettePopup.default"));
for (Palette p : PaletteUtils.getSequencialPalettes()) {
final Palette p3 = PaletteUtils.get3ClassPalette(p);
JMenuItem item = new JMenuItem(new PaletteIcon(p3.getColors()));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gradientSlider.setValues(p3.getPositions(), p3.getColors());
}
});
defaultMenu.add(item);
}
for (Palette p : PaletteUtils.getDivergingPalettes()) {
final Palette p3 = PaletteUtils.get3ClassPalette(p);
JMenuItem item = new JMenuItem(new PaletteIcon(p3.getColors()));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gradientSlider.setValues(p3.getPositions(), p3.getColors());
}
});
defaultMenu.add(item);
}
popupMenu.add(defaultMenu);
//Invert
JMenuItem invertItem = new JMenuItem(NbBundle.getMessage(RankingColorTransformerPanel.class, "PalettePopup.invert"));
invertItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gradientSlider.setValues(invert(gradientSlider.getThumbPositions()), invert(gradientSlider.getColors()));
}
});
popupMenu.add(invertItem);
//Recent
JMenu recentMenu = new JMenu(NbBundle.getMessage(RankingColorTransformerPanel.class, "PalettePopup.recent"));
for (final RankingElementColorTransformer.LinearGradient gradient : recentPalettes.getPalettes()) {
JMenuItem item = new JMenuItem(new PaletteIcon(gradient.getColors()));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gradientSlider.setValues(gradient.getPositions(), gradient.getColors());
}