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 */
021package org.biojava.nbio.structure.xtal;
022
023import java.util.HashMap;
024
025/**
026 * An enum to represent the 7 Bravais lattices
027 *
028 * @author duarte_j
029 *
030 */
031public enum BravaisLattice {
032
033        TRICLINIC    (1, "TRICLINIC",    new CrystalCell(1.00,1.25,1.50, 60,70,80)), // alpha,beta,gamma!=90
034        MONOCLINIC   (2, "MONOCLINIC",   new CrystalCell(1.00,1.25,1.50, 90,60,90)), // beta!=90, alpha=gamma=90
035        ORTHORHOMBIC (3, "ORTHORHOMBIC", new CrystalCell(1.00,1.25,1.50, 90,90,90)), // alpha=beta=gamma=90
036        TETRAGONAL   (4, "TETRAGONAL",   new CrystalCell(1.00,1.00,1.25, 90,90,90)), // alpha=beta=gamma=90, a=b
037        TRIGONAL     (5, "TRIGONAL",     new CrystalCell(1.00,1.00,1.25, 90,90,120)),// a=b!=c, alpha=beta=90, gamma=120
038        HEXAGONAL    (6, "HEXAGONAL",    new CrystalCell(1.00,1.00,1.25, 90,90,120)),// a=b!=c, alpha=beta=90, gamma=120
039        CUBIC        (7, "CUBIC",        new CrystalCell(1.00,1.00,1.00, 90,90,90)); // a=b=c, alpha=beta=gamma=90
040
041        private static HashMap<String, BravaisLattice> name2bl = initname2bl();
042        private String name;
043        private int id;
044        private CrystalCell exampleUnitCell;
045
046        private BravaisLattice(int id, String name, CrystalCell exampleUnitCell) {
047                this.name = name;
048                this.id = id;
049                this.exampleUnitCell = exampleUnitCell;
050        }
051
052        public String getName() {
053                return name;
054        }
055
056        public int getId() {
057                return id;
058        }
059
060        public CrystalCell getExampleUnitCell() {
061                return exampleUnitCell;
062        }
063
064        private static HashMap<String,BravaisLattice> initname2bl(){
065                HashMap<String,BravaisLattice> name2bl = new HashMap<String, BravaisLattice>();
066                for (BravaisLattice bl:BravaisLattice.values()) {
067                        name2bl.put(bl.getName(), bl);
068                }
069                return name2bl;
070        }
071
072        public static BravaisLattice getByName(String blName) {
073                return name2bl.get(blName);
074        }
075}