xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maxber...@apache.org
Subject svn commit: r734650 - in /xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image: GraphicsConstants.java loader/impl/DefaultImageContext.java loader/impl/ImageConverterG2D2Bitmap.java
Date Thu, 15 Jan 2009 09:46:59 GMT
Author: maxberger
Date: Thu Jan 15 01:46:58 2009
New Revision: 734650

URL: http://svn.apache.org/viewvc?rev=734650&view=rev
Log:
Created Constants for default resolution
Added Headless-Check to DefaultImageContext, bug #46520

Added:
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java
  (with props)
Modified:
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/DefaultImageContext.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java

Added: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java?rev=734650&view=auto
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java
(added)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java
Thu Jan 15 01:46:58 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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$ */
+
+package org.apache.xmlgraphics.image;
+
+public final class GraphicsConstants {
+
+    /**
+     * The default DPI used when they cannot be determined by the graphics
+     * environment or loaded from the image.
+     */
+    public static final int DEFAULT_DPI = 72;
+
+    /**
+     * Graphics may be sampled at this resolution.
+     */
+    public static final int DEFAULT_SAMPLE_DPI = 300;
+
+    /**
+     * This class should not be instantiated.
+     */
+    private GraphicsConstants() {
+    }
+}

Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/GraphicsConstants.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/DefaultImageContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/DefaultImageContext.java?rev=734650&r1=734649&r2=734650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/DefaultImageContext.java
(original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/DefaultImageContext.java
Thu Jan 15 01:46:58 2009
@@ -19,8 +19,10 @@
 
 package org.apache.xmlgraphics.image.loader.impl;
 
+import java.awt.GraphicsEnvironment;
 import java.awt.Toolkit;
 
+import org.apache.xmlgraphics.image.GraphicsConstants;
 import org.apache.xmlgraphics.image.loader.ImageContext;
 
 /**
@@ -28,13 +30,18 @@
  */
 public class DefaultImageContext implements ImageContext {
 
-    private float sourceResolution;
+    private final float sourceResolution;
     
     /**
      * Main constructor.
      */
     public DefaultImageContext() {
-        this.sourceResolution = Toolkit.getDefaultToolkit().getScreenResolution();
+        if (GraphicsEnvironment.isHeadless()) {
+            this.sourceResolution = GraphicsConstants.DEFAULT_DPI;
+        } else {
+            this.sourceResolution = Toolkit.getDefaultToolkit()
+                    .getScreenResolution();
+        }
     }
     
     /** {@inheritDoc} */

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java?rev=734650&r1=734649&r2=734650&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java
(original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java
Thu Jan 15 01:46:58 2009
@@ -34,6 +34,7 @@
 import java.awt.image.WritableRaster;
 import java.util.Map;
 
+import org.apache.xmlgraphics.image.GraphicsConstants;
 import org.apache.xmlgraphics.image.loader.Image;
 import org.apache.xmlgraphics.image.loader.ImageFlavor;
 import org.apache.xmlgraphics.image.loader.ImageProcessingHints;
@@ -64,7 +65,7 @@
             withAlpha = false;
         }
 
-        int resolution = 300; //default: 300dpi
+        int resolution = GraphicsConstants.DEFAULT_SAMPLE_DPI;
         Number res = (Number)hints.get(ImageProcessingHints.TARGET_RESOLUTION);
         if (res != null) {
             resolution = res.intValue();



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message