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
-
applyButton
-
-
bSlider
-
-
cancelButton
-
-
colorArray
-
-
colorPanel
-
-
combo
-
-
gSlider
-
-
GUIAction
-
-
jvi
-
-
nameArray
-
-
nextColor
-
-
okButton
-
-
parentFrame
-
-
rSlider
-
-
ColorManager(JFrame)
-
Constructor
-
changeBlueSlider()
-
This is called by the run method when the Blue slider is repositioned.
-
changeColor(int)
-
This method will change the color in the colorPanel to the color in the
specified index.
-
changeGreenSlider()
-
This is called by the run method when the Green slider is repositioned.
-
changeRedSlider()
-
This is called by the run method when the Red slider is repositioned.
-
getBackground()
-
This method returns the color to paint the background of the graph
-
getBrush()
-
This method returns the color of the brush (i.e.
-
getData()
-
This method returns the color the paint the data points that are not in
the brush.
-
getHighlight()
-
This method returns the color to paint any highlighted data points
-
getText()
-
This method returns the color to pain the text on the screen
-
run()
-
This is the method that is called when a new thread is started.
-
setColor(int)
-
This will set the color of the object at the specified index.
-
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.
-
startAction(String)
-
This method is used to start a new thread.
nameArray
protected String nameArray[]
GUIAction
protected String GUIAction
parentFrame
protected JFrame parentFrame
jvi
protected JVizInterface jvi
combo
protected JComboBox combo
applyButton
protected JButton applyButton
okButton
protected JButton okButton
cancelButton
protected JButton cancelButton
rSlider
protected JSlider rSlider
gSlider
protected JSlider gSlider
bSlider
protected JSlider bSlider
colorPanel
protected ColorPanel colorPanel
nextColor
protected Color nextColor
colorArray
protected Color colorArray[]
ColorManager
public ColorManager(JFrame newParentFrame)
- Constructor
- Parameters:
- newParentFrame - parent frame required to display this class as a
dialog box.
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.
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.
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
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
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
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
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
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.
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.
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.
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.
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.
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