|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.talvi.puffinplot.plots.Plot
public abstract class Plot
An abstract superclass for all plots and other data displays. Any class that needs to write or draw to one of PuffinPlot's graph display areas should extend this class. Plot's subclasses include both graphical plots and textual displays such as the plot title and data table.
Field Summary | |
---|---|
protected static java.lang.String |
DEFAULT_PLOT_POSITIONS
the default sizes and positions of the plots |
protected java.awt.geom.Rectangle2D |
dimensions
the plot's dimensions |
protected PlotParams |
params
the plot parameters |
protected static double |
PLOT_POINT_SIZE
the default size of a plotted data point |
Constructor Summary | |
---|---|
Plot(GraphDisplay parent,
PlotParams params,
java.util.prefs.Preferences prefs)
Creates a plot with the supplied parameters. |
Method Summary | |
---|---|
protected void |
addPoint(Datum d,
java.awt.geom.Point2D p,
boolean filled,
boolean special,
boolean line)
Adds a point to this plot's internal buffer. |
void |
addSampleClickListener(SampleClickListener listener)
Adds a listener for sample clicks to this plot. |
void |
applyTextAttributes(java.text.AttributedString as)
Applies this plot's standard text attributes to an attributed string. |
protected void |
clearPoints()
Clear this plot's internal buffer of points. |
protected java.awt.geom.Rectangle2D |
cropRectangle(java.awt.geom.Rectangle2D r,
double left,
double right,
double top,
double bottom)
Returns a cropped version of a specified rectangle. |
abstract void |
draw(java.awt.Graphics2D g)
Draws this plot. |
protected void |
drawPoints(java.awt.Graphics2D g)
Draws the points in this plot's internal buffer. |
java.awt.Stroke |
getDashedStroke()
Returns the default dashed stroke style. |
java.awt.geom.Rectangle2D |
getDimensions()
Returns the dimensions of this plot. |
java.lang.String |
getDimensionsAsString()
Returns a string representation of this plot's dimensions. |
float |
getFontSize()
Returns the standard font size in plot units. |
int |
getMargin()
Returns the size of the margin displayed when resizing the plot. |
abstract java.lang.String |
getName()
Returns an internal name for this plot. |
java.lang.String |
getNiceName()
Returns a user-friendly name for this plot. |
java.awt.Stroke |
getStroke()
Returns the default solid stroke style. |
java.util.Map<? extends java.text.AttributedCharacterIterator.Attribute,?> |
getTextAttributes()
Returns this plot's standard text attributes. |
float |
getTickLength()
Returns the standard length of an axis tick in plot units. |
float |
getUnitSize()
Returns the size of a plot unit in Java 2D units. |
boolean |
isVisible()
Reports whether this plot is visible. |
void |
mouseClicked(java.awt.geom.Point2D position,
java.awt.event.MouseEvent e)
Handles a mouse click event on the plot. |
void |
removeSampleClickListener(SampleClickListener listener)
Removes a sample click listener which was previously added to this plot. |
void |
selectByRectangle(java.awt.geom.Rectangle2D rectangle)
Selects all the plotted data points within a specified rectangle. |
void |
setDimensions(java.awt.geom.Rectangle2D dimensions)
Sets the dimensions of this plot. |
void |
setDimensionsToDefault()
Resets the plot's dimensions to the default, as defined in DEFAULT_PLOT_POSITIONS . |
void |
setVisible(boolean visible)
Sets whether this plot should be drawn. |
protected java.text.AttributedString |
timesTenToThe(java.lang.String significand,
int exponent)
Returns an attributed string representing a number in scientific notation. |
protected java.text.AttributedString |
timesTenToThe(java.lang.String significand,
java.lang.String exponent)
Returns an attributed string representing a number in scientific notation. |
protected void |
writeString(java.awt.Graphics2D g,
java.text.AttributedString as,
float x,
float y)
Writes an attributed text string onto this plot. |
protected void |
writeString(java.awt.Graphics2D g,
java.lang.String text,
float x,
float y)
Writes a text string onto this plot. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final PlotParams params
protected java.awt.geom.Rectangle2D dimensions
protected static final double PLOT_POINT_SIZE
protected static final java.lang.String DEFAULT_PLOT_POSITIONS
Constructor Detail |
---|
public Plot(GraphDisplay parent, PlotParams params, java.util.prefs.Preferences prefs)
parent
- the graph display containing the plotparams
- the parameters of the plotprefs
- the preferences containing the plot configurationMethod Detail |
---|
public java.awt.geom.Rectangle2D getDimensions()
public void setDimensions(java.awt.geom.Rectangle2D dimensions)
dimensions
- dimensions the new dimensions of this plotpublic void setDimensionsToDefault()
DEFAULT_PLOT_POSITIONS
.
public int getMargin()
public java.awt.Stroke getStroke()
public java.awt.Stroke getDashedStroke()
public final float getUnitSize()
public float getTickLength()
public final float getFontSize()
public java.util.Map<? extends java.text.AttributedCharacterIterator.Attribute,?> getTextAttributes()
public void applyTextAttributes(java.text.AttributedString as)
as
- the string to which to apply this plot's standard text
attributesprotected void writeString(java.awt.Graphics2D g, java.lang.String text, float x, float y)
g
- the graphics object to which to write thetext
- the text to writex
- the x co-ordinate of the texty
- the y co-ordinate of the textprotected void writeString(java.awt.Graphics2D g, java.text.AttributedString as, float x, float y)
g
- the graphics object to which to write theas
- the text to writex
- the x co-ordinate of the texty
- the y co-ordinate of the textprotected java.text.AttributedString timesTenToThe(java.lang.String significand, java.lang.String exponent)
significand
- the significand of the numberexponent
- the exponent of the number
protected java.text.AttributedString timesTenToThe(java.lang.String significand, int exponent)
significand
- the significand of the numberexponent
- the exponent of the number
protected java.awt.geom.Rectangle2D cropRectangle(java.awt.geom.Rectangle2D r, double left, double right, double top, double bottom)
r
- a rectangleleft
- the amount to crop at the leftright
- the amount to crop at the righttop
- the amount to crop at the topbottom
- the amount to crop at the bottom
public java.lang.String getDimensionsAsString()
plotSizes
Preferences entry from which the plot reads its initial
dimensions.
protected void drawPoints(java.awt.Graphics2D g)
g
- the graphics object to which to draw the pointsprotected void addPoint(Datum d, java.awt.geom.Point2D p, boolean filled, boolean special, boolean line)
d
- the datum associated with the point (null
if none)p
- the position of the pointfilled
- true
if the point should be filledspecial
- true
if the point should be highlightedline
- true
if a line should be drawn from the previous
point to this one.protected void clearPoints()
public void mouseClicked(java.awt.geom.Point2D position, java.awt.event.MouseEvent e)
position
- the position of the clicke
- the event associated with the clickpublic void selectByRectangle(java.awt.geom.Rectangle2D rectangle)
rectangle
- a rectangle defining which points should be selectedpublic abstract java.lang.String getName()
public java.lang.String getNiceName()
public abstract void draw(java.awt.Graphics2D g)
g
- the graphics object onto which to draw this plotpublic boolean isVisible()
true
if this plot is visible; false
if it is hiddenpublic void setVisible(boolean visible)
visible
- true
to draw this plot; false
not to draw itpublic void addSampleClickListener(SampleClickListener listener)
SampleClickListener.sampleClicked(net.talvi.puffinplot.data.Sample)
method of the supplied listener will be invoked. The listener can be
removed using the removeSampleClickListener(net.talvi.puffinplot.plots.SampleClickListener)
method.
listener
- the listener to addSampleClickListener
,
removeSampleClickListener(net.talvi.puffinplot.plots.SampleClickListener)
public void removeSampleClickListener(SampleClickListener listener)
listener
- the listener to removeaddSampleClickListener(net.talvi.puffinplot.plots.SampleClickListener)
,
SampleClickListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |