001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021/** 022 * 023 */ 024package org.biojava.nbio.structure.symmetry.jmolScript; 025 026import org.biojava.nbio.structure.symmetry.axis.RotationAxisAligner; 027import org.biojava.nbio.structure.symmetry.geometry.Prism; 028import org.biojava.nbio.structure.symmetry.geometry.RectangularPrism; 029 030 031/** 032 * @author Peter 033 * 034 */ 035public class JmolSymmetryScriptGeneratorCn extends JmolSymmetryScriptGeneratorPointGroup { 036 037 public JmolSymmetryScriptGeneratorCn(RotationAxisAligner axisTransformation, String name) { 038 super(axisTransformation, name); 039 if (axisTransformation.getRotationGroup().getPointGroup().equals("C2")) { 040 setPolyhedron(new RectangularPrism(axisTransformation.getDimension().z*2, axisTransformation.getDimension().x*2, axisTransformation.getDimension().y*2)); 041 } else { 042 Prism p = new Prism(axisTransformation.getRotationGroup().getRotation(0).getFold()); 043 p.setHeight(axisTransformation.getDimension().z*2); 044 p.setInscribedRadius(axisTransformation.getRadius()); 045 setPolyhedron(p); 046 } 047 } 048 049 @Override 050 public int getZoom() { 051 // find maximum extension of structure 052 double maxExtension = getMaxExtension(); 053 // find maximum extension of polyhedron 054 RotationAxisAligner at = getAxisTransformation(); 055 double polyhedronExtension = Math.max(getPolyhedron().getCirumscribedRadius(), at.getDimension().z); 056 057 int zoom = Math.round((float)(maxExtension/polyhedronExtension * 110)); 058 if (zoom > 100) { 059 zoom = 100; 060 } 061 return zoom; 062 } 063 064 @Override 065 public int getOrientationCount() { 066 // the last two views (top, bottom) are not that interesting. 067 if (getAxisTransformation().getRotationGroup().getPointGroup().equals("C2")) { 068 return getPolyhedron().getViewCount()-2; 069 } 070 return getPolyhedron().getViewCount(); 071 } 072 073 /** 074 * Returns the name of a specific orientation 075 * @param index orientation index 076 * @return name of orientation 077 */ 078 @Override 079 public String getOrientationName(int index) { 080 if (getAxisTransformation().getRotationGroup().getPointGroup().equals("C2")) { 081 if (index == 0) { 082 return "Front C2 axis"; 083 } else if (index == 2) { 084 return "Back C2 axis"; 085 } 086 } 087 return getPolyhedron().getViewName(index); 088 } 089}