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 contributio
| 39 | * decide on a good way to do this... your contributions welcome). |
| 40 | */ |
| 41 | @SuppressWarnings("unused") |
| 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 | e -> { |
| 71 | Clipboard c = Toolkit.getSystemClipboard(); |
| 72 | c.setContents(new StringSelection(selector.getHexColor()), null); |
| 73 | }); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | selector.show(); |
| 78 | } |
| 79 | } |
nothing calls this directly
no outgoing calls
no test coverage detected