本文整理汇总了Java中org.apache.avalon.framework.configuration.Configuration类的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于org.apache.avalon.framework.configuration包,在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initFopFactoryFromJar
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
public FopFactory initFopFactoryFromJar() throws IOException, SAXException, ConfigurationException {
FopFactory fopFactory = FopFactory.newInstance();
FOURIResolver uriResolver = (FOURIResolver) fopFactory.getURIResolver();
if (context != null) {
uriResolver.setCustomURIResolver(new CustomResolver(context));
} else {
uriResolver.setCustomURIResolver(new CustomResolver());
}
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
Configuration cfg = builder.build(getClass().getResourceAsStream("fop-pdf-thai.xml"));
fopFactory.setUserConfig(cfg);
return fopFactory;
}
示例2: buildFontList
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
/**
* Builds the font list from configuration.
* @param cfg the configuration object
* @param fontResolver a font resolver
* @param listener the font event listener
* @return the list of {@link EmbedFontInfo} objects
* @throws FOPException if an error occurs while processing the configuration
*/
protected List<EmbedFontInfo> buildFontList(Configuration cfg, FontResolver fontResolver,
FontEventListener listener) throws FOPException {
FopFactory factory = userAgent.getFactory();
FontManager fontManager = factory.getFontManager();
if (fontResolver == null) {
//Ensure that we have minimal font resolution capabilities
fontResolver
= FontManager.createMinimalFontResolver
( userAgent.isComplexScriptFeaturesEnabled() );
}
boolean strict = factory.validateUserConfigStrictly();
//Read font configuration
FontInfoConfigurator fontInfoConfigurator
= new FontInfoConfigurator(cfg, fontManager, fontResolver, listener, strict);
List<EmbedFontInfo> fontInfoList = new ArrayList<EmbedFontInfo>();
fontInfoConfigurator.configure(fontInfoList);
return fontInfoList;
}
示例3: buildCfg
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
private static Configuration buildCfg(String type) {
DefaultConfiguration cfg = new DefaultConfiguration("barcode");
//Bar code type
DefaultConfiguration child = new DefaultConfiguration(type);
cfg.addChild(child);
//Human readable text position
DefaultConfiguration attr = new DefaultConfiguration("human-readable");
DefaultConfiguration subAttr = new DefaultConfiguration("placement");
subAttr.setValue("bottom");
attr.addChild(subAttr);
child.addChild(attr);
return cfg;
}
示例4: PostProcessedFoReportOutput
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
/**
*
* @param outStream
* @param outFormat
* @param mimeType
* @param userAgentProps
*/
public PostProcessedFoReportOutput(OutputStream outStream,
FoOutputFormat outFormat,
String mimeType,
Configuration fopConfiguration,
FopUserAgentProperties userAgentProps) {
super(outFormat);
this.foFile = ReportIoUtils.createTempFile("report", ".fo");
this.foReportOutput =
new FoReportOutput(ReportIoUtils.createWriterFromFile(foFile), true, outFormat);
this.outStream = outStream;
this.mimeType = mimeType;
this.fopConfiguration =
fopConfiguration == null ? buildDefaultConfiguration() : fopConfiguration;
this.fopUserAgentProps = userAgentProps;
}
示例5: main
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
try {
String configFile = "examples/fop-eps.xconf";
DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
Configuration c = cfgBuilder.buildFromFile(configFile);
FontInfo fontInfo = PDFDocumentGraphics2DConfigurator.createFontInfo(c, false);
OutputStream out = new FileOutputStream("example_eps.eps");
EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
g2d.setGraphicContext(new GraphicContext());
g2d.setCustomTextHandler(new NativeTextHandler(g2d, fontInfo));
g2d.setupDocument(out, 200, 100);
g2d.setFont(new Font("Arial", Font.PLAIN, 12));
g2d.drawString("Hi there Arial", 50, 50);
g2d.finish();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: configure
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
/**
* Configures a font substitution catalog
*
* @param substitutions font substitutions
* @throws FOPException if something's wrong with the config data
*/
public void configure(FontSubstitutions substitutions) throws FOPException {
Configuration[] substitutionCfgs = cfg.getChildren("substitution");
for (int i = 0; i < substitutionCfgs.length; i++) {
Configuration fromCfg = substitutionCfgs[i].getChild("from", false);
if (fromCfg == null) {
throw new FOPException("'substitution' element without child 'from' element");
}
Configuration toCfg = substitutionCfgs[i].getChild("to", false);
if (fromCfg == null) {
throw new FOPException("'substitution' element without child 'to' element");
}
FontQualifier fromQualifier = getQualfierFromConfiguration(fromCfg);
FontQualifier toQualifier = getQualfierFromConfiguration(toCfg);
FontSubstitution substitution = new FontSubstitution(fromQualifier, toQualifier);
substitutions.add(substitution);
}
}
示例7: createFontsMatcher
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
/**
* Creates a font triplet matcher from a configuration object.
* @param cfg the configuration object
* @param strict true for strict configuraton error handling
* @return the font matcher
* @throws FOPException if an error occurs while building the matcher
*/
public static FontTriplet.Matcher createFontsMatcher(
Configuration cfg, boolean strict) throws FOPException {
List<FontTriplet.Matcher> matcherList = new java.util.ArrayList<FontTriplet.Matcher>();
Configuration[] matches = cfg.getChildren("match");
for (int i = 0; i < matches.length; i++) {
try {
matcherList.add(new FontFamilyRegExFontTripletMatcher(
matches[i].getAttribute("font-family")));
} catch (ConfigurationException ce) {
LogUtil.handleException(log, ce, strict);
continue;
}
}
FontTriplet.Matcher orMatcher = new OrFontTripletMatcher(
matcherList.toArray(new FontTriplet.Matcher[matcherList.size()]));
return orMatcher;
}
示例8: configure
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
/**
* Configures a PDFDocumentGraphics2D instance using an Avalon Configuration object.
* @param graphics the PDFDocumentGraphics2D instance
* @param cfg the configuration
* @param useComplexScriptFeatures true if complex script features enabled
* @throws ConfigurationException if an error occurs while configuring the object
*/
public void configure(PDFDocumentGraphics2D graphics, Configuration cfg,
boolean useComplexScriptFeatures )
throws ConfigurationException {
PDFDocument pdfDoc = graphics.getPDFDocument();
//Filter map
pdfDoc.setFilterMap(
PDFRendererConfigurator.buildFilterMapFromConfiguration(cfg));
//Fonts
try {
FontInfo fontInfo = createFontInfo(cfg, useComplexScriptFeatures);
graphics.setFontInfo(fontInfo);
} catch (FOPException e) {
throw new ConfigurationException("Error while setting up fonts", e);
}
}
示例9: getEffectiveConfiguration
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
/**
* Returns the effective configuration for the transcoder.
* @return the effective configuration
*/
protected Configuration getEffectiveConfiguration() {
Configuration effCfg = this.cfg;
if (effCfg == null) {
//By default, enable font auto-detection if no cfg is given
boolean autoFonts = getAutoFontsDefault();
if (hints.containsKey(KEY_AUTO_FONTS)) {
autoFonts = ((Boolean)hints.get(KEY_AUTO_FONTS)).booleanValue();
}
if (autoFonts) {
DefaultConfiguration c = new DefaultConfiguration("cfg");
DefaultConfiguration fonts = new DefaultConfiguration("fonts");
c.addChild(fonts);
DefaultConfiguration autodetect = new DefaultConfiguration("auto-detect");
fonts.addChild(autodetect);
effCfg = c;
}
}
return effCfg;
}
示例10: configure
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
private void configure(Configuration cfg, PCLRenderingUtil pclUtil) throws FOPException {
String rendering = cfg.getChild("rendering").getValue(null);
if (rendering != null) {
try {
pclUtil.setRenderingMode(PCLRenderingMode.valueOf(rendering));
} catch (IllegalArgumentException e) {
throw new FOPException(
"Valid values for 'rendering' are 'quality', 'speed' and 'bitmap'."
+ " Value found: " + rendering);
}
}
String textRendering = cfg.getChild("text-rendering").getValue(null);
if ("bitmap".equalsIgnoreCase(textRendering)) {
pclUtil.setAllTextAsBitmaps(true);
} else if ("auto".equalsIgnoreCase(textRendering)) {
pclUtil.setAllTextAsBitmaps(false);
} else if (textRendering != null) {
throw new FOPException(
"Valid values for 'text-rendering' are 'auto' and 'bitmap'. Value found: "
+ textRendering);
}
pclUtil.setPJLDisabled(cfg.getChild("disable-pjl").getValueAsBoolean(false));
}
示例11: setupFontInfo
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
/** {@inheritDoc} */
public void setupFontInfo(IFDocumentHandler documentHandler, FontInfo fontInfo)
throws FOPException {
FontManager fontManager = userAgent.getFactory().getFontManager();
final Java2DFontMetrics java2DFontMetrics = new Java2DFontMetrics();
final List fontCollections = new java.util.ArrayList();
fontCollections.add(new Base14FontCollection(java2DFontMetrics));
fontCollections.add(new InstalledFontCollection(java2DFontMetrics));
Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
if (cfg != null) {
FontResolver fontResolver = new DefaultFontResolver(userAgent);
FontEventListener listener = new FontEventAdapter(
userAgent.getEventBroadcaster());
List fontList = buildFontList(cfg, fontResolver, listener);
fontCollections.add(new ConfiguredFontCollection(fontResolver, fontList,
userAgent.isComplexScriptFeaturesEnabled()));
}
fontManager.setup(fontInfo,
(FontCollection[])fontCollections.toArray(
new FontCollection[fontCollections.size()]));
documentHandler.setFontInfo(fontInfo);
}
示例12: configure
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
/**
* Configure the TIFF renderer. Get the configuration to be used for
* compression
* @param renderer tiff renderer
* @throws FOPException fop exception
* {@inheritDoc}
*/
public void configure(Renderer renderer) throws FOPException {
Configuration cfg = super.getRendererConfig(renderer);
if (cfg != null) {
TIFFRenderer tiffRenderer = (TIFFRenderer)renderer;
//set compression
String name = cfg.getChild("compression").getValue(TIFFConstants.COMPRESSION_PACKBITS);
//Some compression formats need a special image format:
tiffRenderer.setBufferedImageType(getBufferedImageTypeFor(name));
if (!"NONE".equalsIgnoreCase(name)) {
tiffRenderer.getWriterParams().setCompressionMethod(name);
}
if (log.isInfoEnabled()) {
log.info("TIFF compression set to " + name);
}
}
super.configure(renderer);
}
示例13: setupFontInfo
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
/** {@inheritDoc} */
public void setupFontInfo(IFDocumentHandler documentHandler, FontInfo fontInfo)
throws FOPException {
final FontManager fontManager = userAgent.getFactory().getFontManager();
final Java2DFontMetrics java2DFontMetrics = new Java2DFontMetrics();
final List fontCollections = new java.util.ArrayList();
fontCollections.add(new Base14FontCollection(java2DFontMetrics));
fontCollections.add(new InstalledFontCollection(java2DFontMetrics));
Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
if (cfg != null) {
FontResolver fontResolver = new DefaultFontResolver(userAgent);
FontEventListener listener = new FontEventAdapter(
userAgent.getEventBroadcaster());
List fontList = buildFontList(cfg, fontResolver, listener);
fontCollections.add(new ConfiguredFontCollection(fontResolver, fontList,
userAgent.isComplexScriptFeaturesEnabled()));
}
fontManager.setup(fontInfo,
(FontCollection[])fontCollections.toArray(
new FontCollection[fontCollections.size()]));
documentHandler.setFontInfo(fontInfo);
}
示例14: configure
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
private void configure(PSRenderingUtil psUtil, Configuration cfg) {
psUtil.setAutoRotateLandscape(
cfg.getChild("auto-rotate-landscape").getValueAsBoolean(false));
Configuration child;
child = cfg.getChild("language-level");
if (child != null) {
psUtil.setLanguageLevel(child.getValueAsInteger(
PSGenerator.DEFAULT_LANGUAGE_LEVEL));
}
child = cfg.getChild("optimize-resources");
if (child != null) {
psUtil.setOptimizeResources(child.getValueAsBoolean(false));
}
child = cfg.getChild("rendering");
if (child != null) {
psUtil.setRenderingMode(PSRenderingMode.valueOf(
child.getValue(psUtil.getRenderingMode().toString())
.toUpperCase(Locale.ENGLISH)));
}
psUtil.setSafeSetPageDevice(
cfg.getChild("safe-set-page-device").getValueAsBoolean(false));
psUtil.setDSCComplianceEnabled(
cfg.getChild("dsc-compliant").getValueAsBoolean(true));
}
示例15: configure
import org.apache.avalon.framework.configuration.Configuration; //导入依赖的package包/类
/**
* Builds a list of EmbedFontInfo objects for use with the setup() method.
*
* @param renderer print renderer
* @throws FOPException if something's wrong with the config data
*/
public void configure(Renderer renderer) throws FOPException {
Configuration cfg = getRendererConfig(renderer);
if (cfg == null) {
log.trace("no configuration found for " + renderer);
return;
}
PrintRenderer printRenderer = (PrintRenderer)renderer;
FontResolver fontResolver = printRenderer.getFontResolver();
FontEventListener listener = new FontEventAdapter(
renderer.getUserAgent().getEventBroadcaster());
List<EmbedFontInfo> embedFontInfoList = buildFontList(cfg, fontResolver, listener);
printRenderer.addFontList(embedFontInfoList);
}