Codeblock | ||
---|---|---|
| ||
// Aktuelle AnnotationRenderSettings holen
final AnnotationRenderSettings annoRenderHints = getPageView().getDocumentControls().getSettings(AnnotationRenderSettings.class);
// Annotationstypen anhand des Namens ermitteln:
// "*" = alle Typen
// "BaseText,BaseArrow" = Nur Text- und Pfeil-Annotationen
// "BaseText" = Nur Text-Annotation
final Collection<AnnotationType> types = getAnnotationTypes("BaseText");
// Annotationstypen an- / ausschalten
for (final AnnotationType annotationType : types) {
// Sichtbarkeit für ausgewählte Annotationstypen umschalten
final boolean visible = annoRenderHints.isAnnotationRenderingEnabled(annotationType);
// Parameter: Annotationstyp, Flag (false = nicht sichtbar, true = sichtbar)
annoRenderHints.setAnnotationRenderingEnabled(annotationType, !visible);
}
getPageView().repaint(); |
Codeblock | ||
---|---|---|
| ||
/**
* Resolves annotation type name(s) to corresponding annotation type instance(s).
*
* @param annotationTypeName List of annotation type names.
* @return Collection containing annotation types
*/
protected Collection<AnnotationType> getAnnotationTypes(String annotationTypeName) {
final String[] typeNames = annotationTypeName.split("\\s*,\\s*");
final AnnotationProfile ap = getAnnotationProfile();
final List<AnnotationType> result = new ArrayList<AnnotationType>();
if (typeNames == null)
return result;
for (final String typeName : typeNames) {
if (typeName.equals("*"))
result.addAll(ap.getTypes());
else {
final AnnotationType type = ap.getType(typeName);
if (type == null)
System.err.println("Invalid annotation type " + Arrays.toString(typeNames)
+ ". No annotation creation provided.");
else
result.add(type);
}
}
return result;
} |
Codeblock | ||
---|---|---|
| ||
/**
* Returns the current annotation profile.
*
* @return Annotation profile
*/
protected AnnotationProfile getAnnotationProfile() {
// AnnotationPageSegment holen, wenn vorhanden
final AnnotationPageSegment aps = Annotations.getAnnotationPageSegment(getPageView().getCurrentPage());
AnnotationProfile ap = null;
if (aps != null) {
// Annotationsprofil aus AnnotationPageSegment holen
ap = aps.getAnnotationProfile();
}
if (null == ap) {
// Wenn nicht vorhanden, Annotationsprofil aus Dokument holen
ap = AnnotationProfile.get(getPageView().getDocument());
}
if (null == ap) {
// Wenn nicht vorhanden, Standardannotationsprofil holen
ap = AnnotationProfile.getDefaultProfile();
}
return ap;
} |