Skip to content

Commit

Permalink
Merge pull request #64 from anastaciocintra/4.0.3-SNAPSHOT
Browse files Browse the repository at this point in the history
4.0.3 snapshot
  • Loading branch information
anastaciocintra authored Mar 30, 2021
2 parents 2e6567b + cdd1b48 commit 14616d1
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .version/changeversion.sh
Original file line number Diff line number Diff line change
@@ -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/<revision>$old<\/revision>/<revision>$new<\/revision>/g" {} \;
Expand Down
7 changes: 6 additions & 1 deletion .version/tips.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ go to oss.sonatype.org
promote... wait
release ... wait some hours
test <putting on dependencies>
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Download code and binaries from the [last release of escpos-coffee](https://gith
<dependency>
<groupId>com.github.anastaciocintra</groupId>
<artifactId>escpos-coffee</artifactId>
<version>4.0.2</version>
<version>4.0.3</version>
</dependency>
```

Expand All @@ -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'
}
```

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


<properties>
<revision>4.0.2</revision>
<revision>4.0.3</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
Expand Down
16 changes: 5 additions & 11 deletions src/main/java/com/github/anastaciocintra/escpos/EscPos.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>ditherMatrix</code> <p>
Expand Down Expand Up @@ -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++){
Expand All @@ -77,6 +80,21 @@ public BitonalOrderedDither(int matrixWidth, int matrixHeight, int thresholdMin,
}
}
}
private int[] shuffle(int size,Random random){
Set<Integer> 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.
*/
Expand Down

0 comments on commit 14616d1

Please sign in to comment.