colorfingerprintconfig.java
来自「dump3 morpheus 0.2.9 src」· Java 代码 · 共 208 行
JAVA
208 行
/**
* DuMP3 version morpheus_0.2.9 - a duplicate/similar file finder in Java<BR>
* Copyright 2005 Alexander Grässer<BR>
* All Rights Reserved, http://dump3.sourceforge.net/<BR>
* <BR>
* This file is part of DuMP3.<BR>
* <BR>
* DuMP3 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later version.<BR>
* <BR>
* DuMP3 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.<BR>
* <BR>
* You should have received a copy of the GNU General Public License along with DuMP3; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
* Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.za.grasser.duplicate.fingerprint.configure;
import java.awt.image.AffineTransformOp;
import java.beans.PropertyVetoException;
import net.za.grasser.duplicate.Configure;
import net.za.grasser.duplicate.fingerprint.ColorFingerprint;
import org.apache.log4j.Logger;
/**
* @author <a href="http://sourceforge.net/sendmessage.php?touser=733840">pyropunk at sourceforge dot net</a>
* @version $Revision: 1.9 $
*/
public class ColorFingerprintConfig extends FingerprintConfig {
/**
* This class ...
*
* @author <a href="http://sourceforge.net/sendmessage.php?touser=733840">pyropunk at sourceforge dot net</a>
* @version $Revision: 1.9 $
*/
static class Factory extends ConfigFactory {
/**
* @see net.za.grasser.duplicate.fingerprint.configure.ConfigFactory#create()
*/
@Override
protected FingerprintConfig create() {
return ColorFingerprintConfig.getInstance();
}
}
static {
ConfigFactory.addFactory(ColorFingerprintConfig.class.getSimpleName(), new Factory());
}
/**
* <code>serialVersionUID</code> ColorFingerprintConfig.java -
*/
private static final long serialVersionUID = 4351025227180155410L;
/**
* <code>log</code> ColorFingerprintConfig -
*/
private static final Logger log = Logger.getLogger(ColorFingerprintConfig.class);
/**
* <code>fc</code> ColorFingerprintConfig -
*/
private static FingerprintConfig fc = null;
/**
* @return FingerprintConfig
*/
public final static FingerprintConfig getInstance() {
if (fc == null) {
fc = new ColorFingerprintConfig();
}
return fc;
}
/**
* <code>subdivide</code> ColorFingerprintConfig - 1=>1 tile, 2=>4 tiles, 3=>16 tiles
*/
private int subdivide = 3;
/**
* <code>keepaspect</code> ColorFingerprintConfig - keep the aspect ratio makes comparrison faster by 2
*/
private boolean keepaspect = true;
/**
* <code>scaling_alg</code> ColorFingerprint - scaling algorithm
*/
private int scalingAlgorithm = AffineTransformOp.TYPE_BILINEAR;
/**
* <code>scalings</code> ColorFingerprintConfig -
*/
private final String[] scalings = {
"NEAREST NEIGHBOR", "BILINEAR", "BICUBIC"
};
/**
*
*/
private ColorFingerprintConfig() {
super();
Configure.load();
// configure
setSubdivide(Configure.getIntProperty("subdivision level", subdivide, ColorFingerprint.class.getName()));
try {
setSimilarityThreshhold((float)Configure.getDoubleProperty("similarity threshhold", 98.0, ColorFingerprint.class.getName()));
} catch (final PropertyVetoException e) {
log.warn("Could not set similarity threshhold.", e);
}
setKeepaspect(Configure.getBooleanProperty("keep aspect", keepaspect, ColorFingerprint.class.getName()));
setScalingAlgorithm(Configure.getProperty("scaling algorithm", "NEAREST NEIGHBOR", ColorFingerprint.class.getName()));
}
/**
* @see net.za.grasser.duplicate.fingerprint.configure.FingerprintConfig#getFingerprintDescription()
*/
@Override
public String getFingerprintDescription() {
return "The fingerprint for image files is created by averaging the"
+ " colors in the image to create a 1 pixel, a 2x2 and a 4x4 image, or if keepaspect is set"
+ " a 3x4 image.<BR>Subdivide varies the number of images created."
+ " A subdivide value of 1 will only create a 1 pixel average image, a subdivide value of 3"
+ " (default) will create images 1x1, 2x2 and 4x4 (or 3x4). Adjusting the scaling algorithm will affect the speed and the accuracy."
+ " Nearest neighbour is fast but inacurate, Bicubic is slow but accurate."
+ " When fingerprints are compared, the 1x1 image is compared first and if the difference" + " is within"
+ " bounds, the 2x2 image is compared pixel by pixel and the differences added. If, after comparing the 4x4 image, the difference is still within"
+ " bounds, the images are considered duplicates.";
}
/**
* @see net.za.grasser.duplicate.fingerprint.configure.FingerprintConfig#getFingerprintName()
*/
@Override
public String getFingerprintName() {
return "Average Color Fingerprint";
}
/**
* @return int - Returns the scalingAlgorithm.
*/
public int getScalingAlgorithm() {
return scalingAlgorithm;
}
/**
* @return String[] - Returns the list of scalingAlgorithms.
*/
public String[] getScalingAlgorithms() {
return scalings;
}
/**
* @return String
*/
public final int getSubdivide() {
return subdivide;
}
/**
* @return boolean - Returns the keepaspect.
*/
public boolean isKeepaspect() {
return keepaspect;
}
/**
* Sets the keepaspect to the value of pKeepaspect. F
*
* @param pKeepaspect boolean - The new value.
*/
public void setKeepaspect(final boolean pKeepaspect) {
keepaspect = pKeepaspect;
}
/**
* Sets the scalingAlgorithm to the value of pScalingAlgorithm.
*
* @param pScalingAlgorithm int - The new value.
*/
public void setScalingAlgorithm(final String pScalingAlgorithm) {
final String alg = pScalingAlgorithm.toUpperCase();
try {
if (alg.startsWith("NEA")) {
scalingAlgorithm = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;
} else if (alg.startsWith("BIL")) {
scalingAlgorithm = AffineTransformOp.TYPE_BILINEAR;
} else if (alg.startsWith("BIC")) {
scalingAlgorithm = AffineTransformOp.TYPE_BICUBIC;
} else {
scalingAlgorithm = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;
}
} catch (final RuntimeException re) {
log.warn("Unknown scaling algorithm.", re);
scalingAlgorithm = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;
}
}
/**
* This method ...
*
* @param pScalingAlgorithm
*/
public void setScalingAlgorithm(final int pScalingAlgorithm) {
scalingAlgorithm = pScalingAlgorithm;
}
/**
* @param pSub
*/
public void setSubdivide(final int pSub) {
subdivide = pSub;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?