Class PtPlotSurface
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- uk.ac.starlink.ttools.plot.PtPlotSurface
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.awt.print.Printable,java.io.Serializable,javax.accessibility.Accessible,PlotSurface
public class PtPlotSurface extends javax.swing.JPanel implements PlotSurface
PlotSurface implementation which uses Ptplot classes for axis plotting- Since:
- 17 Jun 2004
- Author:
- Mark Taylor (Starlink)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.Color_backgroundprotected int_bottomPaddingprotected static java.awt.Color[]_colorsjava.net.URL_documentBaseprotected int_expThresholdprotected java.awt.Color_foregroundprotected boolean_gridprotected int_heightprotected java.awt.Font_labelFontprotected java.awt.FontMetrics_labelFontMetricsprotected int_leftPaddingprotected static double_LOG10SCALEprotected int_lrxThe x value of the lower right corner of the plot rectangle in pixels.protected int_lryThe y value of the lower right corner of the plot rectangle in pixels.protected double_paddingThe factor we pad by so that we don't plot points on the axes.protected int_preferredHeightprotected int_preferredWidthprotected boolean_rangesGivenByZoomingprotected int_rightPaddingprotected boolean_sizeHasBeenSetprotected java.awt.Font_superscriptFontprotected java.awt.FontMetrics_superscriptFontMetricsint_tickLengthLength of tickmarks.protected java.awt.Font_titleFontprotected java.awt.FontMetrics_titleFontMetricsprotected int_topPaddingprotected int_ulxThe x value of the upper left corner of the plot rectangle in pixels.protected int_ulyThe y value of the upper left corner of the plot rectangle in pixels.protected boolean_usecolorprotected int_widthprotected boolean_wrapprotected double_wrapHighprotected double_wrapLowprotected double_xBottomprotected boolean_xflipprotected double_xhighgivenprotected boolean_xlogprotected double_xlowgivenprotected double_xMaxprotected double_xMinprotected boolean_xRangeGivenprotected double_xscaleScaling used for the horizontal axis in plotting points.protected double_xTopprotected double_yBottomprotected boolean_yflipprotected double_yhighgivenprotected boolean_ylogprotected double_ylowgivenprotected double_yMaxprotected double_yMinprotected boolean_yRangeGivenprotected double_yscaleScaling used for the vertical axis in plotting points.protected double_yTopstatic java.lang.StringPTPLOT_RELEASE-
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
-
-
Constructor Summary
Constructors Constructor Description PtPlotSurface()Constructs a new surface.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void_drawPlot(java.awt.Graphics graphics, boolean clearfirst)Draw the axes using the current range, label, and title information.protected void_drawPlot(java.awt.Graphics graphics, boolean clearfirst, java.awt.Rectangle drawRect)Draw the axes using the current range, label, and title information, at the size of the specified rectangle.protected void_drawPoint(java.awt.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)voidaddLegend(int dataset, java.lang.String legend)Add a legend (displayed at the upper right) for the specified data set with the specified string.voidaddXTick(java.lang.String label, double position)Specify a tick mark for the X axis.voidaddYTick(java.lang.String label, double position)Specify a tick mark for the Y axis.voidclear(boolean axes)If the argument is true, clear the axes.voidclearLegends()Clear all legends.java.awt.PointdataToGraphics(double dx, double dy, boolean insideOnly)Converts a point in data space to graphics space.voiddeferIfNecessary(java.lang.Runnable action)If this method is called in the event thread, then simply execute the specified action.voidfillPlot()Rescale so that the data that is currently plotted just fits.java.awt.ShapegetClip()Returns the clip region in which points may be plotted.booleangetColor()Return whether the plot uses color.static java.awt.ColorgetColorByName(java.lang.String name)Convert a color name into a Color.javax.swing.JComponentgetComponent()Returns the graphical component on which the plotting surface is displayed.java.lang.StringgetDataurl()Deprecated.java.net.URLgetDocumentBase()Deprecated.booleangetGrid()Return whether the grid is drawn.java.lang.StringgetLegend(int dataset)Get the legend for a dataset, or null if there is none.java.awt.DimensiongetMaximumSize()If the size of the plot has been set by setSize(), then return that size.java.awt.DimensiongetMinimumSize()Get the minimum size of this component.java.lang.StringgetTitle()Get the title of the graph, or an empty string if there is none.java.lang.StringgetXLabel()Get the label for the X (horizontal) axis, or null if none has been set.booleangetXLog()Return whether the X axis is drawn with a logarithmic scale.double[]getXRange()Get the X range.java.util.Vector[]getXTicks()Get the X ticks that have been specified, or null if none.java.lang.StringgetYLabel()Get the label for the Y (vertical) axis, or null if none has been set.booleangetYLog()Return whether the Y axis is drawn with a logarithmic scale.double[]getYRange()Get the Y range.java.util.Vector[]getYTicks()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.voidinit()Deprecated.voidpaintComponent(java.awt.Graphics graphics)Paint the component contents, which in this base class is only the axes.voidpaintSurface(java.awt.Graphics g)Paints the plotting surface.intprint(java.awt.Graphics graphics, java.awt.print.PageFormat format, int index)Print the plot to a printer, represented by the specified graphics object.voidremoveLegend(int dataset)Remove the legend (displayed at the upper right) for the specified data set.voidresetAxes()Reset the X and Y axes to the ranges that were first specified using setXRange() and setYRange().voidsamplePlot()Do nothing in this base class.voidsetBackground(java.awt.Color background)Set the background color.voidsetBounds(int x, int y, int width, int height)Move and resize this component.voidsetButtons(boolean visible)If the argument is true, make a fill button visible at the upper right.voidsetColor(boolean useColor)If the argument is false, draw the plot without using color (in black and white).voidsetDataRange(double xlo, double ylo, double xhi, double yhi)Requests a range of data space values to be visible on this plotting surface.voidsetDataurl(java.lang.String filespec)Deprecated.voidsetDocumentBase(java.net.URL documentBase)Deprecated.voidsetFont(java.awt.Font font)voidsetForeground(java.awt.Color foreground)Set the foreground color.voidsetGrid(boolean grid)Control whether the grid is drawn.voidsetLabelFont(java.lang.String name)Set the label font, which is used for axis labels and legend labels.voidsetSize(int width, int height)Set the size of the plot.voidsetState(PlotState state)Signals to the plot the characteristics of the plot which will be performed.voidsetTitle(java.lang.String title)Set the title of the graph.voidsetTitleFont(java.lang.String name)Set the title font.voidsetWrap(boolean wrap)Specify whether the X axis is wrapped.voidsetXFlip(boolean xflip)Specify whether the X axis numeric labels should be inverted.voidsetXLabel(java.lang.String label)Set the label for the X (horizontal) axis.voidsetXLog(boolean xlog)Specify whether the X axis is drawn with a logarithmic scale.voidsetXRange(double min, double max)Set the X (horizontal) range of the plot.voidsetYFlip(boolean yflip)Specify whether the Y axis numeric labels should be inverted.voidsetYLabel(java.lang.String label)Set the label for the Y (vertical) axis.voidsetYLog(boolean ylog)Specify whether the Y axis is drawn with a logarithmic scale.voidsetYRange(double min, double max)Set the Y (vertical) range of the plot.voidzoom(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 Detail
-
PTPLOT_RELEASE
public static final java.lang.String PTPLOT_RELEASE
- See Also:
- Constant Field Values
-
_yMax
protected transient double _yMax
-
_yMin
protected transient double _yMin
-
_xMax
protected transient double _xMax
-
_xMin
protected transient double _xMin
-
_padding
protected double _padding
The 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
protected java.awt.Color _background
-
_foreground
protected java.awt.Color _foreground
-
_topPadding
protected int _topPadding
-
_bottomPadding
protected int _bottomPadding
-
_rightPadding
protected int _rightPadding
-
_leftPadding
protected int _leftPadding
-
_ulx
protected int _ulx
The x value of the upper left corner of the plot rectangle in pixels.
-
_uly
protected int _uly
The y value of the upper left corner of the plot rectangle in pixels.
-
_lrx
protected int _lrx
The x value of the lower right corner of the plot rectangle in pixels.
-
_lry
protected int _lry
The y value of the lower right corner of the plot rectangle in pixels.
-
_yscale
protected double _yscale
Scaling 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 _xscale
Scaling 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 _tickLength
Length of tickmarks.
-
_colors
protected static java.awt.Color[] _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
public java.net.URL _documentBase
-
_labelFont
protected java.awt.Font _labelFont
-
_superscriptFont
protected java.awt.Font _superscriptFont
-
_titleFont
protected java.awt.Font _titleFont
-
_labelFontMetrics
protected java.awt.FontMetrics _labelFontMetrics
-
_superscriptFontMetrics
protected java.awt.FontMetrics _superscriptFontMetrics
-
_titleFontMetrics
protected java.awt.FontMetrics _titleFontMetrics
-
-
Method Detail
-
setFont
public void setFont(java.awt.Font font)
- Overrides:
setFontin classjavax.swing.JComponent
-
setState
public void setState(PlotState state)
Description copied from interface:PlotSurfaceSignals 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:
setStatein interfacePlotSurface- Parameters:
state- plot characteristics
-
setDataRange
public void setDataRange(double xlo, double ylo, double xhi, double yhi)Description copied from interface:PlotSurfaceRequests a range of data space values to be visible on this plotting surface.- Specified by:
setDataRangein 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
public java.awt.Point dataToGraphics(double dx, double dy, boolean insideOnly)Description copied from interface:PlotSurfaceConverts a point in data space to graphics space. If the insideOnly flag is true, then null 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:
dataToGraphicsin 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:PlotSurfaceConverts a point in graphics space to data space. If the insideOnly flag is true, then null will be returned in place of any result which would give a point lying outside the visible plotting area.- Specified by:
graphicsToDatain 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
public java.awt.Shape getClip()
Description copied from interface:PlotSurfaceReturns 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 a Rectangle.- Specified by:
getClipin interfacePlotSurface- Returns:
- clip region representing data zone
-
getComponent
public javax.swing.JComponent getComponent()
Description copied from interface:PlotSurfaceReturns 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 set PlotState.- Specified by:
getComponentin interfacePlotSurface- Returns:
- plot surface display component
-
paintSurface
public void paintSurface(java.awt.Graphics g)
Description copied from interface:PlotSurfacePaints the plotting surface. This should do roughly the same as getComponent.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
ScatterPlotimplementation).- Specified by:
paintSurfacein interfacePlotSurface- Parameters:
g- graphics context
-
_zoom
protected void _zoom(int x, int y)
-
addLegend
public void addLegend(int dataset, java.lang.String legend)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
public void addXTick(java.lang.String label, double position)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
public void addYTick(java.lang.String label, double position)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
public void deferIfNecessary(java.lang.Runnable action)
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
public static java.awt.Color getColorByName(java.lang.String name)
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
public java.lang.String getDataurl()
Deprecated.Get the file specification that was given by setDataurl. This method is deprecated. Use read() instead.
-
getDocumentBase
public java.net.URL 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
public java.lang.String getLegend(int dataset)
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
public java.awt.Dimension 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:
getMaximumSizein classjavax.swing.JComponent- Returns:
- The maximum desired size.
-
getMinimumSize
public java.awt.Dimension 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:
getMinimumSizein classjavax.swing.JComponent- Returns:
- The minimum size.
-
getTitle
public java.lang.String getTitle()
Get the title of the graph, or an empty string if there is none.- Returns:
- The title.
-
getXLabel
public java.lang.String 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
public java.util.Vector[] 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
public java.lang.String 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
public java.util.Vector[] 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
public void paintComponent(java.awt.Graphics graphics)
Paint the component contents, which in this base class is only the axes.- Overrides:
paintComponentin classjavax.swing.JComponent- Parameters:
graphics- The graphics context.
-
print
public int print(java.awt.Graphics graphics, java.awt.print.PageFormat format, int index) throws java.awt.print.PrinterExceptionPrint the plot to a printer, represented by the specified graphics object.- Specified by:
printin interfacejava.awt.print.Printable- 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:
java.awt.print.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
public void setBackground(java.awt.Color background)
Set the background color.- Overrides:
setBackgroundin classjavax.swing.JComponent- 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.- Overrides:
setBoundsin classjava.awt.Component- Parameters:
x- The new x-coordinate of this component.y- The new y-coordinate of this component.width- The new width of this component.height- The new height of this component.
-
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
public void setDataurl(java.lang.String filespec)
Deprecated.Set the file to read when init() is called. This method is deprecated. Use read() instead.
-
setDocumentBase
public void setDocumentBase(java.net.URL documentBase)
Deprecated.Set the document base to used when init() is called to read a URL. This method is deprecated. Use read() instead.
-
setForeground
public void setForeground(java.awt.Color foreground)
Set the foreground color.- Overrides:
setForegroundin classjavax.swing.JComponent- 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
public void setLabelFont(java.lang.String name)
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.- Overrides:
setSizein classjava.awt.Component- Parameters:
width- The width, in pixels.height- The height, in pixels.
-
setTitle
public void setTitle(java.lang.String title)
Set the title of the graph.- Parameters:
title- The title.
-
setTitleFont
public void setTitleFont(java.lang.String name)
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
public void setXLabel(java.lang.String label)
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
public void setYLabel(java.lang.String label)
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
protected void _drawPlot(java.awt.Graphics graphics, boolean clearfirst)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
protected void _drawPlot(java.awt.Graphics graphics, boolean clearfirst, java.awt.Rectangle drawRect)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
protected void _drawPoint(java.awt.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. 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)
-
-