// Copyright (c) 1995, 1996 Regents of the University of California. // All rights reserved. // // This software was developed by the Arcadia project // at the University of California, Irvine. // // Redistribution and use in source and binary forms are permitted // provided that the above copyright notice and this paragraph are // duplicated in all such forms and that any documentation, // advertising materials, and other materials related to such // distribution and use acknowledge that the software was developed // by the University of California, Irvine. The name of the // University may not be used to endorse or promote products derived // from this software without specific prior written permission. // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED // WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. // File: Prefs.java // Classes: Prefs // Original Author: Jason Robbins // $Id: Prefs.java,v 1.1.1.1 1997/02/27 20:52:47 chandra Exp $ package uci.graphedit; /*import java.lang.*;*/ import java.util.*; import java.awt.*; /** This class contains preferences that control the behavior of the editor to make it the way that the user likes it. */ public class Prefs { /** The color, thickness, etc. of rubberband lines */ private Hashtable _rubberbandAttrs; /** Construct a new Prefs instance */ public Prefs() { initializeRubberBandAttrs(); } /** Set the rubberband attributes to some default values */ protected void initializeRubberBandAttrs() { _rubberbandAttrs = new Hashtable(); _rubberbandAttrs.put("LineColor", Color.black); _rubberbandAttrs.put("LineThickness", new Integer(0)); } /** Reply the graphical attributes that should be used when the user * is dragging out a rubberband for a new arc or line */ public Hashtable rubberbandAttrs() { return _rubberbandAttrs; } /** The color of the handles used to manipulate DiagramElement's */ private Color _handleColor = new Color(180, 120, 60); /** The color of the handles used to manipulate DiagramElement's */ public Color handleColor() { return _handleColor; } /** The color of the handles used to manipulate DiagramElement's */ public void handleColor(Color c) { _handleColor = c; } /** The color of the highlight shown to draw the users attention */ Color _highlightColor = new Color(130, 255, 100); /** The color of the highlight shown to draw the users attention */ public Color highlightColor() { return _highlightColor; } /** The color of the highlight shown to draw the users attention */ public void highlightColor(Color c) { _highlightColor = c; } /** Times used to fine-tune redrawing behavior */ private long _redrawTimeThreshold = 500, _lastRedrawTime; /** Set the last redraw time. Called from a RedrawManager. Should * this be inside RedrawManager? What if there are multiple * RedrawManager's? */ public void lastRedrawTime(long t) { _lastRedrawTime = t; } /** if the time between redraws gets longer than this threshold, * then switch to a faster redrawing method, at the expense of * quality and/or flicker */ public void redrawTimeThreshold(long t) { _redrawTimeThreshold = t; } /** get the Property that defines a default about whether the * slow, flicker-free redraw method should be used, or the fast, * flicker-full one. */ private boolean _tryOffScreen = Boolean.getBoolean("tryOffScreen"); /** Should off screen images be used to reduce flicker? This is not * the default behavior because some (beta) versions of WWW * browsers do not handle off screen images well. */ public void tryOffScreen(boolean b) { _tryOffScreen = b; } /** Should off screen images be used to reduce flicker? */ public boolean tryOffScreen() { return _tryOffScreen; } /** Determine if the next redraw should be done on screen or * offscreen. Needs-More-Work: this code should be in * RedrawManager. */ public boolean shouldPaintOffScreen() { if (_tryOffScreen) return _lastRedrawTime < _redrawTimeThreshold; else return false; /* if the last redraw was fast, then try this one with less flicker */ /* needs-more-work: should take memory/garbage into account */ } } /* end class Prefs */