All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class edu.wpi.mqp.graphics.jviz.GlyphGraph

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----edu.wpi.mqp.graphics.jviz.GlyphGraph

public class GlyphGraph
extends JComponent
implements Cloneable, Serializable, JVizInterface
This class is in charge of rendering the glyph graphs and highlighting which are in the brush, etc. It follows the original design of the ParallelCoordinatesGraph class fairly closely for format. It extends JComponent because it is the base GUI component. It implements the JVizInterface so the zoom and print functions in the GUI can be called from this class.

Version:
1.0
Author:
Jason Sykes and Matthew C. Jucius

Variable Index

 o brush
 o brushChanged
 o colorManager
 o componentHeight
 o componentWidth
 o data
 o done
 o drawingThread
 o glyphHeight
 o glyphWidth
 o graphImage
 o min
 o modified
 o numAcross
 o popup
 o rayXCoords
 o rayYCoords
 o scale
 o screenSize
 o xCenters
 o xMargin
 o xVals
 o yCenters
 o yMargin
 o yVals
 o zoomFactor

Constructor Index

 o GlyphGraph(Data, Brush, ColorManager)
Constructor

Method Index

 o addNotify()
This method is called by the GUI before paint is first called.
 o getImage()
This method will return the image that is being drawn to.
 o getXMargin()
This method gets the amount of margin to place on the left and right side of the graph.
 o getYMargin()
This method returns the number of pixels of padding to place on the top and bottom of the graph.
 o getZoomFactor()
This method returns the zoom factor of this graph.
 o paint(Graphics)
This method overrides the paint() method in JComponent.
 o printScreen(JFrame)
This method, which is part of the JVizInterface interface, will print this graph to a printer.
 o processMouseEvent(MouseEvent)
This method handles all the mouse clicks and other mouse events.
 o setGraphModified()
This method allows calling calling classes to make sure the graph is redrawn from scratch on the next call to paint()
 o setNewBrushValue(int, int)
This method reshapes the brush when a glyph is clicked on.
 o setXMargin(int)
This method sets the amount of margin to place on the left and right sides of the graph to prevent crowding.
 o setYMargin(int)
This method sets the number of pixels of padding to place on the top and bottom of the graph.
 o setZoomFactor(double)
This method sets the zoom factor to the value specified and then changes the modified bit so that the graph will be redrawn the next time the paint() method is called.
 o showGlyphBrushTool(JFrame)
This method displays the glyph brush tool.
 o updateCoordinates()
This method forms an array of the y coordinates to use to graph each data point.

Variables

 o xMargin
 protected int xMargin
 o yMargin
 protected int yMargin
 o componentWidth
 protected int componentWidth
 o componentHeight
 protected int componentHeight
 o numAcross
 protected int numAcross
 o zoomFactor
 protected double zoomFactor
 o colorManager
 protected ColorManager colorManager
 o xVals
 protected int xVals[][]
 o yVals
 protected int yVals[][]
 o xCenters
 protected int xCenters[]
 o yCenters
 protected int yCenters[]
 o rayXCoords
 protected int rayXCoords[]
 o rayYCoords
 protected int rayYCoords[]
 o glyphWidth
 protected int glyphWidth
 o glyphHeight
 protected int glyphHeight
 o scale
 protected double scale[]
 o min
 protected double min[]
 o screenSize
 protected Dimension screenSize
 o data
 protected Data data
 o brush
 protected Brush brush
 o graphImage
 protected Image graphImage
 o done
 protected boolean done
 o brushChanged
 protected boolean brushChanged
 o modified
 protected boolean modified
 o drawingThread
 protected Thread drawingThread
 o popup
 protected JPopupMenu popup

Constructors

 o GlyphGraph
 public GlyphGraph(Data newData,
                   Brush newBrush,
                   ColorManager newColorManager)
Constructor

Parameters:
newData - data to graph
newBrush - brush to use with the data
newColorManager - object to request colors from when graphing

Methods

 o processMouseEvent
 public void processMouseEvent(MouseEvent e)
This method handles all the mouse clicks and other mouse events. If the mouse popup trigger is pressed, then the popup menu is formed and displayed It was in this method that we found the only problem/difference between the Unix versions of JViz and the Windows based version. In Unix, when the right mouse button is clicked, the only event we get is the popup trigger. In windows, we get a button click and a popup trigger event. This means, if the right mouse button is clicked while it is on one of the dimensions, the brush will change, then the popup menu will change. We had a test to get around this problem, but that caused problem in the UNIX environment, so it was removed. There may be a way to get around this problem, but we could not figure it out. It would be quite valuable to do this. This method also handles direct maninipulation of the brush using mouse clicks.

