public class Plot2D
extends javax.swing.JPanel
javax.swing.JPanel.AccessibleJPaneljavax.swing.JComponent.AccessibleJComponent| Modifier and Type | Field and Description |
|---|---|
static int |
CONST_AUTOMATIC_SHAPE |
static int |
DEFAULT_SHAPE_SIZE |
static int |
DIAMOND_SHAPE |
static int |
ERROR_SHAPE |
protected boolean |
m_axisChanged
if the user changes attribute assigned to an axis
|
protected java.awt.Color |
m_axisColour
Default colour for the axis
|
protected int |
m_axisPad
Axis padding
|
protected java.awt.Color |
m_backgroundColour
Default colour for the plot background
|
protected int |
m_cIndex |
protected java.util.ArrayList<java.awt.Color> |
m_colorList
The list of the colors used
|
protected java.awt.Color[] |
m_DefaultColors
default colours for colouring discrete class
|
protected int[][] |
m_drawnPoints
An array used to show if a point is hidden or not.
|
protected javax.swing.JFrame |
m_InstanceInfo
For popping up text info on data points
|
protected java.lang.Class<?> |
m_InstanceInfoFrameClass
the class for displaying instance info.
|
protected int |
m_JitterVal
the level of jitter
|
protected java.util.Random |
m_JRand
random values for perterbing the data points
|
protected java.awt.Font |
m_labelFont
Font for labels
|
protected java.awt.FontMetrics |
m_labelMetrics |
protected java.lang.String |
m_masterName
The name of the master plot
|
protected PlotData2D |
m_masterPlot
The master plot
|
protected double |
m_maxC |
protected double |
m_maxX
Holds the min and max values of the x, y and colouring attributes over all
plots
|
protected double |
m_maxY |
protected double |
m_minC |
protected double |
m_minX |
protected double |
m_minY |
protected Plot2DCompanion |
m_plotCompanion
An optional "compainion" of the panel.
|
protected Instances |
m_plotInstances
The instances to be plotted
|
protected boolean |
m_plotResize
if the user resizes the window, or the attributes selected for the
attributes change, then the lookup table for points needs to be
recalculated
|
protected java.util.ArrayList<PlotData2D> |
m_plots
The plots to display
|
protected int |
m_sIndex |
protected int |
m_tickSize
Tick size
|
protected int |
m_XaxisEnd |
protected int |
m_XaxisStart
the offsets of the axes once label metrics are calculated
|
protected int |
m_xIndex
Indexes of the attributes to go on the x and y axis and the attribute to
use for colouring and the current shape for drawing
|
protected int |
m_YaxisEnd |
protected int |
m_YaxisStart |
protected int |
m_yIndex |
static int |
MAX_SHAPES |
static int |
MISSING_SHAPE |
static int |
PLUS_SHAPE |
static int |
TRIANGLEDOWN_SHAPE |
static int |
TRIANGLEUP_SHAPE |
static int |
X_SHAPE |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
Plot2D()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPlot(PlotData2D newPlot)
Add a plot to the list of plots to display
|
void |
applySettings(Settings settings,
java.lang.String ownerID)
Apply settings
|
protected static java.awt.Color |
checkAgainstBackground(java.awt.Color c,
java.awt.Color background) |
double |
convertToAttribX(double scx)
convert a Panel x coordinate to a raw x value.
|
double |
convertToAttribY(double scy)
convert a Panel y coordinate to a raw y value.
|
double |
convertToPanelX(double xval)
Convert an raw x value to Panel x coordinate.
|
double |
convertToPanelY(double yval)
Convert an raw y value to Panel y coordinate.
|
void |
determineBounds()
Determine the min and max values for axis and colouring attributes
|
protected static void |
drawDataPoint(double x,
double y,
double xprev,
double yprev,
int size,
int shape,
java.awt.Graphics gx)
Draws a data point at a given set of panel coordinates at a given size and
connects a line to the previous point.
|
protected static void |
drawDataPoint(double x,
double y,
int size,
int shape,
java.awt.Graphics gx)
Draws a data point at a given set of panel coordinates at a given size.
|
PlotData2D |
getMasterPlot()
Get the master plot
|
double |
getMaxC()
Return the current max value of the colouring attribute
|
double |
getMaxX()
Return the current max value of the attribute plotted on the x axis
|
double |
getMaxY()
Return the current max value of the attribute plotted on the y axis
|
double |
getMinC()
Return the current min value of the colouring attribute
|
double |
getMinX()
Return the current min value of the attribute plotted on the x axis
|
double |
getMinY()
Return the current min value of the attribute plotted on the y axis
|
java.util.ArrayList<PlotData2D> |
getPlots()
Return the list of plots
|
static void |
main(java.lang.String[] args)
Main method for testing this class
|
void |
paintComponent(java.awt.Graphics gx)
Renders this component
|
void |
removeAllPlots()
Clears all plots
|
void |
searchPoints(int x,
int y,
boolean newFrame)
Pops up a window displaying attribute information on any instances at a
point+-plotting_point_size (in panel coordinates)
|
void |
setCindex(int c)
Set the index of the attribute to use for colouring
|
void |
setColours(java.util.ArrayList<java.awt.Color> cols)
Set a list of colours to use when colouring points according to class
values or cluster numbers
|
void |
setInstances(Instances inst)
Sets the master plot from a set of instances
|
void |
setJitter(int j)
Set level of jitter and repaint the plot using the new jitter value
|
void |
setMasterPlot(PlotData2D master)
Set the master plot.
|
void |
setPlotCompanion(Plot2DCompanion p)
Set a companion class.
|
void |
setXindex(int x)
Set the index of the attribute to go on the x axis
|
void |
setYindex(int y)
Set the index of the attribute to go on the y axis
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final int MAX_SHAPES
public static final int ERROR_SHAPE
public static final int MISSING_SHAPE
public static final int CONST_AUTOMATIC_SHAPE
public static final int X_SHAPE
public static final int PLUS_SHAPE
public static final int DIAMOND_SHAPE
public static final int TRIANGLEUP_SHAPE
public static final int TRIANGLEDOWN_SHAPE
public static final int DEFAULT_SHAPE_SIZE
protected java.awt.Color m_axisColour
protected java.awt.Color m_backgroundColour
protected java.util.ArrayList<PlotData2D> m_plots
protected PlotData2D m_masterPlot
protected java.lang.String m_masterName
protected Instances m_plotInstances
protected Plot2DCompanion m_plotCompanion
protected java.lang.Class<?> m_InstanceInfoFrameClass
protected javax.swing.JFrame m_InstanceInfo
protected java.util.ArrayList<java.awt.Color> m_colorList
protected java.awt.Color[] m_DefaultColors
protected int m_xIndex
protected int m_yIndex
protected int m_cIndex
protected int m_sIndex
protected double m_maxX
protected double m_minX
protected double m_maxY
protected double m_minY
protected double m_maxC
protected double m_minC
protected final int m_axisPad
protected final int m_tickSize
protected int m_XaxisStart
protected int m_YaxisStart
protected int m_XaxisEnd
protected int m_YaxisEnd
protected boolean m_plotResize
protected boolean m_axisChanged
protected int[][] m_drawnPoints
protected java.awt.Font m_labelFont
protected java.awt.FontMetrics m_labelMetrics
protected int m_JitterVal
protected java.util.Random m_JRand
public void applySettings(Settings settings, java.lang.String ownerID)
settings - the settings to applyownerID - the ID of the owner perspective, panel etc. to use when
looking up our settingspublic void setPlotCompanion(Plot2DCompanion p)
p - a companion classpublic void setJitter(int j)
j - the level of jitterpublic void setColours(java.util.ArrayList<java.awt.Color> cols)
cols - the list of colours to usepublic void setXindex(int x)
x - the index of the attribute to use on the x axispublic void setYindex(int y)
y - the index of the attribute to use on the y axispublic void setCindex(int c)
c - the index of the attribute to use for colouringpublic java.util.ArrayList<PlotData2D> getPlots()
public PlotData2D getMasterPlot()
public double getMaxX()
public double getMaxY()
public double getMinX()
public double getMinY()
public double getMaxC()
public double getMinC()
public void setInstances(Instances inst) throws java.lang.Exception
inst - the instancesjava.lang.Exception - if instances could not be setpublic void setMasterPlot(PlotData2D master) throws java.lang.Exception
master - the plot to make the master plotjava.lang.Exception - if the plot could not be set.public void removeAllPlots()
public void addPlot(PlotData2D newPlot) throws java.lang.Exception
newPlot - the new plot to addjava.lang.Exception - if the plot could not be addedpublic void searchPoints(int x,
int y,
boolean newFrame)
x - the x value of the clicked pointy - the y value of the clicked pointnewFrame - true if instance info is to be displayed in a new frame.public void determineBounds()
public double convertToAttribX(double scx)
scx - The Panel x coordinatepublic double convertToAttribY(double scy)
scy - The Panel y coordinatepublic double convertToPanelX(double xval)
xval - the raw x valuepublic double convertToPanelY(double yval)
yval - the raw y valueprotected static void drawDataPoint(double x,
double y,
double xprev,
double yprev,
int size,
int shape,
java.awt.Graphics gx)
x - the x coordy - the y coordxprev - the x coord of the previous pointyprev - the y coord of the previous pointsize - the size of the pointshape - the shape of the data point (square is reserved for nominal
error data points). Shapes: 0=x, 1=plus, 2=diamond,
3=triangle(up), 4 = triangle (down).gx - the graphics contextprotected static void drawDataPoint(double x,
double y,
int size,
int shape,
java.awt.Graphics gx)
x - the x coordy - the y coordsize - the size of the pointshape - the shape of the data point (square is reserved for nominal
error data points). Shapes: 0=x, 1=plus, 2=diamond,
3=triangle(up), 4 = triangle (down).gx - the graphics contextpublic void paintComponent(java.awt.Graphics gx)
paintComponent in class javax.swing.JComponentgx - the graphics contextprotected static java.awt.Color checkAgainstBackground(java.awt.Color c,
java.awt.Color background)
public static void main(java.lang.String[] args)
args - arguments