Пример #1
0
  public void cset(Interp ip, Object target, String optname, Thing optval) throws HeclException {
    HeclCanvas c = (HeclCanvas) target;

    if (optname.equals("-fullscreen")) {
      c.setFullScreenMode(HeclUtils.thing2bool(optval));
      return;
    }
    if (optname.equals("-autoflush")) {
      c.setAutoFlushMode(HeclUtils.thing2bool(optval));
      return;
    }
    if (optname.equals("-cmdbg")) {
      c.setCmdBgColor(new Color(WidgetInfo.toColor(optval)));
      return;
    }
    if (optname.equals("-cmdfg")) {
      c.setCmdFgColor(new Color(WidgetInfo.toColor(optval)));
      return;
    }
    if (optname.equals("-eventhandler")) {
      EventHandler h = null;
      if (optval.toString().length() > 0) h = new WidgetListener(ip, optval, c);
      c.setEventHandler(h);
      return;
    }
    super.cset(ip, target, optname, optval);
  }
Пример #2
0
 public static int toColor(Thing t) throws HeclException {
   String s = t.toString();
   try {
     return s2int(s.toLowerCase(), colornames, colorvals, "");
   } catch (Exception e) {
   }
   return Integer.parseInt(s, 16);
 }
Пример #3
0
 public static Object asWidget(Thing thing, Class clazz, String clazzname, boolean allownull)
     throws HeclException {
   if (allownull && thing.toString().length() == 0) return null;
   RealThing rt = thing.getVal();
   if (rt instanceof ObjectThing) {
     Object x = ((ObjectThing) rt).get();
     if (allownull && x == null) return null;
     if (clazz.isAssignableFrom(x.getClass())) return x;
   }
   if (clazzname != null) {
     throw HeclException.createInvalidParameter(
         thing, "parameter", clazzname + " widget required.");
   }
   return null;
 }
Пример #4
0
 public static AlertType toAlertType(Thing t) throws HeclException {
   String s = t.toString().toLowerCase();
   int l = alerttypenames.length;
   for (int i = 0; i < l; ++i) if (s.equals(alerttypenames[i])) return alerttypevals[i];
   throw new HeclException("Invalid alert type '" + s + "'!");
 }
Пример #5
0
 public static int toGaugeMax(Thing t) throws HeclException {
   if (Character.isDigit(t.toString().charAt(0))) {
     return HeclUtils.thing2int(t, true, 0);
   }
   return t2int(t, gaugemaxnames, gaugemaxvals, "gauge initval");
 }
Пример #6
0
 protected static int t2int(Thing t, String nametab[], int valtab[], String emsg)
     throws HeclException {
   return s2int(t.toString().toLowerCase(), nametab, valtab, emsg);
 }