Class PtPlotSurface
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Printable
,Serializable
,Accessible
,PlotSurface
- Since:
- 17 Jun 2004
- Author:
- Mark Taylor (Starlink)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Color
protected int
protected static Color[]
protected int
protected Color
protected boolean
protected int
protected Font
protected FontMetrics
protected int
protected static final double
protected int
The x value of the lower right corner of the plot rectangle in pixels.protected int
The y value of the lower right corner of the plot rectangle in pixels.protected double
The factor we pad by so that we don't plot points on the axes.protected int
protected int
protected boolean
protected int
protected boolean
protected Font
protected FontMetrics
int
Length of tickmarks.protected Font
protected FontMetrics
protected int
protected int
The x value of the upper left corner of the plot rectangle in pixels.protected int
The y value of the upper left corner of the plot rectangle in pixels.protected boolean
protected int
protected boolean
protected double
protected double
protected double
protected boolean
protected double
protected boolean
protected double
protected double
protected double
protected boolean
protected double
Scaling used for the horizontal axis in plotting points.protected double
protected double
protected boolean
protected double
protected boolean
protected double
protected double
protected double
protected boolean
protected double
Scaling used for the vertical axis in plotting points.protected double
static final String
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields inherited from interface uk.ac.starlink.ttools.plot.PlotSurface
MAX_COORD
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Draw the axes using the current range, label, and title information.protected void
Draw the axes using the current range, label, and title information, at the size of the specified rectangle.protected void
_drawPoint
(Graphics graphics, int dataset, long xpos, long ypos, boolean clip) Put a mark corresponding to the specified dataset at the specified x and y position.protected void
_help()
Display basic information in its own window.protected void
_setButtonsVisibility
(boolean vis) Deprecated.protected void
_setPadding
(double padding) Set the padding multiple.void
_setYRange
(double min, double max) protected void
_zoom
(int x, int y) void
Add a legend (displayed at the upper right) for the specified data set with the specified string.void
Specify a tick mark for the X axis.void
Specify a tick mark for the Y axis.void
clear
(boolean axes) If the argument is true, clear the axes.void
Clear all legends.dataToGraphics
(double dx, double dy, boolean insideOnly) Converts a point in data space to graphics space.void
deferIfNecessary
(Runnable action) If this method is called in the event thread, then simply execute the specified action.void
fillPlot()
Rescale so that the data that is currently plotted just fits.getClip()
Returns the clip region in which points may be plotted.boolean
getColor()
Return whether the plot uses color.static Color
getColorByName
(String name) Convert a color name into a Color.Returns the graphical component on which the plotting surface is displayed.Deprecated.Deprecated.boolean
getGrid()
Return whether the grid is drawn.getLegend
(int dataset) Get the legend for a dataset, or null if there is none.If the size of the plot has been set by setSize(), then return that size.Get the minimum size of this component.getTitle()
Get the title of the graph, or an empty string if there is none.Get the label for the X (horizontal) axis, or null if none has been set.boolean
getXLog()
Return whether the X axis is drawn with a logarithmic scale.double[]
Get the X range.Vector[]
Get the X ticks that have been specified, or null if none.Get the label for the Y (vertical) axis, or null if none has been set.boolean
getYLog()
Return whether the Y axis is drawn with a logarithmic scale.double[]
Get the Y range.Vector[]
Get the Y ticks that have been specified, or null if none.double[]
graphicsToData
(int px, int py, boolean insideOnly) Converts a point in graphics space to data space.void
init()
Deprecated.void
paintComponent
(Graphics graphics) Paint the component contents, which in this base class is only the axes.void
Paints the plotting surface.int
print
(Graphics graphics, PageFormat format, int index) Print the plot to a printer, represented by the specified graphics object.void
removeLegend
(int dataset) Remove the legend (displayed at the upper right) for the specified data set.void
Reset the X and Y axes to the ranges that were first specified using setXRange() and setYRange().void
Do nothing in this base class.void
setBackground
(Color background) Set the background color.void
setBounds
(int x, int y, int width, int height) Move and resize this component.void
setButtons
(boolean visible) If the argument is true, make a fill button visible at the upper right.void
setColor
(boolean useColor) If the argument is false, draw the plot without using color (in black and white).void
setDataRange
(double xlo, double ylo, double xhi, double yhi) Requests a range of data space values to be visible on this plotting surface.void
setDataurl
(String filespec) Deprecated.void
setDocumentBase
(URL documentBase) Deprecated.void
void
setForeground
(Color foreground) Set the foreground color.void
setGrid
(boolean grid) Control whether the grid is drawn.void
setLabelFont
(String name) Set the label font, which is used for axis labels and legend labels.void
setSize
(int width, int height) Set the size of the plot.void
Signals to the plot the characteristics of the plot which will be performed.void
Set the title of the graph.void
setTitleFont
(String name) Set the title font.void
setWrap
(boolean wrap) Specify whether the X axis is wrapped.void
setXFlip
(boolean xflip) Specify whether the X axis numeric labels should be inverted.void
Set the label for the X (horizontal) axis.void
setXLog
(boolean xlog) Specify whether the X axis is drawn with a logarithmic scale.void
setXRange
(double min, double max) Set the X (horizontal) range of the plot.void
setYFlip
(boolean yflip) Specify whether the Y axis numeric labels should be inverted.void
Set the label for the Y (vertical) axis.void
setYLog
(boolean ylog) Specify whether the Y axis is drawn with a logarithmic scale.void
setYRange
(double min, double max) Set the Y (vertical) range of the plot.void
zoom
(double lowx, double lowy, double highx, double highy) Zoom in or out to the specified rectangle.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, 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, validateTree
Methods inherited from class java.awt.Component
action, 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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
PTPLOT_RELEASE
- See Also:
-
_yMax
protected transient double _yMax -
_yMin
protected transient double _yMin -
_xMax
protected transient double _xMax -
_xMin
protected transient double _xMin -
_padding
protected double _paddingThe factor we pad by so that we don't plot points on the axes. -
_xRangeGiven
protected transient boolean _xRangeGiven -
_yRangeGiven
protected transient boolean _yRangeGiven -
_rangesGivenByZooming
protected transient boolean _rangesGivenByZooming -
_xlowgiven
protected double _xlowgiven -
_xhighgiven
protected double _xhighgiven -
_ylowgiven
protected double _ylowgiven -
_yhighgiven
protected double _yhighgiven -
_xBottom
protected double _xBottom -
_xTop
protected double _xTop -
_yBottom
protected double _yBottom -
_yTop
protected double _yTop -
_xlog
protected boolean _xlog -
_ylog
protected boolean _ylog -
_xflip
protected boolean _xflip -
_yflip
protected boolean _yflip -
_LOG10SCALE
protected static final double _LOG10SCALE -
_grid
protected boolean _grid -
_wrap
protected boolean _wrap -
_wrapHigh
protected double _wrapHigh -
_wrapLow
protected double _wrapLow -
_background
-
_foreground
-
_topPadding
protected int _topPadding -
_bottomPadding
protected int _bottomPadding -
_rightPadding
protected int _rightPadding -
_leftPadding
protected int _leftPadding -
_ulx
protected int _ulxThe x value of the upper left corner of the plot rectangle in pixels. -
_uly
protected int _ulyThe y value of the upper left corner of the plot rectangle in pixels. -
_lrx
protected int _lrxThe x value of the lower right corner of the plot rectangle in pixels. -
_lry
protected int _lryThe y value of the lower right corner of the plot rectangle in pixels. -
_yscale
protected double _yscaleScaling used for the vertical axis in plotting points. The units are pixels/unit, where unit is the units of the Y axis. -
_xscale
protected double _xscaleScaling used for the horizontal axis in plotting points. The units are pixels/unit, where unit is the units of the X axis. -
_usecolor
protected boolean _usecolor -
_tickLength
public int _tickLengthLength of tickmarks. -
_colors
-
_width
protected int _width -
_height
protected int _height -
_preferredWidth
protected int _preferredWidth -
_preferredHeight
protected int _preferredHeight -
_sizeHasBeenSet
protected boolean _sizeHasBeenSet -
_expThreshold
protected int _expThreshold -
_documentBase
-
_labelFont
-
_superscriptFont
-
_titleFont
-
_labelFontMetrics
-
_superscriptFontMetrics
-
_titleFontMetrics
-
-
Constructor Details
-
PtPlotSurface
public PtPlotSurface()Constructs a new surface.
-
-
Method Details
-
setFont
- Overrides:
setFont
in classJComponent
-
setState
Description copied from interface:PlotSurface
Signals to the plot the characteristics of the plot which will be performed. Setting this has no immediate effect, but when the component supplied byPlotSurface.getComponent()
next paints itself it should do so following the specifications made here.- Specified by:
setState
in interfacePlotSurface
- Parameters:
state
- plot characteristics
-
setDataRange
public void setDataRange(double xlo, double ylo, double xhi, double yhi) Description copied from interface:PlotSurface
Requests a range of data space values to be visible on this plotting surface.- Specified by:
setDataRange
in interfacePlotSurface
- Parameters:
xlo
- (approximate) lower bound of X coordinateylo
- (approximate) lower bound of Y coordinatexhi
- (approximate) upper bound of X coordinateyhi
- (approximate) upper bound of Y coordinate
-
dataToGraphics
Description copied from interface:PlotSurface
Converts a point in data space to graphics space. If theinsideOnly
flag is true, thennull
will be returned in place of any result which would give a point lying outside the visible plotting area.The coordinates of the returned point must have absolute values no greater than
PlotSurface.MAX_COORD
.- Specified by:
dataToGraphics
in interfacePlotSurface
- Parameters:
dx
- data space X coordinatedy
- data space Y coordinateinsideOnly
- true to restrict non-null results to those within the plotting surface- Returns:
- point in graphics space corresponding to (x,y),
or
null
-
graphicsToData
public double[] graphicsToData(int px, int py, boolean insideOnly) Description copied from interface:PlotSurface
Converts a point in graphics space to data space. If theinsideOnly
flag is true, thennull
will be returned in place of any result which would give a point lying outside the visible plotting area.- Specified by:
graphicsToData
in interfacePlotSurface
- Parameters:
px
- graphics space X coordinatepy
- graphics space Y coordinateinsideOnly
- true to restrict non-null results to those within the plotting surface- Returns:
- a 2-element array giving x and y data space coordinates,
or
null
-
getClip
Description copied from interface:PlotSurface
Returns the clip region in which points may be plotted. The returned shape should be the sort which can be passed toGraphics.setClip(java.awt.Shape)
- i.e. probably aRectangle
.- Specified by:
getClip
in interfacePlotSurface
- Returns:
- clip region representing data zone
-
getComponent
Description copied from interface:PlotSurface
Returns the graphical component on which the plotting surface is displayed. This will contain things like axes, grids, labels etc. This component will normally overrideJComponent.paintComponent(java.awt.Graphics)
to give a plotting background in accordance with the most recently setPlotState
.- Specified by:
getComponent
in interfacePlotSurface
- Returns:
- plot surface display component
-
paintSurface
Description copied from interface:PlotSurface
Paints the plotting surface. This should do roughly the same asgetComponent.paintComponent
, except that it's public.Requiring this here isn't very tidy, but following quite a bit of experimentation I can't work out any other way to do scatter plot image caching while still drawing to a potentially hardware-accelerated graphics context (see
ScatterPlot
implementation).- Specified by:
paintSurface
in interfacePlotSurface
- Parameters:
g
- graphics context
-
_zoom
protected void _zoom(int x, int y) -
addLegend
Add a legend (displayed at the upper right) for the specified data set with the specified string. Short strings generally fit better than long strings. If the string is empty, or the argument is null, then no legend is added.- Parameters:
dataset
- The dataset index.legend
- The label for the dataset.
-
addXTick
Specify a tick mark for the X axis. The label given is placed on the axis at the position given by position. If this is called once or more, automatic generation of tick marks is disabled. The tick mark will appear only if it is within the X range.- Parameters:
label
- The label for the tick mark.position
- The position on the X axis.
-
addYTick
Specify a tick mark for the Y axis. The label given is placed on the axis at the position given by position. If this is called once or more, automatic generation of tick marks is disabled. The tick mark will appear only if it is within the Y range.- Parameters:
label
- The label for the tick mark.position
- The position on the Y axis.
-
clear
public void clear(boolean axes) If the argument is true, clear the axes. I.e., set all parameters controlling the axes to their initial conditions. For the change to take effect, call repaint(). If the argument is false, do nothing.- Parameters:
axes
- If true, clear the axes parameters.
-
clearLegends
public void clearLegends()Clear all legends. This will show up on the next redraw. -
deferIfNecessary
If this method is called in the event thread, then simply execute the specified action. Otherwise, if there are already deferred actions, then add the specified one to the list. Otherwise, create a list of deferred actions, if necessary, and request that the list be processed in the event dispatch thread. Note that it does not work nearly as well to simply schedule the action yourself on the event thread because if there are a large number of actions, then the event thread will not be able to keep up. By grouping these actions, we avoid this problem. This method is not synchronized, so the caller should be.- Parameters:
action
- The Runnable object to execute.
-
fillPlot
public void fillPlot()Rescale so that the data that is currently plotted just fits. This is done based on the protected variables _xBottom, _xTop, _yBottom, and _yTop. It is up to derived classes to ensure that variables are valid. This method calls repaint(), which eventually causes the display to be updated. -
getColor
public boolean getColor()Return whether the plot uses color.- Returns:
- True if the plot uses color.
-
getColorByName
Convert a color name into a Color. Currently, only a very limited set of color names is supported: black, white, red, green, and blue.- Parameters:
name
- A color name, or null if not found.- Returns:
- An instance of Color.
-
getDataurl
Deprecated.Get the file specification that was given by setDataurl. This method is deprecated. Use read() instead. -
getDocumentBase
Deprecated.Get the document base that was set by setDocumentBase. This method is deprecated. Use read() instead. -
getGrid
public boolean getGrid()Return whether the grid is drawn.- Returns:
- True if a grid is drawn.
-
getLegend
Get the legend for a dataset, or null if there is none. The legend would have been set by addLegend().- Parameters:
dataset
- The dataset index.- Returns:
- The legend label, or null if there is none.
-
getMaximumSize
If the size of the plot has been set by setSize(), then return that size. Otherwise, return what the superclass returns (which is undocumented, but apparently imposes no maximum size). Currently (JDK 1.3), only BoxLayout pays any attention to this.- Overrides:
getMaximumSize
in classJComponent
- Returns:
- The maximum desired size.
-
getMinimumSize
Get the minimum size of this component. This is simply the dimensions specified by setSize(), if this has been called. Otherwise, return whatever the base class returns, which is undocumented.- Overrides:
getMinimumSize
in classJComponent
- Returns:
- The minimum size.
-
getTitle
Get the title of the graph, or an empty string if there is none.- Returns:
- The title.
-
getXLabel
Get the label for the X (horizontal) axis, or null if none has been set.- Returns:
- The X label.
-
getXLog
public boolean getXLog()Return whether the X axis is drawn with a logarithmic scale.- Returns:
- True if the X axis is logarithmic.
-
getXRange
public double[] getXRange()Get the X range. The returned value is an array where the first element is the minimum and the second element is the maximum. return The current X range. -
getXTicks
Get the X ticks that have been specified, or null if none. The return value is an array with two vectors, the first of which specifies the X tick locations (as instances of Double), and the second of which specifies the corresponding labels.- Returns:
- The X ticks.
-
getYLabel
Get the label for the Y (vertical) axis, or null if none has been set.- Returns:
- The Y label.
-
getYLog
public boolean getYLog()Return whether the Y axis is drawn with a logarithmic scale.- Returns:
- True if the Y axis is logarithmic.
-
getYRange
public double[] getYRange()Get the Y range. The returned value is an array where the first element is the minimum and the second element is the maximum. return The current Y range. -
getYTicks
Get the Y ticks that have been specified, or null if none. The return value is an array with two vectors, the first of which specifies the Y tick locations (as instances of Double), and the second of which specifies the corresponding labels.- Returns:
- The Y ticks.
-
init
public void init()Deprecated.Initialize the component, creating the fill button and parsing an input file, if one has been specified. This is deprecated. Call setButtons() and read() instead. -
paintComponent
Paint the component contents, which in this base class is only the axes.- Overrides:
paintComponent
in classJComponent
- Parameters:
graphics
- The graphics context.
-
print
Print the plot to a printer, represented by the specified graphics object.- Specified by:
print
in interfacePrintable
- Parameters:
graphics
- The context into which the page is drawn.format
- The size and orientation of the page being drawn.index
- The zero based index of the page to be drawn.- Returns:
- PAGE_EXISTS if the page is rendered successfully, or NO_SUCH_PAGE if pageIndex specifies a non-existent page.
- Throws:
PrinterException
- If the print job is terminated.
-
removeLegend
public void removeLegend(int dataset) Remove the legend (displayed at the upper right) for the specified data set. If the dataset is not found, nothing will occur. The PlotBox must be repainted in order for this to take effect.- Parameters:
dataset
- The dataset index.
-
resetAxes
public void resetAxes()Reset the X and Y axes to the ranges that were first specified using setXRange() and setYRange(). If these methods have not been called, then reset to the default ranges. This method calls repaint(), which eventually causes the display to be updated. -
samplePlot
public void samplePlot()Do nothing in this base class. Derived classes might want to override this class to give an example of their use. -
setBackground
Set the background color.- Overrides:
setBackground
in classJComponent
- Parameters:
background
- The background color.
-
setBounds
public void setBounds(int x, int y, int width, int height) Move and resize this component. The new location of the top-left corner is specified by x and y, and the new size is specified by width and height. This overrides the base class method to make a record of the new size. -
setButtons
public void setButtons(boolean visible) If the argument is true, make a fill button visible at the upper right. This button auto-scales the plot. NOTE: The button may infringe on the title space, if the title is long. In an application, it is preferable to provide a menu with the fill command. This way, when printing the plot, the printed plot will not have a spurious button. Thus, this method should be used only by applets, which normally do not have menus. This method should only be called from within the event dispatch thread, since it interacts with swing. -
setColor
public void setColor(boolean useColor) If the argument is false, draw the plot without using color (in black and white). Otherwise, draw it in color (the default).- Parameters:
useColor
- False to draw in back and white.
-
setDataurl
Deprecated.Set the file to read when init() is called. This method is deprecated. Use read() instead. -
setDocumentBase
Deprecated.Set the document base to used when init() is called to read a URL. This method is deprecated. Use read() instead. -
setForeground
Set the foreground color.- Overrides:
setForeground
in classJComponent
- Parameters:
foreground
- The foreground color.
-
setGrid
public void setGrid(boolean grid) Control whether the grid is drawn.- Parameters:
grid
- If true, a grid is drawn.
-
setLabelFont
Set the label font, which is used for axis labels and legend labels. The font names understood are those understood by java.awt.Font.decode().- Parameters:
name
- A font name.
-
setSize
public void setSize(int width, int height) Set the size of the plot. This overrides the base class to make it work. In particular, it records the specified size so that getMinimumSize() and getPreferredSize() return the specified value. However, it only works if the plot is placed in its own JPanel. This is because the JPanel asks the contained component for its preferred size before determining the size of the panel. If the plot is placed directly in the content pane of a JApplet, then, mysteriously, this method has no effect. -
setTitle
Set the title of the graph.- Parameters:
title
- The title.
-
setTitleFont
Set the title font. The font names understood are those understood by java.awt.Font.decode().- Parameters:
name
- A font name.
-
setWrap
public void setWrap(boolean wrap) Specify whether the X axis is wrapped. If it is, then X values that are out of range are remapped to be in range using modulo arithmetic. The X range is determined by the most recent call to setXRange() (or the most recent zoom). If the X range has not been set, then use the default X range, or if data has been plotted, then the current fill range.- Parameters:
wrap
- If true, wrapping of the X axis is enabled.
-
setXLabel
Set the label for the X (horizontal) axis.- Parameters:
label
- The label.
-
setXLog
public void setXLog(boolean xlog) Specify whether the X axis is drawn with a logarithmic scale. If you would like to have the X axis drawn with a logarithmic axis, then setXLog(true) should be called before adding any data points.- Parameters:
xlog
- If true, logarithmic axis is used.
-
setXFlip
public void setXFlip(boolean xflip) Specify whether the X axis numeric labels should be inverted.- Parameters:
xflip
- If true, numbers on X axis will be the negative of their true values
-
setXRange
public void setXRange(double min, double max) Set the X (horizontal) range of the plot. If this is not done explicitly, then the range is computed automatically from data available when the plot is drawn. If min and max are identical, then the range is arbitrarily spread by 1.- Parameters:
min
- The left extent of the range.max
- The right extent of the range.
-
setYLabel
Set the label for the Y (vertical) axis.- Parameters:
label
- The label.
-
setYLog
public void setYLog(boolean ylog) Specify whether the Y axis is drawn with a logarithmic scale. If you would like to have the Y axis drawn with a logarithmic axis, then setYLog(true) should be called before adding any data points.- Parameters:
ylog
- If true, logarithmic axis is used.
-
setYFlip
public void setYFlip(boolean yflip) Specify whether the Y axis numeric labels should be inverted.- Parameters:
yflip
- If true, numbers on Y axis will be the negative of their true values
-
setYRange
public void setYRange(double min, double max) Set the Y (vertical) range of the plot. If this is not done explicitly, then the range is computed automatically from data available when the plot is drawn. If min and max are identical, then the range is arbitrarily spread by 0.1.- Parameters:
min
- The bottom extent of the range.max
- The top extent of the range.
-
zoom
public void zoom(double lowx, double lowy, double highx, double highy) Zoom in or out to the specified rectangle. This method calls repaint().- Parameters:
lowx
- The low end of the new X range.lowy
- The low end of the new Y range.highx
- The high end of the new X range.highy
- The high end of the new Y range.
-
_drawPlot
Draw the axes using the current range, label, and title information. If the second argument is true, clear the display before redrawing. This method is called by paintComponent(). To cause it to be called you would normally call repaint(), which eventually causes paintComponent() to be called.Note that this is synchronized so that points are not added by other threads while the drawing is occurring. This method should be called only from the event dispatch thread, consistent with swing policy.
- Parameters:
graphics
- The graphics context.clearfirst
- If true, clear the plot before proceeding.
-
_drawPlot
Draw the axes using the current range, label, and title information, at the size of the specified rectangle. If the second argument is true, clear the display before redrawing. This method is called by paintComponent(). To cause it to be called you would normally call repaint(), which eventually causes paintComponent() to be called.Note that this is synchronized so that points are not added by other threads while the drawing is occurring. This method should be called only from the event dispatch thread, consistent with swing policy.
- Parameters:
graphics
- The graphics context.clearfirst
- If true, clear the plot before proceeding.drawRect
- A specification of the size.
-
_drawPoint
Put a mark corresponding to the specified dataset at the specified x and y position. The mark is drawn in the current color. In this base class, a point is a filled rectangle 6 pixels across. Note that marks greater than about 6 pixels in size will not look very good since they will overlap axis labels and may not fit well in the legend. The clip argument, iftrue
, states that the point should not be drawn if it is out of range. Note that this method is not synchronized, so the caller should be. Moreover this method should always be called from the event thread when being used to write to the screen.- Parameters:
graphics
- The graphics context.dataset
- The index of the data set.xpos
- The X position.ypos
- The Y position.clip
- If true, do not draw if out of range.
-
_help
protected void _help()Display basic information in its own window. -
_setButtonsVisibility
protected void _setButtonsVisibility(boolean vis) Deprecated.Set the visibility of the Fill button. This is deprecated. Use setButtons(). -
_setPadding
protected void _setPadding(double padding) Set the padding multiple. The plot rectangle can be "padded" in each direction -x, +x, -y, and +y. If the padding is set to 0.05 (and the padding is used), then there is 10% more length on each axis than set by the setXRange() and setYRange() methods, 5% in each direction.- Parameters:
padding
- The padding multiple.
-
_setYRange
public void _setYRange(double min, double max)
-