The ImageJ toolbar.
| 50 | |
| 51 | /** The ImageJ toolbar. */ |
| 52 | public class Toolbar extends Canvas implements MouseListener, MouseMotionListener, ItemListener, ActionListener { |
| 53 | |
| 54 | public static final int RECTANGLE = 0; |
| 55 | public static final int OVAL = 1; |
| 56 | public static final int POLYGON = 2; |
| 57 | public static final int FREEROI = 3; |
| 58 | public static final int LINE = 4; |
| 59 | public static final int POLYLINE = 5; |
| 60 | public static final int FREELINE = 6; |
| 61 | public static final int POINT = 7, CROSSHAIR = 7; |
| 62 | public static final int WAND = 8; |
| 63 | public static final int TEXT = 9; |
| 64 | public static final int UNUSED = 10; |
| 65 | public static final int MAGNIFIER = 11; |
| 66 | public static final int HAND = 12; |
| 67 | public static final int DROPPER = 13; |
| 68 | public static final int ANGLE = 14; |
| 69 | public static final int CUSTOM1 = 15; |
| 70 | public static final int CUSTOM2 = 16; |
| 71 | public static final int CUSTOM3 = 17; |
| 72 | public static final int CUSTOM4 = 18; |
| 73 | public static final int CUSTOM5 = 19; |
| 74 | public static final int CUSTOM6 = 20; |
| 75 | public static final int CUSTOM7 = 21; |
| 76 | |
| 77 | public static final int DOUBLE_CLICK_THRESHOLD = 650; //ms |
| 78 | |
| 79 | public static final int RECT_ROI=0, ROUNDED_RECT_ROI=1, ROTATED_RECT_ROI=2; |
| 80 | public static final int OVAL_ROI=0, ELLIPSE_ROI=1, BRUSH_ROI=2; |
| 81 | |
| 82 | public static final String[] builtInTools = {"Arrow","Brush","Command Finder", "Developer Menu","Flood Filler", |
| 83 | "Label Maker","LUT Menu","Overlay Brush","Pencil","Pixel Inspector","Selection Rotator", |
| 84 | "Spray Can","Stacks Menu","ROI Menu"}; |
| 85 | private static final String[] builtInTools2 = {"Pixel Inspection Tool","Paintbrush Tool","Flood Fill Tool"}; |
| 86 | |
| 87 | private static final int NUM_TOOLS = 23; |
| 88 | private static final int MAX_EXTRA_TOOLS = 8; |
| 89 | private static final int MAX_TOOLS = NUM_TOOLS+MAX_EXTRA_TOOLS; |
| 90 | private static final int NUM_BUTTONS = 21; |
| 91 | private static final int BUTTON_WIDTH = 30; |
| 92 | private static final int BUTTON_HEIGHT = 31; |
| 93 | private static final int SIZE = 28; // no longer used |
| 94 | private static final int GAP_SIZE = 9; |
| 95 | private static final int OFFSET = 7; |
| 96 | private static final String BRUSH_SIZE = "toolbar.brush.size"; |
| 97 | public static final String CORNER_DIAMETER = "toolbar.arc.size"; |
| 98 | public static String TOOL_KEY = "toolbar.tool"; |
| 99 | |
| 100 | private Dimension ps; |
| 101 | private boolean[] down; |
| 102 | private static int current; |
| 103 | private int previousTool; |
| 104 | private int x,y; |
| 105 | private int xOffset, yOffset; |
| 106 | private long mouseDownTime; |
| 107 | private Graphics g; |
| 108 | private static Toolbar instance; |
| 109 | private int mpPrevious = RECTANGLE; |