All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class edu.wpi.mqp.graphics.jviz.ColorManager

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Window
                           |
                           +----java.awt.Dialog
                                   |
                                   +----com.sun.java.swing.JDialog
                                           |
                                           +----edu.wpi.mqp.graphics.jviz.ColorManager

public class ColorManager
extends JDialog
implements Runnable
This class is a dialog box that also contains variables which store to colors to draw the elements of the graphs. To make the color selector appear, the show() method can be called. The dialog box contains a combo box which contains the options of the colors that can be changed. It also contains a set of three slider bars which alter the RGB values between 0 and 255 decimal. The third portion of the graph is the color panel. It displays the color represented by the values of the three sliders. This was subclasses so that we could specifically call its paint() method when it needed to be updated. This approach eliminated flicker entirely. By changing the value of the sliders, a new thread is started up. This was to make sure there weren't problems updating the screen as we had seen in the JViz class. It is probably not needed here, but has been left in. If multiple brushes are implemented, modifications or even a complete redesign of this class may be needed. It currently only supports a single brush.

Version:
1.0
Author:
Matthew C. Jucius

Variable Index

 o applyButton
 o bSlider
 o cancelButton
 o colorArray
 o colorPanel
 o combo
 o gSlider
 o GUIAction
 o jvi
 o nameArray
 o nextColor
 o okButton
 o parentFrame
 o rSlider

Constructor Index

 o ColorManager(JFrame)
Constructor

Method Index

 o changeBlueSlider()
This is called by the run method when the Blue slider is repositioned.
 o changeColor(int)
This method will change the color in the colorPanel to the color in the specified index.
 o changeGreenSlider()
This is called by the run method when the Green slider is repositioned.
 o changeRedSlider()
This is called by the run method when the Red slider is repositioned.
 o getBackground()
This method returns the color to paint the background of the graph
 o getBrush()
This method returns the color of the brush (i.e.
 o getData()
This method returns the color the paint the data points that are not in the brush.
 o getHighlight()
This method returns the color to paint any highlighted data points
 o getText()
This method returns the color to pain the text on the screen
 o run()
This is the method that is called when a new thread is started.
 o setColor(int)
This will set the color of the object at the specified index.
 o setVisible(boolean, JVizInterface)
This allows this component to communicate with the display so it can be told to redraw itself when the colors are changed.
 o startAction(String)
This method is used to start a new thread.

Variables

 o nameArray
 protected String nameArray[]
 o GUIAction
 protected String GUIAction
 o parentFrame
 protected JFrame parentFrame
 o jvi
 protected JVizInterface jvi
 o combo
 protected JComboBox combo
 o applyButton
 protected JButton applyButton
 o okButton
 protected JButton okButton
 o cancelButton
 protected JButton cancelButton
 o rSlider
 protected JSlider rSlider
 o gSlider
 protected JSlider gSlider
 o bSlider
 protected JSlider bSlider
 o colorPanel
 protected ColorPanel colorPanel
 o nextColor
 protected Color nextColor
 o colorArray
 protected Color colorArray[]

Constructors

 o ColorManager
 public ColorManager(JFrame newParentFrame)
Constructor

Parameters:
newParentFrame - parent frame required to display this class as a dialog box.

Methods

 o startAction
 public void startAction(String action)
This method is used to start a new thread. The method we use is not thread safe, but deadlock will not occur. The worst case is that a GUI event is missed. We do not forsee that this implementation will cause too many problem, but a safer design would be using a queue of GUI events. We did not have time to implement this strategy for this version. What happens in this method is that it is passes a string, which represents an action to start in the new Thread. The action is stored in the GUIAction variable that the run() method uses to determine which function to call.

 o run
 public void run()
This is the method that is called when a new thread is started. It simply checks a variable and executes the corresponding menthod. This is an attempt to separate the processing the GUI thread from any processing. The methods that are called are by no means compute intensive, so threading might not be needed. In the future, there may be reasons to "unimplement" threads. As explained in the startAction() method documentation, this method is not thread safe.

 o getHighlight
 public Color getHighlight()
This method returns the color to paint any highlighted data points

Returns:
Color object of color to paint data points in the brush
 o getBrush
 public Color getBrush()
This method returns the color of the brush (i.e. the background brush)

Returns:
Color object of color to paint the brush
 o getData
 public Color getData()
This method returns the color the paint the data points that are not in the brush.

Returns:
Color object of the color to paint the data points
 o getBackground
 public Color getBackground()
This method returns the color to paint the background of the graph

Returns:
Color object of the color to paint the background of the graph
Overrides:
getBackground in class Component
 o getText
 public Color getText()
This method returns the color to pain the text on the screen

Returns:
Color object of the color to paint any text
 o setVisible
 public void setVisible(boolean state,
                        JVizInterface newJVI)
This allows this component to communicate with the display so it can be told to redraw itself when the colors are changed.

 o setColor
 public void setColor(int index)
This will set the color of the object at the specified index.

Parameters:
index - index into the colorArray array to change It is set to the color defined by the sliders.
 o changeColor
 public void changeColor(int index)
This method will change the color in the colorPanel to the color in the specified index. It also repsitions the corresponding RGB sliders to the correct positions.

Parameters:
index - index into the colorArray which will be the new color in the colorPanel.
 o changeRedSlider
 public void changeRedSlider()
This is called by the run method when the Red slider is repositioned. This also sets the nextColor variable which is basically the temporary variable we use when changing color values.

 o changeGreenSlider
 public void changeGreenSlider()
This is called by the run method when the Green slider is repositioned. This also sets the nextColor variable which is basically the temporary variable we use when changing color values.

 o changeBlueSlider
 public void changeBlueSlider()
This is called by the run method when the Blue slider is repositioned. This also sets the nextColor variable which is basically the temporary variable we use when changing color values.


All Packages  Class Hierarchy  This Package  Previous  Next  Index