Skip to content

Commit

Permalink
GH-138 Fixes Squiggly Annotation (#139)
Browse files Browse the repository at this point in the history
* Fixes conflict with PropertiesManager renaming

* GH-138 Also checks for Squiggly in buildAnnotation

* GH-138 Uses isTextMarkupAnnotation
  • Loading branch information
gtache authored Sep 12, 2020
1 parent 17295b1 commit 9b963b1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,7 @@ public static Annotation buildAnnotation(Library library, HashMap hashMap) {
annot = new LinkAnnotation(library, hashMap);
}
// highlight version of a TextMarkup annotation.
else if (subType.equals(TextMarkupAnnotation.SUBTYPE_HIGHLIGHT) ||
subType.equals(TextMarkupAnnotation.SUBTYPE_STRIKE_OUT) ||
subType.equals(TextMarkupAnnotation.SUBTYPE_UNDERLINE)) {
else if (TextMarkupAnnotation.isTextMarkupAnnotation(subType)) {
annot = new TextMarkupAnnotation(library, hashMap);
} else if (subType.equals(Annotation.SUBTYPE_LINE)) {
annot = new LineAnnotation(library, hashMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class AnnotationFactory {
* @param subType type of annotation to create
* @param rect bounds of new annotation specified in user space.
* @return new annotation object with the same properties as the one
* specified in annotaiton state.
* specified in annotation state.
*/
public static Annotation buildAnnotation(Library library,
final Name subType,
Expand All @@ -56,9 +56,7 @@ public static Annotation buildAnnotation(Library library,
return LinkAnnotation.getInstance(library, rect);
}
// highlight version of a TextMarkup annotation.
else if (subType.equals(TextMarkupAnnotation.SUBTYPE_HIGHLIGHT) ||
subType.equals(TextMarkupAnnotation.SUBTYPE_STRIKE_OUT) ||
subType.equals(TextMarkupAnnotation.SUBTYPE_UNDERLINE)) {
else if (TextMarkupAnnotation.isTextMarkupAnnotation(subType)) {
return TextMarkupAnnotation.getInstance(library, rect,
subType);
} else if (subType.equals(Annotation.SUBTYPE_LINE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.icepdf.core.pobjects.annotations;

import org.icepdf.core.pobjects.Dictionary;
import org.icepdf.core.pobjects.*;
import org.icepdf.core.pobjects.graphics.Shapes;
import org.icepdf.core.pobjects.graphics.commands.*;
Expand All @@ -26,10 +27,8 @@
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand All @@ -52,6 +51,9 @@ public class TextMarkupAnnotation extends MarkupAnnotation {
public static final Name SUBTYPE_SQUIGGLY = new Name("Squiggly");
public static final Name SUBTYPE_STRIKE_OUT = new Name("StrikeOut");

public static final Set<Name> ALL_SUBTYPES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(SUBTYPE_HIGHLIGHT,
SUBTYPE_UNDERLINE, SUBTYPE_SQUIGGLY, SUBTYPE_STRIKE_OUT)));

private static Color highlightColor;
private static Color strikeOutColor;
private static Color underlineColor;
Expand Down Expand Up @@ -196,7 +198,7 @@ public void init() throws InterruptedException {
*
* @param library document library
* @param rect bounding rectangle in user space
* @param subType subtype of the markup annotation
* @param subType subtype of the markup annotation
* @return new TextMarkupAnnotation Instance.
*/
public static TextMarkupAnnotation getInstance(Library library,
Expand Down Expand Up @@ -238,10 +240,7 @@ public static TextMarkupAnnotation getInstance(Library library,


public static boolean isTextMarkupAnnotation(Name subType) {
return SUBTYPE_HIGHLIGHT.equals(subType) ||
SUBTYPE_UNDERLINE.equals(subType) ||
SUBTYPE_SQUIGGLY.equals(subType) ||
SUBTYPE_STRIKE_OUT.equals(subType);
return ALL_SUBTYPES.contains(subType);
}

/**
Expand Down

0 comments on commit 9b963b1

Please sign in to comment.