parent
5dc8f476f7
commit
33734a9821
@ -0,0 +1,7 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class Msk1 {
|
||||||
|
public boolean operation(int y, int x, int msk) {
|
||||||
|
return (y % 2 == 0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class Msk2 {
|
||||||
|
public boolean operation(int y, int x, int msk) {
|
||||||
|
return (x % 3 == 0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class Msk3 {
|
||||||
|
public boolean operation(int y, int x, int msk) {
|
||||||
|
return ((x + y) % 3 == 0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class Msk4 {
|
||||||
|
public boolean operation(int y, int x, int msk) {
|
||||||
|
return ((x / 3 + y / 2) % 2 == 0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class Msk5 {
|
||||||
|
public boolean operation(int y, int x, int msk) {
|
||||||
|
return (x * y % 2 + x * y % 3 == 0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class Msk6 {
|
||||||
|
public boolean operation(int y, int x, int msk) {
|
||||||
|
return ((x * y % 2 + x * y % 3) % 2 == 0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class Msk7 {
|
||||||
|
public boolean operation(int y, int x, int msk) {
|
||||||
|
return (((x + y) % 2 + x * y % 3) % 2 == 0);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class MskCommandFactory {
|
||||||
|
public static Command getCommand(int msk) {
|
||||||
|
Command theCommand = null;
|
||||||
|
|
||||||
|
Msk0 msk0 = new Msk0();
|
||||||
|
Msk1 msk1 = new Msk1();
|
||||||
|
Msk2 msk2 = new Msk2();
|
||||||
|
Msk3 msk3 = new Msk3();
|
||||||
|
Msk4 msk4 = new Msk4();
|
||||||
|
Msk5 msk5 = new Msk5();
|
||||||
|
Msk6 msk6 = new Msk6();
|
||||||
|
Msk7 msk7 = new Msk7();
|
||||||
|
|
||||||
|
switch (msk) {
|
||||||
|
case 0:
|
||||||
|
theCommand = new msk0Command(msk0);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
theCommand = new msk1Command(msk1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
theCommand = new msk2Command(msk2);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
theCommand = new msk3Command(msk3);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
theCommand = new msk4Command(msk4);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
theCommand = new msk5Command(msk5);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
theCommand = new msk6Command(msk6);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
theCommand = new msk7Command(msk7);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
return theCommand;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class msk1Command implements Command {
|
||||||
|
private Msk1 theMsk1;
|
||||||
|
|
||||||
|
public msk1Command(Msk1 theMsk1) {
|
||||||
|
this.theMsk1 = theMsk1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean excute(int y, int x, int msk) {
|
||||||
|
return theMsk1.operation(y, x, msk);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class msk2Command implements Command {
|
||||||
|
private Msk2 theMsk2;
|
||||||
|
|
||||||
|
public msk2Command(Msk2 theMsk2) {
|
||||||
|
this.theMsk2 = theMsk2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean excute(int y, int x, int msk) {
|
||||||
|
return theMsk2.operation(y, x, msk);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class msk3Command implements Command {
|
||||||
|
private Msk3 theMsk3;
|
||||||
|
|
||||||
|
public msk3Command(Msk3 theMsk3) {
|
||||||
|
this.theMsk3 = theMsk3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean excute(int y, int x, int msk) {
|
||||||
|
return theMsk3.operation(y, x, msk);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class msk4Command implements Command {
|
||||||
|
private Msk4 theMsk4;
|
||||||
|
|
||||||
|
public msk4Command(Msk4 theMsk4) {
|
||||||
|
this.theMsk4 = theMsk4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean excute(int y, int x, int msk) {
|
||||||
|
return theMsk4.operation(y, x, msk);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class msk5Command implements Command {
|
||||||
|
private Msk5 theMsk5;
|
||||||
|
|
||||||
|
public msk5Command(Msk5 theMsk5) {
|
||||||
|
this.theMsk5 = theMsk5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean excute(int y, int x, int msk) {
|
||||||
|
return theMsk5.operation(y, x, msk);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class msk6Command implements Command {
|
||||||
|
private Msk6 theMsk6;
|
||||||
|
|
||||||
|
public msk6Command(Msk6 theMsk6) {
|
||||||
|
this.theMsk6 = theMsk6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean excute(int y, int x, int msk) {
|
||||||
|
return theMsk6.operation(y, x, msk);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package io.nayuki.qrcodegen;
|
||||||
|
|
||||||
|
public class msk7Command implements Command {
|
||||||
|
private Msk7 theMsk7;
|
||||||
|
|
||||||
|
public msk7Command(Msk7 theMsk7) {
|
||||||
|
this.theMsk7 = theMsk7;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean excute(int y, int x, int msk) {
|
||||||
|
return theMsk7.operation(y, x, msk);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue