Beispiel #1
0
 public void setComponentValueFor(TColor col, float val) {
   switch (component) {
     case 0:
       col.setRed(val);
       break;
     case 1:
       col.setGreen(val);
       break;
     case 2:
     default:
       col.setBlue(val);
   }
 }
Beispiel #2
0
 /**
  * A color is a set of 3 values separated by spaces
  *
  * @param property the property key associated to the color
  * @param defaultValue the color to return if the property key is not associated to a color
  * @return the color associated to the property key, or <code>defaultValue</code> if there is no
  *     color associated to the property
  */
 public Color getColor(String property, Color defaultValue) {
   // TODO enhance error handling
   Color color = defaultValue;
   String colorValue = getProperty(property);
   if (colorValue == null) {
     displayError("Property " + property + " not found"); // $NON-NLS-1$ //$NON-NLS-2$
   } else {
     color = null;
     try {
       color = TColor.translateColor(colorValue, null);
     } catch (Exception e) {
     }
     if (color == null) {
       try {
         StringTokenizer tokenizer = new StringTokenizer(colorValue);
         int red = Integer.parseInt(tokenizer.nextToken());
         int green = Integer.parseInt(tokenizer.nextToken());
         int blue = Integer.parseInt(tokenizer.nextToken());
         color = new Color(red, green, blue);
       } catch (Exception ex) {
         displayError("Failed loading color " + property); // $NON-NLS-1$
       }
     }
   }
   return color;
 }