public abstract class Renderer extends java.lang.Object implements DataSetConsumer, Editable, Displayable
| Modifier and Type | Field and Description |
|---|---|
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_FONT_SIZE
font size relative to the parent, so "" or "1em" is the same size.
|
static java.lang.String |
CONTROL_KEY_LINE_STYLE |
static java.lang.String |
CONTROL_KEY_LINE_THICK |
static java.lang.String |
CONTROL_KEY_REFERENCE |
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_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_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) |
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 |
encodePlotSymbolControl(PlotSymbol psym)
encode the plot symbol as a string, such as:
none, cicles, 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.
|
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.
|
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.
|
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.
|
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.Graphics g,
DasAxis xAxis,
DasAxis yAxis,
ProgressMonitor mon)
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 |
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 |
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 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_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 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
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 static boolean isTableDataSet(QDataSet ds)
protected void invalidateParentCacheImage()
public QDataSet getDataSet()
public QDataSet getConsumedDataSet()
getConsumedDataSet in interface DataSetConsumerpublic boolean isDumpDataSet()
public void setDumpDataSet(boolean dumpDataSet)
dumpDataSet - New value of property dumpDataSet.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
DasExceptionpublic java.lang.String getDataSetID()
public void setControl(java.lang.String s)
s - the controletcpublic 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.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.protected java.awt.geom.AffineTransform getAffineTransform(DasAxis xAxis, DasAxis yAxis)
public abstract void render(java.awt.Graphics g,
DasAxis xAxis,
DasAxis yAxis,
ProgressMonitor mon)
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 coordinatesmon - a monitor for the operation. Note the render operation should
be fast (<300ms).public 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).DasExceptionprotected 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)
DisplayabledrawListIcon in interface Displayableg - the graphics context.x - the x position, typically 0.y - the y position, typically 0.public javax.swing.Icon getListIcon()
Displayablenull if there
is no icon available, or a roughly 16x16 pixel icon.getListIcon in interface Displayablepublic java.lang.String getListLabel()
DisplayableString that will help the user
identify this item when choosing from a list.getListLabel in interface Displayablepublic 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"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 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)