org.krysalis.barcode4j.image.loader.ImageLoaderFactoryBarcode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of barcode4j-xgc Show documentation
Show all versions of barcode4j-xgc Show documentation
This module contains SPI implementation for Apache XML-Graphics barcode images
The newest version!
/*
* Copyright 2008,2010 Jeremias Maerki.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* $Id: ImageLoaderFactoryBarcode.java,v 1.1 2010-11-18 09:34:22 jmaerki Exp $ */
package org.krysalis.barcode4j.image.loader;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.AbstractImageLoaderFactory;
import org.apache.xmlgraphics.image.loader.spi.ImageLoader;
/**
* Factory class for the ImageLoader for barcodes.
*/
public class ImageLoaderFactoryBarcode extends AbstractImageLoaderFactory {
/** MIME type for Barcode4J's barcode XML */
public static final String MIME_TYPE = "application/x-barcode4j+xml";
/** {@inheritDoc} */
@Override
public String[] getSupportedMIMETypes() {
return new String[] {MIME_TYPE};
}
/** {@inheritDoc} */
@Override
public ImageFlavor[] getSupportedFlavors(String mime) {
return new ImageFlavor[] {ImageBarcode.BARCODE_IMAGE_FLAVOR};
}
/** {@inheritDoc} */
@Override
public ImageLoader newImageLoader(ImageFlavor targetFlavor) {
return new ImageLoaderBarcode(targetFlavor);
}
/** {@inheritDoc} */
@Override
public boolean isAvailable() {
try {
Class.forName("org.krysalis.barcode4j.BarcodeGenerator"); // todo: get rid of this as it won't work with GraalVM native image
return true;
} catch (Exception e) {
//ignore
}
return false;
}
}