|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.rosuda.ibase.toolkit.PlotComponent org.rosuda.ibase.toolkit.PGSCanvas org.rosuda.ibase.toolkit.BaseCanvas
public class BaseCanvas
BaseCanvas - basis for all interactive plots which rely on plot primitives concept. To ensure consistent behavior all plots should be based on this class whenever possible. BaseCanvas includes key and mouse handling, selection and queries.
Although BaseCanvas is not abstract, is it not usable on its own (except maybe for testing). Any subclasses should override at least the updateObjects()
method to initialize plot primitives. Displaying and selection of following plot primitives is supported out-of-the-box: points, rectangles and polygons. The subclass constructor should (beside calling super constructor) set any of the control flags to customize the behavior of this class.
BaseCanvas implements all key and mouse listeners as well as commander interface (actions are mapped into commands). This implies that a subclass it free to overload any individual methods of those. Just make sure that you provide calls to parent methods to preserve all functionality.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.rosuda.ibase.toolkit.PGSCanvas |
---|
PGSCanvas.IDlgCL |
Field Summary | |
---|---|
protected boolean |
allow180
if set to false then rotating is allowed only between orientation values 0 and 1 (ergo rotation over 180 degrees is not allowed) |
protected boolean |
allowDragMove
if set to true then move-dragging is allowed. |
protected boolean |
allowDragZoom
if set to true then zoom-dragging is allowed. |
protected boolean |
allowZoom
if set to true then zoom is allowed |
protected boolean |
alphaHighlighting
if set to true alpha will be applied to highlighting, too |
boolean |
autoAdjustMargins
if set to true then the margins can be adjusted automatically |
protected boolean |
baseDrag
run-time flag is set to true if baseDragging is in process |
protected int |
baseDragX1
|
protected int |
baseDragX2
|
protected int |
baseDragY1
|
protected int |
baseDragY2
|
java.awt.Color |
borderColor
|
java.awt.Color |
borderColorSel
|
protected static java.lang.String |
C_BLACK
|
protected int |
changingHilitingNeedsUpdateRoot
|
java.awt.Color |
COL_INVALID
|
java.awt.Color |
COL_OUTLINE
|
java.awt.Color |
COL_SELBG
|
java.awt.Color |
COL_ZOOMBG
|
protected int |
defaultMBottom
|
protected int |
defaultMBottom1
|
protected int |
defaultMBottom2
|
protected int |
defaultMBottom3
|
protected int |
defaultMLeft
|
protected int |
defaultMLeft1
|
protected int |
defaultMLeft2
|
protected int |
defaultMLeft3
|
protected int |
defaultMRight
|
protected int |
defaultMRight1
|
protected int |
defaultMRight2
|
protected int |
defaultMRight3
|
protected int |
defaultMTop
|
protected int |
defaultMTop1
|
protected int |
defaultMTop2
|
protected int |
defaultMTop3
|
protected boolean |
dontCache
by default BaseCanvas caches layers whenever possible, that is only paintInit(org.rosuda.pograss.PoGraSS) is guaranteed to be run before paintBack(org.rosuda.pograss.PoGraSS) , paintObjects(org.rosuda.pograss.PoGraSS) and paintSelected(org.rosuda.pograss.PoGraSS) . |
protected boolean |
dontPaint
prevents painting (and thus calling updateObjects) until set to false. |
java.awt.Color |
fillColor
|
java.awt.Color |
fillColorSel
|
protected boolean |
fillInside
if set to true plot primitives are filled. |
protected int |
H
|
int |
horizontalMedDist
|
int |
horizontalMinDist
|
protected boolean |
ignoreNotifications
if set to true all notifications are rejected. |
protected boolean |
inQuery
run-time flag is set to true if query mode is on - (currently it means that |
protected boolean |
inZoom
run-time flag is set to true if zoom mode is on |
protected boolean |
isExtQuery
if set to true extended query is used |
protected int |
lastQueriedIndex
|
protected PlotPrimitive |
lastQueriedPrimitive
|
protected SMarker |
m
marker of the plot. |
protected static java.lang.String |
M_ALPHADOWN
|
protected static java.lang.String |
M_ALPHAUP
|
protected static java.lang.String |
M_RESETZOOM
|
protected static java.lang.String |
M_SETCB1
|
protected static java.lang.String |
M_SETCB64
|
protected static java.lang.String |
M_TRANSHIGHL
|
protected int |
mBottom
plot area margins. |
protected java.awt.MenuItem |
MItransHighl
|
protected int |
mLeft
plot area margins. |
protected int |
mouseX
|
protected int |
mouseY
|
protected boolean |
moveDrag
run-time flag is set to true if the current baseDrag is a move |
protected int |
mRight
plot area margins. |
protected int |
mTop
plot area margins. |
protected boolean |
objectClipping
if set to true don't paint objects outside the margins defined by mLeft etc. |
protected Axis[] |
opAx
arrays of additional axes that are updated upon resize. can be null |
protected Axis[] |
opAy
|
protected int |
orientation
orientation of the plot. |
protected boolean |
paintOutline
if set to true outline of plot primitives is painted (applies to default paint handler. subclasses of BaseCanvas don't have to respect this flag if may display more complex primitives) |
protected java.awt.PopupMenu |
pop
|
protected PlotPrimitive[] |
pp
plot primitives which form the basis for data display and selection |
protected float |
ppAlpha
|
protected float |
ppAlphaH
alpha value for hilited primitives; is only used when seperateAlphas is true |
protected QueryPopup |
qi
query popup window |
protected java.util.List |
queryables
List of objects that respond to queries not including those contained in pp . |
protected boolean |
resizeOnRotate
if set to true then rotating the canvas also results in flipped size geometry of the canvas. |
boolean |
rotateYLabels
|
double |
rotateYLabelsBy
|
protected boolean |
selDrag
run-time flag is set to true if the current baseDrag is a selection |
protected boolean |
selectedPaintOutline
same functionality as paintOutline but applies to selected objects only |
protected boolean |
seperateAlphas
if set to true hilited and normal primitives can have different alphas |
protected boolean |
showOnlyHilited
if set to true only hilighted primitives will be shown |
protected boolean |
showQuery
|
protected boolean |
updateGeometry
if set to true then next repaint will force update of geometry, that is it will behave as if the canvas size was changed resulting in updated axes and objects. |
int |
verticalMedDist
|
int |
verticalMinDist
|
protected int |
W
|
protected PlotTextVector |
xLabels
PlotText object containing labels. |
protected PlotTextVector |
yLabels
|
protected boolean |
zoomDrag
run-time flag is set to true if the current baseDrag is a zoom |
protected boolean |
zoomRetainsAspect
if set to true then zooming-in always retians the aspect ratio (at least default zoom handling via axes does. |
protected java.util.List |
zoomSequence
this list can be used to track the sequence of zooms. |
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 | |
---|---|
BaseCanvas(int gd,
java.awt.Frame f,
SMarker mark)
basic constructor. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
|
void |
addXLabels(PoGraSS g,
Axis axis,
java.lang.String[] names,
int[] maxWidths,
int[] positions,
boolean ticks,
boolean abbreviate)
|
void |
addXLabels(PoGraSS g,
Axis axis,
java.lang.String[] names,
int[] maxWidths,
int[] positions,
boolean ticks,
boolean abbreviate,
boolean top)
|
void |
addXLabels(PoGraSS g,
Axis axis,
java.lang.String[] names,
int maxWidth,
int[] positions,
boolean ticks,
boolean abbreviate)
|
void |
addXLabels(PoGraSS g,
Axis axis,
java.lang.String[] names,
int maxWidth,
int[] positions,
boolean ticks,
boolean abbreviate,
boolean top)
|
void |
addYLabels(PoGraSS g,
Axis axis,
boolean ticks,
boolean abbreviate)
|
void |
addYLabels(PoGraSS g,
Axis axis,
java.lang.String[] names,
int[] maxH,
int[] positions,
boolean ticks,
boolean abbreviate)
|
void |
addYLabels(PoGraSS g,
Axis axis,
SVar sVar,
boolean ticks,
boolean abbreviate)
|
boolean |
adjustMargin(PoGraSS g)
Possibly adjust mLeft etc. |
protected void |
createMenu(java.awt.Frame f,
boolean rotate,
boolean zoom,
boolean transparency,
boolean activeCB,
java.lang.String[] view)
|
void |
dispose()
|
protected void |
endAddingLabels()
|
protected java.lang.String |
getAxisQuery(int x,
int y)
|
Axis |
getAxisX()
|
Axis |
getAxisY()
|
double[] |
getBoundValues()
|
protected int |
getDefaultMLeft()
|
protected PlotPrimitive |
getFirstPrimitiveContaining(int x,
int y)
Determine the first plot primitive containing the given point. |
int |
getMBottom()
|
java.awt.Dimension |
getMinimumSize()
|
int |
getMLeft()
|
int |
getMRight()
|
int |
getMTop()
|
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. |
boolean |
isShowLabels()
|
void |
keyPressed(java.awt.event.KeyEvent e)
|
void |
keyReleased(java.awt.event.KeyEvent e)
|
void |
keyTyped(java.awt.event.KeyEvent e)
|
void |
mouseClicked(java.awt.event.MouseEvent ev)
|
void |
mouseDragged(java.awt.event.MouseEvent e)
|
void |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
|
void |
mouseMoved(java.awt.event.MouseEvent ev)
|
void |
mousePressed(java.awt.event.MouseEvent ev)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
|
void |
Notifying(NotifyMsg msg,
java.lang.Object o,
java.util.Vector path)
notification handler - rebuild objects if necessary (AxisDataChange/VarChange) and repaint |
void |
paintBack(PoGraSS g)
|
void |
paintInit(PoGraSS g)
|
void |
paintObjects(PoGraSS g)
|
void |
paintPoGraSS(PoGraSS g)
actual paint method - subclasses should NOT override this method! |
void |
paintPost(PoGraSS g)
|
void |
paintSelected(PoGraSS g)
|
void |
performZoomIn(int x1,
int y1,
int x2,
int y2)
|
void |
performZoomIn(int x1,
int y1,
int x2,
int y2,
Axis xAx,
Axis xAy)
|
void |
performZoomOut(int x,
int y)
|
java.lang.String |
queryObject(int i)
|
java.lang.String |
queryObject(PlotPrimitive p)
|
java.lang.String |
queryPlotSpace()
|
void |
resetZoom()
|
void |
rotate()
|
void |
rotate(int amount)
|
java.lang.Object |
run(java.lang.Object o,
java.lang.String cmd)
default handing of commands "exportPGS" and "exportPS". |
protected void |
setAxDefaultGeometry()
|
protected void |
setAyDefaultGeometry()
|
protected void |
setColors(PPrimBase ppb)
|
void |
setDefaultMargins(int[] margins)
sets the default margins. order: left, right, top, bottom |
void |
setExtQueryString(java.lang.String str)
needed for setting manually extended query string |
void |
setMBottom(int mBottom)
|
void |
setMLeft(int mLeft)
|
void |
setMRight(int mRight)
|
void |
setMTop(int mTop)
|
void |
setQueryText(java.lang.String s)
|
void |
setQueryText(java.lang.String s,
int cid)
|
void |
setQueryText(java.lang.String s,
int[] cid)
|
void |
setShowLabels(boolean showLabels)
|
protected void |
startAddingLabels()
|
void |
updateObjects()
rebuilds plot primitives - subclasses should override this method. |
void |
useExtQuery(boolean b)
|
Methods inherited from class org.rosuda.ibase.toolkit.PGSCanvas |
---|
beginPaint, endPaint, finalize, forcedFlush, getData, 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 |
---|
public java.awt.Color COL_OUTLINE
public java.awt.Color COL_INVALID
public java.awt.Color COL_SELBG
public java.awt.Color COL_ZOOMBG
protected static final java.lang.String C_BLACK
protected static final java.lang.String M_RESETZOOM
protected static final java.lang.String M_TRANSHIGHL
protected static final java.lang.String M_ALPHADOWN
protected static final java.lang.String M_ALPHAUP
protected static final java.lang.String M_SETCB1
protected static final java.lang.String M_SETCB64
public java.awt.Color fillColor
public java.awt.Color borderColor
public java.awt.Color fillColorSel
public java.awt.Color borderColorSel
protected QueryPopup qi
protected PlotPrimitive[] pp
protected java.util.List queryables
pp
.
Should contain only objects which implement the interface Queryable.
protected boolean dontCache
paintInit(org.rosuda.pograss.PoGraSS)
is guaranteed to be run before paintBack(org.rosuda.pograss.PoGraSS)
, paintObjects(org.rosuda.pograss.PoGraSS)
and paintSelected(org.rosuda.pograss.PoGraSS)
. This implies that none of the later three can rely on anything happening in the preceeding paint methods. This is not the usual behavior of PoGraSS. Setting this dontCache flag to true
will enforce the defined PoGraSS behavior which means that all paint.. parts are called in the specified order, no matter which layer is being updated.
protected SMarker m
public boolean autoAdjustMargins
true
then the margins can be adjusted automatically
protected int mLeft
protected int mRight
protected int mTop
protected int mBottom
protected int orientation
protected boolean resizeOnRotate
true
then rotating the canvas also results in flipped size geometry of the canvas.
protected boolean allow180
false
then rotating is allowed only between orientation values 0 and 1 (ergo rotation over 180 degrees is not allowed)
protected boolean allowZoom
true
then zoom is allowed
protected boolean allowDragZoom
true
then zoom-dragging is allowed. Otherwise stepwise zoom by clicing is the only available zoom method.
protected boolean zoomRetainsAspect
true
then zooming-in always retians the aspect ratio (at least default zoom handling via axes does. If you implement a subclass providing its own zooming features you should honor this flag where applicable)
protected boolean allowDragMove
true
then move-dragging is allowed.
protected boolean baseDrag
true
if baseDragging is in process
protected boolean selDrag
true
if the current baseDrag is a selection
protected boolean zoomDrag
true
if the current baseDrag is a zoom
protected boolean moveDrag
true
if the current baseDrag is a move
protected boolean inQuery
true
if query mode is on - (currently it means that
protected boolean inZoom
true
if zoom mode is on
protected boolean showOnlyHilited
true
only hilighted primitives will be shown
protected boolean ignoreNotifications
true
all notifications are rejected. Any subclass is free to use it, BaseCanvas modifies this flag in default zoom processing methods to prevent partial updates when ax and ay are updated sequentially. Any method changing this flag should always restore the state of the flag after it finishes! Also use with care in multi-threaded applications to prevent deadlocks.
protected java.util.List zoomSequence
performZoomIn(int, int, int, int)
and performZoomOut(int, int)
is free to use this list in any way which suits the implementation.The current default implementation uses pairs of ZoomDescriptorComponent
objects to store status of PGSCanvas.ax
and PGSCanvas.ay
axes. The list is automatically initilized to an empty list by the base constructor.
protected int W
protected int H
protected int baseDragX1
protected int baseDragX2
protected int baseDragY1
protected int baseDragY2
protected boolean paintOutline
true
outline of plot primitives is painted (applies to default paint handler. subclasses of BaseCanvas don't have to respect this flag if may display more complex primitives)
protected boolean selectedPaintOutline
paintOutline
but applies to selected objects only
protected boolean fillInside
true
plot primitives are filled.
protected boolean dontPaint
protected boolean updateGeometry
true
then next repaint will force update of geometry, that is it will behave as if the canvas size was changed resulting in updated axes and objects. paintPoGraSS(org.rosuda.pograss.PoGraSS)
resets this flag to false
after calling updateObjects()
and setting everything up.
protected boolean objectClipping
true
don't paint objects outside the margins defined by mLeft etc.
protected boolean alphaHighlighting
true
alpha will be applied to highlighting, too
protected boolean seperateAlphas
true
hilited and normal primitives can have different alphas
protected float ppAlpha
protected float ppAlphaH
seperateAlphas
is true
protected Axis[] opAx
protected Axis[] opAy
protected PlotTextVector xLabels
protected PlotTextVector yLabels
protected boolean isExtQuery
true
extended query is used
protected java.awt.MenuItem MItransHighl
protected java.awt.PopupMenu pop
protected int mouseX
protected int mouseY
protected PlotPrimitive lastQueriedPrimitive
protected int lastQueriedIndex
protected int defaultMLeft
protected int defaultMRight
protected int defaultMTop
protected int defaultMBottom
protected int defaultMLeft1
protected int defaultMRight1
protected int defaultMTop1
protected int defaultMBottom1
protected int defaultMLeft2
protected int defaultMRight2
protected int defaultMTop2
protected int defaultMBottom2
protected int defaultMLeft3
protected int defaultMRight3
protected int defaultMTop3
protected int defaultMBottom3
public int horizontalMedDist
public int horizontalMinDist
public int verticalMedDist
public int verticalMinDist
public boolean rotateYLabels
public double rotateYLabelsBy
protected int changingHilitingNeedsUpdateRoot
protected boolean showQuery
Constructor Detail |
---|
public BaseCanvas(int gd, java.awt.Frame f, SMarker mark)
f
- frame owning this canvas. since BaseCanvas itself doesn't modify any attribute of the frame except for title it is possible to put more canvases into one frame. This doesn't have to hold for subclasses, especially those providing their own menus.mark
- marker which will be used for selection/linked highlightingMethod Detail |
---|
public void Notifying(NotifyMsg msg, java.lang.Object o, java.util.Vector path)
Notifying
in interface Dependent
Notifying
in class PGSCanvas
o
- Object that sent the notification. The actual content is implementation-dependent.path
- This parameter is null for non-cascaded notify - in that case further calls to NotifyAll are not allowed. Otherwise it contains a Vector with all objects notified so far during cascaded notify. To aviod cyclic notifications every instance must either reject cascaded notifications (i.e. no calls to NotifyAll at all) or check for occurence of itself in the chain before calling NotifyAll.
The only valid recursive calls in Notifying are NotifyAll(path) and NotifyAll(..,path), because only these two pass the "path" parameter to avoid cyclic loops.
public void dispose()
dispose
in class PGSCanvas
public void updateObjects()
public java.awt.Dimension getMinimumSize()
public Axis getAxisX()
public Axis getAxisY()
public void paintPoGraSS(PoGraSS g)
paintPoGraSS
in class PGSCanvas
public void paintInit(PoGraSS g)
public void paintBack(PoGraSS g)
public void paintObjects(PoGraSS g)
public void paintSelected(PoGraSS g)
public void paintPost(PoGraSS g)
public void mouseClicked(java.awt.event.MouseEvent ev)
mouseClicked
in interface java.awt.event.MouseListener
public java.lang.String queryObject(int i)
public java.lang.String queryObject(PlotPrimitive p)
public java.lang.String queryPlotSpace()
public void rotate(int amount)
public void rotate()
public void performZoomIn(int x1, int y1, int x2, int y2)
public void performZoomIn(int x1, int y1, int x2, int y2, Axis xAx, Axis xAy)
public void performZoomOut(int x, int y)
public void resetZoom()
public void mousePressed(java.awt.event.MouseEvent ev)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseMoved(java.awt.event.MouseEvent ev)
mouseMoved
in interface java.awt.event.MouseMotionListener
protected java.lang.String getAxisQuery(int x, int y)
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
public java.lang.Object run(java.lang.Object o, java.lang.String cmd)
PGSCanvas
super.run(o,cmd)
to retain this functionality
run
in interface Commander
run
in class PGSCanvas
o
- origin of the commandcmd
- command string
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
public void setQueryText(java.lang.String s)
public void setQueryText(java.lang.String s, int cid)
public void setQueryText(java.lang.String s, int[] cid)
public boolean isShowLabels()
public void setShowLabels(boolean showLabels)
protected PlotPrimitive[] getPrimitivesContaining(int x, int y)
protected PlotPrimitive getFirstPrimitiveContaining(int x, int y)
protected PlotPrimitive[] getPrimitivesIntersecting(java.awt.Rectangle rec)
public double[] getBoundValues()
public boolean adjustMargin(PoGraSS g)
true
if margins have been changedprotected void createMenu(java.awt.Frame f, boolean rotate, boolean zoom, boolean transparency, boolean activeCB, java.lang.String[] view)
public void setExtQueryString(java.lang.String str)
public void useExtQuery(boolean b)
public void setDefaultMargins(int[] margins)
public void addXLabels(PoGraSS g, Axis axis, java.lang.String[] names, int maxWidth, int[] positions, boolean ticks, boolean abbreviate)
public void addXLabels(PoGraSS g, Axis axis, java.lang.String[] names, int maxWidth, int[] positions, boolean ticks, boolean abbreviate, boolean top)
public void addXLabels(PoGraSS g, Axis axis, java.lang.String[] names, int[] maxWidths, int[] positions, boolean ticks, boolean abbreviate)
public void addXLabels(PoGraSS g, Axis axis, java.lang.String[] names, int[] maxWidths, int[] positions, boolean ticks, boolean abbreviate, boolean top)
public void addYLabels(PoGraSS g, Axis axis, boolean ticks, boolean abbreviate)
public void addYLabels(PoGraSS g, Axis axis, SVar sVar, boolean ticks, boolean abbreviate)
public void addYLabels(PoGraSS g, Axis axis, java.lang.String[] names, int[] maxH, int[] positions, boolean ticks, boolean abbreviate)
public int getMBottom()
public void setMBottom(int mBottom)
public int getMLeft()
public void setMLeft(int mLeft)
public int getMRight()
public void setMRight(int mRight)
public int getMTop()
public void setMTop(int mTop)
protected void setColors(PPrimBase ppb)
protected void endAddingLabels()
protected void startAddingLabels()
protected int getDefaultMLeft()
protected void setAyDefaultGeometry()
protected void setAxDefaultGeometry()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |