Save a new point annotation from input
430551
function savePoint() {
  if (input.value.trim().length > 0) {
    let clientX = parseInt(input.style.left, 10);
    let clientY = parseInt(input.style.top, 10);
    let content = input.value.trim();
    let svg = findSVGAtPoint(clientX, clientY);
    if (!svg) {
      return;
    }

    let rect = svg.getBoundingClientRect();
    let { documentId, pageNumber } = getMetadata(svg);
    let annotation = Object.assign({
        type: 'point'
      }, scaleDown(svg, {
        x: clientX - rect.left,
        y: clientY - rect.top
      })
    );

    PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)
      .then((annotation) => {
        PDFJSAnnotate.getStoreAdapter().addComment(
          documentId,
          annotation.uuid,
          content
        );

        appendChild(svg, annotation);
      });
  }

  closeInput();
}
889101
def encode_annotation(annotation):
    """"""
    tree = etree.Element('annotation', {'id': annotation.id})
    encode_infons(tree, annotation.infons)
    for location in annotation.locations:
        tree.append(encode_location(location))
    etree.SubElement(tree, 'text').text = annotation.text
    return tree
825785
def add_point(self, name, value, **attrs):
        
        return Points(self.requester).create(self.id, name, value, **attrs)
1374347
function(event) {
        this.feature = event.feature;
        var loc = this.layer.map.getLonLatFromViewPortPx(event.pixel);
        this.considerSnapping(
            event.vertex, new OpenLayers.Geometry.Point(loc.lon, loc.lat)
        );
    }
407488
def _dump_multipoint(obj, big_endian, meta):
    
    coords = obj['coordinates']
    vertex = coords[0]
    num_dims = len(vertex)

    wkb_string, byte_fmt, byte_order = _header_bytefmt_byteorder(
        'MultiPoint', num_dims, big_endian, meta
    )

    point_type = _WKB[_INT_TO_DIM_LABEL.get(num_dims)]['Point']
    if big_endian:
        point_type = BIG_ENDIAN + point_type
    else:
        point_type = LITTLE_ENDIAN + point_type[::-1]

    wkb_string += struct.pack('%sl' % byte_order, len(coords))
    for vertex in coords:
        # POINT type strings
        wkb_string += point_type
        wkb_string += struct.pack(byte_fmt, *vertex)

    return wkb_string
584263
function onPointerMoveCaptured( tracker, event ) {
        var pointsList = tracker.getActivePointersListByType( getPointerType( event ) );
        if ( pointsList.getById( event.pointerId ) ) {
            handlePointerMove( tracker, event );
        }
        $.stopEvent( event );
    }
444774
def _annotate(ax, annotate, height, left, width):
    
    annotate_yrange_factor = 0.010
    xticks = np.array(left) + width / 2.0
    ymin, ymax = ax.get_ylim()
    yrange = ymax - ymin

    # Reset ymax and ymin so there's enough room to see the annotation of
    # the top-most
    if ymax > 0:
        ymax += yrange * 0.15
    if ymin < 0:
        ymin -= yrange * 0.15
    ax.set_ylim(ymin, ymax)
    yrange = ymax - ymin

    offset_ = yrange * annotate_yrange_factor
    if isinstance(annotate, collections.Iterable):
        annotations = map(str, annotate)
    else:
        annotations = ['%.3f' % h if type(h) is np.float_ else str(h)
                       for h in height]
    for x, h, annotation in zip(xticks, height, annotations):
        # Adjust the offset to account for negative bars
        offset = offset_ if h >= 0 else -1 * offset_
        verticalalignment = 'bottom' if h >= 0 else 'top'

        if len(str(annotation)) > 6:
            size = 7
        elif len(str(annotation)) > 5:
            size = 8
        else:
            size = 10
        # Finally, add the text to the axes
        ax.annotate(annotation, (x, h + offset),
                    verticalalignment=verticalalignment,
                    horizontalalignment='center',
                    size=size)
1044500
public void insertPointAfter( PolygonPoint a, PolygonPoint newPoint )
    {
        // Validate that 
        int index = _points.indexOf( a );
        if( index != -1 )
        {
            newPoint.setNext( a.getNext() );
            newPoint.setPrevious( a );
            a.getNext().setPrevious( newPoint );
            a.setNext( newPoint );
            _points.add( index+1, newPoint );
        }
        else
        {
            throw new RuntimeException( "Tried to insert a point into a Polygon after a point not belonging to the Polygon" );
        }
    }
1048543
function highlightDataPoints({values}) {
            let accumulator = 0;

            cleanDataPointHighlights();

            // ensure order stays constant
            let sortedValues = order.reduce((acc, current) => {
                return [...acc, values.find(({name}) => name === current)];
            },[]);

            sortedValues.forEach((d, index) => {
                let marker = verticalMarkerContainer
                    .append('g')
                    .classed('circle-container', true)
                        .append('circle')
                        .classed('data-point-highlighter', true)
                        .attr('cx', highlightCircleSize)
                        .attr('cy', 0)
                        .attr('r', highlightCircleRadius)
                        .style('stroke-width', highlightCircleStroke)
                        .style('stroke', categoryColorMap[d.name])
                        .style('cursor', 'pointer')
                        .on('click', function() {
                            addGlowFilter(this);
                            handleHighlightClick(this, d);
                        })
                        .on('mouseout', function() {
                            removeFilter(this);
                        });

                accumulator = accumulator + sortedValues[index][valueLabel];

                marker.attr('transform', `translate( ${(- highlightCircleSize)}, ${(yScale(accumulator))} )` );
            });
        }
420693
function saveText() {
  if (input.value.trim().length > 0) {
    let clientX = parseInt(input.style.left, 10);
    let clientY = parseInt(input.style.top, 10);
    let svg = findSVGAtPoint(clientX, clientY);
    if (!svg) {
      return;
    }

    let { documentId, pageNumber } = getMetadata(svg);
    let rect = svg.getBoundingClientRect();
    let annotation = Object.assign({
        type: 'textbox',
        size: _textSize,
        color: _textColor,
        content: input.value.trim()
      }, scaleDown(svg, {
        x: clientX - rect.left,
        y: clientY -  rect.top,
        width: input.offsetWidth,
        height: input.offsetHeight
      })
    );

    PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)
      .then((annotation) => {
        appendChild(svg, annotation);
      });
  }
  
  closeInput();
}
1352537
private void write(MultiPoint points, JsonGenerator gen) throws IOException {
        gen.writeStringField("type", "MultiPoint");
        gen.writeFieldName("coordinates");
        writeCoordinates(points.getCoordinates(), gen);
    }
753404
function createAnnotation(desc) {
  utils.check(['type', 'hasTarget', 'annotatedBy'], desc);

  var anno = { type: desc.type, hasTarget: desc.hasTarget, annotatedAt : desc.annotatedAt || new Date().toISOString(), annotatedBy : desc.annotatedBy, state: desc.state || utils.states.annotations.unvalidated};

 // used to create a hierarchical position
 // FIXME reconcile roots / position
  var position = desc.roots || [], flattened = desc.type + unitSep;
  anno.roots = desc.roots || [];
  if (desc.type === 'quote') {
    utils.check(['ranges', 'quote'], desc);
    if (!desc.ranges || desc.ranges.length < 1) {
      utils.checkError(desc, 'missing ranges');
    }
    anno.quote = desc.quote;
    anno.ranges = desc.ranges;
    position.push(anno.quote);
    flattened += position.join(unitSep);
  } else if (desc.type === 'category') {
    utils.check(['category'], desc);
    anno.category = Array.isArray(desc.category) ? desc.category : [desc.category];
    position = position.concat(anno.category);
    flattened += position.join(unitSep);
  } else if (desc.type === 'value' || desc.type === 'valueQuote') {
    utils.check(['key', 'value'], desc);
    if (desc.type === 'valueQuote') {
      utils.check(['ranges'], desc);
      anno.ranges = desc.ranges;
    }
    anno.key = desc.key;
    anno.value = desc.value;
    position.push(desc.key);
    flattened += position.join(unitSep) + unitSep + desc.value;

// add data types
    if (desc.isA) {
      try {
        anno.isA = desc.isA;
        anno.typed = {};
        anno.typed[desc.isA] = dataTypes[desc.isA](desc.value);
      } catch (e) {
        anno.typed.failure = e;
        GLOBAL.warn('isA failed', e, desc);
      }
    }
  } else {
    throw new Error('unknown type ' + desc.type);
  }
  anno.position = position;
  anno.flattened = flattened;
  if (anno.attributes) {
    anno.attributes = desc.attributes; // additional attributes
  }
  return anno;
}
1361571
function(line) {
			// Find any existing annotation
			var annotationModel = this.getAnnotationModel();
			var textModel = this.getModel();
			if (textModel.getBaseModel) {
				textModel = textModel.getBaseModel();
			}
			var type = AT.ANNOTATION_HIGHLIGHTED_LINE;
			var annotations = annotationModel.getAnnotations(0, textModel.getCharCount());
			var remove = null;
			while (annotations.hasNext()) {
				var annotation = annotations.next();
				if (annotation.type === type) {
					remove = annotation;
					break;
				}
			}
			var lineStart = textModel.getLineStart(line);
			var lineEnd = textModel.getLineEnd(line);
			var add = AT.createAnnotation(type, lineStart, lineEnd);
			// Replace to or add the new annotation
			if (remove) {
				annotationModel.replaceAnnotations([remove], [add]);
			} else {
				annotationModel.addAnnotation(add);
			}
		}
458868
def _clone_post_init(self, obj=None, **kwargs):
        
        # Initialize the extra attributes
        if obj is None or obj is self:
            # We must be asrootpy-ing a ROOT object
            # or freshly init-ing a rootpy object
            for attr, value in Plottable.EXTRA_ATTRS.items():
                # Use the default value
                setattr(self, attr, value)
        else:
            for attr, value in Plottable.EXTRA_ATTRS.items():
                setattr(self, attr, getattr(obj, attr))

        # Create aliases from deprecated to current attributes
        for depattr, newattr in Plottable.EXTRA_ATTRS_DEPRECATED.items():
            setattr(Plottable, depattr,
                    property(
                        fget=Plottable._get_attr_depr(depattr, newattr),
                        fset=Plottable._set_attr_depr(depattr, newattr)))

        if obj is None or obj is self:
            # We must be asrootpy-ing a ROOT object
            # or freshly init-ing a rootpy object
            # Initialize style attrs to style of TObject
            if isinstance(self, ROOT.TAttLine):
                self._linecolor = Color(ROOT.TAttLine.GetLineColor(self))
                self._linestyle = LineStyle(ROOT.TAttLine.GetLineStyle(self))
                self._linewidth = ROOT.TAttLine.GetLineWidth(self)
            else:  # HistStack
                self._linecolor = Color(Plottable.DEFAULT_DECOR['linecolor'])
                self._linestyle = LineStyle(Plottable.DEFAULT_DECOR['linestyle'])
                self._linewidth = Plottable.DEFAULT_DECOR['linewidth']

            if isinstance(self, ROOT.TAttFill):
                self._fillcolor = Color(ROOT.TAttFill.GetFillColor(self))
                self._fillstyle = FillStyle(ROOT.TAttFill.GetFillStyle(self))
            else:  # HistStack
                self._fillcolor = Color(Plottable.DEFAULT_DECOR['fillcolor'])
                self._fillstyle = FillStyle(Plottable.DEFAULT_DECOR['fillstyle'])

            if isinstance(self, ROOT.TAttMarker):
                self._markercolor = Color(ROOT.TAttMarker.GetMarkerColor(self))
                self._markerstyle = MarkerStyle(ROOT.TAttMarker.GetMarkerStyle(self))
                self._markersize = ROOT.TAttMarker.GetMarkerSize(self)
            else:  # HistStack
                self._markercolor = Color(Plottable.DEFAULT_DECOR['markercolor'])
                self._markerstyle = MarkerStyle(Plottable.DEFAULT_DECOR['markerstyle'])
                self._markersize = Plottable.DEFAULT_DECOR['markersize']

            if obj is None:
                # Populate defaults if we are not asrootpy-ing existing object
                decor = dict(**Plottable.DEFAULT_DECOR)
                decor.update(Plottable.EXTRA_ATTRS)
                if 'color' in kwargs:
                    decor.pop('linecolor', None)
                    decor.pop('fillcolor', None)
                    decor.pop('markercolor', None)
                decor.update(kwargs)
                self.decorate(**decor)

        else:
            # Initialize style attrs to style of the other object
            if isinstance(obj, ROOT.TAttLine):
                self.SetLineColor(obj.GetLineColor())
                self.SetLineStyle(obj.GetLineStyle())
                self.SetLineWidth(obj.GetLineWidth())
            if isinstance(obj, ROOT.TAttFill):
                self.SetFillColor(obj.GetFillColor())
                self.SetFillStyle(obj.GetFillStyle())
            if isinstance(obj, ROOT.TAttMarker):
                self.SetMarkerColor(obj.GetMarkerColor())
                self.SetMarkerStyle(obj.GetMarkerStyle())
                self.SetMarkerSize(obj.GetMarkerSize())
            if kwargs:
                self.decorate(**kwargs)
978812
function _insertPoint(eventData, insertInfo) {
  const toolData = getToolState(eventData.element, this.name);

  if (toolData === undefined) {
    return;
  }

  // Get the toolData from insertInfo
  const data = toolData.data[insertInfo.toolIndex];

  const insertIndex = _getInsertionIndex(insertInfo);

  if (insertIndex === Infinity) {
    return;
  }

  const handleData = new FreehandHandleData(eventData.currentPoints.image);

  const points = data.handles.points;

  // Add the new handle
  points.splice(insertIndex, 0, handleData);

  // Add the line from the previous handle to the inserted handle (note the tool is now one increment longer)
  points[insertIndex - 1].lines.pop();
  points[insertIndex - 1].lines.push(eventData.currentPoints.image);

  addLine(points, insertIndex);

  data.active = true;
  data.highlight = true;

  // Force onImageRendered to fire
  data.invalidated = true;
  external.cornerstone.updateImage(eventData.element);
}
948724
function(pos) {
    
    // remove active class
    els = document.querySelectorAll('#sg-annotations > .sg-annotations-list > li');
    for (i = 0; i < els.length; ++i) {
      els[i].classList.remove('active');
    }
    
    // add active class to called element and scroll to it
    for (i = 0; i < els.length; ++i) {
      if ((i+1) == pos) {
        els[i].classList.add('active');
        $('.sg-pattern-extra-info').animate({scrollTop: els[i].offsetTop - 10}, 600);
      }
    }
    
  }
585132
function(index) {
                        tsdb.saveAnnotation(annotations[index], function(data) {
                            annotations[index] = data;
                            receivedResponses++;
                            if (receivedResponses == expectedResponses) {
                                if (errorsReceived.length > 0) {
                                    errorFn(annotations, errorsReceived);
                                }
                                else {
                                    successFn(annotations);
                                }
                            }
                        }, function(error) {
                            receivedResponses++;
                            errorsReceived.push(error);
                            if (receivedResponses == expectedResponses) {
                                errorFn(annotations, errorsReceived);
                            }
                        })
                    }