Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 1999-2101 Alibaba Group.
   *
   * 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.
  */
 package com.alibaba.simpleimage.util;
 
 
just use log image info

Author(s):
wendell
 
 public class ImageLog {
 
     private Log log;
 
     public static ImageLog getLog(Class<?> clazz) {
         Log log = LogFactory.getLog(clazz);
 
         return new ImageLog(log);
     }
 
     private ImageLog(Log log){
         this. = log;
     }
 
     protected String formatMsg(Object actionRenderedImage img) {
         String msgFmt = action + ": {0}={1} DataType={2} Width={3} Height={4}";
         String clazz = img.getColorModel().getColorSpace().getClass().getSimpleName();
         int type = img.getColorModel().getColorSpace().getType();
         int dataType = img.getData().getDataBuffer().getDataType();
         int w = img.getWidth();
         int h = img.getHeight();
 
         String msg = MessageFormat.format(msgFmtclazzgetColorSpaceName(type), getDataTypeName(dataType), wh);
 
         return msg;
     }
 
     protected String getColorSpaceName(int type) {
         switch (type) {
             case 0:
                 return "TYPE_XYZ";
             case 1:
                 return "TYPE_Lab";
             case 2:
                 return "TYPE_Luv";
             case 3:
                 return "TYPE_YCbCr";
             case 4:
                 return "TYPE_Yxy";
             case 5:
                 return "TYPE_RGB";
             case 6:
                 return "TYPE_GRAY";
             case 7:
                 return "TYPE_HSV";
             case 8:
                 return "TYPE_HLS";
             case 9:
                 return "TYPE_CMYK";
             case 11:
                 return "TYPE_CMY";
             case 12:
                 return "TYPE_2CLR";
             case 13:
                 return "TYPE_3CLR";
             case 14:
                 return "TYPE_4CLR";
             case 15:
                 return "TYPE_5CLR";
             case 16:
                 return "TYPE_6CLR";
             case 17:
                 return "TYPE_7CLR";
             case 18:
                 return "TYPE_8CLR";
             case 19:
                 return "TYPE_9CLR";
             case 20:
                 return "TYPE_ACLR";
             case 21:
                 return "TYPE_BCLR";
            case 22:
                return "TYPE_CCLR";
            case 23:
                return "TYPE_DCLR";
            case 24:
                return "TYPE_ECLR";
            case 25:
                return "TYPE_FCLR";
            default:
                return "TYPE_UNDEFINED";
        }
    }
    protected String getDataTypeName(int dataType) {
        switch (dataType) {
            case 0:
                return "TYPE_BYTE";
            case 1:
                return "TYPE_USHORT";
            case 2:
                return "TYPE_SHORT";
            case 3:
                return "TYPE_INT";
            case 4:
                return "TYPE_FLOAT";
            case 5:
                return "TYPE_DOUBLE";
            default:
                return "TYPE_UNDEFINED";
        }
    }
    public void info(Object msg) {
        if (.isInfoEnabled()) {
            .info(msg);
        }
    }
    public void info(Object actionRenderedImage img) {
        if (.isInfoEnabled()) {
            String msg = formatMsg(actionimg);
            .info(msg);
        }
    }
    public void debug(Object msg) {
        if (.isDebugEnabled()) {
            .debug(msg);
        }
    }
    public void debug(Object actionRenderedImage img) {
        if (.isDebugEnabled()) {
            String msg = formatMsg(actionimg);
            .debug(msg);
        }
    }
    public void fatal(Object actionRenderedImage img) {
        if (.isFatalEnabled()) {
            String msg = formatMsg(actionimg);
            .fatal(msg);
        }
    }
    public void fatal(Object msg) {
        if (.isFatalEnabled()) {
            .fatal(msg);
        }
    }
    public void error(Object msg) {
        if (.isErrorEnabled()) {
            .error(msg);
        }
    }
    public void error(Object actionRenderedImage img) {
        if (.isErrorEnabled()) {
            String msg = formatMsg(actionimg);
            .error(msg);
        }
    }
    public void trace(Object msg) {
        if (.isTraceEnabled()) {
            .trace(msg);
        }
    }
    public void trace(Object actionRenderedImage img) {
        if (.isTraceEnabled()) {
            String msg = formatMsg(actionimg);
            .trace(msg);
        }
    }
    public void warn(Object msg) {
        if (.isWarnEnabled()) {
            .warn(msg);
        }
    }
    public void warn(Object actionRenderedImage img) {
        if (.isWarnEnabled()) {
            String msg = formatMsg(actionimg);
            .warn(msg);
        }
    }
New to GrepCode? Check out our FAQ X