Changeset 182 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures/SimulationScript.java
- Timestamp:
- 01/11/2020 05:45:23 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/scriptbuilder/structures/SimulationScript.java
r169 r182 33 33 34 34 /** 35 * All default options for GUI colorings of incidents. 36 */ 37 public static final Color[] incidentColors = 38 { 39 Color.BLACK, 40 Color.BLUE, 41 Color.RED, 42 new Color(0x38, 0x5E, 0x0F), 43 new Color(128, 0, 128), 44 Color.MAGENTA, 45 new Color(0x23, 0x6B, 0x8E), 46 Color.ORANGE, 47 new Color(0x60, 0x33, 0x11), 48 Color.GRAY 49 }; 50 35 * Strings to show in the incident color combo box. Last item should be black, 36 * which will be used if invalid color is provided to lookupColor(). 37 */ 38 public static final String[] colorNames = {"BLUE", "RED", "CYAN", "GREEN", 39 "ORANGE", "MAGENTA", "YELLOW", "BLACK"}; 40 /** 41 * Allowed color choices for incident display. 42 * These colors must match the items in colorNames. 43 */ 44 public static final Color[] incidentColors = {Color.BLUE, Color.RED, Color.CYAN, 45 Color.GREEN, Color.ORANGE, Color.MAGENTA, Color.YELLOW, Color.BLACK}; 51 46 /** 52 47 * The file to which this script will be saved. … … 428 423 return count; 429 424 } 430 425 426 /** Given a color, find its index in the incidentColors. 427 * @param color a java color 428 * @return the index of color in incidentColors, or last index if color isn't 429 * in incidentColors. The last item in incidentColors should be black. 430 */ 431 public static int lookupColor(Color color) 432 { 433 int idx = 0; 434 // search color array for target 435 while(idx < incidentColors.length && !incidentColors[idx].equals(color)) 436 { 437 idx++; 438 } 439 // if color not found, return index of last item. 440 if (idx == incidentColors.length) 441 { 442 return idx-1; 443 } 444 else return idx; 445 } 431 446 }
Note: See TracChangeset
for help on using the changeset viewer.
