Skip to content

Commit

Permalink
GH-314 clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Corless committed Feb 3, 2024
1 parent 357b96b commit 4ec6874
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ public void resetAppearanceStream(double dx, double dy, AffineTransform pageSpac
return;
}

// todo: Revisit as there is a lot of duplicate code here also found in textMarkupAnnotations, however
// this may change when image redaction code is added.

Appearance appearance = appearances.get(currentAppearance);
AppearanceState appearanceState = appearance.getSelectedAppearanceState();
appearanceState.setShapes(new Shapes());
Expand Down
4 changes: 2 additions & 2 deletions core/core-awt/src/main/java/org/icepdf/core/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public static String convertByteArrayToByteString(byte[] bytes) {

/**
* Utility method for decrypting a String object found in a dictionary
* as a plaing text. The string can be encrypted as well as octal encoded,
* as a plain text. The string can be encrypted as well as octal encoded,
* which is handle by this method.
*
* @param library document library used for encryption handling.
Expand Down Expand Up @@ -397,7 +397,7 @@ public static String convertStringObject(Library library, StringObject stringObj
}

/**
* Convert a utf-8 encoded string into an octal encded byte[] array.
* Convert an utf-8 encoded string into an octal encoded byte[] array.
*
* @param literalString string to convert.
* @return converted string value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.icepdf.core.pobjects.PObject;
import org.icepdf.core.pobjects.Page;
import org.icepdf.core.pobjects.StateManager;
import org.icepdf.core.pobjects.annotations.Annotation;
import org.icepdf.core.pobjects.annotations.RedactionAnnotation;

import java.io.IOException;
Expand Down Expand Up @@ -40,11 +41,11 @@ public static void burnRedactions(Document document) throws InterruptedException
private static void convertRedactionToSquareAnnotation(StateManager stateManager,
List<RedactionAnnotation> redactionAnnotations) {
for (RedactionAnnotation redactionAnnotation : redactionAnnotations) {
// redactionAnnotation.setSubtype(Annotation.SUBTYPE_SQUARE);
// redactionAnnotation.setFlag(Annotation.FLAG_LOCKED, true);
// redactionAnnotation.setFlag(Annotation.FLAG_READ_ONLY, true);
// redactionAnnotation.setFlag(Annotation.FLAG_LOCKED_CONTENTS, true);
// stateManager.addChange(new PObject(redactionAnnotation, redactionAnnotation.getPObjectReference()));
redactionAnnotation.setSubtype(Annotation.SUBTYPE_SQUARE);
redactionAnnotation.setFlag(Annotation.FLAG_LOCKED, true);
redactionAnnotation.setFlag(Annotation.FLAG_READ_ONLY, true);
redactionAnnotation.setFlag(Annotation.FLAG_LOCKED_CONTENTS, true);
stateManager.addChange(new PObject(redactionAnnotation, redactionAnnotation.getPObjectReference()));
stateManager.addDeletion(new PObject(redactionAnnotation, redactionAnnotation.getPObjectReference()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public ImageStream encode() throws IOException {
if (isGrayScaleImage(imageStream)) {
byteArray = createFromGrayScaleImage(imageStream);
} else {
// may need to look at the mask value, if arrray we have ColorKeyMask and are rgba?
// BufferedImage image = imageStream.getDecodedImage();
// ImageUtility.displayImage(imageStream.getDecodedImage(),
// imageStream.getPObjectReference().toString() + image.getWidth() +
// " " + "x" + image.getHeight());
byteArray = createFromRGBImage(imageStream);
}
byte[] outputData = createFlateEncodedBytes(byteArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
*
* @since 7.2
*/
public class TextRedactionAnnotationHandler extends HighLightAnnotationHandler {
public class RedactionAnnotationHandler extends HighLightAnnotationHandler {

private boolean isOverImage = false;

public TextRedactionAnnotationHandler(DocumentViewController documentViewController,
AbstractPageViewComponent pageViewComponent) {
public RedactionAnnotationHandler(DocumentViewController documentViewController,
AbstractPageViewComponent pageViewComponent) {
super(documentViewController, pageViewComponent);
markupSubType = Annotation.SUBTYPE_REDACT;
selectionBoxColour = Color.BLACK;
Expand Down Expand Up @@ -175,8 +175,6 @@ public void createMarkupAnnotationFromSelectionBox() {

convertToPageSpace(redactionBounds, highlightPath);

// todo cleanup duplication

AffineTransform pageTransform = getToPageSpaceTransform();
annotation.setColor(Color.BLACK);
annotation.setMarkupBounds(redactionBounds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ public void setToolMode(final int viewToolMode) {
break;
case DocumentViewModel.DISPLAY_TOOL_REDACTION_ANNOTATION:
// handler is responsible for the initial creation of the annotation
currentToolHandler = new TextRedactionAnnotationHandler(
currentToolHandler = new RedactionAnnotationHandler(
documentViewController, this);
((TextRedactionAnnotationHandler) currentToolHandler).createMarkupAnnotation(null);
((RedactionAnnotationHandler) currentToolHandler).createMarkupAnnotation(null);
documentViewController.clearSelectedText();
break;

Expand Down Expand Up @@ -237,8 +237,9 @@ public ArrayList<AbstractAnnotationComponent> getAnnotationComponents() {
public AnnotationComponent getComponentFor(Annotation annot) {
if (annotationToComponent == null) {
initializeAnnotationsComponent(getPage());
return annotationToComponent.get(annot.getPObjectReference());
}
return annotationToComponent.get(annot.getPObjectReference());
return null;
}

/**
Expand Down

0 comments on commit 4ec6874

Please sign in to comment.