@Override
  public void onPaint(Graphics2D graphics2D) {
    this.runtimeMillis = System.currentTimeMillis() - this.startTimeMillis;
    graphics2D.setColor(new Color(0, 0, 100, 120));
    graphics2D.fillRect(25, 240, 350, 82);

    graphics2D.setColor(Color.GREEN);
    graphics2D.fillRect(25, 240, 3 * this.expTracker.getPercentageToNextLevel(Skill.HERBLORE), 9);

    graphics2D.setColor(Color.WHITE);
    graphics2D.drawRect(25, 240, 350, 9);
    graphics2D.drawRect(25, 240, 350, 82);

    int cleanedPerHour =
        (int)
            (3600000.0
                / (double) (System.currentTimeMillis() - this.startTimeMillis)
                * (double) this.herbsCleaned);
    String profitsPerHour =
        String.valueOf(cleanedPerHour * this.profitPerClean)
            .replaceAll("(\\d)(?=(\\d{3})+$)", "$1,");

    graphics2D.setFont(new Font("Monospaced", 0, 12));
    graphics2D.drawString(
        "Herbs cleaned: " + this.herbsCleaned + " | (" + cleanedPerHour + ")", 28, 260);
    graphics2D.drawString("Current State: " + this.textualState, 28, 270);
    graphics2D.drawString("Time running: " + Core.formatElapsedTime(this.runtimeMillis), 28, 280);
    graphics2D.drawString(
        "XP Gained: "
            + this.expTracker.getExperienceGained(Skill.HERBLORE)
            + (" | (" + this.expTracker.getLevelsGained(Skill.HERBLORE) + ")"),
        28,
        290);
    graphics2D.drawString(
        "XP/hr: "
            + this.expTracker.gainedPerHour(Skill.HERBLORE)
            + " | Profit/hr: "
            + profitsPerHour,
        28,
        300);
    graphics2D.drawString(
        "Time till next level: "
            + Core.formatElapsedTime(this.expTracker.timeUntilNextLevel(Skill.HERBLORE)),
        28,
        310);

    graphics2D.drawLine(
        (int) this.getMouse().getPosition().getX(),
        (int) this.getMouse().getPosition().getY() + 10,
        (int) this.getMouse().getPosition().getX(),
        (int) this.getMouse().getPosition().getY() - 10);
    graphics2D.drawLine(
        (int) this.getMouse().getPosition().getX() + 10,
        (int) this.getMouse().getPosition().getY(),
        (int) this.getMouse().getPosition().getX() - 10,
        (int) this.getMouse().getPosition().getY());

    graphics2D.setColor(Color.RED);
    graphics2D.drawString("by Chicken Wing      v1.0", 70, 320);
  }
예제 #2
0
 public void toggleShowMeasurements() {
   if (showMeasurements.isSelected()) {
     measurements.setStructures(currentNucId, currentStructureIdx);
     measurements.setObjects(list.getSelectedValues());
     this.container.add(measurements);
   } else this.container.remove(measurements);
   core.refreshDisplay();
 }
예제 #3
0
 public void hide(boolean refresh) {
   container.remove(layout);
   if (showMeasurements.isSelected()) {
     container.remove(measurements);
     showMeasurements.setSelected(false);
   }
   if (refresh) core.refreshDisplay();
 }
예제 #4
0
파일: KeyTest.java 프로젝트: Gogoro/Undef
  // init also call init from superclass
  public void init() {
    super.init();

    Window w = s.getFullScreenWindow();
    w.setFocusTraversalKeysEnabled(false); // just be a tab button, not just jump to next form
    w.addKeyListener(this);

    mess = "Press escape to exit";
  }
예제 #5
0
 private void setSortKeys() {
   if (currentChannels != null && currentChannels.length == 1) {
     MeasurementKey mkey =
         new MeasurementKey(new int[] {currentChannels[0].getIdx()}, MeasurementObject.Number);
     System.out.println("Query:" + mkey.toString());
     ((ObjectManagerLayout) layout).setKeys(Core.getExperiment().getKeys().get(mkey));
   } else {
     ((ObjectManagerLayout) layout).unableSortKeys();
   }
 }
  public void templateMatching() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    int match_method = 5;
    int max_Trackbar = 5;
    Mat data = Highgui.imread("images/training_data/1" + "/data (" + 1 + ").jpg");
    Mat temp = Highgui.imread("images/template.jpg");
    Mat img = data.clone();

    int result_cols = img.cols() - temp.cols() + 1;
    int result_rows = img.rows() - temp.rows() + 1;
    Mat result = new Mat(result_rows, result_cols, CvType.CV_32FC1);

    Imgproc.matchTemplate(img, temp, result, match_method);
    Core.normalize(result, result, 0, 1, Core.NORM_MINMAX, -1, new Mat());

    double minVal;
    double maxVal;
    Point minLoc;
    Point maxLoc;
    Point matchLoc;
    // minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );
    Core.MinMaxLocResult res = Core.minMaxLoc(result);

    if (match_method == Imgproc.TM_SQDIFF || match_method == Imgproc.TM_SQDIFF_NORMED) {
      matchLoc = res.minLoc;
    } else {
      matchLoc = res.maxLoc;
    }

    // / Show me what you got
    Core.rectangle(
        img,
        matchLoc,
        new Point(matchLoc.x + temp.cols(), matchLoc.y + temp.rows()),
        new Scalar(0, 255, 0));

    // Save the visualized detection.
    Highgui.imwrite("images/samp.jpg", img);
  }
  public static Mat getCCH(Mat image) {
    ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>();
    Mat hierarchy = new Mat();
    Imgproc.findContours(
        image, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);

    Mat chainHistogram = Mat.zeros(1, 8, CvType.CV_32F);
    int n = 0;
    MatOfPoint2f approxCurve = new MatOfPoint2f();
    for (MatOfPoint contour : contours) {

      // get the freeman chain code from the contours
      int rows = contour.rows();
      // System.out.println("\nrows"+rows+"\n"+contour.dump());
      int direction = 7;
      Mat prevPoint = contours.get(0).row(0);
      n += rows - 1;
      for (int i = 1; i < rows; i++) {
        // get the current point
        double x1 = contour.get(i - 1, 0)[1];
        double y1 = contour.get(i - 1, 0)[0];

        // get the second point
        double x2 = contour.get(i, 0)[1];
        double y2 = contour.get(i, 0)[0];

        if (x2 == x1 && y2 == y1 + 1) direction = 0;
        else if (x2 == x1 - 1 && y2 == y1 + 1) direction = 1;
        else if (x2 == x1 - 1 && y2 == y1) direction = 2;
        else if (x2 == x1 - 1 && y2 == y1 - 1) direction = 3;
        else if (x2 == x1 && y2 == y1 - 1) direction = 4;
        else if (x2 == x1 + 1 && y2 == y1 - 1) direction = 5;
        else if (x2 == x1 + 1 && y2 == y1) direction = 6;
        else if (x2 == x1 + 1 && y2 == y1 + 1) direction = 7;
        else System.out.print("err");
        double counter = chainHistogram.get(0, direction)[0];
        chainHistogram.put(0, direction, ++counter);
        System.out.print(direction);
      }
    }
    System.out.println("\n" + chainHistogram.dump());
    Scalar alpha = new Scalar(n); // the factor
    Core.divide(chainHistogram, alpha, chainHistogram);
    System.out.println("\nrows=" + n + " " + chainHistogram.dump());
    return chainHistogram;
  }
  @Override
  public int onLoop() throws InterruptedException {
    State state = null;
    for (State cur : this.states) {
      if (cur.shouldExecute()) {
        state = cur;
        break;
      }
    }

    if (state == null) {
      return 100;
    }

    this.textualState = state.getTextualState();
    state.onLoop();
    return Core.random(200, 400);
  }
예제 #9
0
 private void sort(String key, Object3DGui[] objectsGui, int structureIdx) {
   Object3DGui.setAscendingOrger(((ObjectManagerLayout) layout).getAscendingOrder());
   HashMap<Integer, BasicDBObject> objects =
       Core.getExperiment().getConnector().getObjects(currentNucId, structureIdx);
   boolean notFound = false;
   for (Object3DGui o : objectsGui) {
     BasicDBObject dbo = objects.get(o.getLabel());
     if (dbo != null) {
       if (dbo.containsField(key)) o.setValue(dbo.getDouble(key));
       else {
         o.setValue(-1);
         notFound = true;
       }
     }
   }
   if (notFound)
     ij.IJ.log("Warning measurement: " + key + " not found for one or several objects");
   Arrays.sort(objectsGui);
 }
예제 #10
0
파일: Look.java 프로젝트: Gogoro/Undef
  // init
  public void init() {
    super.init();
    mouse = new Point();
    center = new Point();
    image = new Point();
    centering = false;

    try {
      robot = new Robot();
      recenterMouse();
      mouse.x = center.x;
      mouse.y = center.y;
    } catch (Exception e) {
      System.out.println("Exception 1");
    }

    Window w = s.getFullScreenWindow();
    w.addMouseMotionListener(this);
    w.addKeyListener(this);
    bg = new ImageIcon("/Users/Ole/Desktop/undefined/images/bg.jpg").getImage();
  }
예제 #11
0
 public void show(boolean refresh) {
   container.add(layout);
   if (refresh) core.refreshDisplay();
 }