示例#1
0
  /**
   * Add a canvas to GUI.
   *
   * @param newCanvas new Canvas to be added to the screen
   */
  public static void setCanvas(Canvas newCanvas) {
    if (canvas != null) {
      TouchClient.remove(canvas);
    }
    canvas = newCanvas;

    TouchClient.add(canvas);
  }
示例#2
0
  /** Clear the entire workspace by removing all zones and then loading the GUI again. */
  public static void clearWorkspace() {
    LOGGER.info("Clearing workspace");

    brushes.clear();
    paints.clear();

    // remove all zones
    Zone[] zones = TouchClient.getZones();
    for (int i = 0; i < zones.length; i++) {
      Zone z = zones[i];
      TouchClient.remove(z);
    }

    loadGUI();
  }
示例#3
0
  /**
   * Remove an item from the screen.
   *
   * @param item the item to remove
   */
  public static void removeItem(MoveableItem item) {
    if (item instanceof Paint) paints.remove(item);
    else if (!(item instanceof Eraser)) brushes.remove(item);

    TouchClient.remove(item);
    notifyListeners(item, ITEM_REMOVED);
  }
示例#4
0
  /**
   * Add an item to the screen.
   *
   * @param item the item to add
   */
  public static void addItem(MoveableItem item) {
    if (item instanceof Paint) paints.add((Paint) item);
    else if (item instanceof Brush && !(item instanceof Eraser)) brushes.add((Brush) item);

    TouchClient.add(item);
    notifyListeners(item, ITEM_ADDED);
  }
示例#5
0
  /**
   * Draw loop. Only background and debug information is drawn here, everything else is drawn by
   * TouchClient and TTSManager.
   */
  @Override
  public void draw() {
    background(backgroundColour);
    if (backgroundImage != null && backgroundImage.length() > 0 && bg != null) {
      imageMode(CORNER);
      image(bg, 0, 0, displayWidth, displayHeight);
    }

    if (Settings.showDebugInfo) {
      String s1 = Math.round(frameRate) + "fps, # of zones: " + TouchClient.getZones().length;
      String s2 = "brushes: " + brushes.size() + ", paints: " + paints.size();

      String s3 = "state: ";
      switch (state) {
        case RUNNING:
          s3 += "Running";
          break;
        case IDLE:
          s3 += "idle";
          break;
        case PAUSED:
          s3 += "paused";
          break;
      }

      text(s1, 10, 10);
      text(s2, 10, 20);
      text(s3, 10, 30);

      text(s1, 10, height - 30);
      text(s2, 10, height - 20);
      text(s3, 10, height - 10);

      text(s1, width - 150, 10);
      text(s2, width - 150, 20);
      text(s3, width - 150, 30);

      text(s1, width - 150, height - 30);
      text(s2, width - 150, height - 20);
      text(s3, width - 150, height - 10);
    }

    if (getInactiveTime() >= Settings.resetPromptDelay && !ResetDialog.isOnScreen())
      TouchClient.add(new ResetDialog());
  }
示例#6
0
  /** Reset the workspace to defaults: clear the workspace and then load the default layout. */
  public static void resetToDefaults() {
    LOGGER.info("Reset workspace and load defaults.");
    clearWorkspace();
    loadLayout(Settings.dataFolder + Settings.defaultLayoutFile);
    // Put drawers on top
    if (leftDrawer != null) TouchClient.putZoneOnTop(leftDrawer);
    if (rightDrawer != null) TouchClient.putZoneOnTop(rightDrawer);
    if (topDrawer != null) {
      TouchClient.putZoneOnTop(topDrawer);
    }

    setSelectedBrush(getAllBrushes().get(0));
    setSelectedPaint(getAllPaints().get(0));
    setActionPerformed();

    PromptManager.reset();
    idleApplication();
  }
示例#7
0
  /**
   * Load a workspace layout from the provided file.
   *
   * @param filename valid file that contains a workspace layout
   */
  public static void loadLayout(String filename) {
    LOGGER.info("Loading layout from file: " + filename);

    try {
      SimpleMarshaller.unmarshallLayout(new File(filename));
    } catch (Exception e) {
      LOGGER.error("Failed to load layout. " + e.getLocalizedMessage());
    }

    // Put drawers on top
    if (leftDrawer != null) TouchClient.putZoneOnTop(leftDrawer);
    if (rightDrawer != null) TouchClient.putZoneOnTop(rightDrawer);
    if (topDrawer != null) {
      TouchClient.putZoneOnTop(topDrawer);
    }

    setSelectedBrush(getAllBrushes().get(0));
    setSelectedPaint(getAllPaints().get(0));
  }
示例#8
0
  /**
   * Load a save file, including the layout and painting.
   *
   * @param save SaveFile object to load data from
   */
  public static void loadSave(SaveFile save) {
    LOGGER.info("Loading a save file " + save.filename);

    clearWorkspace();
    loadLayout(save.layoutPath);
    canvas.clearAndLoad(save.drawingPath);

    // Put drawers on top
    if (leftDrawer != null) TouchClient.putZoneOnTop(leftDrawer);
    if (rightDrawer != null) TouchClient.putZoneOnTop(rightDrawer);
    if (topDrawer != null) {
      TouchClient.putZoneOnTop(topDrawer);
    }

    setSelectedBrush(getAllBrushes().get(0));
    setSelectedPaint(getAllPaints().get(0));

    PromptManager.reset();
  }
