public abstract class Renderer extends java.lang.Object implements DataSetConsumer, Editable, Displayable
Modifier and Type | Field and Description |
---|---|
protected Painter |
bottomDecorator |
protected DasColorBar |
colorBar |
protected java.lang.String |
control
generic control string, that is handled by the renderer.
|
static java.lang.String |
CONTROL_KEY_COLOR
allocate a bunch of canonical properties.
|
static java.lang.String |
CONTROL_KEY_COLOR_TABLE |
static java.lang.String |
CONTROL_KEY_DRAW_ERROR |
static java.lang.String |
CONTROL_KEY_FILL_COLOR |
static java.lang.String |
CONTROL_KEY_FILL_DIRECTION |
static java.lang.String |
CONTROL_KEY_FILL_TEXTURE
when filling a region, use this texture (solid,hash,backhash,crosshash) to fill.
|
static java.lang.String |
CONTROL_KEY_FONT_SIZE
font size relative to the parent, so "" or "1em" is the same size.
|
static java.lang.String |
CONTROL_KEY_LINE_STYLE
used in ContoursRenderer and EventsRenderer, values like DotDashes and Solid
|
static java.lang.String |
CONTROL_KEY_LINE_THICK |
static java.lang.String |
CONTROL_KEY_MODULO_X |
static java.lang.String |
CONTROL_KEY_MODULO_Y
modulo Y indicates that a difference in 23 hours is the same as -1 hours.
|
static java.lang.String |
CONTROL_KEY_REFERENCE |
static java.lang.String |
CONTROL_KEY_SPECIAL_COLORS
mapping from one double value to color, like:
"0.0:white"
This might be expanded to support "ge(100.0):red;lt(0):gray;within(0to100);green" and nominal values.
|
static java.lang.String |
CONTROL_KEY_SYMBOL |
static java.lang.String |
CONTROL_KEY_SYMBOL_SIZE |
protected boolean |
drawLegendLabel |
protected QDataSet |
ds
The dataset that is being plotted by the Renderer.
|
protected int |
firstValidIndex
keep track of first and last valid points of the dataset to simplify
subclass code and allow them to check if there are any valid points.
|
protected java.lang.String |
id |
protected java.lang.Exception |
lastException
When a dataset cannot be loaded, the exception causing the failure
will be rendered instead.
|
protected int |
lastValidIndex |
protected java.lang.String |
legendLabel |
protected static java.util.logging.Logger |
logger |
protected java.lang.String |
MARKER_DATASET |
protected java.lang.String |
MARKER_X_AXIS_RANGE |
protected java.lang.String |
MARKER_Y_AXIS_RANGE |
protected java.util.Set<java.lang.String> |
needWorkMarkers |
static java.lang.String |
PROP_ACTIVE
display the renderer.
|
static java.lang.String |
PROP_BOTTOMDECORATOR |
static java.lang.String |
PROP_COLORBAR |
static java.lang.String |
PROP_CONTROL |
static java.lang.String |
PROP_DRAWLEGENDLABEL
true if the legend label should be drawn.
|
static java.lang.String |
PROP_ID |
static java.lang.String |
PROP_LEGENDLABEL
If non-null and non-zero-length, use this label to describe the renderer
in the plot's legend.
|
static java.lang.String |
PROP_RECORDFILE |
static java.lang.String |
PROP_TOPDECORATOR |
protected java.beans.PropertyChangeSupport |
propertyChangeSupport
Utility field used by bound properties.
|
protected java.lang.Exception |
renderException
This is the exception to be rendered.
|
protected Painter |
topDecorator |
Modifier | Constructor and Description |
---|---|
protected |
Renderer() |
protected |
Renderer(DataSetDescriptor dsd) |
protected |
Renderer(QDataSet ds) |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptContext(int x,
int y)
Returns true if the render will accept the context for a point.
|
boolean |
acceptsDataSet(QDataSet ds)
return true if the dataset appears to be in a scheme accepted by this renderer.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a PropertyChangeListener to the listener list.
|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener) |
protected void |
addToStats(int numberOfPoints,
long millis,
char t)
record the stat to a file.
|
static Datum |
decodeDatum(java.lang.String s,
Datum deft) |
static FillStyle |
decodeFillStyle(java.lang.String s,
FillStyle deflt)
decode the string into a fill style
|
static PsymConnector |
decodePlotSymbolConnectorControl(java.lang.String s,
PsymConnector deflt)
decode the string into a plot symbol.
|
static PlotSymbol |
decodePlotSymbolControl(java.lang.String s,
PlotSymbol deflt)
decode the string into a plot symbol.
|
void |
drawListIcon(java.awt.Graphics2D g,
int x,
int y)
implement this to provide nice drawing of icon on printing graphics context.
|
static java.lang.String |
encodeBooleanControl(boolean v)
return the encoding for the boolean value.
|
static java.lang.String |
encodeColorControl(java.awt.Color color)
encode the Color control.
|
static java.lang.String |
encodeDatum(Datum d) |
static java.lang.String |
encodeFillStyle(FillStyle fillStyle)
encode the fill style as a string, such as:
none, outline, and solid.
|
static java.lang.String |
encodePlotSymbolConnectorControl(PsymConnector psymConnector)
encode the plot symbol connector as a string, such as:
solid, dotted
|
static java.lang.String |
encodePlotSymbolControl(PlotSymbol psym)
encode the plot symbol as a string, such as:
none, circles, triangles, cross, ex, star, diamond, box
|
static java.lang.String |
formatControl(java.util.Map<java.lang.String,java.lang.String> c)
convenient and official location for method that formats control string.
|
protected java.awt.geom.AffineTransform |
getAffineTransform(DasAxis xAxis,
DasAxis yAxis) |
boolean |
getBooleanControl(java.lang.String key,
boolean deft)
get the boolean control.
|
Painter |
getBottomDecorator() |
DasColorBar |
getColorBar()
get the colorbar for the renderer.
|
java.awt.Color |
getColorControl(java.lang.String key,
java.awt.Color deft)
get the Color control.
|
QDataSet |
getConsumedDataSet()
return the data for DataSetConsumer, which might be rebinned.
|
java.lang.String |
getControl()
get the string which summarizes the state of the renderer.
|
java.lang.String |
getControl(java.lang.String key,
java.lang.String deft)
Get the control.
|
DataLoader |
getDataLoader() |
QDataSet |
getDataSet()
returns the current dataset being displayed.
|
DataSetDescriptor |
getDataSetDescriptor() |
java.lang.String |
getDataSetID() |
Datum |
getDatumControl(java.lang.String key,
Datum deft)
get the Datum control.
|
double[] |
getDoubleArrayControl(java.lang.String key,
double[] deft)
get the double array control.
|
double |
getDoubleControl(java.lang.String key,
double deft)
get the double control.
|
java.lang.String |
getId() |
int |
getIntegerControl(java.lang.String key,
int deft)
get the integer control.
|
protected QDataSet |
getInternalDataSet()
Renderers should use this internally instead of getDataSet() to support
subclasses preprocessing datasets
|
java.lang.Exception |
getLastException() |
java.lang.String |
getLegendLabel()
get the label to describe the renderer in the plot's legend.
|
javax.swing.Icon |
getListIcon()
An icon can be provided that will be shown in a list
along with the textual description of the element.
|
java.lang.String |
getListLabel()
return a
String that will help the user
identify this item when choosing from a list. |
DasPlot |
getParent() |
int |
getRenderCount()
return the number of times render has been called since the last reset.
|
java.lang.String |
getStatsFile() |
Painter |
getTopDecorator() |
int |
getUpdateCount()
return the number of times updatePlotImage has been called since the last reset.
|
DasAxis.Memento |
getXmemento() |
DasAxis.Memento |
getYmemento() |
boolean |
hasControl(java.lang.String key)
return true if the control is specified.
|
protected void |
incrementRenderCount() |
protected void |
incrementUpdateCount() |
protected void |
installRenderer() |
protected void |
invalidateParentCacheImage() |
boolean |
isActive()
true when the renderer should be drawn.
|
boolean |
isDrawLegendLabel()
get the switch used to turn off legend label.
|
boolean |
isDumpDataSet()
Getter for property dumpDataSet.
|
static boolean |
isTableDataSet(QDataSet ds) |
static java.util.Map<java.lang.String,java.lang.String> |
parseControl(java.lang.String c)
convenient and official location for method that parses control string.
|
static double |
parseLayoutString(java.lang.String sizeStr,
int nsize,
double emSize,
double fail)
return the size encoded as normalized by the container size and em size.
|
void |
postException(java.lang.Exception exception)
notify user of an exception, in the context of the plot.
|
void |
postMessage(java.lang.String message,
int messageType,
Datum x,
Datum y)
post the message, checking to see that there is a parent first.
|
void |
postMessage(java.lang.String message,
java.util.logging.Level messageLevel,
Datum x,
Datum y)
Notify user of an exception, in the context of the plot.
|
protected void |
refresh()
recalculate the plot image and repaint.
|
protected void |
refreshImage()
Deprecated.
call refresh which also checks the parent.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a PropertyChangeListener from the listener list.
|
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener) |
abstract void |
render(java.awt.Graphics2D g,
DasAxis xAxis,
DasAxis yAxis)
Render is called whenever the image needs to be refreshed or the content
has changed.
|
protected void |
renderException(java.awt.Graphics g,
DasAxis xAxis,
DasAxis yAxis,
java.lang.Exception e)
render the exception on the graphics context.
|
void |
resetCounters()
reset the counters.
|
void |
setActive(boolean active)
set the active property, when false the renderer will not be drawn.
|
void |
setBottomDecorator(Painter bottomDecorator)
add additional painting code to the renderer, which is called before
the renderer is called.
|
void |
setColorBar(DasColorBar cb)
set a colorbar for the renderer.
|
void |
setControl(java.lang.String s)
set the control string which contains a number of properties.
|
void |
setDataSet(QDataSet ds)
Set the dataset to be plotted.
|
void |
setDataSetDescriptor(DataSetDescriptor dsd) |
void |
setDataSetID(java.lang.String id) |
void |
setDataSetLoader(DataLoader loader) |
void |
setDrawLegendLabel(boolean drawLegendLabel)
set the switch used to turn off legend label.
|
void |
setDumpDataSet(boolean dumpDataSet)
Setter for property dumpDataSet setting this to
true causes the dataSet to be dumped.
|
void |
setException(java.lang.Exception e)
set the exception to be rendered instead of the dataset.
|
void |
setId(java.lang.String id) |
void |
setLastException(java.lang.Exception e)
TODO: what is the difference between lastException and exception?
|
void |
setLegendLabel(java.lang.String legendLabel)
set the label to describe the renderer in the plot's legend.
|
void |
setParent(DasPlot parent) |
void |
setStatsFile(java.lang.String recordFile)
name of the file where rendering speed is recorded.
|
void |
setTopDecorator(Painter topDecorator)
add additional painting code to the renderer, which is called after
the renderer is called.
|
static java.awt.Font |
setUpFont(java.awt.Font f,
java.lang.String fontSize)
handle the fontSize property, which has values like "1em" and "7px"
|
protected void |
setUpFont(java.awt.Graphics g1,
java.lang.String fontSize)
handle the fontSize property, which has values like "1em" and "7px"
|
protected void |
uninstallRenderer() |
void |
update()
Something has changed with the Render, and the plot should come back
to allow this render to repaint.
|
void |
updateCacheImage()
The cacheImage is invalidated and updateEvent posted on the event thread
by calling update.
|
protected void |
updateImmediately()
updateImmediately is called from DasPlot when it gets an update event from the
AWT Event thread.
|
void |
updatePlotImage(DasAxis xAxis,
DasAxis yAxis,
ProgressMonitor monitor)
updatePlotImage is called once the expensive operation of loading
the data is completed.
|
protected static final java.util.logging.Logger logger
protected QDataSet ds
protected java.lang.Exception lastException
protected java.lang.Exception renderException
protected int firstValidIndex
protected int lastValidIndex
protected java.util.Set<java.lang.String> needWorkMarkers
protected final java.lang.String MARKER_DATASET
protected final java.lang.String MARKER_X_AXIS_RANGE
protected final java.lang.String MARKER_Y_AXIS_RANGE
protected Painter bottomDecorator
public static final java.lang.String PROP_BOTTOMDECORATOR
protected Painter topDecorator
public static final java.lang.String PROP_TOPDECORATOR
public static final java.lang.String CONTROL_KEY_COLOR
public static final java.lang.String CONTROL_KEY_FILL_COLOR
public static final java.lang.String CONTROL_KEY_FILL_DIRECTION
public static final java.lang.String CONTROL_KEY_COLOR_TABLE
public static final java.lang.String CONTROL_KEY_LINE_THICK
public static final java.lang.String CONTROL_KEY_LINE_STYLE
public static final java.lang.String CONTROL_KEY_SYMBOL
public static final java.lang.String CONTROL_KEY_SYMBOL_SIZE
public static final java.lang.String CONTROL_KEY_SPECIAL_COLORS
public static final java.lang.String CONTROL_KEY_FILL_TEXTURE
public static final java.lang.String CONTROL_KEY_FONT_SIZE
public static final java.lang.String CONTROL_KEY_REFERENCE
public static final java.lang.String CONTROL_KEY_DRAW_ERROR
public static final java.lang.String CONTROL_KEY_MODULO_Y
public static final java.lang.String CONTROL_KEY_MODULO_X
public static final java.lang.String PROP_CONTROL
protected java.lang.String control
fill=red,above,5.0;grey,below,0.0&ref=2.5
(Note these are example controls which are not implemented.)public static final java.lang.String PROP_ACTIVE
public static final java.lang.String PROP_LEGENDLABEL
protected java.lang.String legendLabel
protected boolean drawLegendLabel
public static final java.lang.String PROP_DRAWLEGENDLABEL
protected java.lang.String id
public static final java.lang.String PROP_ID
public static final java.lang.String PROP_COLORBAR
protected DasColorBar colorBar
public static final java.lang.String PROP_RECORDFILE
protected java.beans.PropertyChangeSupport propertyChangeSupport
protected Renderer(DataSetDescriptor dsd)
protected Renderer(QDataSet ds)
protected Renderer()
public DasPlot getParent()
public void setParent(DasPlot parent)
public DasAxis.Memento getXmemento()
public DasAxis.Memento getYmemento()
public void postMessage(java.lang.String message, int messageType, Datum x, Datum y)
message
- the messagemessageType
- the message type, DasPlot.INFO, DasPlot.WARNING, or DasPlot.SEVERE.x
- the X position or nully
- the Y position or nullpublic void postMessage(java.lang.String message, java.util.logging.Level messageLevel, Datum x, Datum y)
message
- the text to be displayed, may contain granny text.messageLevel
- allows java.util.logging.Level to be used, for example Level.INFO, Level.WARNING, and Level.SEVEREx
- if non-null, the location on the x axis giving context for the text.y
- if non-null, the location on the y axis giving context for the text.public void postException(java.lang.Exception exception)
exception
- the exception to post.public static boolean isTableDataSet(QDataSet ds)
protected void invalidateParentCacheImage()
public QDataSet getDataSet()
protected QDataSet getInternalDataSet()
public QDataSet getConsumedDataSet()
getConsumedDataSet
in interface DataSetConsumer
public boolean isDumpDataSet()
public void setDumpDataSet(boolean dumpDataSet)
dumpDataSet
- New value of property dumpDataSet.public Painter getBottomDecorator()
public void setBottomDecorator(Painter bottomDecorator)
bottomDecorator
- the Painter to call, or null to clear.public Painter getTopDecorator()
public void setTopDecorator(Painter topDecorator)
topDecorator
- the Painter to call, or null to clear.public void setLastException(java.lang.Exception e)
e
- public java.lang.Exception getLastException()
public boolean acceptsDataSet(QDataSet ds)
ds
- public void setDataSet(QDataSet ds)
ds
- public void setException(java.lang.Exception e)
e
- public void setDataSetID(java.lang.String id) throws DasException
DasException
public java.lang.String getDataSetID()
public void setControl(java.lang.String s)
s
- the controletc
public java.lang.String getControl()
public static java.lang.String formatControl(java.util.Map<java.lang.String,java.lang.String> c)
c
- public static java.util.Map<java.lang.String,java.lang.String> parseControl(java.lang.String c)
c
- the control string or null.public java.lang.String getControl(java.lang.String key, java.lang.String deft)
key
- the key name.deft
- the default value (or null)getDoubleControl(java.lang.String, double)
,
getBooleanControl(java.lang.String, boolean)
public boolean hasControl(java.lang.String key)
key
- the key namepublic boolean getBooleanControl(java.lang.String key, boolean deft)
key
- the key name.deft
- the default value.public static java.lang.String encodeBooleanControl(boolean v)
v
- the boolean value.public double getDoubleControl(java.lang.String key, double deft)
key
- the key name.deft
- the default value.public int getIntegerControl(java.lang.String key, int deft)
key
- the key name.deft
- the default value.public double[] getDoubleArrayControl(java.lang.String key, double[] deft)
key
- the key name.deft
- the default value.public Datum getDatumControl(java.lang.String key, Datum deft)
key
- the key name.deft
- the default value, which also provides the units.public java.awt.Color getColorControl(java.lang.String key, java.awt.Color deft)
key
- the key name.deft
- the default valueColorUtil.decodeColor(java.lang.String)
public static java.lang.String encodeColorControl(java.awt.Color color)
color
- ColorUtil.encodeColor(java.awt.Color)
public static java.lang.String encodePlotSymbolControl(PlotSymbol psym)
psym
- the plot symbol.public static PlotSymbol decodePlotSymbolControl(java.lang.String s, PlotSymbol deflt)
s
- the symbol name, such as none, circles, triangles, cross, ex, star, diamond, boxdeflt
- the symbol to use when the value is not parsed.public static java.lang.String encodePlotSymbolConnectorControl(PsymConnector psymConnector)
psymConnector
- public static PsymConnector decodePlotSymbolConnectorControl(java.lang.String s, PsymConnector deflt)
s
- the symbol name, such as none, dashes, dashFinedeflt
- the symbol to use when the value is not parsed.public static FillStyle decodeFillStyle(java.lang.String s, FillStyle deflt)
s
- the symbol name, such as none, solid, and outline.deflt
- the value to use when the value is not parsed.public static java.lang.String encodeFillStyle(FillStyle fillStyle)
fillStyle
- public static java.lang.String encodeDatum(Datum d)
protected java.awt.geom.AffineTransform getAffineTransform(DasAxis xAxis, DasAxis yAxis)
public abstract void render(java.awt.Graphics2D g, DasAxis xAxis, DasAxis yAxis)
g
- the graphics context in the canvas reference frame.xAxis
- the axis relating x data coordinates to horizontal pixel coordinatesyAxis
- the axis relating y data coordinates to horizontal pixel coordinatespublic boolean acceptContext(int x, int y)
x
- the x coordinate in the canvas coordinate system.y
- the y coordinate in the canvas coordinate system.protected void renderException(java.awt.Graphics g, DasAxis xAxis, DasAxis yAxis, java.lang.Exception e)
g
- the graphics context in the canvas reference framexAxis
- the axis relating x data coordinates to horizontal pixel coordinatesyAxis
- the axis relating y data coordinates to horizontal pixel coordinatese
- the exception.public void updatePlotImage(DasAxis xAxis, DasAxis yAxis, ProgressMonitor monitor) throws DasException
xAxis
- the axis relating x data coordinates to horizontal pixel coordinatesyAxis
- the axis relating y data coordinates to horizontal pixel coordinatesmonitor
- a monitor for the operation. Note the updatePlotImage operation should be fast (<1000ms).DasException
protected void refreshImage()
public void update()
public void updateCacheImage()
protected void updateImmediately()
protected void refresh()
public void setDataSetDescriptor(DataSetDescriptor dsd)
public DataLoader getDataLoader()
public void setDataSetLoader(DataLoader loader)
public DataSetDescriptor getDataSetDescriptor()
protected void installRenderer()
protected void uninstallRenderer()
public boolean isActive()
public void setActive(boolean active)
active
- false if the renderer should not be drawn.public java.lang.String getLegendLabel()
public void setLegendLabel(java.lang.String legendLabel)
legendLabel
- the label to describe the rendererpublic boolean isDrawLegendLabel()
public void setDrawLegendLabel(boolean drawLegendLabel)
drawLegendLabel
- true if the legend label should be drawnpublic java.lang.String getId()
public void setId(java.lang.String id)
public void drawListIcon(java.awt.Graphics2D g, int x, int y)
Displayable
drawListIcon
in interface Displayable
g
- the graphics context.x
- the x position, typically 0.y
- the y position, typically 0.public javax.swing.Icon getListIcon()
Displayable
null
if there
is no icon available, or a roughly 16x16 pixel icon.getListIcon
in interface Displayable
public java.lang.String getListLabel()
Displayable
String
that will help the user
identify this item when choosing from a list.getListLabel
in interface Displayable
public void setColorBar(DasColorBar cb)
cb
- a colorbarpublic DasColorBar getColorBar()
public static java.awt.Font setUpFont(java.awt.Font f, java.lang.String fontSize)
f
- the parent font.fontSize
- fontSize property, for example "1em" and "7px"public static double parseLayoutString(java.lang.String sizeStr, int nsize, double emSize, double fail) throws java.text.ParseException
sizeStr
- spec like "5em" or "50%"nsize
- the dimension for percents, for example the size of the canvas or column.emSize
- the size of the current font, for ems.fail
- value to return if the spec cannot be parsed.java.text.ParseException
DasDevicePosition.parseLayoutStr(java.lang.String, double, int, double)
protected void setUpFont(java.awt.Graphics g1, java.lang.String fontSize)
g1
- fontSize
- fontSize property, for example "1em" and "7px"protected void incrementRenderCount()
public int getRenderCount()
protected void incrementUpdateCount()
public int getUpdateCount()
public void resetCounters()
public java.lang.String getStatsFile()
public void setStatsFile(java.lang.String recordFile)
recordFile
- protected void addToStats(int numberOfPoints, long millis, char t)
numberOfPoints
- millis
- millisecondst
- 'r' for rendering, 'u' for updatePlotImagepublic void addPropertyChangeListener(java.beans.PropertyChangeListener l)
l
- The listener to add.public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
l
- The listener to remove.public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)