Parameters:
e - MouseEvent passed by the GUI
Overrides:
processMouseEvent in class Component
 o setNewBrushValue
 public boolean setNewBrushValue(int x,
                                 int y)
This method reshapes the brush when a glyph is clicked on. When the user clicks somewhere on the screen, the appropriate glyph is calculated from the x and y coordinates and then the center of the brush is changed to that brush's center. For each axis(dimension) if the glyph's value is above the center of the brush then the max for that axis is changed. If it is below the center of the brush then the min for that axis is changed.

Parameters:
x - X-coordinate where mouse pointer clicked
y - Y-coordinate where mouse pointer clicked
Returns:
true if successfully changed
 o printScreen
 public boolean printScreen(JFrame frame)
This method, which is part of the JVizInterface interface, will print this graph to a printer. Printing in Java redirects what is called in the paint() method to a printer. It will even print in color. NOTE - Currently this will print out a different sized graph depending on what the screen resolution of the monitor is since we use that to determine how big to make the on-screen image. It currently resizes the image to 50% and prints that out. It should be small enough to fit on paper, even if you are working at a higher resolution. There is a way to determine what the printer resolution is. Future versions could use this information to be more flexible with the printing options.

Parameters:
frame - parent frame
 o setGraphModified
 public void setGraphModified()
This method allows calling calling classes to make sure the graph is redrawn from scratch on the next call to paint()

 o updateCoordinates
 public void updateCoordinates()
This method forms an array of the y coordinates to use to graph each data point. This method gets called whenever the image needs to be redrawn. These functions make calls to draw the lines quite neat.

 o paint
 public void paint(Graphics g)
This method overrides the paint() method in JComponent. It draws the graph on the screen.

Parameters:
g - Graphics object passed by the GUI
Overrides:
paint in class JComponent
 o getXMargin
 public int getXMargin()
This method gets the amount of margin to place on the left and right side of the graph. This is so lines aren't drawn the extreme edges of the graphs. By default, it is set to 15 pixels

Returns:
number of pixels for the x margin
 o setXMargin
 public boolean setXMargin(int newXMargin)
This method sets the amount of margin to place on the left and right sides of the graph to prevent crowding. By default this value is 15 pixels

Parameters:
newXMargin - number of pixels to assign to xMargin
Returns:
true if successful in changing value
 o getYMargin
 public int getYMargin()
This method returns the number of pixels of padding to place on the top and bottom of the graph. The default value is 15 pixels.

Returns:
number of pixels of padding to place on the top and bottom of the graph.
 o setYMargin
 public boolean setYMargin(int newYMargin)
This method sets the number of pixels of padding to place on the top and bottom of the graph. The default vaule is 15 pixels.

Parameters:
newYMargin - number of pixels to assign to yMargin
Returns:
true if successfully set y Margin.
 o getZoomFactor
 public double getZoomFactor()
This method returns the zoom factor of this graph. The zoom factor is the decimal representation of the percentage of zoom. To display the graph at half size, the zoom factor would be .5. 1 is 100%, or full size.

Returns:
zoom factor as a double
 o setZoomFactor
 public boolean setZoomFactor(double newZoomFactor)
This method sets the zoom factor to the value specified and then changes the modified bit so that the graph will be redrawn the next time the paint() method is called. If the zoom factor is too high, the image needed for drawing the graph may need more memory than is available. We may want to pop up a dialog box in the future or handle this more gracefully/efficiently.

Parameters:
newZoomFactor - new zoom factor for the graph
Returns:
true if new zoomfactor is greater than 0
 o showGlyphBrushTool
 public void showGlyphBrushTool(JFrame parentFrame)
This method displays the glyph brush tool.

Parameters:
parentFrame - Passes the parent frame.
 o addNotify
 public void addNotify()
This method is called by the GUI before paint is first called. We override it and add functionality to the default action. This is where we initially create the image to paint on. We could not create the image in the constructor.

Overrides:
addNotify in class JComponent
 o getImage
 public Image getImage()
This method will return the image that is being drawn to.


All Packages  Class Hierarchy  This Package  Previous  Next  Index