org.rosuda.ibase.plots
Class ScatterCanvas

java.lang.Object
  extended by org.rosuda.ibase.toolkit.PlotComponent
      extended by org.rosuda.ibase.toolkit.PGSCanvas
          extended by org.rosuda.ibase.toolkit.BaseCanvas
              extended by org.rosuda.ibase.plots.ScatterCanvas
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.print.Printable, java.util.EventListener, Commander, Dependent
Direct Known Subclasses:
MapScatterCanvas, SectScatterCanvas

public class ScatterCanvas
extends BaseCanvas

implementation of scatterplots

Version:
$Id: ScatterCanvas.java 2734 2007-04-25 09:44:28Z wichtrey $

Nested Class Summary
 
Nested classes/interfaces inherited from class org.rosuda.ibase.toolkit.PGSCanvas
PGSCanvas.IDlgCL
 
Field Summary
 boolean bgTopOnly
          Deprecated. only used by klimt
 int changePtDiamBy
          The number of pixels the point diameter should be changed when in-/decreasing it.
 java.awt.Color COL_CUSTOMBG
          Custom background color.
 boolean customFieldBg
           
protected  boolean drag
           
 boolean drawAxes
          Whether axes shoud be drawn.
protected  int[] filter
           
protected  int H
           
protected  java.awt.MenuItem MIlabels
           
 int minimalDiam
          minimal point diameter
 int ptDiam
          diameter of a point
protected  int pts
          # of points
protected  boolean showLabels
          flag whether axis labels should be shown
protected  java.util.TreeMap sortedPointsX
          sorted set of the points, used to check with log(n) time cost if a point belongs to an existing primitive
protected  java.util.TreeMap sortedPointsY
          sorted set of the points, used to check with log(n) time cost if a point belongs to an existing primitive
protected  int TH
           
protected  int TW
           
protected  SVar[] v
          array of two variables (X and Y)
protected  int W
           
protected  int x1
           
protected  int x2
           
protected  int Y
           
protected  int y1
           
protected  int y2
           
protected  boolean zoomRetainsAspect
           
 
Fields inherited from class org.rosuda.ibase.toolkit.BaseCanvas
allow180, allowDragMove, allowDragZoom, allowZoom, alphaHighlighting, autoAdjustMargins, baseDrag, baseDragX1, baseDragX2, baseDragY1, baseDragY2, borderColor, borderColorSel, C_BLACK, changingHilitingNeedsUpdateRoot, COL_INVALID, COL_OUTLINE, COL_SELBG, COL_ZOOMBG, defaultMBottom, defaultMBottom1, defaultMBottom2, defaultMBottom3, defaultMLeft, defaultMLeft1, defaultMLeft2, defaultMLeft3, defaultMRight, defaultMRight1, defaultMRight2, defaultMRight3, defaultMTop, defaultMTop1, defaultMTop2, defaultMTop3, dontCache, dontPaint, fillColor, fillColorSel, fillInside, horizontalMedDist, horizontalMinDist, ignoreNotifications, inQuery, inZoom, isExtQuery, lastQueriedIndex, lastQueriedPrimitive, m, M_ALPHADOWN, M_ALPHAUP, M_RESETZOOM, M_SETCB1, M_SETCB64, M_TRANSHIGHL, mBottom, MItransHighl, mLeft, mouseX, mouseY, moveDrag, mRight, mTop, objectClipping, opAx, opAy, orientation, paintOutline, pop, pp, ppAlpha, ppAlphaH, qi, queryables, resizeOnRotate, rotateYLabels, rotateYLabelsBy, selDrag, selectedPaintOutline, seperateAlphas, showOnlyHilited, showQuery, updateGeometry, verticalMedDist, verticalMinDist, xLabels, yLabels, zoomDrag, zoomSequence
 
Fields inherited from class org.rosuda.ibase.toolkit.PGSCanvas
ax, ay, cancel, desc, inProgress, intDlg, myFrame, pageFormat, paintLayerCounter, pm
 
Fields inherited from class org.rosuda.ibase.toolkit.PlotComponent
AWTGrDevID, GrDevID, JOGLGrDevID, layers, SWINGGrDevID
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
ScatterCanvas(int gd, java.awt.Frame f, SVar v1, SVar v2, SMarker mark)
          create a new scatterplot
 
Method Summary
protected  java.lang.String getAxisQuery(int x, int y)
           
 SVar getData(int id)
          this method provides an API to fetch data contents of the plot.
protected  PlotPrimitive getFirstPrimitiveContaining(int x, int y)
          Determine the first plot primitive containing the given point.
protected  Axis getMouseOverAxis(int x, int y)
           
protected  PlotPrimitive[] getPrimitivesContaining(int x, int y)
          Determine the plot primitives containing the given point.
protected  PlotPrimitive[] getPrimitivesIntersecting(java.awt.Rectangle rec)
          Determine the plot primitives intersecting the given rectangle.
 double getSpaceprop()
          Get the amount of space around the data points.
 void keyPressed(java.awt.event.KeyEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent ev)
           
 void paintBack(PoGraSS g)
           
 void paintPost(PoGraSS g)
           
 java.lang.String queryObject(PlotPrimitive p)
           
 java.lang.String queryPlotSpace()
           
 void rotate()
           
 java.lang.Object run(java.lang.Object o, java.lang.String cmd)
          default handing of commands "exportPGS" and "exportPS".
 void setEquiscale(boolean equiscale)
           
 void setFilter(int[] f)
          Deprecated.  
 void setFilter(java.util.Vector v)
          Deprecated.  
 void setSpaceprop(double SPACEPROP)
          Sets the amount of space around the data points. 1.0 means no space, 1.5 means half as much space around the data as is used for the data itself.
 void updateObjects()
          rebuilds plot primitives - subclasses should override this method.
 
Methods inherited from class org.rosuda.ibase.toolkit.BaseCanvas
actionPerformed, addXLabels, addXLabels, addXLabels, addXLabels, addYLabels, addYLabels, addYLabels, adjustMargin, createMenu, dispose, endAddingLabels, getAxisX, getAxisY, getBoundValues, getDefaultMLeft, getMBottom, getMinimumSize, getMLeft, getMRight, getMTop, isShowLabels, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mousePressed, mouseReleased, Notifying, paintInit, paintObjects, paintPoGraSS, paintSelected, performZoomIn, performZoomIn, performZoomOut, queryObject, resetZoom, rotate, setAxDefaultGeometry, setAyDefaultGeometry, setColors, setDefaultMargins, setExtQueryString, setMBottom, setMLeft, setMRight, setMTop, setQueryText, setQueryText, setQueryText, setShowLabels, startAddingLabels, useExtQuery
 
Methods inherited from class org.rosuda.ibase.toolkit.PGSCanvas
beginPaint, endPaint, finalize, forcedFlush, getFrame, getGlobalNotifier, getPlotManager, getTitle, getXAxis, getYAxis, nextLayer, paintLayer, print, setFrame, setOption, setOption, setOption, setOption, setOption, setOption, setTitle
 
Methods inherited from class org.rosuda.ibase.toolkit.PlotComponent
addKeyListener, addMouseListener, addMouseMotionListener, getBounds, getComponent, getHeight, getLocation, getParent, getSize, getWidth, newQueryPopup, newQueryPopup, paintLayer, repaint, setBackground, setCursor, setSize, setSize, setToolTipText, setUpdateRoot
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

v

protected SVar[] v
array of two variables (X and Y)


showLabels

protected boolean showLabels
flag whether axis labels should be shown


bgTopOnly

public boolean bgTopOnly
Deprecated. only used by klimt
if true partition nodes above current node only


ptDiam

public int ptDiam
diameter of a point


minimalDiam

public int minimalDiam
minimal point diameter


customFieldBg

public boolean customFieldBg

pts

protected int pts
# of points


x1

protected int x1

y1

protected int y1

x2

protected int x2

y2

protected int y2

drag

protected boolean drag

MIlabels

protected java.awt.MenuItem MIlabels

Y

protected int Y

W

protected int W

H

protected int H

TW

protected int TW

TH

protected int TH

filter

protected int[] filter

zoomRetainsAspect

protected boolean zoomRetainsAspect

COL_CUSTOMBG

public java.awt.Color COL_CUSTOMBG
Custom background color. Defaults to white.


changePtDiamBy

public int changePtDiamBy
The number of pixels the point diameter should be changed when in-/decreasing it.


drawAxes

public boolean drawAxes
Whether axes shoud be drawn.


sortedPointsX

