/** * Updates the shadow map for a given wavelet. */ private void updateShadowMap(Wavelet wavelet) { for (Blip blip : wavelet.getBlips().values()) { if (isShadowBlip(blip)) { String shadowBlipId = blip.getBlipId(); if (!shadowBlipMap.containsValue(shadowBlipId)) { String originalBlipId = blip.getAnnotations().get(ECHOEY_ANNOTATION).get(0).getValue(); shadowBlipMap.put(originalBlipId, shadowBlipId); } } } }
Annotation annotation = existingList.get(i); String name = annotation.getName(); String value = annotation.getValue(); int start = annotation.getRange().getStart(); int end = annotation.getRange().getEnd(); value.equals(existingList.get(j).getValue())) { end = existingList.get(j).getRange().getEnd(); existingList.remove(j--);
this.annotations.add(annotation.getName(), annotation.getValue(), annotation.getRange().getStart(), annotation.getRange().getEnd());
case ANNOTATE: Annotation annotation = Annotation.class.cast(next); blip.getAnnotations().add(annotation.getName(), annotation.getValue(), start, end); break; case CLEAR_ANNOTATION: values = new ArrayList<String>(arguments.length); for (Object item : arguments) { values.add(Annotation.class.cast(item).getValue());
/** * Updates an existing shadow blip. * * @param shadowBlip the blip that is shadowing. * @param blipToShadow the blip being shadowed. */ private void updateShadowBlip(Blip shadowBlip, Blip blipToShadow) { Preconditions.checkNotNull(shadowBlip, "Shadow blip can't be null"); Preconditions.checkNotNull(blipToShadow, "Blip to shadow can't be null"); shadowBlip.all().replace(blipToShadow.getContent()); for (Annotation annotation : blipToShadow.getAnnotations()) { if (annotation.getName().equals(ECHOEY_ANNOTATION)) { continue; } shadowBlip.range(annotation.getRange().getStart(), annotation.getRange().getEnd()).annotate( annotation.getName(), annotation.getValue()); } shadowBlip.all().annotate(ECHOEY_ANNOTATION, blipToShadow.getBlipId()); shadowBlipMap.put(blipToShadow.getBlipId(), shadowBlip.getBlipId()); }
for (Annotation annotation : blip.getAnnotations()) { Range range = annotation.getRange(); annotations.add(new Annotation(annotation.getName(), annotation.getValue(), range.getStart(), range.getEnd()));
/** * Copies the content of the source blip into the target blip. * * @param fromBlip the source blip. * @param toBlip the target blip. */ public static void copyBlipContents(Blip fromBlip, Blip toBlip) { for (BlipContent blipContent: fromBlip.all().values()) { toBlip.append(blipContent); } for (Annotation annotation : fromBlip.getAnnotations()) { Range range = annotation.getRange(); toBlip.range(range.getStart() + 1, range.getEnd() + 1).annotate(annotation.getName(), annotation.getValue()); } }
public void testAdd() throws Exception { Annotations annotations = new Annotations(); annotations.add("name", "value", 3, 5); assertEquals(1, annotations.get("name").size()); annotations.add("name", "value", 1, 2); annotations.add("name", "value", 10, 15); assertEquals(3, annotations.get("name").size()); annotations.add("name", "value", 4, 7); assertEquals(3, annotations.get("name").size()); assertEquals(new Range(3, 7), annotations.get("name").get(2).getRange()); annotations.add("name", "value2", 6, 7); assertEquals(4, annotations.get("name").size()); assertEquals(new Range(3, 6), annotations.get("name").get(2).getRange()); assertEquals("value", annotations.get("name").get(2).getValue()); assertEquals(new Range(6, 7), annotations.get("name").get(3).getRange()); assertEquals("value2", annotations.get("name").get(3).getValue()); }
public void testAdd() throws Exception { Annotations annotations = new Annotations(); annotations.add("name", "value", 3, 5); assertEquals(1, annotations.get("name").size()); annotations.add("name", "value", 1, 2); annotations.add("name", "value", 10, 15); assertEquals(3, annotations.get("name").size()); annotations.add("name", "value", 4, 7); assertEquals(3, annotations.get("name").size()); assertEquals(new Range(3, 7), annotations.get("name").get(2).getRange()); annotations.add("name", "value2", 6, 7); assertEquals(4, annotations.get("name").size()); assertEquals(new Range(3, 6), annotations.get("name").get(2).getRange()); assertEquals("value", annotations.get("name").get(2).getValue()); assertEquals(new Range(6, 7), annotations.get("name").get(3).getRange()); assertEquals("value2", annotations.get("name").get(3).getValue()); }