//Copyright (c) 2000-2003 San Diego Supercomputer Center (SDSC), //a facility operated by the University of California, San Diego (UCSD) // //Users and possessors of this source code are hereby granted a //nonexclusive, royalty-free copyright and design patent license to //use this code in individual software. License is not granted for //commercial resale, in whole or in part, without prior written //permission from SDSC. This source is provided "AS IS" without express //or implied warranty of any kind. // //For further information, please see: http://mbt.sdsc.edu // package edu.sdsc.mbt.viewables; import java.awt.*; import java.util.prefs.*; import java.io.*; /** * This class is a storage and manipulation utility to handle viewing options * set through PreferencesDialog. * Allows to store current configuration settings from StructureStyles, updating them * and saving and restoring configuration from persistent storage. * @see edu.sdsc.mbt.viewables.StructureStyles * @see edu.sdsc.sirius.dialogs.PreferencesDialog * @author Oleksandr V. Buzko */ public class StylesPreferences { /** * Constants that define selection modes. */ public static final int SELECTION_ATOM = 0; public static final int SELECTION_RESIDUE = 1; public static final int SELECTION_FRAGMENT = 2; public static final int SELECTION_STRUCTURE = 3; public static final int POSITION_LEFT = 0; public static final int POSITION_TOP = 1; public static final int RIBBON_LINE = 0; public static final int RIBBON_RENDERED = 1; public static final int RIBBON_CYLINDER_HELICES = 2; public static final int RIBBON_UNIFORM_ROUND = 3; public static final int RIBBON_FLAT_HELICES = 4; public static final int SURFACE_DOT = 0; public static final int SURFACE_MESH = 1; public static final int SURFACE_SOLID = 2; public static final int SURFACE_QUALITY_LOW = 0; public static final int SURFACE_QUALITY_MEDIUM = 1; public static final int SURFACE_QUALITY_HIGH = 2; public static final int SURFACE_QUALITY_ULTRA = 3; /** * Constants that define structure rendering modes for each atom to allow different rendering of defined structure fragments. */ public static final short RENDERING_LINES = 0; public static final short RENDERING_STICK = 1; public static final short RENDERING_BALL_STICK = 2; public static final short RENDERING_CPK = 3; public static final short RENDERING_RIBBON = 4; /** * Constants that define rendering quality. */ public static final short RENDERING_FAST = 0; public static final short RENDERING_BEST = 1; public static final int ATOMIC_RADIUS = 0; public static final int UNIFORM_RADIUS = 1; /** * Constants that define modes of motion: zooming into a structure by changing the angle of view * or physically moving the camera (in the latter case, fog interferes with the motion) */ public static final int MAGNIFICATION_MOVE = 0; public static final int MAGNIFICATION_ZOOM = 1; public static final int SMOOTH_LAF = 0; public static final int NATIVE_LAF = 1; public static final int defaultLAF = SMOOTH_LAF; //this scale is used to generate atom radii public static double atomRadiusScale = 0.25; public static double cpkRadiusScale = 0.65; private static final double defaultLineWidth = 2.0; private static final boolean defaultIndexedColor = false; private static final int defaultRibbonStyle = RIBBON_RENDERED; private static final boolean defaultRenderBondOrder = true; private static final boolean defaultStructureColorSequence = false;//use solid colors for consecutive structure loads private static final int defaultToolbarPosition = POSITION_LEFT; private static final boolean defaultZoomMiddle = false;//middle button is zoom operator (otherwise, Alt-left button) private static final boolean defaultAntialiasing = false; public static boolean smoothRibbon = true; public static float helixThickness = 0.4f; //defaults private static final float defaultSelectionColor[] = { 1.0f, 1.0f, 0.0f }; private static final float defaultBackgroundColor[] = { 0.0f, 0.0f, 0.0f }; private static final float defaultMonitorColor[] = { 0.0f, 0.9f, 0.1f }; private static final int defaultSelectionMode = SELECTION_ATOM; private static final short defaultRenderingMode = RENDERING_LINES; private static final short defaultStructureView = RENDERING_LINES; // private static final short defaultStructureView = RENDERING_RIBBON; private static final boolean defaultSelectAtomLabel = true; private static final boolean defaultUndoEnabled = false; private static final int defaultUndoBufferDepth = 10; private static final int defaultMenuFontSize = 0;//deviation from the default private static final int defaultCpkQuality = 10;//number of sphere divisions for rendering of CPK private static final float defaultRenderingFastQuality = 1.0f; private static final float defaultRenderingBestQuality = 3.0f; private static final float defaultRibbonQuality = 1.0f; private static final float defaultRibbonDiameter = 1.0f; private static final float defaultCylinderDiameter = 3.0f; private static final double defaultStickSize = 0.15; private static final double defaultBondRadiusScale = 0.5; private static final double defaultSphereRadius = 0.19; private static final double defaultBallRadius = 1.5; private static final int defaultBallRadiusOption = StylesPreferences.ATOMIC_RADIUS; private static final boolean defaultCommonColoring = true; private static final boolean defaultCommonSelection = true; private static final boolean defaultCommonRibbonColoring = true; private static final String defaultWorkingDirectory = "."; private static final float[] defaultHelixColor = new float[]{ 1.0f, 0.0f, 0.0f}; private static final float[] defaultStrandColor = new float[]{ 1.0f, 1.0f, 0.0f}; private static final float[] defaultTurnColor = new float[]{0.2f, 0.9f, 0.4f}; private static final float[] defaultCoilColor = new float[]{ 0.1f, 0.4f, 0.9f }; private static final int defaultMagnificationMode = MAGNIFICATION_MOVE; private static final int defaultStartupMagnificationMode = MAGNIFICATION_MOVE; private static final short defaultStartupRenderingQuality = RENDERING_FAST; private static final boolean defaultShowBondOrder = true; private static final boolean defaultDeriveBondOrder = false; private static final boolean defaultShowCellGrid = true; private static final boolean defaultShowResidueTips = false; private static final boolean defaultShowSs = false;//whether to show the color-coded strip on top of every sequence private static final Font defaultSequenceViewerFont = new Font("Monospaced", Font.BOLD, 16); private static final Color[] defaultChainColors = new Color[]{ Color.red, Color.YELLOW, Color.CYAN, Color.BLUE, Color.GREEN }; private static final Color[] defaultStructureColors = new Color[]{ Color.red, Color.YELLOW, Color.CYAN, Color.ORANGE, Color.BLUE, Color.GREEN, Color.MAGENTA }; private static final boolean defaultShowBoundWaters = false; private static final boolean defaultDisplayToolbar = true; private static final boolean defaultShowToolbarTips = true; private static final int defaultFramerate = 40; private static final int defaultMouseFactor = 3; private static final boolean defaultFogEnabled = true; private static final boolean defaultDockRama = true; private static final boolean defaultToolbarPDB = true; private static final boolean defaultToolbarUndo = false; private static final boolean defaultToolbarVisibility = true; private static final boolean defaultToolbarRendering = true; private static final boolean defaultToolbarColoring = true; private static final boolean defaultToolbarLabels = true; private static final boolean defaultToolbarCenter = true; private static final boolean defaultToolbarSeparate = true; private static final boolean defaultToolbarCommon = true; private static final boolean defaultToolbarDistance = false; private static final boolean defaultToolbarAngle = false; private static final boolean defaultToolbarDihedral = false; private static final boolean defaultToolbarFog = true; private static final boolean defaultFastGeometry = false; private static final Color defaultSequenceResidueColor = new Color( 0.0f, 0.0f, 0.0f ); public static final Color defaultCellBackgroundColor = new Color( 0.7f, 0.7f, 0.7f ); //instance variables public static float selectionColor[] = new float[3]; /** * Color of background in 3D viewer */ public static float backgroundColor[] = new float[3]; public static boolean toolbarChanged = false; public static boolean toolbarPDB = defaultToolbarPDB; public static boolean toolbarUndo = defaultToolbarUndo; public static boolean toolbarVisibility = defaultToolbarVisibility; public static boolean toolbarRendering = defaultToolbarRendering; public static boolean toolbarColoring = defaultToolbarColoring; public static boolean toolbarLabels = defaultToolbarLabels; public static boolean toolbarCenter = defaultToolbarCenter; public static boolean toolbarSeparate = defaultToolbarSeparate; public static boolean toolbarCommon = defaultToolbarCommon; public static boolean toolbarDistance = defaultToolbarDistance; public static boolean toolbarAngle = defaultToolbarAngle; public static boolean toolbarDihedral = defaultToolbarDihedral; public static boolean toolbarFog = defaultToolbarFog; public static boolean zoomMiddle = defaultZoomMiddle; public static boolean fastGeometry = defaultFastGeometry; public static int toolbarPosition = defaultToolbarPosition; public static boolean selectAtomLabel = defaultSelectAtomLabel; public static boolean antialiasing = defaultAntialiasing; private static final String defaultPovrayInstallationDirectoryWin = "C:\\Program Files\\POV-Ray for Windows v3.6"; private static final String defaultPovrayInstallationDirectoryLinux = "/usr/local"; public static String povrayInstallationDirectoryWin = defaultPovrayInstallationDirectoryWin; public static String povrayInstallationDirectoryLinux = defaultPovrayInstallationDirectoryLinux; /** * Color used to display distance monitors in StructureViewer */ public static float monitorColor[] = new float[3]; public static int ribbonStyle = defaultRibbonStyle; public static boolean renderBondOrder = defaultRenderBondOrder; public static int LAF = defaultLAF;//look and feel - changeable on Mac public static int structureColorIndex = 0; /** * The variable that sets selection level between atom and residue */ public static int selectionMode = defaultSelectionMode; public static short renderingMode = defaultRenderingMode; public static short structureView = defaultStructureView; public static int cpkQuality = defaultCpkQuality; public static int menuFontSize = defaultMenuFontSize; public static boolean structureColorSequence = defaultStructureColorSequence; public static boolean showCellGrid = defaultShowCellGrid; public static boolean showResidueTips = defaultShowResidueTips; public static boolean showSs = defaultShowSs; public static Font sequenceViewerFont = defaultSequenceViewerFont; public static boolean undoEnabled = defaultUndoEnabled; public static int undoBufferDepth = defaultUndoBufferDepth; /** * Numeric values that reflect quality of rendering. */ public static float renderingFastQuality = defaultRenderingFastQuality; public static float renderingBestQuality = defaultRenderingBestQuality; public static float ribbonQuality = defaultRibbonQuality; public static float ribbonDiameter = defaultRibbonDiameter; public static float cylinderDiameter = defaultCylinderDiameter; public static boolean commonRibbonColoring = defaultCommonRibbonColoring; public static boolean commonColoring = defaultCommonColoring; public static boolean commonSelection = defaultCommonSelection; public static double stickSize = defaultStickSize;//radius of sticks in stick representation public static double bondRadiusScale = defaultBondRadiusScale;//ratio of bond to atom radius in ball-and-stick public static double sphereRadius = defaultSphereRadius; public static double ballRadius = defaultBallRadius; public static int ballRadiusOption = defaultBallRadiusOption; public static int startupMagnificationMode = defaultStartupMagnificationMode; public static short startupRenderingQuality = defaultStartupRenderingQuality; public static int magnificationMode = startupMagnificationMode; public static String workingDirectory = defaultWorkingDirectory; public static boolean showBondOrder = defaultShowBondOrder; public static boolean deriveBondOrder = defaultDeriveBondOrder; public static boolean showBoundWaters = defaultShowBoundWaters; public static int mouseFactor = defaultMouseFactor; public static boolean fogEnabled = defaultFogEnabled; public static boolean indexedColor = defaultIndexedColor; public static Color[] chainColors = defaultChainColors; public static Color[] structureColors = defaultStructureColors; public static double lineWidth = defaultLineWidth; public static boolean displayToolbar = defaultDisplayToolbar; public static boolean showToolbarTips = defaultShowToolbarTips; /** * Variables that define colors of the secondary structure elements. */ public static float[] HELIX_COLOR; public static float[] STRAND_COLOR; public static float[] TURN_COLOR; public static float[] COIL_COLOR; public static boolean dockRama = defaultDockRama; public static Color sequenceResidueColor = defaultSequenceResidueColor; public static Color cellBackgroundColor = defaultCellBackgroundColor; private String preferencesLocation = "/edu/sdsc/sirius/viewer"; public StylesPreferences(String location){ preferencesLocation = location; //initialize instance variables selectionColor[0] = defaultSelectionColor[0]; selectionColor[1] = defaultSelectionColor[1]; selectionColor[2] = defaultSelectionColor[2]; backgroundColor[0] = defaultBackgroundColor[0]; backgroundColor[1] = defaultBackgroundColor[1]; backgroundColor[2] = defaultBackgroundColor[2]; monitorColor[0] = defaultMonitorColor[0]; monitorColor[1] = defaultMonitorColor[1]; monitorColor[2] = defaultMonitorColor[2]; HELIX_COLOR = new float[] {defaultHelixColor[0], defaultHelixColor[1], defaultHelixColor[2] }; STRAND_COLOR = new float[]{defaultStrandColor[0], defaultStrandColor[1], defaultStrandColor[2]}; TURN_COLOR = new float[]{defaultTurnColor[0], defaultTurnColor[1], defaultTurnColor[2]}; COIL_COLOR = new float[]{defaultCoilColor[0], defaultCoilColor[1], defaultCoilColor[2]}; chainColors = defaultChainColors; structureColors = defaultStructureColors; workingDirectory = (new File(defaultWorkingDirectory)).getAbsolutePath(); if (workingDirectory.endsWith(".")){ workingDirectory = workingDirectory.substring(0, workingDirectory.length()-1); } // System.out.println("Default: " + workingDirectory); } /** * This method uses hard-coded defaults to restore the configuration of the application. * Both StructureStyles and persistent Preferences are updated. */ public static void resetStylesDefaults(){ LAF = defaultLAF; selectionColor[0] = defaultSelectionColor[0]; selectionColor[1] = defaultSelectionColor[1]; selectionColor[2] = defaultSelectionColor[2]; monitorColor[0] = defaultMonitorColor[0]; monitorColor[1] = defaultMonitorColor[1]; monitorColor[2] = defaultMonitorColor[2]; backgroundColor[0] = defaultBackgroundColor[0]; backgroundColor[1] = defaultBackgroundColor[1]; backgroundColor[2] = defaultBackgroundColor[2]; selectionMode = defaultSelectionMode; renderingMode = defaultRenderingMode; structureView = defaultStructureView; cpkQuality = defaultCpkQuality; renderingFastQuality = defaultRenderingFastQuality; renderingBestQuality = defaultRenderingBestQuality; ribbonQuality = defaultRibbonQuality; ribbonDiameter = defaultRibbonDiameter; cylinderDiameter = defaultCylinderDiameter; commonRibbonColoring = defaultCommonRibbonColoring; commonColoring = defaultCommonColoring; commonSelection = defaultCommonSelection; undoEnabled = defaultUndoEnabled; undoBufferDepth = defaultUndoBufferDepth; stickSize = defaultStickSize; bondRadiusScale = defaultBondRadiusScale; sphereRadius = defaultSphereRadius; ballRadius = defaultBallRadius; ballRadiusOption = defaultBallRadiusOption; toolbarPosition = defaultToolbarPosition; selectAtomLabel = defaultSelectAtomLabel; startupMagnificationMode = defaultStartupMagnificationMode; startupRenderingQuality = defaultStartupRenderingQuality; workingDirectory = defaultWorkingDirectory; showBondOrder = defaultShowBondOrder; deriveBondOrder = defaultDeriveBondOrder; showBoundWaters = defaultShowBoundWaters; mouseFactor = defaultMouseFactor; fogEnabled = defaultFogEnabled; renderBondOrder = defaultRenderBondOrder; sequenceResidueColor = defaultSequenceResidueColor; structureColorSequence = defaultStructureColorSequence; showCellGrid = defaultShowCellGrid; showResidueTips = defaultShowResidueTips; showSs = defaultShowSs; sequenceViewerFont = defaultSequenceViewerFont; cellBackgroundColor = defaultCellBackgroundColor; sequenceViewerFont = defaultSequenceViewerFont; lineWidth = defaultLineWidth; displayToolbar = defaultDisplayToolbar; showToolbarTips = defaultShowToolbarTips; toolbarPDB = defaultToolbarPDB; toolbarUndo = defaultToolbarUndo; toolbarVisibility = defaultToolbarVisibility; toolbarRendering = defaultToolbarRendering; toolbarColoring = defaultToolbarColoring; toolbarLabels = defaultToolbarLabels; toolbarCenter = defaultToolbarCenter; toolbarSeparate = defaultToolbarSeparate; toolbarCommon = defaultToolbarCommon; toolbarDistance = defaultToolbarDistance; toolbarAngle = defaultToolbarAngle; toolbarDihedral = defaultToolbarDihedral; toolbarFog = defaultToolbarFog; fastGeometry = defaultFastGeometry; zoomMiddle = defaultZoomMiddle; antialiasing = defaultAntialiasing; /** * Constants that define colors of the secondary structure elements. */ HELIX_COLOR = defaultHelixColor; STRAND_COLOR = defaultStrandColor; TURN_COLOR = defaultTurnColor; COIL_COLOR = defaultCoilColor; for (int i = 0; i < defaultChainColors.length; i++){ chainColors[i] = defaultChainColors[i]; } for (int i = 0; i < defaultStructureColors.length; i++){ structureColors[i] = defaultStructureColors[i]; } dockRama = defaultDockRama; } public void writePreferences(){ Preferences root = Preferences.userRoot(); final Preferences node = root.node(preferencesLocation); node.putInt("LAF", LAF); //start writing settings to the node node.putFloat("selectionColor0", selectionColor[0]); node.putFloat("selectionColor1", selectionColor[1]); node.putFloat("selectionColor2", selectionColor[2]); node.putFloat("monitorColor0", monitorColor[0]); node.putFloat("monitorColor1", monitorColor[1]); node.putFloat("monitorColor2", monitorColor[2]); node.putFloat("backgroundColor0", backgroundColor[0]); node.putFloat("backgroundColor1", backgroundColor[1]); node.putFloat("backgroundColor2", backgroundColor[2]); node.putInt("selectionMode", selectionMode); node.putInt("renderingMode", renderingMode); node.putInt("structureView", structureView); node.putInt("cpkQuality", cpkQuality); node.putInt("menuFontSize", menuFontSize); node.putBoolean("structureColorSequence", structureColorSequence); node.putFloat("renderingFastQuality", renderingFastQuality); node.putFloat("renderingBestQuality", renderingBestQuality); node.putFloat("ribbonQuality", ribbonQuality); node.putFloat("ribbonDiameter", ribbonDiameter); node.putFloat("cylinderDiameter", cylinderDiameter); node.putBoolean("commonRibbonColoring", commonRibbonColoring); node.putBoolean("commonColoring", commonColoring); node.putBoolean("commonSelection", commonSelection); node.putBoolean("fastGeometry", fastGeometry); node.putBoolean("zoomMiddle", zoomMiddle); node.putBoolean("antialiasing", antialiasing); node.putDouble("stickSize", stickSize); node.putDouble("bondRadiusScale", bondRadiusScale); node.putDouble("sphereRadius", sphereRadius); node.putDouble("ballRadius", ballRadius); node.putDouble("lineWidth", lineWidth); node.putInt("ballRadiusOption", ballRadiusOption); node.putInt("toolbarPosition", toolbarPosition); node.putBoolean("selectAtomLabel", selectAtomLabel); node.putInt("startupMagnificationMode", startupMagnificationMode); node.putInt("startupRenderingQuality", startupRenderingQuality); node.put("workingDirectory", workingDirectory); node.putBoolean("showBondOrder", showBondOrder); node.putBoolean("deriveBondOrder", deriveBondOrder); node.putBoolean("renderBondOrder", renderBondOrder); node.putBoolean("undoEnabled", undoEnabled); node.putInt("undoBufferDepth", undoBufferDepth); node.putBoolean("showCellGrid", showCellGrid); node.putBoolean("showResidueTips", showResidueTips); node.putBoolean("showSs", showSs); node.put("sequenceViewerFontFace", sequenceViewerFont.getFamily()); node.putInt("sequenceViewerFontSize", sequenceViewerFont.getSize()); node.putInt("sequenceViewerFontStyle", sequenceViewerFont.getStyle()); node.putBoolean("dockRama", dockRama); node.putBoolean("showBoundWaters", showBoundWaters); node.putInt("mouseFactor", mouseFactor); node.putBoolean("fogEnabled", fogEnabled); node.put("povrayDirWin", povrayInstallationDirectoryWin); node.put("povrayDirLinux", povrayInstallationDirectoryLinux); node.putBoolean("displayToolbar", displayToolbar); node.putBoolean("showToolbarTips", showToolbarTips); node.putInt("sequenceResidueColor1", sequenceResidueColor.getRed()); node.putInt("sequenceResidueColor2", sequenceResidueColor.getGreen()); node.putInt("sequenceResidueColor3", sequenceResidueColor.getBlue()); node.putBoolean("toolbarPDB", toolbarPDB); node.putBoolean("toolbarUndo", toolbarUndo); node.putBoolean("toolbarVisibility", toolbarVisibility); node.putBoolean("toolbarRendering", toolbarRendering); node.putBoolean("toolbarColoring", toolbarColoring); node.putBoolean("toolbarLabels", toolbarLabels); node.putBoolean("toolbarCenter", toolbarCenter); node.putBoolean("toolbarSeparate", toolbarSeparate); node.putBoolean("toolbarCommon", toolbarCommon); node.putBoolean("toolbarDistance", toolbarDistance); node.putBoolean("toolbarAngle", toolbarAngle); node.putBoolean("toolbarDihedral", toolbarDihedral); node.putBoolean("toolbarFog", toolbarFog); node.putFloat("helixColor0", HELIX_COLOR[0]); node.putFloat("helixColor1", HELIX_COLOR[1]); node.putFloat("helixColor2", HELIX_COLOR[2]); node.putFloat("strandColor0", STRAND_COLOR[0]); node.putFloat("strandColor1", STRAND_COLOR[1]); node.putFloat("strandColor2", STRAND_COLOR[2]); node.putFloat("turnColor0", TURN_COLOR[0]); node.putFloat("turnColor1", TURN_COLOR[1]); node.putFloat("turnColor2", TURN_COLOR[2]); node.putFloat("coilColor0", COIL_COLOR[0]); node.putFloat("coilColor1", COIL_COLOR[1]); node.putFloat("coilColor2", COIL_COLOR[2]); //save default colors for (int i = 0; i < chainColors.length; i++){ Color c = chainColors[i]; node.putInt("chainColor"+i+"_1", c.getRed()); node.putInt("chainColor"+i+"_2", c.getGreen()); node.putInt("chainColor"+i+"_3", c.getBlue()); } for (int i = 0; i < structureColors.length; i++){ Color c = structureColors[i]; node.putInt("structureColor"+i+"_1", c.getRed()); node.putInt("structureColor"+i+"_2", c.getGreen()); node.putInt("structureColor"+i+"_3", c.getBlue()); } try{ node.flush(); } catch (BackingStoreException ex){ System.out.println("Unable to save preferences: " + ex); } } public void readPreferences(){ Preferences root = Preferences.userRoot(); final Preferences node = root.node(preferencesLocation); LAF = node.getInt("LAF", defaultLAF); selectionColor[0] = node.getFloat("selectionColor0", defaultSelectionColor[0]); selectionColor[1] = node.getFloat("selectionColor1", defaultSelectionColor[1]); selectionColor[2] = node.getFloat("selectionColor2", defaultSelectionColor[2]); selectionMode = node.getInt("selectionMode", defaultSelectionMode); renderingMode = (short)node.getInt("renderingMode", defaultRenderingMode); structureView = (short)node.getInt("structureView", defaultStructureView); //these don't have to be changed, as they are controlled only through Preferences dialog //and are not changed elsewhere, which may give different current and default settings monitorColor[0] = node.getFloat("monitorColor0", defaultMonitorColor[0]); monitorColor[1] = node.getFloat("monitorColor1", defaultMonitorColor[1]); monitorColor[2] = node.getFloat("monitorColor2", defaultMonitorColor[2]); backgroundColor[0] = node.getFloat("backgroundColor0", defaultBackgroundColor[0]); backgroundColor[1] = node.getFloat("backgroundColor1", defaultBackgroundColor[1]); backgroundColor[2] = node.getFloat("backgroundColor2", defaultBackgroundColor[2]); cpkQuality = node.getInt("cpkQuality", defaultCpkQuality); menuFontSize = node.getInt("menuFontSize", defaultMenuFontSize); renderingFastQuality = node.getFloat("renderingFastQuality", defaultRenderingFastQuality); renderingBestQuality = node.getFloat("renderingBestQuality", defaultRenderingBestQuality); ribbonQuality = node.getFloat("ribbonQuality", defaultRibbonQuality); ribbonDiameter = node.getFloat("ribbonDiameter", defaultRibbonDiameter); cylinderDiameter = node.getFloat("cylindernDiameter", defaultCylinderDiameter); commonRibbonColoring = node.getBoolean("commonRibbonColoring", defaultCommonRibbonColoring); commonColoring = node.getBoolean("commonColoring", defaultCommonColoring); commonSelection = node.getBoolean("commonSelection", defaultCommonSelection); undoEnabled = node.getBoolean("undoEnabled", defaultUndoEnabled); undoBufferDepth = node.getInt("undoBufferDepth", defaultUndoBufferDepth); stickSize = node.getDouble("stickSize", defaultStickSize); bondRadiusScale = node.getDouble("bondRadiusScale", defaultBondRadiusScale); sphereRadius = node.getDouble("sphereRadius", defaultSphereRadius); ballRadius = node.getDouble("ballRadius", defaultBallRadius); lineWidth = node.getDouble("lineWidth", defaultLineWidth); toolbarPosition = node.getInt("toolbarPosition", defaultToolbarPosition); selectAtomLabel = node.getBoolean("selectAtomLabel", defaultSelectAtomLabel); ballRadiusOption = node.getInt("ballRadiusOption", defaultBallRadiusOption); structureColorSequence = node.getBoolean("structureColorSequence", defaultStructureColorSequence); startupMagnificationMode = node.getInt("startupMagnificationMode", defaultStartupMagnificationMode); startupRenderingQuality = (short)node.getInt("startupRenderingQuality", defaultStartupRenderingQuality); // magnificationMode = startupMagnificationMode; //generate default values for class labels float[] colors = new float[4]; workingDirectory = node.get("workingDirectory", defaultWorkingDirectory); showBondOrder = node.getBoolean("showBondOrder", defaultShowBondOrder); deriveBondOrder = node.getBoolean("deriveBondOrder", defaultDeriveBondOrder); showBoundWaters = node.getBoolean("showBoundWaters", defaultShowBoundWaters); mouseFactor = node.getInt("mouseFactor", defaultMouseFactor); fogEnabled = node.getBoolean("fogEnabled", defaultFogEnabled); povrayInstallationDirectoryWin = node.get("povrayDirWin", defaultPovrayInstallationDirectoryWin); povrayInstallationDirectoryLinux = node.get("povrayDirLinux", defaultPovrayInstallationDirectoryLinux); renderBondOrder = node.getBoolean("renderBondOrder", defaultRenderBondOrder); displayToolbar = node.getBoolean("displayToolbar", defaultDisplayToolbar); showToolbarTips = node.getBoolean("showToolbarTips", defaultShowToolbarTips); dockRama = node.getBoolean("dockRama", defaultDockRama); fastGeometry = node.getBoolean("fastGeometry", defaultFastGeometry); zoomMiddle = node.getBoolean("zoomMiddle", defaultZoomMiddle); antialiasing = node.getBoolean("antialiasing", defaultAntialiasing); sequenceResidueColor = new Color( node.getInt("sequenceResidueColor1", defaultSequenceResidueColor.getRed()), node.getInt("sequenceResidueColor2", defaultSequenceResidueColor.getGreen()), node.getInt("sequenceResidueColor3", defaultSequenceResidueColor.getBlue() )); for (int i = 0; i < defaultChainColors.length; i++){ int red = node.getInt("chainColor"+i+"_1", defaultChainColors[i].getRed()); int green = node.getInt("chainColor"+i+"_2", defaultChainColors[i].getGreen()); int blue = node.getInt("chainColor"+i+"_3", defaultChainColors[i].getBlue()); chainColors[i] = new Color(red, green, blue); } for (int i = 0; i < defaultStructureColors.length; i++){ int red = node.getInt("structureColor"+i+"_1", defaultStructureColors[i].getRed()); int green = node.getInt("structureColor"+i+"_2", defaultStructureColors[i].getGreen()); int blue = node.getInt("structureColor"+i+"_3", defaultStructureColors[i].getBlue()); structureColors[i] = new Color(red, green, blue); } StylesPreferences.structureColorIndex = 0; toolbarPDB = node.getBoolean("toolbarPDB", defaultToolbarPDB); toolbarUndo = node.getBoolean("toolbarUndo", defaultToolbarUndo); toolbarVisibility = node.getBoolean("toolbarVisibility", defaultToolbarVisibility); toolbarRendering = node.getBoolean("toolbarRendering", defaultToolbarRendering); toolbarColoring = node.getBoolean("toolbarColoring", defaultToolbarColoring); toolbarLabels = node.getBoolean("toolbarLabels", defaultToolbarLabels); toolbarCenter = node.getBoolean("toolbarCenter", defaultToolbarCenter); toolbarSeparate = node.getBoolean("toolbarSeparate", defaultToolbarSeparate); toolbarCommon = node.getBoolean("toolbarCommon", defaultToolbarCommon); toolbarDistance = node.getBoolean("toolbarDistance", defaultToolbarDistance); toolbarAngle = node.getBoolean("toolbarAngle", defaultToolbarAngle); toolbarDihedral = node.getBoolean("toolbarDihedral", defaultToolbarDihedral); toolbarFog = node.getBoolean("toolbarFog", defaultToolbarFog); showCellGrid = node.getBoolean("showCellGrid", defaultShowCellGrid); showResidueTips = node.getBoolean("showResidueTips", defaultShowResidueTips); showSs = node.getBoolean("showSs", defaultShowSs); sequenceViewerFont = new Font(node.get("sequenceViewerFontFace", defaultSequenceViewerFont.getFamily()), node.getInt("sequenceViewerFontStyle", defaultSequenceViewerFont.getStyle()), node.getInt("sequenceViewerFontSize", defaultSequenceViewerFont.getSize())); HELIX_COLOR = new float[]{ node.getFloat("helixColor0", defaultHelixColor[0]), node.getFloat("helixColor1", defaultHelixColor[1]), node.getFloat("helixColor2", defaultHelixColor[2]) }; STRAND_COLOR = new float[]{ node.getFloat("strandColor0", defaultStrandColor[0]), node.getFloat("strandColor1", defaultStrandColor[1]), node.getFloat("strandColor2", defaultStrandColor[2])}; TURN_COLOR = new float[]{ node.getFloat("turnColor0", defaultTurnColor[0]), node.getFloat("turnColor1", defaultTurnColor[1]), node.getFloat("turnColor2", defaultTurnColor[2])}; COIL_COLOR = new float[]{ node.getFloat("coilColor0", defaultCoilColor[0]), node.getFloat("coilColor1", defaultCoilColor[1]), node.getFloat("coilColor2", defaultCoilColor[2])}; } public void importPreferences(InputStream in) throws Exception{ Preferences.importPreferences(in); readPreferences(); } public void exportPreferences(OutputStream out) throws Exception{ Preferences root = Preferences.userRoot(); final Preferences node = root.node(preferencesLocation); //first, update the preferences on the disk writePreferences(); node.exportSubtree(out); } public static void getSelectionColor( float[] color ) { if ( color == null ) throw new NullPointerException( "null color" ); color[0] = selectionColor[0]; color[1] = selectionColor[1]; color[2] = selectionColor[2]; } }