Auto format common package

This commit is contained in:
moezbhatti
2019-04-10 21:51:39 -04:00
parent 1e6b041d05
commit 69d2ae0544
3 changed files with 53 additions and 70 deletions
+1 -2
View File
@@ -16,5 +16,4 @@
~ You should have received a copy of the GNU General Public License ~ You should have received a copy of the GNU General Public License
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>. ~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
--> -->
<manifest package="com.moez.QKSMS" <manifest package="com.moez.QKSMS" />
/>
@@ -70,8 +70,7 @@ public class AnimatedGifEncoder {
* Sets the delay time between each frame, or changes it for subsequent frames * Sets the delay time between each frame, or changes it for subsequent frames
* (applies to last frame added). * (applies to last frame added).
* *
* @param ms * @param ms int delay time in milliseconds
* int delay time in milliseconds
*/ */
public void setDelay(int ms) { public void setDelay(int ms) {
delay = Math.round(ms / 10.0f); delay = Math.round(ms / 10.0f);
@@ -82,8 +81,7 @@ public class AnimatedGifEncoder {
* subsequent frames. Default is 0 if no transparent color has been set, * subsequent frames. Default is 0 if no transparent color has been set,
* otherwise 2. * otherwise 2.
* *
* @param code * @param code int disposal code.
* int disposal code.
*/ */
public void setDispose(int code) { public void setDispose(int code) {
if (code >= 0) { if (code >= 0) {
@@ -96,8 +94,7 @@ public class AnimatedGifEncoder {
* 1; 0 means play indefinitely. Must be invoked before the first image is * 1; 0 means play indefinitely. Must be invoked before the first image is
* added. * added.
* *
* @param iter * @param iter int number of iterations.
* int number of iterations.
*/ */
public void setRepeat(int iter) { public void setRepeat(int iter) {
if (iter >= 0) { if (iter >= 0) {
@@ -112,8 +109,7 @@ public class AnimatedGifEncoder {
* color becomes the transparent color for that frame. May be set to null to * color becomes the transparent color for that frame. May be set to null to
* indicate no transparent color. * indicate no transparent color.
* *
* @param color * @param color Color to be treated as transparent on display.
* Color to be treated as transparent on display.
*/ */
public void setTransparent(int color) { public void setTransparent(int color) {
transparent = color; transparent = color;
@@ -126,8 +122,7 @@ public class AnimatedGifEncoder {
* <code>setSize</code> was invoked, the size is used for all subsequent frames. * <code>setSize</code> was invoked, the size is used for all subsequent frames.
* Otherwise, the actual size of the image is used for each frames. * Otherwise, the actual size of the image is used for each frames.
* *
* @param im * @param im BufferedImage containing frame to write.
* BufferedImage containing frame to write.
* @return true if successful. * @return true if successful.
*/ */
public boolean addFrame(@Nullable Bitmap im) { public boolean addFrame(@Nullable Bitmap im) {
@@ -140,17 +135,14 @@ public class AnimatedGifEncoder {
* Invoking <code>finish()</code> flushes all frames. If <code>setSize</code> was invoked, the * Invoking <code>finish()</code> flushes all frames. If <code>setSize</code> was invoked, the
* size is used for all subsequent frames. Otherwise, the actual size of the image is used for * size is used for all subsequent frames. Otherwise, the actual size of the image is used for
* each frame. * each frame.
* * <p>
* See page 11 of http://giflib.sourceforge.net/gif89.txt for the position of the frame * See page 11 of http://giflib.sourceforge.net/gif89.txt for the position of the frame
* *
* @param im * @param im BufferedImage containing frame to write.
* BufferedImage containing frame to write. * @param x Column number, in pixels, of the left edge of the image, with respect to the left
* @param x * edge of the Logical Screen.
* Column number, in pixels, of the left edge of the image, with respect to the left * @param y Row number, in pixels, of the top edge of the image with respect to the top edge of
* edge of the Logical Screen. * the Logical Screen.
* @param y
* Row number, in pixels, of the top edge of the image with respect to the top edge of
* the Logical Screen.
* @return true if successful. * @return true if successful.
*/ */
public boolean addFrame(@Nullable Bitmap im, int x, int y) { public boolean addFrame(@Nullable Bitmap im, int x, int y) {
@@ -225,8 +217,7 @@ public class AnimatedGifEncoder {
* Sets frame rate in frames per second. Equivalent to * Sets frame rate in frames per second. Equivalent to
* <code>setDelay(1000/fps)</code>. * <code>setDelay(1000/fps)</code>.
* *
* @param fps * @param fps float frame rate (frames per second)
* float frame rate (frames per second)
*/ */
public void setFrameRate(float fps) { public void setFrameRate(float fps) {
if (fps != 0f) { if (fps != 0f) {
@@ -253,10 +244,8 @@ public class AnimatedGifEncoder {
* Sets the fixed GIF frame size for all the frames. * Sets the fixed GIF frame size for all the frames.
* This should be called before start. * This should be called before start.
* *
* @param w * @param w int frame width.
* int frame width. * @param h int frame width.
* @param h
* int frame width.
*/ */
public void setSize(int w, int h) { public void setSize(int w, int h) {
if (started) { if (started) {
@@ -278,10 +267,8 @@ public class AnimatedGifEncoder {
/** /**
* Sets current GIF frame size. * Sets current GIF frame size.
* *
* @param w * @param w int frame width.
* int frame width. * @param h int frame width.
* @param h
* int frame width.
*/ */
private void setFrameSize(int w, int h) { private void setFrameSize(int w, int h) {
width = w; width = w;
@@ -292,8 +279,7 @@ public class AnimatedGifEncoder {
* Initiates GIF file creation on the given stream. The stream is not closed * Initiates GIF file creation on the given stream. The stream is not closed
* automatically. * automatically.
* *
* @param os * @param os OutputStream on which GIF images are written.
* OutputStream on which GIF images are written.
* @return false if initial write failed. * @return false if initial write failed.
*/ */
public boolean start(@Nullable OutputStream os) { public boolean start(@Nullable OutputStream os) {
@@ -313,8 +299,7 @@ public class AnimatedGifEncoder {
/** /**
* Initiates writing of a GIF file with the specified name. * Initiates writing of a GIF file with the specified name.
* *
* @param file * @param file String containing output file name.
* String containing output file name.
* @return false if open or initial write failed. * @return false if open or initial write failed.
*/ */
public boolean start(@NonNull String file) { public boolean start(@NonNull String file) {
@@ -366,7 +351,6 @@ public class AnimatedGifEncoder {
/** /**
* Returns index of palette color closest to c * Returns index of palette color closest to c
*
*/ */
private int findClosest(int color) { private int findClosest(int color) {
if (colorTab == null) if (colorTab == null)
@@ -377,7 +361,7 @@ public class AnimatedGifEncoder {
int minpos = 0; int minpos = 0;
int dmin = 256 * 256 * 256; int dmin = 256 * 256 * 256;
int len = colorTab.length; int len = colorTab.length;
for (int i = 0; i < len;) { for (int i = 0; i < len; ) {
int dr = r - (colorTab[i++] & 0xff); int dr = r - (colorTab[i++] & 0xff);
int dg = g - (colorTab[i++] & 0xff); int dg = g - (colorTab[i++] & 0xff);
int db = b - (colorTab[i] & 0xff); int db = b - (colorTab[i] & 0xff);
@@ -430,7 +414,7 @@ public class AnimatedGifEncoder {
hasTransparentPixels = transparentPercentage > MIN_TRANSPARENT_PERCENTAGE; hasTransparentPixels = transparentPercentage > MIN_TRANSPARENT_PERCENTAGE;
if (Log.isLoggable(TAG, Log.DEBUG)) { if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "got pixels for frame with " + transparentPercentage Log.d(TAG, "got pixels for frame with " + transparentPercentage
+ "% transparent pixels"); + "% transparent pixels");
} }
} }
@@ -6,7 +6,7 @@ class NeuQuant {
protected static final int netsize = 256; /* number of colours used */ protected static final int netsize = 256; /* number of colours used */
/* four primes near 500 - assume no image has a length so large */ /* four primes near 500 - assume no image has a length so large */
/* that it is divisible by all four primes */ /* that it is divisible by all four primes */
protected static final int prime1 = 499; protected static final int prime1 = 499;
protected static final int prime2 = 491; protected static final int prime2 = 491;
@@ -17,19 +17,19 @@ class NeuQuant {
protected static final int minpicturebytes = (3 * prime4); protected static final int minpicturebytes = (3 * prime4);
/* minimum size for input image */ /* minimum size for input image */
/* /*
* Program Skeleton ---------------- [select samplefac in range 1..30] [read * Program Skeleton ---------------- [select samplefac in range 1..30] [read
* image from input file] pic = (unsigned char*) malloc(3*width*height); * image from input file] pic = (unsigned char*) malloc(3*width*height);
* initnet(pic,3*width*height,samplefac); learn(); unbiasnet(); [write output * initnet(pic,3*width*height,samplefac); learn(); unbiasnet(); [write output
* image header, using writecolourmap(f)] inxbuild(); write output image using * image header, using writecolourmap(f)] inxbuild(); write output image using
* inxsearch(b,g,r) * inxsearch(b,g,r)
*/ */
/* /*
* Network Definitions ------------------- * Network Definitions -------------------
*/ */
protected static final int maxnetpos = (netsize - 1); protected static final int maxnetpos = (netsize - 1);
@@ -54,19 +54,19 @@ class NeuQuant {
/* defs for decreasing radius factor */ /* defs for decreasing radius factor */
protected static final int initrad = (netsize >> 3); /* protected static final int initrad = (netsize >> 3); /*
* for 256 cols, radius * for 256 cols, radius
* starts * starts
*/ */
protected static final int radiusbiasshift = 6; /* at 32.0 biased by 6 bits */ protected static final int radiusbiasshift = 6; /* at 32.0 biased by 6 bits */
protected static final int radiusbias = (((int) 1) << radiusbiasshift); protected static final int radiusbias = (((int) 1) << radiusbiasshift);
protected static final int initradius = (initrad * radiusbias); /* protected static final int initradius = (initrad * radiusbias); /*
* and * and
* decreases * decreases
* by a * by a
*/ */
protected static final int radiusdec = 30; /* factor of 1/30 each cycle */ protected static final int radiusdec = 30; /* factor of 1/30 each cycle */
@@ -86,9 +86,9 @@ class NeuQuant {
protected static final int alpharadbias = (((int) 1) << alpharadbshift); protected static final int alpharadbias = (((int) 1) << alpharadbshift);
/* /*
* Types and Global Variables -------------------------- * Types and Global Variables --------------------------
*/ */
protected byte[] thepicture; /* the input image itself */ protected byte[] thepicture; /* the input image itself */
@@ -101,7 +101,7 @@ class NeuQuant {
protected int[] netindex = new int[256]; protected int[] netindex = new int[256];
/* for network lookup - really 256 */ /* for network lookup - really 256 */
protected int[] bias = new int[netsize]; protected int[] bias = new int[netsize];
@@ -110,7 +110,7 @@ class NeuQuant {
protected int[] radpower = new int[initrad]; protected int[] radpower = new int[initrad];
/* radpower for precomputation */ /* radpower for precomputation */
/* /*
* Initialise network in range (0,0,0) to (255,255,255) and set parameters * Initialise network in range (0,0,0) to (255,255,255) and set parameters
@@ -168,7 +168,7 @@ class NeuQuant {
p = network[i]; p = network[i];
smallpos = i; smallpos = i;
smallval = p[1]; /* index on g */ smallval = p[1]; /* index on g */
/* find smallest in i..netsize-1 */ /* find smallest in i..netsize-1 */
for (j = i + 1; j < netsize; j++) { for (j = i + 1; j < netsize; j++) {
q = network[j]; q = network[j];
if (q[1] < smallval) { /* index on g */ if (q[1] < smallval) { /* index on g */
@@ -177,7 +177,7 @@ class NeuQuant {
} }
} }
q = network[smallpos]; q = network[smallpos];
/* swap p (i) and q (smallpos) entries */ /* swap p (i) and q (smallpos) entries */
if (i != smallpos) { if (i != smallpos) {
j = q[0]; j = q[0];
q[0] = p[0]; q[0] = p[0];
@@ -192,7 +192,7 @@ class NeuQuant {
q[3] = p[3]; q[3] = p[3];
p[3] = j; p[3] = j;
} }
/* smallval entry is now in position i */ /* smallval entry is now in position i */
if (smallval != previouscol) { if (smallval != previouscol) {
netindex[previouscol] = (startpos + i) >> 1; netindex[previouscol] = (startpos + i) >> 1;
for (j = previouscol + 1; j < smallval; j++) for (j = previouscol + 1; j < smallval; j++)
@@ -426,7 +426,7 @@ class NeuQuant {
*/ */
protected void altersingle(int alpha, int i, int b, int g, int r) { protected void altersingle(int alpha, int i, int b, int g, int r) {
/* alter hit neuron */ /* alter hit neuron */
int[] n = network[i]; int[] n = network[i];
n[0] -= (alpha * (n[0] - b)) / initalpha; n[0] -= (alpha * (n[0] - b)) / initalpha;
n[1] -= (alpha * (n[1] - g)) / initalpha; n[1] -= (alpha * (n[1] - g)) / initalpha;
@@ -438,10 +438,10 @@ class NeuQuant {
*/ */
protected int contest(int b, int g, int r) { protected int contest(int b, int g, int r) {
/* finds closest neuron (min dist) and updates freq */ /* finds closest neuron (min dist) and updates freq */
/* finds best neuron (min dist-bias) and returns position */ /* finds best neuron (min dist-bias) and returns position */
/* for frequently chosen neurons, freq[i] is high and bias[i] is negative */ /* for frequently chosen neurons, freq[i] is high and bias[i] is negative */
/* bias[i] = gamma*((1/netsize)-freq[i]) */ /* bias[i] = gamma*((1/netsize)-freq[i]) */
int i, dist, a, biasdist, betafreq; int i, dist, a, biasdist, betafreq;
int bestpos, bestbiaspos, bestd, bestbiasd; int bestpos, bestbiaspos, bestd, bestbiasd;