class ImageAnnotation

Public Instance Methods

add_annotation_js_string() click to toggle source
# File app/models/image_annotation.rb, line 23
def add_annotation_js_string
  "add_to_annotation_grid('#{self.extract_coords.to_json()}')"
end
extract_coords() click to toggle source

Return a hash containing the coordinates of the rectangle containing the annotation.

Returns:

A hash with keys id, x1, y1, x2, y2 where (x1, y1) is the top left corner and (x2, y2) is the bottom right corner of the rectangle and id is the annotation_text_id instance.

# File app/models/image_annotation.rb, line 17
def extract_coords
  horiz_range = {:start => [x1, x2].min, :end => [x1, x2].max}
  vert_range = {:start => [y1, y2].min, :end => [y1, y2].max}
  {:id => annotation_text_id, :x_range => horiz_range, :y_range => vert_range}
end
remove_annotation_js_string() click to toggle source
# File app/models/image_annotation.rb, line 27
def remove_annotation_js_string
  "remove_annotation(null, null, #{self.annotation_text.id});"
end