⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 axis.java

📁 一款用Java实现QR解码的源代码。
💻 JAVA
字号:
/*
 * Created on 2004/12/28
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package jp.sourceforge.qrcode.codec.geom;

import jp.sourceforge.qrcode.codec.reader.QRCodeImageReader;

/**
 * @author Owner
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class Axis {
	int sin, cos;
	int modulePitch;
	Point origin;
	
	public Axis(int sin, int cos, int modulePitch) {
		this.sin = sin;
		this.cos = cos;
		this.modulePitch = modulePitch;
		this.origin = new Point();
	}
	
	public void setOrigin(Point origin) {
		this.origin = origin;
	}
	
	public void setModulePitch(int modulePitch) {
		this.modulePitch = modulePitch;
	}
	
	public Point translate(Point offset) {
		int moveX = offset.getX();
		int moveY = offset.getY();
		return this.translate(moveX, moveY);
	}
	
	public Point translate(int moveX, int moveY) {
		int dp = QRCodeImageReader.DECIMAL_POINT;
		Point point = new Point(origin.getX(), origin.getY());
		int xf = 0, yf = 0;
		if (moveX >= 0 & moveY >= 0) yf = 1;
		else if (moveX < 0 & moveY >= 0) yf = -1;
		else if (moveX >= 0 & moveY < 0) yf = -1;
		else if (moveX < 0 & moveY < 0) yf = 1;
		
		if (moveX != 0 && moveY != 0)
			point.translate(
					(((modulePitch * moveX) >> dp) * cos - 
					((modulePitch * moveY) >> dp) * sin) 
					>> dp, 
					yf * (((modulePitch * moveX) >> dp) * cos + 
					((modulePitch * moveY) >> dp) * sin)
					>> dp);
		else if (moveY == 0) { 
			if (moveX < 0) yf = -yf;
			point.translate(
					(((modulePitch * moveX) >> dp) * cos)
					>> dp, 
					yf * (((modulePitch * moveX) >> dp) * sin) 
					>> dp);
		}
		else if (moveX == 0) {
			if (moveY < 0) yf = -yf;
			point.translate(
					-yf * (((modulePitch * moveY) >> dp) * sin)
					>> dp, 
					(((modulePitch * moveY) >> dp) * cos)
					>> dp);	
		}
		return point;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -