diff --git a/.version/changeversion.sh b/.version/changeversion.sh index d17591c..a7463c4 100755 --- a/.version/changeversion.sh +++ b/.version/changeversion.sh @@ -1,5 +1,5 @@ -old="4.0.2-SNAPSHOT" -new="4.0.2" +new="4.0.3" +old="4.0.3-SNAPSHOT" find ../ -type f \( -name "pom.xml" \) \ -exec sed -i -e "s/$old<\/revision>/$new<\/revision>/g" {} \; diff --git a/.version/tips.txt b/.version/tips.txt index 7b2b4d3..e1ce7c2 100644 --- a/.version/tips.txt +++ b/.version/tips.txt @@ -31,8 +31,13 @@ go to oss.sonatype.org promote... wait release ... wait some hours test -on github +on github (after oss part) pull request of the released branch create a new release ------ escpos-samples production +create a branch with name of actual version from master +ex master to 4.0.2 +// the actual version is on master branch +same on .version/changeversion.sh +change version on wiki diff --git a/README.md b/README.md index d2bdd42..cfefee4 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Download code and binaries from the [last release of escpos-coffee](https://gith com.github.anastaciocintra escpos-coffee - 4.0.2 + 4.0.3 ``` @@ -65,7 +65,7 @@ repositories { Step 2. Add the dependency ``` dependencies { - implementation 'com.github.anastaciocintra:escpos-coffee:4.0.2' + implementation 'com.github.anastaciocintra:escpos-coffee:4.0.3' } ``` @@ -85,7 +85,7 @@ Then the jar file will be generated inside the 'target/' folder, just add the ja ## Samples -You can find all samples codes on https://github.com/anastaciocintra/escpos-coffee-samples +You can find all samples codes on [https://github.com/anastaciocintra/escpos-coffee-samples](https://github.com/anastaciocintra/escpos-coffee-samples) ### getstart sample diff --git a/pom.xml b/pom.xml index ef0c814..31b3bbc 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ - 4.0.2 + 4.0.3 UTF-8 UTF-8 1.8 diff --git a/src/main/java/com/github/anastaciocintra/escpos/EscPos.java b/src/main/java/com/github/anastaciocintra/escpos/EscPos.java index 1c6afd3..32bdbfe 100644 --- a/src/main/java/com/github/anastaciocintra/escpos/EscPos.java +++ b/src/main/java/com/github/anastaciocintra/escpos/EscPos.java @@ -379,7 +379,7 @@ public EscPos write(String text) throws UnsupportedEncodingException, IOExceptio */ public EscPos writeLF(Style style, String text) throws UnsupportedEncodingException, IOException { write(style, text); - write(10); + write(LF); return this; } @@ -478,23 +478,17 @@ public EscPos cut(CutMode mode) throws IOException { * @exception IOException if an I/O error occurs. * @exception IllegalArgumentException if nLines out of range 0 to 255 */ - public EscPos feed(Style style, int nLines) throws IOException, IllegalArgumentException { + public EscPos feed(Style style, int nLines) throws IOException, IllegalArgumentException{ if (nLines < 1 || nLines > 255) { throw new IllegalArgumentException("nLines must be between 1 and 255"); } - if(nLines == 1){ + byte[] configBytes = style.getConfigBytes(); + write(configBytes, 0, configBytes.length); + for(int n = 0; n < nLines; n++){ write(LF); - }else { - byte[] configBytes = style.getConfigBytes(); - write(configBytes, 0, configBytes.length); - write(ESC); - write('d'); - write(nLines); } return this; - } - /** * Call feed with default style. * diff --git a/src/main/java/com/github/anastaciocintra/escpos/image/BitonalOrderedDither.java b/src/main/java/com/github/anastaciocintra/escpos/image/BitonalOrderedDither.java index 73a7564..7f9bc7a 100644 --- a/src/main/java/com/github/anastaciocintra/escpos/image/BitonalOrderedDither.java +++ b/src/main/java/com/github/anastaciocintra/escpos/image/BitonalOrderedDither.java @@ -5,7 +5,10 @@ package com.github.anastaciocintra.escpos.image; import static java.lang.Math.round; + +import java.util.HashSet; import java.util.Random; +import java.util.Set; /** * Implements ordered dithering based on a ditherMatrix

@@ -67,8 +70,8 @@ public BitonalOrderedDither(int matrixWidth, int matrixHeight, int thresholdMin, float positionValue = (float)thresholdMin; Random randomCoordinates = new Random(1); - int shuffledX[] = randomCoordinates.ints(0, matrixWidth).distinct().limit(matrixWidth).toArray(); - int shuffledY[] = randomCoordinates.ints(0, matrixHeight).distinct().limit(matrixHeight).toArray(); + int shuffledX[] = shuffle(matrixWidth, randomCoordinates); + int shuffledY[] = shuffle(matrixHeight, randomCoordinates); for(int x = 0; x < matrixWidth; x++){ for(int y = 0; y < matrixHeight; y++){ @@ -77,6 +80,21 @@ public BitonalOrderedDither(int matrixWidth, int matrixHeight, int thresholdMin, } } } + private int[] shuffle(int size,Random random){ + Set set = new HashSet<>(); + int intArray[] = new int[size]; + int i = 0; + while(set.size() < size){ + int val = random.nextInt(size); + if(set.contains(val)){ + continue; + } + set.add(val); + intArray[i++] = val; + } + + return intArray; + } /** * Creates a new BitonalOrderedDither with default values. */