protected java.util.TreeMap sortedPointsX
sorted set of the points, used to check with log(n) time cost if a point belongs to an existing primitive


sortedPointsY

protected java.util.TreeMap sortedPointsY
sorted set of the points, used to check with log(n) time cost if a point belongs to an existing primitive

Constructor Detail

ScatterCanvas

public ScatterCanvas(int gd,
                     java.awt.Frame f,
                     SVar v1,
                     SVar v2,
                     SMarker mark)
create a new scatterplot

Parameters:
f - associated frame (or null if none)
v1 - variable 1
v2 - variable 2
mark - associated marker
Method Detail

getData

public SVar getData(int id)
Description copied from class: PGSCanvas
this method provides an API to fetch data contents of the plot. The id is implementation-dependent, but first two variables x and y should be mapped to 0 and 1 correspondingly. Therefore every plot containting data must support getData(0). For invalid ids null is returned.

Overrides:
getData in class PGSCanvas

setFilter

public void setFilter(int[] f)
Deprecated. 


setFilter

public void setFilter(java.util.Vector v)
Deprecated. 


rotate

public void rotate()
Overrides:
rotate in class BaseCanvas

updateObjects

public void updateObjects()
Description copied from class: BaseCanvas
rebuilds plot primitives - subclasses should override this method. It is not defined as abstract only for convenience, but minimal subclass simply overrides this method.

Overrides:
updateObjects in class BaseCanvas

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Specified by:
keyPressed in interface java.awt.event.KeyListener
Overrides:
keyPressed in class BaseCanvas

run

public java.lang.Object run(java.lang.Object o,
                            java.lang.String cmd)
Description copied from class: PGSCanvas
default handing of commands "exportPGS" and "exportPS". Any descendant should call super.run(o,cmd) to retain this functionality

Specified by:
run in interface Commander
Overrides:
run in class BaseCanvas
Parameters:
o - origin of the command
cmd - command string
Returns:
any object, the actual interpretation is up to the calling object

paintBack

public void paintBack(PoGraSS g)
Overrides:
paintBack in class BaseCanvas

queryObject

public java.lang.String queryObject(PlotPrimitive p)
Overrides:
queryObject in class BaseCanvas

queryPlotSpace

public java.lang.String queryPlotSpace()
Overrides:
queryPlotSpace in class BaseCanvas

paintPost

public void paintPost(PoGraSS g)
Overrides:
paintPost in class BaseCanvas

getFirstPrimitiveContaining

protected PlotPrimitive getFirstPrimitiveContaining(int x,
                                                    int y)
Description copied from class: BaseCanvas
Determine the first plot primitive containing the given point. Can be overridden to achieve better performance.

Overrides:
getFirstPrimitiveContaining in class BaseCanvas
Returns:
The matching primitive or null if point doesn't belong to any primitive.

getPrimitivesContaining

protected PlotPrimitive[] getPrimitivesContaining(int x,
                                                  int y)
Description copied from class: BaseCanvas
Determine the plot primitives containing the given point. Can be overridden to achieve better performance.

Overrides:
getPrimitivesContaining in class BaseCanvas
Returns:
Array of matching primitives.

getPrimitivesIntersecting

protected PlotPrimitive[] getPrimitivesIntersecting(java.awt.Rectangle rec)
Description copied from class: BaseCanvas
Determine the plot primitives intersecting the given rectangle. Can be overridden to achieve better performance.

Overrides:
getPrimitivesIntersecting in class BaseCanvas
Returns:
Array of intersecting primitives.

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent ev)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class BaseCanvas

getMouseOverAxis

protected Axis getMouseOverAxis(int x,
                                int y)

getAxisQuery

protected java.lang.String getAxisQuery(int x,
                                        int y)
Overrides:
getAxisQuery in class BaseCanvas

getSpaceprop

public double getSpaceprop()
Get the amount of space around the data points.

Returns:
amount of space
See Also:
setSpaceprop(double)

setSpaceprop

public void setSpaceprop(double SPACEPROP)
Sets the amount of space around the data points. 1.0 means no space, 1.5 means half as much space around the data as is used for the data itself. updateObjects() needs to be called afterwards.

Parameters:
SPACEPROP - New amount of space. Defaults to 1.1.

setEquiscale

public void setEquiscale(boolean equiscale)