Color selector tool for the Tools menu. Using the keyboard shortcuts, you can copy/paste the values for the colors and paste them into your program. We didn't do any sort of auto-insert of colorMode() or fill() or stroke() code cuz we couldn't decide on a good way to do this.. your contribution
| 40 | * decide on a good way to do this.. your contributions welcome). |
| 41 | */ |
| 42 | public class ColorSelector implements Tool { |
| 43 | |
| 44 | /** |
| 45 | * Only create one instance, otherwise we'll have dozens of animation |
| 46 | * threads going if you open/close a lot of editor windows. |
| 47 | */ |
| 48 | private static volatile ColorChooser selector; |
| 49 | |
| 50 | private Base base; |
| 51 | |
| 52 | |
| 53 | public String getMenuTitle() { |
| 54 | return Language.text("menu.tools.color_selector"); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | public void init(Base base) { |
| 59 | this.base = base; |
| 60 | } |
| 61 | |
| 62 | |
| 63 | public void run() { |
| 64 | if (selector == null) { |
| 65 | synchronized (ColorSelector.class) { |
| 66 | if (selector == null) { |
| 67 | selector = new ColorChooser(base.getActiveEditor(), |
| 68 | false, Color.WHITE, |
| 69 | Language.text("menu.edit.copy"), |
| 70 | new ActionListener() { |
| 71 | |
| 72 | @Override |
| 73 | public void actionPerformed(ActionEvent e) { |
| 74 | Clipboard c = Toolkit.getSystemClipboard(); |
| 75 | c.setContents(new StringSelection(selector.getHexColor()), null); |
| 76 | } |
| 77 | }); |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | selector.show(); |
| 82 | } |
| 83 | } |
nothing calls this directly
no outgoing calls
no test coverage detected