Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparation for 2.0 release hiding svg api for now #28 #41

Merged
merged 1 commit into from
Oct 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,6 @@ QRCode.from(johnSpecial).withCharset("UTF-8").file();

```

#### SVG creation

```java
QRCode.from("www.example.org").svg();
```

**SVG creation is _not_ available on android**

#### Android only

On Android you have a special method `bitmap()` which returns a `android.graphics.Bitmap` without creating a `File` object before, so you can use the generated `android.graphics.Bitmap` immediately inside an `ImageView`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private static SVGGraphics2D toSvgDocument(BitMatrix matrix, MatrixToImageConfig
return svgGraphics;
}

public static void writeToPath(BitMatrix matrix, String format, Path file) throws IOException {
public static void writeToPath(BitMatrix matrix, Path file) throws IOException {
SVGGraphics2D g2 = toSvgDocument(matrix, DEFAULT_CONFIG);
SVGUtils.writeToSVG(file.toFile(), g2.getSVGElement());
}
Expand Down
16 changes: 7 additions & 9 deletions javase/src/main/java/net/glxn/qrgen/javase/QRCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ public static AbstractQRCode from(VCard vcard) {
return new QRCode(vcard.toString());
}

public File svg() {
private File svg() {
File file;
try {
file = createTempSvgFile();
MatrixToSvgWriter.writeToPath(createMatrix(text), imageType.toString(), file.toPath());
MatrixToSvgWriter.writeToPath(createMatrix(text), file.toPath());
} catch (Exception e) {
throw new QRGenerationException("Failed to create QR svg from text due to underlying exception", e);
}

return file;
}

public File svg(String name) {
private File svg(String name) {
File file;
try {
file = createTempSvgFile(name);
MatrixToSvgWriter.writeToPath(createMatrix(text), imageType.toString(), file.toPath());
MatrixToSvgWriter.writeToPath(createMatrix(text), file.toPath());
} catch (Exception e) {
throw new QRGenerationException("Failed to create QR svg from text due to underlying exception", e);
}
Expand Down Expand Up @@ -109,13 +109,11 @@ protected void writeToStream(OutputStream stream) throws IOException, WriterExce
MatrixToImageWriter.writeToStream(createMatrix(text), imageType.toString(), stream);
}

protected File createTempSvgFile() throws IOException {
File file = File.createTempFile("QRCode", ".svg");
file.deleteOnExit();
return file;
private File createTempSvgFile() throws IOException {
return createTempSvgFile("QRCode");
}

protected File createTempSvgFile(String name) throws IOException {
private File createTempSvgFile(String name) throws IOException {
File file = File.createTempFile(name, ".svg");
file.deleteOnExit();
return file;
Expand Down
6 changes: 0 additions & 6 deletions javase/src/test/java/net/glxn/qrgen/javase/QRCodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@

public class QRCodeTest {

@Test
public void shouldGetSvgFromText() throws Exception {
File file = QRCode.from("www.example.org").svg();
Assert.assertNotNull(file);
}

@Test
public void shouldGetFileFromVCardWithDefaults() throws Exception {
VCard johnDoe = new VCard("John Doe")
Expand Down