ViewPoint.java
/*
* Created on 2005/07/28
* Copyright (C) 2005 Koga Laboratory. All rights reserved.
*
*/
package org.mklab.tool.graph.gnuplot.decoration;
/**
* 視点を表すクラスです。
*
* @author koga
* @version $Revision: 1.8 $, 2005/07/28
*/
public class ViewPoint implements GnuplotComponent {
/** x軸周りの回転角度(度) */
private double xRotation = 60;
/** z軸周りの回転角度(度) */
private double zRotation = 30;
/** 全体の倍率 */
private double scale = 1;
/** z軸方向の倍率 */
private double zScale = 1;
/**
* 視点を設定します。
*
* @param xRotation x軸周りの回転角度(度)
* @param zRotation z軸周りの回転角度(度)
* @param scale 全体の倍率
* @param zScale z軸方向の倍率
*/
public void setViewPoint(double xRotation, double zRotation, double scale, double zScale) {
this.xRotation = xRotation;
this.zRotation = zRotation;
this.scale = scale;
this.zScale = zScale;
}
/**
* x軸周りの回転角度(度)を設定します。
*
* @param rotation x軸周りの回転角度(度)
*/
public void setXRotation(double rotation) {
this.xRotation = rotation;
}
/**
* x軸周りの回転角度(度)を返します。
*
* @return x軸周りの回転角度(度)
*/
public double getXRotation() {
return this.xRotation;
}
/**
* z軸周りの回転角度(度)を設定します。
*
* @param rotation z軸周りの回転角度(度)
*/
public void setZRotation(double rotation) {
this.zRotation = rotation;
}
/**
* z軸周りの回転角度(度)を返します。
*
* @return z軸周りの回転角度(度)
*/
public double getZRotation() {
return this.zRotation;
}
/**
* 全体の倍率を設定します。
*
* @param scale 全体の倍率
*/
public void setScale(double scale) {
this.scale = scale;
}
/**
* 全体の倍率を返します。
*
* @return 全体の倍率
*/
public double getScale() {
return this.scale;
}
/**
* z軸方向の倍率を設定します。
*
* @param zScale z軸方向の倍率
*/
public void setZScale(double zScale) {
this.zScale = zScale;
}
/**
* z軸方向の倍率を返します。
*
* @return z軸方向の倍率
*/
public double getZSale() {
return this.zScale;
}
/**
* @see org.mklab.tool.graph.gnuplot.decoration.GnuplotComponent#getCommand()
*/
@SuppressWarnings("nls")
public String getCommand() {
return "set view " + getXRotation() + "," + getZRotation() + "," + getScale() + "," + getZSale();
}
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(this.scale);
result = prime * result + (int)(temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(this.xRotation);
result = prime * result + (int)(temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(this.zRotation);
result = prime * result + (int)(temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(this.zScale);
result = prime * result + (int)(temp ^ (temp >>> 32));
return result;
}
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
ViewPoint other = (ViewPoint)obj;
if (Double.doubleToLongBits(this.scale) != Double.doubleToLongBits(other.scale)) return false;
if (Double.doubleToLongBits(this.xRotation) != Double.doubleToLongBits(other.xRotation)) return false;
if (Double.doubleToLongBits(this.zRotation) != Double.doubleToLongBits(other.zRotation)) return false;
if (Double.doubleToLongBits(this.zScale) != Double.doubleToLongBits(other.zScale)) return false;
return true;
}
}