Examples of AnnotatedImage


Examples of org.openmrs.module.drawing.AnnotatedImage

   * @see org.openmrs.obs.handler.ImageHandler#saveObs(org.openmrs.Obs)
   */
  @Override
  public Obs saveObs(Obs obs) {
    ComplexData c = obs.getComplexData();
    AnnotatedImage ai = (AnnotatedImage) c.getData();
    obs.setComplexData(new ComplexData(c.getTitle(), ai.getImage()));
    Obs o = super.saveObs(obs);
    for (ImageAnnotation annotation : ai.getAnnotations())
      saveAnnotation(o, annotation, annotation.getStatus() == Status.DELETE);
    log.info("drawing:saving complexObs:" + o);
   
    return o;
  }
View Full Code Here

Examples of org.openmrs.module.drawing.AnnotatedImage

      img = ImageIO.read(imageFile);
    }
    catch (IOException e) {
      log.error("Trying to read file: " + imageFile.getAbsolutePath(), e);
    }
    AnnotatedImage aimage = loadMetadata(obs, new AnnotatedImage(img));
   
    String url = "/" + WebConstants.WEBAPP_NAME + "/module/drawing/manage.form?obsId=" + obs.getId();
    if (view == WebConstants.HYPERLINK_VIEW) {
      obs.setComplexData(new ComplexData(imageFile.getName(), url));
    } else if (view == WebConstants.HTML_VIEW) {
View Full Code Here

Examples of org.openmrs.module.drawing.AnnotatedImage

    String encodedImage = submission.getParameter("encodedImage" + id);
    if (!StringUtils.isNotBlank(encodedImage) && encodedImage.contains(","))
      throw new RuntimeException("Image not encoded in proper format");
   
    try {
      AnnotatedImage ai = new AnnotatedImage(DrawingUtil.base64ToImage(encodedImage));
      ai.setAnnotations(DrawingUtil.getAnnotations(submission, id));
      if (session.getContext().getMode() == Mode.EDIT && existingObs != null)
        session.getSubmissionActions().modifyObs(existingObs, questionConcept,
            new ComplexData(existingObs.getComplexData().getTitle(), ai), null, null);
      else
        session.getSubmissionActions().createObs(questionConcept, new ComplexData("drawingObs.png", ai), null, null);
View Full Code Here

Examples of org.openmrs.module.drawing.AnnotatedImage

  public String generateHtml(FormEntryContext context) {
    StringBuilder sb = new StringBuilder();
   
    if (context.getMode().equals(Mode.VIEW) && existingObs != null) {
      Obs complexObs = Context.getObsService().getComplexObs(existingObs.getId(), "");
      AnnotatedImage ai = (AnnotatedImage) existingObs.getComplexData().getData();
      String encodedImage = null;
      try {
        encodedImage = DrawingUtil.imageToBase64(ai.getImage());
      }
      catch (IOException e) {
        log.error("unable to encode image to Base64 format", e);
      }
      sb.append("<link rel='stylesheet' media='screen' type='text/css' href='/" + WebConstants.WEBAPP_NAME
              + "/moduleResources/drawing/drawingHtmlForm.css' />");
      sb.append("<script type='text/javascript'>var ancount"
              + id
              + "=0;    var redDot ='/openmrstru/moduleResources/drawing/red-dot.png';var close = '/openmrstru/moduleResources/drawing/close.gif';function createMarker"
              + id
              + "(identification, x, y, text, stat) {var annotationId = \"marker"
              + id
              + "\" + ancount"
              + id
              + ";ancount"
              + id
              + "++;var annDivData = \"<img src='\" + close + \"' style='float:right' onClick='$j(this).parent().parent().fadeOut(500)'/><span style='background-color:white'>\" + text + \"</span></br>\";var v = '<div class=\"container\"><div style=\"position:absolute;z-index:5;display:none\"><div id=\"' + annotationId + '_data\" class=\"divContainerDown\">' + annDivData + '</div><div class=\"calloutDown\"><div class=\"calloutDown2\"></div></div></div>';$j('#canvasDiv"
              + id
              + "').append(v + '<img id=\"' + annotationId + '\" src=\"' + redDot + '\" style=\"top:' + y + 'px;left:' + x + 'px;position:absolute;z-index:4\"/></div>');$j('#' + annotationId).click(function(event) {$j('#' + annotationId + '_data').parent().css('top', event.pageY-$j('#canvasDiv"
              + id
              + "').offset().top - $j('#' + annotationId + '_data').parent().height());$j('#' + annotationId + '_data').parent().css('left', event.pageX-$j('#canvasDiv"
              + id
              + "').offset().left - $j('#' + annotationId + '_data').parent().width() / 8 - 5);$j('#' + annotationId + '_data').parent().show();});}");
     
      sb.append("$j(document).ready(function(){");
      for (ImageAnnotation annotation : ai.getAnnotations())
        sb.append("createMarker" + id + "(" + annotation.getId() + "," + annotation.getLocation().getX() + ","
                + annotation.getLocation().getY() + ",'" + annotation.getText() + "','" + annotation.getStatus()
                + "');");
      sb.append("})</script>");
      sb.append("<h4>" + complexObs.getConcept().getName(Context.getLocale()).getName() + "</h4>");
      sb.append("<div id='canvasDiv" + id + "' style='position:relative'><img  src='" + encodedImage + "'></div>");
     
      //sb.append(complexData.getData());
    } else if (context.getMode() == Mode.EDIT || context.getMode() == Mode.ENTER) {
      sb.append("<link rel='stylesheet' type='text/css' href='/" + WebConstants.WEBAPP_NAME
              + "/moduleResources/drawing/paint.css' />");
      sb.append("<link rel='stylesheet' media='screen' type='text/css' href='/" + WebConstants.WEBAPP_NAME
              + "/moduleResources/drawing/colorpicker.css' />");
      sb.append("<script type='text/javascript' src='/" + WebConstants.WEBAPP_NAME
              + "/moduleResources/drawing/paint.js'></script>");
      sb.append("<script type='text/javascript' src='/" + WebConstants.WEBAPP_NAME
              + "/moduleResources/drawing/colorpicker.js'></script>");
      sb.append("<script type='text/javascript'>$j(document).ready(function(){var v" + id + "=new DrawingEditor('"
              + id + "');v" + id + ".prepareCanvas();");
     
      if (context.getMode() == Mode.EDIT && existingObs != null && existingObs.isComplex()
              && existingObs.getComplexData() != null) {
        AnnotatedImage ai = (AnnotatedImage) existingObs.getComplexData().getData();
       
        for (ImageAnnotation annotation : ai.getAnnotations())
          sb.append("v" + id + ".createMarker(" + annotation.getId() + "," + annotation.getLocation().getX() + ","
                  + annotation.getLocation().getY() + ",'" + annotation.getText() + "','" + annotation.getStatus()
                  + "');");
        String encodedImage = null;
        try {
          encodedImage = DrawingUtil.imageToBase64(ai.getImage());
        }
        catch (IOException e) {
          log.error("unable to encode image to Base64 format", e);
        }
        if (StringUtils.isNotEmpty(encodedImage))
View Full Code Here

Examples of org.openmrs.module.drawing.AnnotatedImage

      int obsId = Integer.parseInt(request.getParameter("obsId"));
      Obs obs = Context.getObsService().getComplexObs(obsId, "");
      if (obs == null || !obs.getConcept().isComplex()) {
        log.error("obs is not complex ");
      } else {
        AnnotatedImage ai = (AnnotatedImage) obs.getComplexData().getData();
        String encodedImage;
        try {
          encodedImage = DrawingUtil.imageToBase64(ai.getImage());
          model.addAttribute("encodedImage", encodedImage);
        }
        catch (IOException e) {
          log.error("Error generated", e);
        }
        model.addAttribute("annotations", ai.getAnnotations());
        model.addAttribute("obsId", obs.getId());
       
      }
    }
  }
View Full Code Here

Examples of org.openmrs.module.drawing.AnnotatedImage

   
    try {
      Date date = StringUtils.isBlank(dateString) ? new Date() : Context.getDateFormat().parse(dateString);
      Obs o = new Obs(patient, concept, date, null);
      o.setEncounter(encounter);
      AnnotatedImage ai = new AnnotatedImage(DrawingUtil.base64ToImage(encodedImage));
      ai.setAnnotations(DrawingUtil.getAnnotations(request, ""));
      o.setComplexData(new ComplexData("drawingObs.png", ai));
      Errors obsErrors = new BindException(o, "obs");
      ValidationUtils.invokeValidator(new ObsValidator(), o, obsErrors);
      if (!obsErrors.hasErrors()) {
        Context.getObsService().saveObs(o, "saving obs");
View Full Code Here

Examples of org.openmrs.module.drawing.AnnotatedImage

    Obs obs = Context.getObsService().getComplexObs(Integer.parseInt(obsId.trim()), "");
    if (obs == null) {
      log.error("obs cannot be null");
      request.getSession().setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "drawing.save.error");
    }
    AnnotatedImage ai = (AnnotatedImage) obs.getComplexData().getData();
    ai.setImage(DrawingUtil.base64ToImage(encodedImage));
    ai.setAnnotations(DrawingUtil.getAnnotations(request, ""));
    obs.setComplexData(new ComplexData(obs.getComplexData().getTitle(), ai));
    Context.getObsService().saveObs(obs, "saving obs");
   
    return "redirect:/module/drawing/manage.form?obsId=" + obs.getId();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.