Package org.freehep.util

Examples of org.freehep.util.UserProperties


            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);
     
View Full Code Here


    private Paint currentPaint;

    private Font currentFont;

    public AbstractVectorGraphics() {
        properties = new UserProperties();
        creator = "FreeHEP Graphics2D Driver";
        isDeviceIndependent = false;
        cachedShape = new SymbolShape();
        colorMode = PrintColor.COLOR;
View Full Code Here

            return;
        properties.setProperties(newProperties);
    }

    protected void initProperties(Properties defaults) {
        properties = new UserProperties();
        properties.setProperties(defaults);
    }
View Full Code Here

    public static final String COMPRESS_QUALITY = ".CompressQuality";

    private static final Map /* UserProperties */defaultProperties = new HashMap();

    public static Properties getDefaultProperties(String format) {
        UserProperties properties = (UserProperties) defaultProperties
                .get(format);
        if (properties == null) {
            properties = new UserProperties();
            defaultProperties.put(format, properties);

            String formatKey = rootKey + "." + format;

            // set our parameters
            if (canWriteTransparent(format)) {
                properties.setProperty(formatKey + TRANSPARENT, true);
                properties.setProperty(formatKey + BACKGROUND, false);
                properties
                        .setProperty(formatKey + BACKGROUND_COLOR, Color.GRAY);
            } else {
                properties.setProperty(formatKey + BACKGROUND, false);
                properties
                        .setProperty(formatKey + BACKGROUND_COLOR, Color.GRAY);
            }

            // set our parameters
            properties.setProperty(formatKey + ANTIALIAS, true);
            properties.setProperty(formatKey + ANTIALIAS_TEXT, true);

            // copy parameters from specific format
            ImageWriter writer = getPreferredImageWriter(format);
            if (writer != null) {
                ImageWriteParam param = writer.getDefaultWriteParam();

                // compression
                if (param.canWriteCompressed()) {
                    param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
                    properties.setProperty(formatKey + COMPRESS, true);
                    String[] compressionTypes = param.getCompressionTypes();
                    String compressionType = param.getCompressionType();
                    properties.setProperty(formatKey + COMPRESS_MODE, compressionType != null ? compressionType : compressionTypes[0]);
                    properties.setProperty(formatKey + COMPRESS_DESCRIPTION,
                            "Custom");
                    float compressionQuality = 0.0f;
                    try {
                      compressionQuality = param.getCompressionQuality();
                    } catch (IllegalStateException e) {
                      // ignored
                    }
                    properties.setProperty(formatKey + COMPRESS_QUALITY, compressionQuality);
                } else {
                    properties.setProperty(formatKey + COMPRESS, false);
                    properties.setProperty(formatKey + COMPRESS_MODE, "");
                    properties.setProperty(formatKey + COMPRESS_DESCRIPTION,
                            "Custom");
                    properties.setProperty(formatKey + COMPRESS_QUALITY, 0.0f);
                }

                // progressive
                if (param.canWriteProgressive()) {
                    properties
                            .setProperty(
                                    formatKey + PROGRESSIVE,
                                    param.getProgressiveMode() != ImageWriteParam.MODE_DISABLED);
                } else {
                    properties.setProperty(formatKey + PROGRESSIVE, false);
                }
            } else {
                System.err.println(ImageGraphics2D.class
                        + ": No writer for format '" + format + "'.");
            }
View Full Code Here

        if (writer == null)
            throw new IOException(ImageGraphics2D.class
                    + ": No writer for format '" + format + "'.");

        // get the parameters for this format
        UserProperties user = new UserProperties(properties);
        ImageWriteParam param = writer.getDefaultWriteParam();
        if (param instanceof ImageParamConverter) {
            param = ((ImageParamConverter) param).getWriteParam(user);
        }

        // now set the standard write parameters
        String formatKey = rootKey + "." + format;
        if (param.canWriteCompressed()) {
            if (user.isProperty(formatKey + COMPRESS)) {
                if (user.getProperty(formatKey + COMPRESS_MODE).equals("")) {
                    param.setCompressionMode(ImageWriteParam.MODE_DEFAULT);
                } else {
                    param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
                    param.setCompressionType(user.getProperty(formatKey
                            + COMPRESS_MODE));
                    param.setCompressionQuality(user.getPropertyFloat(formatKey
                            + COMPRESS_QUALITY));
                }
            } else {
                if (canWriteUncompressed(format)) {
                    param.setCompressionMode(ImageWriteParam.MODE_DISABLED);
                }
            }
        }
        if (param.canWriteProgressive()) {
            if (user.isProperty(formatKey + PROGRESSIVE)) {
                param.setProgressiveMode(ImageWriteParam.MODE_DEFAULT);
            } else {
                param.setProgressiveMode(ImageWriteParam.MODE_DISABLED);
            }
        }
View Full Code Here

     * @param bkg Background color for the image
     * @return Properties used to create a RAW image
     * @param code Color encoding, e.g. {@link ImageConstants#COLOR_MODEL_RGB}
     */
    public static UserProperties getRAWProperties(Color bkg, String code) {
        UserProperties result = new UserProperties();
        result.setProperty(RawImageWriteParam.BACKGROUND, bkg);
        result.setProperty(RawImageWriteParam.CODE, code);
        result.setProperty(RawImageWriteParam.PAD, 1);
        return result;
    }
View Full Code Here

        code = "ARGB";
        pad = 1;
    }

    public ImageWriteParam getWriteParam(Properties properties) {
        UserProperties p = new UserProperties(properties);
        setBackground(p.getPropertyColor(BACKGROUND, bkg));
        setCode(p.getProperty(CODE, code));
        setPad(p.getPropertyInt(PAD, pad));
        return this;
    }
View Full Code Here

        emf.writeDWORD(BitmapInfoHeader.size);
        emf.writeDWORD(size + BitmapInfoHeader.size); // bitmap follows bmi

        emf.pushBuffer();

        UserProperties properties = new UserProperties();
        properties.setProperty(RawImageWriteParam.BACKGROUND, bkg);
        properties.setProperty(RawImageWriteParam.CODE, "BGR");
        properties.setProperty(RawImageWriteParam.PAD, 4);
        ImageGraphics2D.writeImage((RenderedImage)image, "raw", properties,
                new NoCloseOutputStream(emf));

        // emf.writeImage(image, bkg, "BGR", 4);
        int length = emf.popBuffer();
View Full Code Here

TOP

Related Classes of org.freehep.util.UserProperties

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.