Exemple #1
0
  public Thing handlecmd(Interp ip, Object target, String subcmd, Thing[] argv, int startat)
      throws HeclException {
    HeclCanvas c = (HeclCanvas) target;

    if (subcmd.equals(WidgetInfo.NREPAINT)) {
      c.repaint();
      return null;
    }
    if (subcmd.equals("servicerepaints")) {
      c.serviceRepaints();
      return null;
    }
    if (subcmd.equals("flush")) {
      if (argv.length == startat) {
        // Simple case, flush whole buffer
        c.flushGraphics();
        return null;
      }

      // x, y, w, h
      if (startat + 4 != argv.length)
        throw HeclException.createWrongNumArgsException(argv, startat, "x y w h");

      c.flushGraphics(
          IntThing.get(argv[startat]),
          IntThing.get(argv[startat + 1]),
          IntThing.get(argv[startat + 2]),
          IntThing.get(argv[startat + 3]));
      return null;
    }
    if (subcmd.equals("graphics")) return ObjectThing.create(c.getDrawable());
    return super.handlecmd(ip, target, subcmd, argv, startat);
  }
Exemple #2
0
 public Thing cmdCode(Interp interp, Thing[] argv) throws HeclException {
   if (argv.length == 2) {
     Vector v = ListThing.get(argv[1]);
     int[] colors = new int[v.size()];
     for (int i = 0; i < v.size(); i++) {
       colors[i] = Integer.parseInt(((Thing) v.elementAt(i)).toString(), 16);
     }
     Skin skin = new Skin(colors);
     return ObjectThing.create(skin);
   } else if (argv.length == 3) {
     Vector v = ListThing.get(argv[1]);
     int newSize = IntThing.get(argv[2]);
     Image[] img = new Image[9];
     for (int i = 0; i < v.size(); i++) {
       img[i] = (Image) ObjectThing.get((Thing) v.elementAt(i));
     }
     return ObjectThing.create(new Skin(img, newSize));
   } else {
     throw HeclException.createWrongNumArgsException(
         argv, 2, "mwt.skin expect either <color[]> or <image[], size>");
   }
 }