Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

66
LINES

< > BotCompany Repo | #1006612 // Screenshot Distinguisher [v1, working on function]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 3874K of libraries. Click here for Pure Java version (11159L/79K/271K).

!7

concept UserScreenshot { // see #1006593, don't change this here
  S text;
  new Ref<PNGFile> pngFile;
}

concept Task {
  new Ref<UserScreenshot> s1;
  new Ref<UserScreenshot> s2;
  Pt p1, p2;
}

concept Forwarded {
  new Ref<Task> task;
  S programID;
  long conceptID;
}

p-substance {
  db();
  final Concepts in = new Concepts(#1006593).load();
  final JComboBox cb1 = jcomboboxFromConcepts(in, UserScreenshot, "text");
  final JComboBox cb2 = jcomboboxFromConcepts(in, UserScreenshot, "text");
  JComponent form = makeForm("", "Please choose 2 screenshots to compare.",
    "Screenshot 1", cb1,
    "Screenshot 2", cb2, r {
    UserScreenshot s1 = conceptFromComboBox(cb1, in, UserScreenshot);
    UserScreenshot s2 = conceptFromComboBox(cb2, in, UserScreenshot);
    doIt(s1, s2);
  });
  print("Buttons: " + childrenOfType(form, JButton.class));
  renameSubmitButton(form, "Yo!");
  final JTable tasks = makeConceptsTable(Task);
  JTable forwarded = makeConceptsTable(Forwarded);
  JPanel tasksPanel = centerAndSouth(tasks,
    jRightAligned(tableDependButton(tasks, jbutton("Forward",
      r { forwardTask(selectedConcept(tasks, Task)) }))));
  showFrame(jtabs("New Task", form, "Tasks", tasksPanel,
    "Forwarded", forwarded));
}

static void doIt(UserScreenshot a, UserScreenshot b) {
  Pt p1 = parseFirstPoint(a.text);
  Pt p2 = parseFirstPoint(b.text);
  if (p1 == null || p2 == null) {
    messageBox("Not sure what to do");
    ret;
  }
  
  Task task = cnew(Task, s1 := copyScreenshot(a), s2 := copyScreenshot(b), +p1, +p2);
  
  messageBox("Made task " + task.id + ". " + p1 + " vs " + p2);
}

static UserScreenshot copyScreenshot(UserScreenshot s) {
  PNGFile pngFile = copyPNGFile(s.pngFile!);
  ret cnew(UserScreenshot, text := s.text, +pngFile);
}

svoid forwardTask(Task task) {
  Forwarded fw = findBackRef(Forwarded, task);
  if (fw != null) { messageBox("Already forwarded!"); ret; }
  
  // TODO: Forward to image distinguisher
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006612
Snippet name: Screenshot Distinguisher [v1, working on function]
Eternal ID of this version: #1006612/2
Text MD5: e8f664b6aca86be2583065bcec179d63
Transpilation MD5: 9add50de2d6b94d9a3092c23f0f9a2da
Author: stefan
Category: javax / gui
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-09-15 19:45:01
Source code size: 2026 bytes / 66 lines
Pitched / IR pitched: No / No
Views / Downloads: 607 / 974
Version history: 1 change(s)
Referenced in: #1006625 - A. I.