コメントに同意します。式を自分で実装する努力をしないでください。
import java.awt.geom.{AffineTransform => JTransform}
object AffineTransform {
implicit def toJava(at: AffineTransform): JTransform = at.toJava
implicit def fromJava(j: JTransform): AffineTransform = {
import j._
AffineTransform(getScaleX, getShearY,
getShearX, getScaleY,
getTranslateX, getTranslateY)
}
val identity: AffineTransform = new JTransform()
}
final case class AffineTransform(scaleX: Double, shearY: Double,
shearX: Double, scaleY: Double,
translateX: Double, translateY: Double) {
def toJava: JTransform = new JTransform(scaleX, shearY,
shearX, scaleY,
translateX, translateY)
override def toString = "AffineTransform[[" +
scaleX + ", " + shearX + ", " + translateX + "], [" +
shearY + ", " + scaleY + ", " + translateY + "]]"
def scale(sx: Double, sy: Double): AffineTransform = {
val j = toJava; j.scale(sx, sy); j
}
// ... etc
}
テスト:
AffineTransform.identity.scale(0.5, 1.0)