1 package devisor2.grid.options; 2 3 import java.awt.*; 4 import devisor2.grid.GUI.framework.*; 5 6 /** 7 * This is the convenience class for easy access of all draw options 8 * such as colors, fonts and paint flags. <br> 9 * These options are still being stored in the Options class, therefore 10 * also made persistent with it, and this class is updated every time 11 * any of these options are changed. Updating is taken care of by the 12 * constructor only.<br> 13 * For easy access, there is a reference to the most recent instance of this 14 * class in the ControlCenter, which you can access as usual. 15 * 16 * @author Dominik Goeddeke 17 * @version 1.0 18 */ 19 public class DrawControl 20 { 21 22 /** 23 * The constructor just initializes all the class variables, which are 24 * public for easier access. Feel free to make them private and provide 25 * get methods :-) 26 * 27 * @param op - the Options instance to read values from 28 */ DrawControl(Options op)29 public DrawControl (Options op) 30 { 31 // screen and MainFrame size updated from within startup class. 32 displaycoords = Boolean.valueOf(op.get (Options.draw_usercoords)).booleanValue(); 33 draw_orientationmarkers = Boolean.valueOf(op.get (Options.draw_orientationmarkers)).booleanValue(); 34 35 // init draw flags 36 draw_boundary = Boolean.valueOf(op.get (Options.draw_drawboundary)).booleanValue(); 37 number_boundary = Boolean.valueOf(op.get (Options.draw_numberboundary)).booleanValue(); 38 draw_node = Boolean.valueOf(op.get (Options.draw_drawnode)).booleanValue(); 39 number_node = Boolean.valueOf(op.get (Options.draw_numbernode)).booleanValue(); 40 draw_edge = Boolean.valueOf(op.get (Options.draw_drawedge)).booleanValue(); 41 number_edge = Boolean.valueOf(op.get (Options.draw_numberedge)).booleanValue(); 42 draw_element = Boolean.valueOf(op.get (Options.draw_drawelement)).booleanValue(); 43 number_element = Boolean.valueOf(op.get (Options.draw_numberelement)).booleanValue(); 44 cross_element = Boolean.valueOf(op.get (Options.draw_crosselement)).booleanValue(); 45 fill_element = Boolean.valueOf(op.get (Options.draw_fillelement)).booleanValue(); 46 draw_grid = Boolean.valueOf(op.get (Options.draw_drawgrid)).booleanValue(); 47 draw_perimeter = Boolean.valueOf(op.get (Options.draw_drawperimeter)).booleanValue(); 48 highlight_rect = Boolean.valueOf(op.get (Options.draw_drawrect)).booleanValue(); 49 // colors 50 color_node = new Color (Integer.parseInt(op.get(Options.color_node))); 51 color_edge = new Color (Integer.parseInt(op.get(Options.color_edge))); 52 color_edgebase = new Color (Integer.parseInt(op.get(Options.color_edgebase))); 53 color_element = new Color (Integer.parseInt(op.get(Options.color_element))); 54 color_boundarynumber = new Color (Integer.parseInt(op.get(Options.color_boundarynumber))); 55 color_nodenumber = new Color (Integer.parseInt(op.get(Options.color_nodenumber))); 56 color_edgenumber = new Color (Integer.parseInt(op.get(Options.color_edgenumber))); 57 color_elementnumber = new Color (Integer.parseInt(op.get(Options.color_elementnumber))); 58 color_selection = new Color (Integer.parseInt(op.get(Options.color_selection))); 59 color_rect = new Color (Integer.parseInt(op.get(Options.color_rect))); 60 color_grid = new Color (Integer.parseInt(op.get(Options.color_grid))); 61 color_background = new Color (Integer.parseInt(op.get(Options.color_background))); 62 color_lasso = new Color (Integer.parseInt(op.get(Options.color_lasso))); 63 64 // fill colors for parallel blocks palette 65 parallel_palette = new Color[16]; 66 parallel_palette[0] = new Color (Integer.parseInt(op.get(Options.color_fill0))); 67 parallel_palette[1] = new Color (Integer.parseInt(op.get(Options.color_fill1))); 68 parallel_palette[2] = new Color (Integer.parseInt(op.get(Options.color_fill2))); 69 parallel_palette[3] = new Color (Integer.parseInt(op.get(Options.color_fill3))); 70 parallel_palette[4] = new Color (Integer.parseInt(op.get(Options.color_fill4))); 71 parallel_palette[5] = new Color (Integer.parseInt(op.get(Options.color_fill5))); 72 parallel_palette[6] = new Color (Integer.parseInt(op.get(Options.color_fill6))); 73 parallel_palette[7] = new Color (Integer.parseInt(op.get(Options.color_fill7))); 74 parallel_palette[8] = new Color (Integer.parseInt(op.get(Options.color_fill8))); 75 parallel_palette[9] = new Color (Integer.parseInt(op.get(Options.color_fill9))); 76 parallel_palette[10] = new Color (Integer.parseInt(op.get(Options.color_fill10))); 77 parallel_palette[11] = new Color (Integer.parseInt(op.get(Options.color_fill11))); 78 parallel_palette[12] = new Color (Integer.parseInt(op.get(Options.color_fill12))); 79 parallel_palette[13] = new Color (Integer.parseInt(op.get(Options.color_fill13))); 80 parallel_palette[14] = new Color (Integer.parseInt(op.get(Options.color_fill14))); 81 parallel_palette[15] = new Color (Integer.parseInt(op.get(Options.color_fill15))); 82 83 // boundary color palette 84 boundary_palette = new Color[16]; 85 boundary_palette[0] = new Color (Integer.parseInt(op.get(Options.color_boundary0))); 86 boundary_palette[1] = new Color (Integer.parseInt(op.get(Options.color_boundary1))); 87 boundary_palette[2] = new Color (Integer.parseInt(op.get(Options.color_boundary2))); 88 boundary_palette[3] = new Color (Integer.parseInt(op.get(Options.color_boundary3))); 89 boundary_palette[4] = new Color (Integer.parseInt(op.get(Options.color_boundary4))); 90 boundary_palette[5] = new Color (Integer.parseInt(op.get(Options.color_boundary5))); 91 boundary_palette[6] = new Color (Integer.parseInt(op.get(Options.color_boundary6))); 92 boundary_palette[7] = new Color (Integer.parseInt(op.get(Options.color_boundary7))); 93 boundary_palette[8] = new Color (Integer.parseInt(op.get(Options.color_boundary8))); 94 boundary_palette[9] = new Color (Integer.parseInt(op.get(Options.color_boundary9))); 95 boundary_palette[10] = new Color (Integer.parseInt(op.get(Options.color_boundary10))); 96 boundary_palette[11] = new Color (Integer.parseInt(op.get(Options.color_boundary11))); 97 boundary_palette[12] = new Color (Integer.parseInt(op.get(Options.color_boundary12))); 98 boundary_palette[13] = new Color (Integer.parseInt(op.get(Options.color_boundary13))); 99 boundary_palette[14] = new Color (Integer.parseInt(op.get(Options.color_boundary14))); 100 boundary_palette[15] = new Color (Integer.parseInt(op.get(Options.color_boundary15))); 101 102 103 // fonts 104 font_numbering = new Font (op.get(Options.font_numbering), Integer.parseInt(op.get(Options.font_numbering_style)), Integer.parseInt (op.get(Options.font_numbering_size))); 105 106 107 // world_x1=-1*100000; 108 // world_y1=-1*100000; 109 // world_x2= 1*100000; 110 // world_y2= 1*100000; 111 112 // act_x1=world_x1; 113 // act_x2=world_x2; 114 // act_y1=world_y1; 115 // act_y2=world_y2; 116 117 // click tolerance 118 tolerance = Integer.parseInt (op.get(Options.click_tolerance)); 119 } 120 121 /** 122 * the physical screen width 123 */ 124 public int screen_width; 125 /** 126 * the physical screen heigth 127 */ 128 public int screen_height; 129 /** 130 * the actual MainFrame width 131 */ 132 133 public int used_screen_width; 134 /** 135 * the physical screen heigth 136 */ 137 public int used_screen_height; 138 /** 139 * the actual MainFrame width 140 */ 141 public int world_x1,world_y1,world_x2,world_y2; 142 143 /** 144 * the actual MainFrame width 145 */ 146 public int act_x1,act_y1,act_x2,act_y2; 147 148 149 /** 150 * flag to toggle user coords of mouse position feedback 151 */ 152 public boolean displaycoords; 153 154 /** 155 * flag to toggle drawing of orientation markers 156 */ 157 public boolean draw_orientationmarkers; 158 159 /** 160 * flag to indicate if boundaries are painted 161 */ 162 public boolean draw_boundary; 163 /** 164 * flag to indicate if boundary numbers are painted 165 */ 166 public boolean number_boundary; 167 /** 168 * flag to indicate if nodes are painted 169 */ 170 public boolean draw_node; 171 /** 172 * flag to indicate if node numbers are painted 173 */ 174 public boolean number_node; 175 /** 176 * flag to indicate if edges are painted 177 */ 178 public boolean draw_edge; 179 /** 180 * flag to indicate if edge numbers are painted 181 */ 182 public boolean number_edge; 183 /** 184 * flag to indicate if elements are painted 185 */ 186 public boolean draw_element; 187 /** 188 * flag to indicate if element numbers are painted 189 */ 190 public boolean number_element; 191 /** 192 * flag to indicate if elements are crossed 193 */ 194 public boolean cross_element; 195 /** 196 * flag to indicate if elements are filled 197 */ 198 public boolean fill_element; 199 /** 200 * flag to indicate if the grid is painted 201 */ 202 public boolean draw_grid; 203 /** 204 * flag to indicate if the perimeter is painted 205 */ 206 public boolean draw_perimeter; 207 /** 208 * flag to indicate if rectangular elements are highlighted 209 */ 210 public boolean highlight_rect; 211 212 213 214 215 216 /** 217 * color nodes are painted with 218 */ 219 public Color color_node; 220 /** 221 * base color edges are painted with 222 */ 223 public Color color_edgebase; 224 /** 225 * color edges are painted with 226 */ 227 public Color color_edge; 228 /** 229 * color elements are painted with 230 */ 231 public Color color_element; 232 /** 233 * boundarynumbers are painted with 234 */ 235 public Color color_boundarynumber; 236 /** 237 * color nodenumbers are painted with 238 */ 239 public Color color_nodenumber; 240 /** 241 * color edgenumbers are painted with 242 */ 243 public Color color_edgenumber; 244 /** 245 * color elementnumbers are painted with 246 */ 247 public Color color_elementnumber; 248 /** 249 * highlight color for selections 250 */ 251 public Color color_selection; 252 /** 253 * highlight color for rectangular status 254 */ 255 public Color color_rect; 256 /** 257 * color of the grid 258 */ 259 public Color color_grid; 260 /** 261 * color of the background 262 */ 263 public Color color_background; 264 /** 265 * color of the lasso 266 */ 267 public Color color_lasso; 268 269 /** 270 * all fillxx colors in one palette 271 */ 272 public Color[] parallel_palette; 273 274 /** 275 * the palette for boundary colors 276 */ 277 public Color[] boundary_palette; 278 279 /** 280 * font used to display numbering 281 */ 282 public Font font_numbering; 283 284 /** 285 * click tolerance (i.e. the distance added in all directions 286 * to the click point so that all objects inside this rectangle 287 * count as clicked on) 288 */ 289 public int tolerance; 290 291 292 293 } 294