Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected void cleanup() {
}

@Override
public void run() {
public void run() {
try {
Thread.sleep(1);
// call setup once we started
Expand Down Expand Up @@ -151,7 +151,7 @@ public void run() {
* @return one of the well-known statuses
*/
@Override
public int getStatus() {
public int getStatus() {
return this.status;
}

Expand All @@ -175,12 +175,12 @@ public boolean isExecutable() {

/**
* Stop this watchable if it is not already finished.
* Stop will cause all processing to cease,
* Stop will cause all processing to cease,
* and the watchable to be destroyed.
*/
@Override
public void stop() {
if (!isFinished()) setStatus(Watchable.STOPPED);
public void stop() {
if (!isFinished()) setStatus(Watchable.STOPPED);
}

/**
Expand All @@ -190,7 +190,7 @@ public void stop() {
* different time is called during execution.
*/
@Override
public synchronized void go() {
public synchronized void go() {
this.gate = null;

execute(false);
Expand All @@ -216,7 +216,7 @@ public synchronized void go(boolean synchronous) {
* @param steps the number of steps to run for
*/
@Override
public synchronized void go(int steps) {
public synchronized void go(int steps) {
this.gate = new Gate();
this.gate.setStopIterations(steps);

Expand All @@ -230,7 +230,7 @@ public synchronized void go(int steps) {
* @param millis the number of milliseconds to run for
*/
@Override
public synchronized void go(long millis) {
public synchronized void go(long millis) {
this.gate = new Gate();
this.gate.setStopTime(millis);

Expand Down Expand Up @@ -277,27 +277,27 @@ protected synchronized void execute(boolean synchronous) {
this.thread = Thread.currentThread();
run();
} else {
this.thread = new Thread(this);
this.thread.setName(getClass().getName());
//Fix for NPE: Taken from http://java.net/jira/browse/PDF_RENDERER-46
synchronized (statusLock) {
Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() {
this.thread = new Thread(this);
this.thread.setName(getClass().getName());
//Fix for NPE: Taken from http://java.net/jira/browse/PDF_RENDERER-46
synchronized (statusLock) {
Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException( Thread th, Throwable ex )
{
PDFDebugger.debug( "Uncaught exception: " + ex );
}
};
thread.setUncaughtExceptionHandler( h );
thread.start();
thread.start();
try {
this.statusLock.wait(5000);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt(); // ← Preserve the interrupt status
PDFDebugger.debug("Thread interrupted while waiting for status change.");
}

}
}
}
}

Expand Down Expand Up @@ -334,17 +334,17 @@ public static void setSuppressSetErrorStackTrace(boolean suppressTrace) {
* Set an error on this watchable
*/
protected void setError(Exception error) {
exception = error;
exception = error;
if (!SuppressSetErrorStackTrace) {
errorHandler.publishException(error);
}

setStatus(Watchable.ERROR);
}

public Exception getException() {
return exception;
}
public Exception getException() {
return exception;
}

/** A class that lets us give it a target time or number of steps,
* and will tell us to stop after that much time or that many steps
Expand Down
120 changes: 60 additions & 60 deletions openpdf-renderer/src/main/java/org/openpdf/renderer/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* PDFRenderer API.
*/
public class Configuration {
private static Configuration INSTANCE;
private static Configuration INSTANCE;

/** whether grey scale images will be converted to ARGB */
private boolean convertGreyscaleImagesToArgb = true;
Expand All @@ -31,60 +31,60 @@ public class Configuration {
/** Print link annotations on pdf **/
private boolean printLinkAnnotations = true;

public static synchronized Configuration getInstance() {
if (INSTANCE == null) {
INSTANCE = new Configuration();
}
return INSTANCE;
}
public static synchronized Configuration getInstance() {
if (INSTANCE == null) {
INSTANCE = new Configuration();
}
return INSTANCE;
}

/**
* Enables or disables the conversion of greyscale images to ARGB.
* Disabling this may have a lower memory overhead with high resolution
* (e.g. scanned) images. Note that this has to be called before
* {@link #getImage()} is called to have an effect.
*
* Enabled by default.
* @param aFlag whether greyscale images shall be converted to ARGB.
*/
public void setConvertGreyscaleImagesToArgb(boolean aFlag) {
convertGreyscaleImagesToArgb = aFlag;
}
* Enables or disables the conversion of greyscale images to ARGB.
* Disabling this may have a lower memory overhead with high resolution
* (e.g. scanned) images. Note that this has to be called before
* {@link #getImage()} is called to have an effect.
*
* Enabled by default.
* @param aFlag whether greyscale images shall be converted to ARGB.
*/
public void setConvertGreyscaleImagesToArgb(boolean aFlag) {
convertGreyscaleImagesToArgb = aFlag;
}

/**
* Returns <code>true</code> if greyscale images will be converted to ARGB
*/
public boolean isConvertGreyscaleImagesToArgb() {
return convertGreyscaleImagesToArgb;
}
/**
* Returns <code>true</code> if greyscale images will be converted to ARGB
*/
public boolean isConvertGreyscaleImagesToArgb() {
return convertGreyscaleImagesToArgb;
}

/**
* If an image is higher than the given size (in pixels) then
* the image will be rendered in chunks, rather than as one big image.
* This may lead to lower memory consumption for e.g. scanned PDFs with
* large images.
*
* Set to a value <= 0 to disable banded image rendering.
* Defaults to 0 (off)
*
* @param aSize the height threshold at which to enable banded image rendering
*/
public void setThresholdForBandedImageRendering(int aSize) {
thresholdForBandedImageRendering = aSize;
}
/**
* If an image is higher than the given size (in pixels) then
* the image will be rendered in chunks, rather than as one big image.
* This may lead to lower memory consumption for e.g. scanned PDFs with
* large images.
*
* Set to a value <= 0 to disable banded image rendering.
* Defaults to 0 (off)
*
* @param aSize the height threshold at which to enable banded image rendering
*/
public void setThresholdForBandedImageRendering(int aSize) {
thresholdForBandedImageRendering = aSize;
}

/**
* Returns the image height threshold at which to enable banded image rendering.
* @return the threshold value, or a value <= 0 if banded rendering is disabled
*/
public int getThresholdForBandedImageRendering() {
return thresholdForBandedImageRendering;
}
/**
* Returns the image height threshold at which to enable banded image rendering.
* @return the threshold value, or a value <= 0 if banded rendering is disabled
*/
public int getThresholdForBandedImageRendering() {
return thresholdForBandedImageRendering;
}

/**
* Is the color converting op switched on or off?
* @return - the usage of this color convert op
*/
/**
* Is the color converting op switched on or off?
* @return - the usage of this color convert op
*/
public boolean isAvoidColorConvertOp() {
return avoidColorConvertOp;
}
Expand Down Expand Up @@ -131,14 +131,14 @@ public void setUseBlurResizingForImages(boolean useBlurResizingForImages) {
* @param printSignatureField
*/
public void setPrintSignatureFields(boolean printSignatureFields) {
this.printSigantureFields = printSignatureFields;
this.printSigantureFields = printSignatureFields;
}

/**
* @return <code>true</code> if signature fields will be printed on pdf
*/
public boolean isPrintSignatureFields() {
return this.printSigantureFields;
return this.printSigantureFields;
}

/**
Expand All @@ -147,14 +147,14 @@ public boolean isPrintSignatureFields() {
* @param printStampAnnotation
*/
public void setPrintStampAnnotations(boolean printStampAnnotations) {
this.printStampAnnotations = printStampAnnotations;
this.printStampAnnotations = printStampAnnotations;
}

/**
* @return <code>true</code> if stamp annotations will be printed on pdf
*/
public boolean isPrintStampAnnotations() {
return this.printStampAnnotations;
return this.printStampAnnotations;
}

/**
Expand All @@ -163,30 +163,30 @@ public boolean isPrintStampAnnotations() {
* @param printWidgetAnnotations
*/
public void setPrintWidgetAnnotations(boolean printWidgetAnnotations) {
this.printWidgetAnnotations = printWidgetAnnotations;
this.printWidgetAnnotations = printWidgetAnnotations;
}

/**
* @return <code>true</code> if widget annotations will be printed on pdf
*/
public boolean isPrintWidgetAnnotations() {
return this.printWidgetAnnotations;
}
return this.printWidgetAnnotations;
}

/**
* Print freetext annotations on pdf
*
* @param printFreetextAnnotations
*/
public void setPrintFreetextAnnotations(boolean printFreetextAnnotations) {
this.printFreetextAnnotations = printFreetextAnnotations;
this.printFreetextAnnotations = printFreetextAnnotations;
}

/**
* @return <code>true</code> if freetext annotations will be printed on pdf
*/
public boolean isPrintFreetextAnnotations() {
return this.printFreetextAnnotations;
return this.printFreetextAnnotations;
}

/**
Expand All @@ -195,13 +195,13 @@ public boolean isPrintFreetextAnnotations() {
* @param printLinkAnnotations
*/
public void setPrintLinkAnnotations(boolean printLinkAnnotations) {
this.printLinkAnnotations = printLinkAnnotations;
this.printLinkAnnotations = printLinkAnnotations;
}

/**
* @return <code>true</code> if link annotations will be printed on pdf
*/
public boolean isPrintLinkAnnotations() {
return this.printLinkAnnotations;
return this.printLinkAnnotations;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public Identity8BitCharsetEncoder() {
}

@Override
protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
while (in.remaining() > 0) {
if (out.remaining() < 1) {
return CoderResult.OVERFLOW;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@
int comp = key.compareTo(posKey);
if (comp == 0) {
// they match. Return the value
int tmp = (pos * 2) + 1;
if(array.length>tmp){
int tmp = (pos * 2) + 1;
if(array.length>tmp){
return array[tmp];
}else {
return null;
}
}else {

Check notice on line 116 in openpdf-renderer/src/main/java/org/openpdf/renderer/NameTree.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

openpdf-renderer/src/main/java/org/openpdf/renderer/NameTree.java#L116

WhitespaceAround: '}' is not followed by whitespace. Empty blocks may only be represented as {} when not part of a multi-block statement (4.1.3)
return null;
}
} else if (comp > 0) {
// too big, search the top half of the tree
start = pos + 1;
Expand Down
Loading