public void calculateScaleRange() {
        if( !automaticScale && userScaleRange != 0.0 ) {
            scaleRange = userScaleRange;
        } else {
            RootedTree tree = treePane.getTree();
            if (tree != null) {
                final double treeHeight = tree.getHeight(tree.getRootNode());

                if( treeHeight == 0.0 ) {
                    scaleRange = 0.0;
                } else {

                    double low = treeHeight / 10.0;
                    double b = -(Math.ceil(Math.log10(low)) - 1);
                    for(int n = 0; n < 3; ++n) {
                        double factor = Math.pow(10, b);
                        double x = ((int)(low * factor) + 1)/factor;
                        if( n == 2 || x < treeHeight / 5.0 ) {
                            scaleRange = x;
                            break;
                        }
                        ++b;
                    }
                }
            }
        }

    }