[31] | 1 | package vnsim.gui; |
---|
| 2 | |
---|
| 3 | public class MyColor { |
---|
| 4 | |
---|
| 5 | public static final MyColor color_InterstatalHighway = new MyColor(1.0f, 0.7f, 0.7f); |
---|
| 6 | public static final MyColor color_StatalHighway = new MyColor(1.0f, 0.8f, 0.5f); |
---|
| 7 | public static final MyColor color_PrimaryRoad = new MyColor(1.0f, 0.8f, 0.5f); |
---|
| 8 | public static final MyColor color_SecondaryRoad = new MyColor(1.0f, 1.0f, 0.55f); |
---|
| 9 | public static final MyColor color_LocalRoad = new MyColor(0.82f, 0.82f, 0.82f); |
---|
| 10 | public static final MyColor color_VehicularTrail = new MyColor(0.7f, 0.6f, 0.2f); |
---|
| 11 | public static final MyColor color_AccessRamp = new MyColor(0.9f, 0.9f, 0.4f); |
---|
| 12 | public static final MyColor color_PedestrianRoad = new MyColor(0.4f, 1.0f, 0.4f); |
---|
| 13 | public static final MyColor color_DefaultRoad = new MyColor(1.0f, 0.0f, 0.0f); |
---|
| 14 | public static final MyColor color_SemaphoreRed = new MyColor(1.0f, 0.0f, 0.0f); |
---|
| 15 | public static final MyColor color_SemaphoreYellow = new MyColor(1.0f, 0.8f, 0.5f); |
---|
| 16 | public static final MyColor color_SemaphoreGreen = new MyColor(0.0f, 1.0f, 0.0f); |
---|
| 17 | |
---|
| 18 | private float red = 0f; |
---|
| 19 | private float blue = 0f; |
---|
| 20 | private float green = 0f; |
---|
| 21 | |
---|
| 22 | /** |
---|
| 23 | * Builds a new MyColor object. |
---|
| 24 | * |
---|
| 25 | * @param red |
---|
| 26 | * RED component of the new color. |
---|
| 27 | * @param green |
---|
| 28 | * GREEN component of the new color. |
---|
| 29 | * @param blue |
---|
| 30 | * BLUE component of the new color. |
---|
| 31 | */ |
---|
| 32 | public MyColor(float red, float green, float blue) { |
---|
| 33 | this.red = red; |
---|
| 34 | this.green = green; |
---|
| 35 | this.blue = blue; |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | /** |
---|
| 39 | * |
---|
| 40 | * @return RED component of this color. |
---|
| 41 | */ |
---|
| 42 | public float getRed() { |
---|
| 43 | return red; |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | /** |
---|
| 47 | * |
---|
| 48 | * @param red |
---|
| 49 | * New RED component. |
---|
| 50 | */ |
---|
| 51 | public void setRed(float red) { |
---|
| 52 | this.red = red; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | /** |
---|
| 56 | * |
---|
| 57 | * @return BLUE component of this color. |
---|
| 58 | */ |
---|
| 59 | public float getBlue() { |
---|
| 60 | return blue; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | /** |
---|
| 64 | * |
---|
| 65 | * @param blue |
---|
| 66 | * New BLUE component. |
---|
| 67 | */ |
---|
| 68 | public void setBlue(float blue) { |
---|
| 69 | this.blue = blue; |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | /** |
---|
| 73 | * |
---|
| 74 | * @return GREEN component of this color. |
---|
| 75 | */ |
---|
| 76 | public float getGreen() { |
---|
| 77 | return green; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | /** |
---|
| 81 | * |
---|
| 82 | * @param green |
---|
| 83 | * New GREEN component. |
---|
| 84 | */ |
---|
| 85 | public void setGreen(float green) { |
---|
| 86 | this.green = green; |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | public static MyColor chooseRoadColor(int roadType) { |
---|
| 90 | switch (roadType) { |
---|
| 91 | case 49:// interstatal highway |
---|
| 92 | return color_InterstatalHighway; |
---|
| 93 | |
---|
| 94 | case 50:// statal highway and primary road |
---|
| 95 | return color_StatalHighway; |
---|
| 96 | |
---|
| 97 | case 51:// secondary road |
---|
| 98 | return color_PrimaryRoad; |
---|
| 99 | |
---|
| 100 | case 52: // local road |
---|
| 101 | return color_LocalRoad; |
---|
| 102 | |
---|
| 103 | case 53:// vehicular trail |
---|
| 104 | return color_VehicularTrail; |
---|
| 105 | |
---|
| 106 | case 54:// access ramp |
---|
| 107 | return color_AccessRamp; |
---|
| 108 | |
---|
| 109 | case 55:// pedestrian road |
---|
| 110 | return color_PedestrianRoad; |
---|
| 111 | |
---|
| 112 | default: |
---|
| 113 | return color_DefaultRoad; |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | protected static MyColor chooseSemaphoreColor(int color) { |
---|
| 118 | switch (color) { |
---|
| 119 | case 1: |
---|
| 120 | return color_SemaphoreRed; |
---|
| 121 | case 2: |
---|
| 122 | return color_SemaphoreYellow; |
---|
| 123 | case 3: |
---|
| 124 | return color_SemaphoreGreen; |
---|
| 125 | default: |
---|
| 126 | return color_SemaphoreRed; |
---|
| 127 | } |
---|
| 128 | } |
---|
| 129 | } |
---|