All Packages Class Hierarchy This Package Previous Next Index
Class edu.wpi.mqp.graphics.jviz.ScatterPlotGraph
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----com.sun.java.swing.JComponent
|
+----edu.wpi.mqp.graphics.jviz.ScatterPlotGraph
- public class ScatterPlotGraph
- extends JComponent
- implements Cloneable, Serializable, JVizInterface
This class is probably the most sophisticated and complicated class in JViz.
It controls most of what happens with the Parallel Coordinates graph
rendering This class extends JComponent since that is the lowest common
denominator of GUI components. There is no need to use a component that
is a subclass of JComponent because we do not need its functionality. It
implements the JVizInterface so the calling GUI can call the zoom and
print methods in this class.
- Version:
- 1.0
- Author:
- William Kellogg and Matthew C. Jucius
-
activeDimensions
-
-
boxheight
-
-
boxwidth
-
-
brush
-
-
brushChanged
-
-
colorManager
-
-
componentHeight
-
-
componentWidth
-
-
ctrlDown
-
-
data
-
-
dim_max
-
-
dim_min
-
-
done
-
-
dragBrushEndH
-
-
dragBrushEndV
-
-
dragBrushStartH
-
-
dragBrushStartV
-
-
drawingThread
-
-
first
-
-
graphImage
-
-
modified
-
-
popup
-
-
scale
-
-
screenSize
-
-
shiftDown
-
-
shiftXmax
-
-
shiftXmin
-
-
shiftYmax
-
-
shiftYmin
-
-
xDim
-
-
xMargin
-
-
yDim
-
-
yMargin
-
-
zoomFactor
-
-
ScatterPlotGraph(Data, Brush, ColorManager)
-
Constructor
-
addNotify()
-
This method is called by the GUI before paint is first called.
-
getImage()
-
This method will return the image that is being drawn to.
-
getXMargin()
-
This method gets the amount of margin to place on the left and right
side of the graph.
-
getYMargin()
-
This method returns the number of pixels of padding to place on the top
and bottom of the graph.
-
getZoomFactor()
-
This method returns the zoom factor of this graph.
-
paint(Graphics)
-
This method overrides the paint() method in JComponent.
-
printScreen(JFrame)
-
This method, which is part of the JVizInterface interface, will print
this graph to a printer.
-
processMouseEvent(MouseEvent)
-
This method handles all the mouse clicks and other mouse events.
-
processMouseMotionEvent(MouseEvent)
-
This method overrides the processMouseMotionEvent method in JComponent.
-
setGraphModified()
-
This method allows calling calling classes to make sure the graph is
redrawn from scratch on the next call to paint()
-
setNewBrushValue(int, int)
-
This method will reshape the brush if the user clicks on any of the grids
within the matrix except those on the main diagonal.
-
setXMargin(int)
-
This method sets the amount of margin to place on the left and right sides
of the graph to prevent crowding.
-
setYMargin(int)
-
This method sets the number of pixels of padding to place on the top
and bottom of the graph.
-
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.
-
updateCoordinates()
-
This method gets called whenever the image needs to be redrawn.
xMargin
protected int xMargin
yMargin
protected int yMargin
xDim
protected int xDim
yDim
protected int yDim
boxheight
protected int boxheight
boxwidth
protected int boxwidth
zoomFactor
protected double zoomFactor
componentHeight
protected int componentHeight
componentWidth
protected int componentWidth
shiftDown
protected boolean shiftDown
ctrlDown
protected boolean ctrlDown
dragBrushStartH
protected double dragBrushStartH
dragBrushStartV
protected double dragBrushStartV
dragBrushEndH
protected double dragBrushEndH
dragBrushEndV
protected double dragBrushEndV
shiftXmin
protected double shiftXmin
shiftXmax
protected double shiftXmax
shiftYmin
protected double shiftYmin
shiftYmax
protected double shiftYmax
first
protected int first
dim_min
protected double dim_min[]
dim_max
protected double dim_max[]
scale
protected double scale[]
activeDimensions
protected int activeDimensions[]
screenSize
protected Dimension screenSize
data
protected Data data
brush
protected Brush brush
colorManager
protected ColorManager colorManager
graphImage
protected Image graphImage
done
protected boolean done
brushChanged
protected boolean brushChanged
modified
protected boolean modified
drawingThread
protected Thread drawingThread
popup
protected JPopupMenu popup
ScatterPlotGraph
public ScatterPlotGraph(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
processMouseMotionEvent
public void processMouseMotionEvent(MouseEvent e)
- This method overrides the processMouseMotionEvent method in JComponent.
It monitors where the mouse pointer is. If it moves over one of the
parallel vertical lines denoting a dimension, it will determine whether
the brush will be resized larger or smaller if clicked. It changes the
pointer to point up if the upper bounds of the brush will be changed or
changes the pointer to point down if the lower bounds of the brush will
be changed. This is to add a little more feedback for the user. Also, it
is not a detriment to performance.
- Parameters:
- e - MouseEvent object passed to this function by the GUI.
- Overrides:
- processMouseMotionEvent in class JComponent
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 chenge. We
had a test to get around this problem, but that caused problems in the UNIX
environment, so it was removed. There may be a way to get around this, 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, the shift key, and also the ocntrol key.
- Parameters:
- e - MouseEvent passed by the GUI
- Overrides:
- processMouseEvent in class Component
setNewBrushValue
public boolean setNewBrushValue(int x,
int y)
- This method will reshape the brush if the user clicks on any of the grids
within the matrix except those on the main diagonal. It changes the value
of the brush to the coordinates of the point clicked. If the x coordiante
is beyond the center of the brush, then the max boundary will change. If it
is less than the center, then the minimum value will be changed.
The same goes for the y coordinate. If the y coordinate is above the center of
the brush, then the max boundary will be changed. If it is below the center,
then the minimum value will be changed. If the X coordinate is not on a
dimension, none of the values are changed.
- Parameters:
- x - X-coordinate where mouse pointer clicked
- y - Y-coordinate where mouse pointer clicked
- Returns:
-
true
if successfully changed
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()
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
updateCoordinates
public void updateCoordinates()
- This method gets called whenever the image needs to be redrawn.
The method determines the height and width of the image as well as
calculating the scale for each dimension and filling in the dim_min array
These functions make calls to draw the lines quite neat.
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
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
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
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.
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.
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
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, so
we catch that exception. 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
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
getImage
public Image getImage()
- This method will return the image that is being drawn to.
All Packages Class Hierarchy This Package Previous Next Index