示例#9
0
 /**
  * Set the provided drawer to a certain position.
  *
  * @param newDrawer new drawer to add to the GUI
  * @param drawerId position of the new drawer, can be on of the following: {@link #TOP_DRAWER},
  *     {@link #LEFT_DRAWER} or {@link #RIGHT_DRAWER}
  */
 public static void setDrawer(Drawer newDrawer, int drawerId) {
   switch (drawerId) {
     case TOP_DRAWER:
       if (topDrawer != null) TouchClient.remove(topDrawer);
       topDrawer = newDrawer;
       break;
     case LEFT_DRAWER:
       if (leftDrawer != null) TouchClient.remove(leftDrawer);
       leftDrawer = newDrawer;
       break;
     case RIGHT_DRAWER:
       if (rightDrawer != null) TouchClient.remove(rightDrawer);
       rightDrawer = newDrawer;
       break;
     default:
       return;
   }
   TouchClient.add(newDrawer);
 }
示例#10
0
 /**
  * Start the colouring mode: show a file browser set to the colouring folder.
  *
  * @see FileBrowserDialog
  */
 public static void colouringMode() {
   FileBrowserDialog imageFileBrowser =
       new FileBrowserDialog(
           uiStrings.getString("ImageFileBrowserHeaderText"),
           Settings.colouringFolder,
           ".png",
           Settings.fileBrowserColumns,
           Settings.fileBrowserRows);
   imageFileBrowser.addListener(instance);
   TouchClient.add(imageFileBrowser);
 }
示例#11
0
 /**
  * Show a file browser set to the save folder.
  *
  * @see FileBrowserDialog
  */
 public static void load() {
   FileBrowserDialog saveFileBrowser =
       new FileBrowserDialog(
           uiStrings.getString("SaveFileBrowserHeaderText"),
           Settings.saveFolder,
           SaveFile.SAVE_FILE_EXT,
           Settings.fileBrowserColumns,
           Settings.fileBrowserRows);
   saveFileBrowser.addListener(instance);
   TouchClient.add(saveFileBrowser);
 }
示例#12
0
  /**
   * Perform the initial setup: set size, initialise TouchClient, load GUI and layout, initialise
   * PromptManager and TTSManager.
   */
  @Override
  public void setup() {
    size(Settings.width, Settings.height, P3D);
    frameRate(Settings.targetFPS);
    LOGGER.info(
        "Application started with parameters: width="
            + Settings.width
            + ", height="
            + Settings.height
            + ", fps="
            + Settings.targetFPS);

    instance = this;

    font = createDefaultFont(20);

    // Figure out the touch source
    TouchSource source;
    String sourceString = Settings.touchSourse.toUpperCase();
    if ("TUIO_DEVICE".equals(sourceString)) source = TouchSource.TUIO_DEVICE;
    else if ("MOUSE".equals(sourceString)) source = TouchSource.MOUSE;
    else if ("WM_TOUCH".equals(sourceString)) source = TouchSource.WM_TOUCH;
    else if ("ANDROID".equals(sourceString)) source = TouchSource.ANDROID;
    else if ("SMART".equals(sourceString)) source = TouchSource.SMART;
    else source = TouchSource.MOUSE;

    TouchClient.init(this, source);
    TouchClient.setWarnUnimplemented(false);
    // TouchClient.setTouchDraw(TouchDraw.SMOOTH, 0);
    TouchClient.setDrawTouchPoints(TouchDraw.SMOOTH, 0);

    loadGUI();
    loadLayout(Settings.dataFolder + Settings.defaultLayoutFile);

    PromptManager.init(this);
    TTSManager.init();
    setActionPerformed();
    state = ApplicationState.IDLE;
    SplashScreen.remove();
  }
示例#13
0
  /** Take a screenshot and save it using the current time as the file name. */
  public static void takeScreenshot() {
    Date now = new Date();
    SimpleDateFormat sdt = new SimpleDateFormat("yyyy.MM.dd-HH.mm.ss.SSS");

    String filename = "data\\screenshot_" + sdt.format(now) + ".png";

    PGraphics pg;
    pg = instance.createGraphics(instance.width, instance.height, P3D);
    pg.beginDraw();
    instance.draw();
    TouchClient.draw();
    PromptManager.draw();
    pg.endDraw();

    if (pg.save(filename)) LOGGER.info("Screenshot saved: " + filename);
    else LOGGER.error("Failed to save screenshot.");
  }
示例#14
0
 /**
  * Show the save dialog.
  *
  * @see SaveDialog
  */
 public static void save() {
   TouchClient.add(new SaveDialog());
 }
示例#15
0
 /** @return the array of all Zone objects currently registered with the TouchClient. */
 public static Zone[] getChildren() {
   return TouchClient.getZones();
 }