本文整理汇总了Java中org.freehep.graphicsio.ImageConstants类的典型用法代码示例。如果您正苦于以下问题:Java ImageConstants类的具体用法?Java ImageConstants怎么用?Java ImageConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageConstants类属于org.freehep.graphicsio包,在下文中一共展示了ImageConstants类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstance
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
public static ImageExportFileType getInstance(String format) {
format = format.toLowerCase();
if (format.equals(ImageConstants.GIF.toLowerCase()))
return exportFileType("org.freehep.graphicsio.gif.GIFExportFileType");
if (format.equals(ImageConstants.PNG.toLowerCase()))
return exportFileType("org.freehep.graphicsio.png.PNGExportFileType");
if (format.equals(ImageConstants.JPG.toLowerCase()))
return exportFileType("org.freehep.graphicsio.jpg.JPGExportFileType");
if (format.equals(ImageConstants.RAW.toLowerCase()))
return exportFileType("org.freehep.graphicsio.raw.RawExportFileType");
if (format.equals(ImageConstants.BMP.toLowerCase()))
return exportFileType("org.freehep.graphicsio.bmp.BMPExportFileType");
if (format.equals(ImageConstants.WBMP.toLowerCase()))
return exportFileType("org.freehep.graphicsio.wbmp.WBMPExportFileType");
return null;
}
示例2: getFilterName
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
/**
* returns the decode-format for an image -format
*
* @param encode {@link ImageConstants#ZLIB} or {@link ImageConstants#JPG}
* @return {@link #decodeFilters(String[])}
*/
private PDFName[] getFilterName(String encode) {
if (ImageConstants.ZLIB.equals(encode)) {
return decodeFilters(new String[] {
ImageConstants.ENCODING_FLATE,
ImageConstants.ENCODING_ASCII85});
}
if (ImageConstants.JPG.equals(encode)) {
return decodeFilters(new String[] {
ImageConstants.ENCODING_DCT,
ImageConstants.ENCODING_ASCII85});
}
throw new IllegalArgumentException("unknown image encoding " + encode + " for PDFStream");
}
示例3: exportToSVG
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
public static void exportToSVG(OutputStream outputStream, PlanComponent planComponent) throws IOException
{
List<Selectable> homeItems = planComponent.getPaintedItems();
Rectangle2D svgItemBounds = planComponent.getItemsBounds(null, homeItems);
if (svgItemBounds == null)
{
svgItemBounds = new Rectangle2D.Float();
}
float svgScale = 1f;
float extraMargin = planComponent.getStrokeWidthExtraMargin(homeItems, PaintMode.EXPORT);
Dimension imageSize = new Dimension((int) Math.ceil(svgItemBounds.getWidth() * svgScale + 2 * extraMargin),
(int) Math.ceil(svgItemBounds.getHeight() * svgScale + 2 * extraMargin));
SVGGraphics2D exportG2D = new SVGGraphics2D(outputStream, imageSize)
{
@Override
public void writeHeader() throws IOException
{
// Use English locale to avoid wrong encoding when localized dates contain accentuated letters
Locale defaultLocale = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
super.writeHeader();
Locale.setDefault(defaultLocale);
}
};
UserProperties properties = new UserProperties();
properties.setProperty(SVGGraphics2D.STYLABLE, true);
properties.setProperty(SVGGraphics2D.WRITE_IMAGES_AS, ImageConstants.PNG);
properties.setProperty(SVGGraphics2D.TITLE,
planComponent.home.getName() != null ? planComponent.home.getName() : "");
properties.setProperty(SVGGraphics2D.FOR, System.getProperty("user.name", ""));
exportG2D.setProperties(properties);
exportG2D.startExport();
exportG2D.translate(-svgItemBounds.getMinX() + extraMargin, -svgItemBounds.getMinY() + extraMargin);
planComponent.checkCurrentThreadIsntInterrupted(PaintMode.EXPORT);
planComponent.paintContent(exportG2D, svgScale, PaintMode.EXPORT);
exportG2D.endExport();
}
示例4: ImageSizePanel
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
public ImageSizePanel(Properties user, String rootKey) {
super("Image Size");
key = rootKey + "." + ImageConstants.IMAGE_SIZE;
UserProperties options = new UserProperties(user);
initialDimension = options.getPropertyDimension(key);
imageSizeCombo = new JComboBox(imageSizeList);
add(TableLayout.LEFT, new JLabel("Preset Sizes"));
add(TableLayout.RIGHT, imageSizeCombo);
add(TableLayout.LEFT, new JLabel("Width"));
imageWidth = new JFormattedTextField(new TextFieldFormatter());
imageWidth.setColumns(10);
add(TableLayout.RIGHT, imageWidth);
add(TableLayout.LEFT, new JLabel("Height"));
imageHeight = new JFormattedTextField(new TextFieldFormatter());
imageHeight.setColumns(10);
add(TableLayout.RIGHT, imageHeight);
imageSizeCombo.addItemListener(new ComboListener());
imageWidth.addActionListener(new TextFieldListener());
imageHeight.addActionListener(new TextFieldListener());
// now set the initial values
imageWidth.setValue(new Integer(initialDimension.width));
imageHeight.setValue(new Integer(initialDimension.height));
// trigger the changes
new TextFieldListener().actionPerformed(null);
new ComboListener().itemStateChanged(null);
}
示例5: ImagePanel
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
public ImagePanel(Properties options, String rootKey, String[] formats) {
super("Images");
add(TableLayout.FULL, new JLabel("Write Images as"));
ButtonGroup group = new ButtonGroup();
OptionRadioButton imageType[] = new OptionRadioButton[formats.length];
for (int i = 0; i < formats.length; i++) {
imageType[i] = new OptionRadioButton(options, rootKey + "."
+ ImageConstants.WRITE_IMAGES_AS, formats[i]);
add(TableLayout.FULL, imageType[i]);
group.add(imageType[i]);
// add(TableLayout.RIGHT, new OptionTextField(options,
// rootKey+"."+keys[i], 40));
}
}
示例6: ImageTypePanel
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
public ImageTypePanel(Properties user, String rootKey, String[] types) {
super("Image Type");
key = rootKey + "." + ImageConstants.WRITE_IMAGES_AS;
UserProperties options = new UserProperties(user);
initialType = options.getProperty(key);
imageTypeCombo = new OptionComboBox(options, key, types);
// FREEHEP-575
imageTypeCombo.setSelectedItem(initialType);
add(TableLayout.LEFT, new JLabel("Include Images as "));
add(TableLayout.RIGHT, imageTypeCombo);
}
示例7: ImageBytes
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
/**
* Encodes the passed image
*
* @param image image to convert
* @param bkg background color
* @param format format could be {@link ImageConstants#ZLIB} or {@link ImageConstants#JPEG}
* @param colorModel e.g. {@link org.freehep.graphicsio.ImageConstants#COLOR_MODEL_RGB}
* @throws IOException thrown by {@link org.freehep.graphicsio.ImageGraphics2D#toByteArray(java.awt.image.RenderedImage, String, String, java.util.Properties)}
*/
public ImageBytes(RenderedImage image, Color bkg, String format, String colorModel) throws IOException {
// ZLIB encoding, transparent images allways require ZLIB
if (ImageConstants.ZLIB.equals(format) || (image.getColorModel().hasAlpha() && (bkg == null))) {
bytes = toZLIB(image, bkg, colorModel);
this.format = ImageConstants.ZLIB;
}
// JPG encoding
else if (ImageConstants.JPEG.equals(format)) {
bytes = toJPG(image);
this.format = ImageConstants.JPG;
} else {
// calculate both byte arrays
byte[] jpgBytes = toJPG(image);
byte[] zlibBytes = toZLIB(image, bkg, colorModel);
// compare sizes to determine smalles format
if (jpgBytes.length < 0.5 * zlibBytes.length) {
bytes = jpgBytes;
this.format = ImageConstants.JPG;
} else {
bytes = zlibBytes;
this.format = ImageConstants.ZLIB;
}
}
}
示例8: toJPG
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
/**
* Creates the JPG bytes for PDF images
*
* @param image image to convert
* @return bytes
* @throws IOException thrown by {@link org.freehep.graphicsio.ImageGraphics2D#toByteArray(java.awt.image.RenderedImage, String, String, java.util.Properties)}
*/
private byte[] toJPG(RenderedImage image) throws IOException {
return ImageGraphics2D.toByteArray(
image,
ImageConstants.JPG,
ImageConstants.ENCODING_ASCII85,
null);
}
示例9: imageMask
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
public void imageMask(RenderedImage image, String encode)
throws IOException {
ImageBytes bytes = new ImageBytes(image, null, encode, ImageConstants.COLOR_MODEL_A);
entry("Width", image.getWidth());
entry("Height", image.getHeight());
entry("BitsPerComponent", 8);
entry("ColorSpace", pdf.name("DeviceGray"));
entry("Filter", getFilterName(bytes.getFormat()));
write(bytes.getBytes());
}
示例10: createOptionPanel
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
public JPanel createOptionPanel(Properties user) {
UserProperties options = new UserProperties(user, PSGraphics2D
.getDefaultProperties());
preview = new OptionPanel("Preview Image");
previewCheckBox = new OptionCheckBox(options, PSGraphics2D.PREVIEW,
"Include preview");
preview.add(TableLayout.FULL, previewCheckBox);
final JLabel previewLabel = new JLabel("Bits per sample");
preview.add(TableLayout.LEFT, previewLabel);
previewCheckBox.enables(previewLabel);
final OptionComboBox previewComboBox = new OptionComboBox(options,
PSGraphics2D.PREVIEW_BITS, bitsList);
preview.add(TableLayout.RIGHT, previewComboBox);
previewCheckBox.enables(previewComboBox);
preview.setVisible(false);
// rootKeys for FontProperties
String rootKey = PSGraphics2D.class.getName();
String abstractRootKey = AbstractVectorGraphicsIO.class.getName();
JPanel infoPanel = new InfoPanel(options, rootKey, new String[] {
InfoConstants.FOR, InfoConstants.TITLE });
// TableLayout.LEFT Panel
JPanel leftPanel = new OptionPanel();
leftPanel
.add(TableLayout.COLUMN, new PageLayoutPanel(options, rootKey));
leftPanel
.add(TableLayout.COLUMN, new PageMarginPanel(options, rootKey));
leftPanel.add(TableLayout.COLUMN_FILL, new JLabel());
// TableLayout.RIGHT Panel
JPanel rightPanel = new OptionPanel();
rightPanel.add(TableLayout.COLUMN, new BackgroundPanel(options,
rootKey, false));
rightPanel.add(TableLayout.COLUMN, preview);
rightPanel.add(TableLayout.COLUMN, new ImageTypePanel(options, rootKey,
new String[] { ImageConstants.SMALLEST, ImageConstants.ZLIB,
ImageConstants.JPG }));
rightPanel.add(TableLayout.COLUMN, new FontPanel(options, rootKey,
abstractRootKey));
rightPanel.add(TableLayout.COLUMN_FILL, new JLabel());
// Make the full panel.
OptionPanel optionsPanel = new OptionPanel();
optionsPanel.add("0 0 [5 5 5 5] wt", leftPanel);
optionsPanel.add("1 0 [5 5 5 5] wt", rightPanel);
optionsPanel.add("0 1 2 1 [5 5 5 5] wt", infoPanel);
optionsPanel.add(TableLayout.COLUMN_FILL, new JLabel());
return optionsPanel;
}
示例11: createOptionPanel
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
public JPanel createOptionPanel(Properties user) {
UserProperties options = new UserProperties(user, SVGGraphics2D
.getDefaultProperties());
String rootKey = SVGGraphics2D.class.getName();
String abstractRootKey = AbstractVectorGraphicsIO.class.getName();
OptionPanel imageSize = new ImageSizePanel(options, rootKey);
OptionPanel format = new OptionPanel("Format");
format.add(TableLayout.LEFT, new JLabel("SVG Version"));
format.add(TableLayout.RIGHT, new OptionComboBox(options,
SVGGraphics2D.VERSION, versionList));
compress = new OptionCheckBox(options, SVGGraphics2D.COMPRESS,
"Compress");
format.add(TableLayout.FULL, compress);
format.add(TableLayout.FULL, new OptionCheckBox(options,
SVGGraphics2D.STYLABLE, "Stylable"));
OptionPanel imageExport = new OptionPanel("Embed / Export Images");
OptionCheckBox exportImages = new OptionCheckBox(options,
SVGGraphics2D.EXPORT_IMAGES, "Export");
imageExport.add(TableLayout.FULL, exportImages);
JLabel exportSuffixLabel = new JLabel("Image Suffix");
imageExport.add(TableLayout.LEFT, exportSuffixLabel);
exportImages.enables(exportSuffixLabel);
final OptionTextField exportSuffix = new OptionTextField(options,
SVGGraphics2D.EXPORT_SUFFIX, 20);
imageExport.add(TableLayout.RIGHT, exportSuffix);
exportImages.enables(exportSuffix);
InfoPanel infoPanel = new InfoPanel(options, rootKey, new String[] {
InfoConstants.CREATOR, InfoConstants.TITLE, });
// TableLayout.LEFT Panel
JPanel leftPanel = new OptionPanel();
leftPanel.add(TableLayout.COLUMN, imageSize);
leftPanel.add(TableLayout.COLUMN, format);
leftPanel.add(TableLayout.COLUMN_FILL, new JLabel());
// TableLayout.RIGHT Panel
JPanel rightPanel = new OptionPanel();
rightPanel.add(TableLayout.COLUMN, new BackgroundPanel(options,
rootKey, true));
rightPanel.add(TableLayout.COLUMN, imageExport);
rightPanel.add(TableLayout.COLUMN, new ImageTypePanel(options, rootKey,
new String[] { ImageConstants.SMALLEST, ImageConstants.PNG,
ImageConstants.JPG }));
rightPanel.add(TableLayout.COLUMN, new FontPanel(options, null,
abstractRootKey));
rightPanel.add(TableLayout.COLUMN_FILL, new JLabel());
// Make the full panel.
OptionPanel panel = new OptionPanel();
panel.add("0 0 [5 5 5 5] wt", leftPanel);
panel.add("1 0 [5 5 5 5] wt", rightPanel);
panel.add("0 1 2 1 [5 5 5 5] wt", infoPanel);
panel.add(TableLayout.COLUMN_FILL, new JLabel());
return panel;
}
示例12: createOptionPanel
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
public JPanel createOptionPanel(Properties user) {
UserProperties options = new UserProperties(user, PDFGraphics2D
.getDefaultProperties());
OptionPanel format = new OptionPanel("Format");
OptionComboBox version = new OptionComboBox(options,
PDFGraphics2D.VERSION, versionList);
format.add(TableLayout.LEFT, new JLabel("PDF Version"));
format.add(TableLayout.RIGHT, version);
format.add(TableLayout.FULL, new OptionCheckBox(options,
PDFGraphics2D.COMPRESS, "Compress"));
JPanel preview = new OptionPanel("Preview");
JCheckBox thumbnails = new OptionCheckBox(options,
PDFGraphics2D.THUMBNAILS, "Include Thumbnail");
thumbnails.setToolTipText("Thumbnails are automatically generated by "
+ "Acrobat Reader 5");
preview.add(TableLayout.FULL, thumbnails);
version.selects(PDFGraphics2D.VERSION4, thumbnails);
// rootKeys for FontProperties
String rootKey = PDFGraphics2D.class.getName();
String abstractRootKey = AbstractVectorGraphicsIO.class.getName();
JPanel infoPanel = new InfoPanel(options, rootKey, new String[] {
InfoConstants.AUTHOR, InfoConstants.TITLE,
InfoConstants.SUBJECT, InfoConstants.KEYWORDS });
// TableLayout.LEFT Panel
JPanel leftPanel = new OptionPanel();
leftPanel
.add(TableLayout.COLUMN, new PageLayoutPanel(options, rootKey));
leftPanel
.add(TableLayout.COLUMN, new PageMarginPanel(options, rootKey));
leftPanel.add(TableLayout.COLUMN_FILL, new JLabel());
// TableLayout.RIGHT Panel
JPanel rightPanel = new OptionPanel();
rightPanel.add(TableLayout.COLUMN, format);
rightPanel.add(TableLayout.COLUMN, preview);
rightPanel.add(TableLayout.COLUMN, new BackgroundPanel(options,
rootKey, true));
rightPanel.add(TableLayout.COLUMN, new ImageTypePanel(options, rootKey,
new String[] { ImageConstants.SMALLEST, ImageConstants.ZLIB,
ImageConstants.JPG }));
rightPanel.add(TableLayout.COLUMN, new FontPanel(options, rootKey,
abstractRootKey));
rightPanel.add(TableLayout.COLUMN_FILL, new JLabel());
// Make the full panel.
OptionPanel optionsPanel = new OptionPanel();
optionsPanel.add("0 0 [5 5 5 5] wt", leftPanel);
optionsPanel.add("1 0 [5 5 5 5] wt", rightPanel);
optionsPanel.add("0 1 2 1 [5 5 5 5] wt", infoPanel);
optionsPanel.add(TableLayout.COLUMN_FILL, new JLabel());
return optionsPanel;
}
示例13: inlineImage
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
/**
* Inline Image convenience function (see Table 4.39 and 4.40). Ouputs the
* data of the image using "DeviceRGB" colorspace, and the requested
* encoding.
* @param image Image to write
* @param bkg Background color, null for transparent image
* @param encode {@link org.freehep.graphicsio.ImageConstants#ZLIB} or {@link org.freehep.graphicsio.ImageConstants#JPG}
* @throws java.io.IOException thrown by ImageBytes
*/
public void inlineImage(RenderedImage image, Color bkg, String encode)
throws IOException {
ImageBytes bytes = new ImageBytes(image, bkg, ImageConstants.JPG, ImageConstants.COLOR_MODEL_RGB);
println("BI");
imageInfo("Width", image.getWidth());
imageInfo("Height", image.getHeight());
imageInfo("ColorSpace", pdf.name("DeviceRGB"));
imageInfo("BitsPerComponent", 8);
imageInfo("Filter", getFilterName(bytes.getFormat()));
print("ID\n");
write(bytes.getBytes());
println("\nEI");
}
示例14: toZLIB
import org.freehep.graphicsio.ImageConstants; //导入依赖的package包/类
/**
* Creates the ZLIB Bytes for PDF images
*
* @param image image to convert
* @param bkg background color
* @param colorModel e.g. {@link org.freehep.graphicsio.ImageConstants#COLOR_MODEL_RGB}
* @return bytes
* @throws IOException thrown by {@link org.freehep.graphicsio.ImageGraphics2D#toByteArray(java.awt.image.RenderedImage, String, String, java.util.Properties)}
*/
private byte[] toZLIB(RenderedImage image, Color bkg, String colorModel) throws IOException {
return ImageGraphics2D.toByteArray(
image,
ImageConstants.RAW,
ImageConstants.ENCODING_FLATE_ASCII85,
ImageGraphics2D.getRAWProperties(bkg, colorModel));
}