Skip to content

Commit 86d6e47

Browse files
committed
remove svg support
close #69
1 parent cc005d4 commit 86d6e47

5 files changed

Lines changed: 42 additions & 131 deletions

File tree

javase/pom.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<parent>
@@ -80,10 +81,6 @@
8081
<artifactId>core</artifactId>
8182
<version>${project.version}</version>
8283
</dependency>
83-
<dependency>
84-
<groupId>org.jfree</groupId>
85-
<artifactId>jfreesvg</artifactId>
86-
</dependency>
8784
<dependency>
8885
<groupId>junit</groupId>
8986
<artifactId>junit</artifactId>

javase/src/main/java/net/glxn/qrgen/javase/MatrixToSvgWriter.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

javase/src/main/java/net/glxn/qrgen/javase/QRCode.java

Lines changed: 38 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.google.zxing.client.j2se.MatrixToImageWriter;
77
import com.google.zxing.qrcode.QRCodeWriter;
88
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
9-
109
import net.glxn.qrgen.core.AbstractQRCode;
1110
import net.glxn.qrgen.core.exception.QRGenerationException;
1211
import net.glxn.qrgen.core.image.ImageType;
@@ -28,6 +27,40 @@ protected QRCode(String text) {
2827
qrWriter = new QRCodeWriter();
2928
}
3029

30+
/**
31+
* Create a QR code from the given text. <br><br>
32+
* <p>
33+
* There is a size limitation to how much you can put into a QR code. This has been tested to work with up to a length of
34+
* 2950
35+
* characters.<br><br>
36+
* </p>
37+
* <p>
38+
* The QRCode will have the following defaults: <br> {size: 100x100}<br>{imageType:PNG} <br><br>
39+
* </p>
40+
* Both size and imageType can be overridden: <br> Image type override is done by calling {@link
41+
* QRCode#to(ImageType)} e.g. QRCode.from("hello world").to(JPG) <br> Size override is done
42+
* by calling
43+
* {@link QRCode#withSize} e.g. QRCode.from("hello world").to(JPG).withSize(125, 125) <br>
44+
*
45+
* @param text the text to encode to a new QRCode, this may fail if the text is too large. <br>
46+
* @return the QRCode object <br>
47+
*/
48+
public static QRCode from(String text) {
49+
return new QRCode(text);
50+
}
51+
52+
/**
53+
* Creates a a QR Code from the given {@link VCard}.
54+
* <p>
55+
* The QRCode will have the following defaults: <br> {size: 100x100}<br>{imageType:PNG} <br><br>
56+
* </p>
57+
* @param vcard the vcard to encode as QRCode
58+
* @return the QRCode object
59+
*/
60+
public static QRCode from(VCard vcard) {
61+
return new QRCode(vcard.toString());
62+
}
63+
3164
/**
3265
* Overrides the imageType from its default {@link net.glxn.qrgen.core.image.ImageType#PNG}
3366
*
@@ -56,6 +89,7 @@ public QRCode withSize(int width, int height) {
5689
* Overrides the default charset by supplying a {@link com.google.zxing.EncodeHintType#CHARACTER_SET} hint to {@link
5790
* com.google.zxing.qrcode.QRCodeWriter#encode}
5891
*
92+
* @param charset the charset as string, e.g. UTF-8
5993
* @return the current QRCode object
6094
*/
6195
public QRCode withCharset(String charset) {
@@ -66,6 +100,7 @@ public QRCode withCharset(String charset) {
66100
* Overrides the default error correction by supplying a {@link com.google.zxing.EncodeHintType#ERROR_CORRECTION} hint to
67101
* {@link com.google.zxing.qrcode.QRCodeWriter#encode}
68102
*
103+
* @param level the error correction level to use by {@link com.google.zxing.qrcode.QRCodeWriter#encode}
69104
* @return the current QRCode object
70105
*/
71106
public QRCode withErrorCorrection(ErrorCorrectionLevel level) {
@@ -75,70 +110,15 @@ public QRCode withErrorCorrection(ErrorCorrectionLevel level) {
75110
/**
76111
* Sets hint to {@link com.google.zxing.qrcode.QRCodeWriter#encode}
77112
*
113+
* @param hintType the hintType to set
114+
* @param value the concrete value to set
78115
* @return the current QRCode object
79116
*/
80117
public QRCode withHint(EncodeHintType hintType, Object value) {
81118
hints.put(hintType, value);
82119
return this;
83120
}
84121

85-
/**
86-
* Create a QR code from the given text. <br/><br/>
87-
* <p/>
88-
* There is a size limitation to how much you can put into a QR code. This has been tested to work with up to a length of
89-
* 2950
90-
* characters.<br/><br/>
91-
* <p/>
92-
* The QRCode will have the following defaults: <br/> {size: 100x100}<br/>{imageType:PNG} <br/><br/>
93-
* <p/>
94-
* Both size and imageType can be overridden: <br/> Image type override is done by calling {@link
95-
* AbstractQRCode#to(net.glxn.qrgen.core.image.ImageType)} e.g. QRCode.from("hello world").to(JPG) <br/> Size override is done
96-
* by calling
97-
* {@link AbstractQRCode#withSize} e.g. QRCode.from("hello world").to(JPG).withSize(125, 125) <br/>
98-
*
99-
* @param text the text to encode to a new QRCode, this may fail if the text is too large. <br/>
100-
* @return the QRCode object <br/>
101-
*/
102-
public static QRCode from(String text) {
103-
return new QRCode(text);
104-
}
105-
106-
/**
107-
* Creates a a QR Code from the given {@link VCard}.
108-
* <p/>
109-
* The QRCode will have the following defaults: <br/> {size: 100x100}<br/>{imageType:PNG} <br/><br/>
110-
*
111-
* @param vcard the vcard to encode as QRCode
112-
* @return the QRCode object
113-
*/
114-
public static QRCode from(VCard vcard) {
115-
return new QRCode(vcard.toString());
116-
}
117-
118-
public File svg() {
119-
File file;
120-
try {
121-
file = createTempSvgFile();
122-
MatrixToSvgWriter.writeToPath(createMatrix(text), file.toPath(), matrixToImageConfig);
123-
} catch (Exception e) {
124-
throw new QRGenerationException("Failed to create QR svg from text due to underlying exception", e);
125-
}
126-
127-
return file;
128-
}
129-
130-
public File svg(String name) {
131-
File file;
132-
try {
133-
file = createTempSvgFile(name);
134-
MatrixToSvgWriter.writeToPath(createMatrix(text), file.toPath(), matrixToImageConfig);
135-
} catch (Exception e) {
136-
throw new QRGenerationException("Failed to create QR svg from text due to underlying exception", e);
137-
}
138-
139-
return file;
140-
}
141-
142122
@Override
143123
public File file() {
144124
File file;

javase/src/test/java/net/glxn/qrgen/javase/QRCodeTest.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
import com.google.zxing.WriterException;
88
import com.google.zxing.common.BitMatrix;
99
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
10-
1110
import net.glxn.qrgen.core.exception.QRGenerationException;
1211
import net.glxn.qrgen.core.image.ImageType;
1312
import net.glxn.qrgen.core.scheme.VCard;
14-
1513
import org.junit.Assert;
1614
import org.junit.Test;
1715

@@ -24,24 +22,6 @@
2422

2523
public class QRCodeTest {
2624

27-
@Test
28-
public void shouldGetSvgFromText() throws Exception {
29-
File file = QRCode.from("www.example.org").svg();
30-
Assert.assertNotNull(file);
31-
}
32-
33-
@Test
34-
public void shouldGetSvgWithSizeFromText() throws Exception {
35-
File file = QRCode.from("www.example.com").withSize(250, 250).svg();
36-
Assert.assertNotNull(file);
37-
}
38-
39-
@Test
40-
public void shouldGetSvgWithSizeAndColorFromText() {
41-
File file = QRCode.from("www.example.com").withSize(250, 250).withColor(30, 90).svg();
42-
Assert.assertNotNull(file);
43-
}
44-
4525
@Test
4626
public void shouldGetFileFromVCardWithDefaults() throws Exception {
4727
VCard johnDoe = new VCard("John Doe")

pom.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<parent>
@@ -44,7 +45,6 @@
4445

4546
<properties>
4647
<zxing.version>3.1.0</zxing.version>
47-
<jfree.svg.version>2.1</jfree.svg.version>
4848
<junit.version>4.8.2</junit.version>
4949
<robolectric.version>2.2</robolectric.version>
5050
<fest-android.version>1.0.7</fest-android.version>
@@ -156,11 +156,6 @@
156156
<artifactId>core</artifactId>
157157
<version>${zxing.version}</version>
158158
</dependency>
159-
<dependency>
160-
<groupId>org.jfree</groupId>
161-
<artifactId>jfreesvg</artifactId>
162-
<version>${jfree.svg.version}</version>
163-
</dependency>
164159
<dependency>
165160
<groupId>com.google.android</groupId>
166161
<artifactId>android</artifactId>

0 commit comments

Comments
 (0)