package edu.sdsc.mbt; import edu.sdsc.mbt.viewables.StylesPreferences; import edu.sdsc.mbt.viewers.GLViewerImpl.*; import edu.sdsc.sirius.dialogs.*; import edu.sdsc.sirius.util.*; public class LabelComponent extends AnnotationComponent { public Atom atom; public String label; private int TYPE = AnnotationComponentRegistry.TYPE_LABEL; public float[] color = new float[]{ 1.0f, 1.0f, 1.0f }; public int dataType = LabelDialog.TYPE_NAME; public int font = LabelGeometry.MEDIUM_FONT; public LabelComponent(Atom atom, int dataType, int font, String label){ this.atom = atom; this.label = label; this.dataType = dataType; if (font > -1) this.font = font; } public LabelComponent(Atom atom, int dataType, int font, String label, boolean selected, float[] color){ this.atom = atom; this.label = label; this.dataType = dataType; if (font > -1) this.font = font; this.selected = selected; this.color[0] = color[0]; this.color[1] = color[1]; this.color[2] = color[2]; } public int getType(){ return TYPE; } public int getLabelType(){ return this.dataType; } public String getText(){ if (dataType == LabelDialog.TYPE_CUSTOM){ return label; } else if (dataType == LabelDialog.TYPE_NAME){ return atom.name; } else if (dataType == LabelDialog.TYPE_ELEMENT){ return atom.getElement(); } else if (dataType == LabelDialog.TYPE_CHARGE){ if (atom.partialCharge > 0){ return "+" + StringUtils.getFormattedNumber((double)atom.partialCharge, 3); } return StringUtils.getFormattedNumber((double)atom.partialCharge, 3); } else if (dataType == LabelDialog.TYPE_HYBRIDIZATION){ if (atom.hybridization == Atom.SP) return "SP"; if (atom.hybridization == Atom.SP2) return "SP2"; return "SP3"; } return atom.name;//default } public float[] getColor(){ if (selected){ return StylesPreferences.selectionColor; } else{ return color; } } public float[] getSetColor(){ return color; } public int getFont(){ return font; } public void setFont(int font){ this.font = font; } private boolean selected = false; private boolean visible = true; public void setSelected(boolean selected){ this.selected = selected; } public boolean getSelected(){ return selected; } public final boolean getVisible() { return visible; } public final void setVisible(boolean visible) { this.visible = visible; } }