congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
QRCode
Code IndexAdd Tabnine to your IDE (free)

How to use
QRCode
in
net.glxn.qrgen

Best Java code snippets using net.glxn.qrgen.QRCode (Showing top 11 results out of 315)

origin: primefaces/primefaces

@Override
public void handle(FacesContext context) throws IOException {
  Map<String, String> params = context.getExternalContext().getRequestParameterMap();
  ExternalContext externalContext = context.getExternalContext();
  String sessionKey = params.get(Constants.DYNAMIC_CONTENT_PARAM);
  Map<String, Object> session = externalContext.getSessionMap();
  Map<String, String> barcodeMapping = (Map) session.get(Constants.BARCODE_MAPPING);
  String value = barcodeMapping.get(sessionKey);
  if (value != null) {
    boolean cache = Boolean.parseBoolean(params.get(Constants.DYNAMIC_CONTENT_CACHE_PARAM));
    externalContext.setResponseStatus(200);
    externalContext.setResponseContentType("image/png");
    handleCache(externalContext, cache);
    ErrorCorrectionLevel ecl = ErrorCorrectionLevel.L;
    String errorCorrection = params.get("qrec");
    if (!LangUtils.isValueBlank(errorCorrection)) {
      ecl = ErrorCorrectionLevel.valueOf(errorCorrection);
    }
    QRCode.from(value).to(ImageType.PNG).withErrorCorrection(ecl).withCharset("UTF-8")
          .writeTo(externalContext.getResponseOutputStream());
    externalContext.responseFlushBuffer();
    context.responseComplete();
  }
}
origin: winder/Universal-G-Code-Sender

  !hostAddress.equals("127.0.0.1")){
String url = "http://"+hostAddress+":"+port;
ByteArrayOutputStream bout = QRCode.from(url).to(ImageType.PNG).stream();
out.add(new PendantURLBean(url, bout.toByteArray()));
System.out.println("Listening on: "+url);
origin: pwm-project/pwm

try
  imageBytes = QRCode.from( qrCodeContent )
      .withCharset( PwmConstants.DEFAULT_CHARSET.toString() )
      .withSize( width, height )
      .stream()
      .toByteArray();
origin: net.glxn/qrgen

/**
 * returns a {@link File} representation of the QR code. The file is set to be deleted on exit (i.e. {@link
 * java.io.File#deleteOnExit()}). If you want the file to live beyond the life of the jvm process, you should make a copy.
 *
 * @return qrcode as file
 */
public File file() {
  File file;
  try {
    file = createTempFile();
    MatrixToImageWriter.writeToPath(createMatrix(), imageType.toString(), file.toPath());
  } catch (Exception e) {
    throw new QRGenerationException("Failed to create QR image from text due to underlying exception", e);
  }
  return file;
}
origin: net.glxn/qrgen

/**
 * Create a QR code from the given text.    <br/><br/>
 * <p/>
 * 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 2950
 * characters.<br/><br/>
 * <p/>
 * The QRCode will have the following defaults:     <br/> {size: 100x100}<br/>{imageType:PNG}  <br/><br/>
 * <p/>
 * Both size and imageType can be overridden:   <br/> Image type override is done by calling {@link
 * QRCode#to(net.glxn.qrgen.image.ImageType)} e.g. QRCode.from("hello world").to(JPG) <br/> Size override is done by calling
 * {@link QRCode#withSize} e.g. QRCode.from("hello world").to(JPG).withSize(125, 125)  <br/>
 *
 * @param text the text to encode to a new QRCode, this may fail if the text is too large. <br/>
 * @return the QRCode object    <br/>
 */
public static QRCode from(String text) {
  return new QRCode(text);
}
origin: net.glxn/qrgen

/**
 * Overrides the default charset by supplying a {@link com.google.zxing.EncodeHintType#CHARACTER_SET} hint to {@link
 * com.google.zxing.qrcode.QRCodeWriter#encode}
 *
 * @return the current QRCode object
 */
public QRCode withCharset(String charset) {
  return withHint(EncodeHintType.CHARACTER_SET, charset);
}
origin: net.glxn/qrgen

private void writeToStream(OutputStream stream) throws IOException, WriterException {
  MatrixToImageWriter.writeToStream(createMatrix(), imageType.toString(), stream);
}
origin: net.glxn/qrgen

/**
 * returns a {@link File} representation of the QR code. The file has the given name. The file is set to be deleted on exit
 * (i.e. {@link java.io.File#deleteOnExit()}). If you want the file to live beyond the life of the jvm process, you should
 * make a copy.
 *
 * @param name name of the created file
 * @return qrcode as file
 * @see #file()
 */
public File file(String name) {
  File file;
  try {
    file = createTempFile(name);
    MatrixToImageWriter.writeToPath(createMatrix(), imageType.toString(), file.toPath());
  } catch (Exception e) {
    throw new QRGenerationException("Failed to create QR image from text due to underlying exception", e);
  }
  return file;
}
origin: net.glxn/qrgen

/**
 * Creates a a QR Code from the given {@link VCard}.
 * <p/>
 * The QRCode will have the following defaults:     <br/> {size: 100x100}<br/>{imageType:PNG}  <br/><br/>
 *
 * @param vcard the vcard to encode as QRCode
 * @return the QRCode object
 */
public static QRCode from(VCard vcard) {
  return new QRCode(vcard.toString());
}
origin: net.glxn/qrgen

/**
 * Overrides the default error correction by supplying a {@link com.google.zxing.EncodeHintType#ERROR_CORRECTION} hint to
 * {@link com.google.zxing.qrcode.QRCodeWriter#encode}
 *
 * @return the current QRCode object
 */
public QRCode withErrorCorrection(ErrorCorrectionLevel level) {
  return withHint(EncodeHintType.ERROR_CORRECTION, level);
}
origin: org.primefaces/primefaces

public void handle(FacesContext context) throws IOException {
  Map<String, String> params = context.getExternalContext().getRequestParameterMap();
  ExternalContext externalContext = context.getExternalContext();
  String sessionKey = (String) params.get(Constants.DYNAMIC_CONTENT_PARAM);
  Map<String, Object> session = externalContext.getSessionMap();
  Map<String, String> barcodeMapping = (Map) session.get(Constants.BARCODE_MAPPING);
  String value = barcodeMapping.get(sessionKey);
  if (value != null) {
    boolean cache = Boolean.valueOf(params.get(Constants.DYNAMIC_CONTENT_CACHE_PARAM));
    externalContext.setResponseStatus(200);
    externalContext.setResponseContentType("image/png");
    handleCache(externalContext, cache);
    ErrorCorrectionLevel ecl = ErrorCorrectionLevel.L;
    String errorCorrection = params.get("qrec");
    if (!ComponentUtils.isValueBlank(errorCorrection)) {
      ecl = ErrorCorrectionLevel.valueOf(errorCorrection);
    }
    QRCode.from(value).to(ImageType.PNG).withErrorCorrection(ecl).withCharset("UTF-8")
          .writeTo(externalContext.getResponseOutputStream());
    externalContext.responseFlushBuffer();
    context.responseComplete();
  }
}
net.glxn.qrgenQRCode

Javadoc

QRCode generator. This is a simple class that is built on top of ZXING

Please take a look at their framework, as it has a lot of features.
This small project is just a wrapper that gives a convenient interface to work with.

Start here: QRCode#from(String) (e.g QRCode.from("hello"))

Most used methods

  • from
    Creates a a QR Code from the given VCard. The QRCode will have the following defaults: {size: 100x1
  • stream
    returns a ByteArrayOutputStream representation of the QR code
  • to
    Overrides the imageType from its default ImageType#PNG
  • withCharset
    Overrides the default charset by supplying a com.google.zxing.EncodeHintType#CHARACTER_SET hint to c
  • <init>
  • createMatrix
  • createTempFile
  • withErrorCorrection
    Overrides the default error correction by supplying a com.google.zxing.EncodeHintType#ERROR_CORRECTI
  • withHint
    Sets hint to com.google.zxing.qrcode.QRCodeWriter#encode
  • withSize
    Overrides the size of the qr from its default 125x125
  • writeTo
    writes a representation of the QR code to the supplied OutputStream
  • writeToStream
  • writeTo,
  • writeToStream

Popular in Java

  • Making http requests using okhttp
  • getResourceAsStream (ClassLoader)
  • notifyDataSetChanged (ArrayAdapter)
  • getExternalFilesDir (Context)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • JCheckBox (javax.swing)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now