A renderer that draws shapes for each data item, and lines between data
items (for use with the
| Method from org.jfree.chart.renderer.category.LineAndShapeRenderer Detail: |
public Object clone() throws CloneNotSupportedException {
LineAndShapeRenderer clone = (LineAndShapeRenderer) super.clone();
clone.seriesLinesVisible
= (BooleanList) this.seriesLinesVisible.clone();
clone.seriesShapesVisible
= (BooleanList) this.seriesShapesVisible.clone();
clone.seriesShapesFilled
= (BooleanList) this.seriesShapesFilled.clone();
return clone;
}
Returns an independent copy of the renderer. |
public void drawItem(Graphics2D g2,
CategoryItemRendererState state,
Rectangle2D dataArea,
CategoryPlot plot,
CategoryAxis domainAxis,
ValueAxis rangeAxis,
CategoryDataset dataset,
int row,
int column,
int pass) {
// do nothing if item is not visible
if (!getItemVisible(row, column)) {
return;
}
// do nothing if both the line and shape are not visible
if (!getItemLineVisible(row, column)
&& !getItemShapeVisible(row, column)) {
return;
}
// nothing is drawn for null...
Number v = dataset.getValue(row, column);
if (v == null) {
return;
}
PlotOrientation orientation = plot.getOrientation();
// current data point...
double x1;
if (this.useSeriesOffset) {
x1 = domainAxis.getCategorySeriesMiddle(dataset.getColumnKey(
column), dataset.getRowKey(row), dataset, this.itemMargin,
dataArea, plot.getDomainAxisEdge());
}
else {
x1 = domainAxis.getCategoryMiddle(column, getColumnCount(),
dataArea, plot.getDomainAxisEdge());
}
double value = v.doubleValue();
double y1 = rangeAxis.valueToJava2D(value, dataArea,
plot.getRangeAxisEdge());
if (pass == 0 && getItemLineVisible(row, column)) {
if (column != 0) {
Number previousValue = dataset.getValue(row, column - 1);
if (previousValue != null) {
// previous data point...
double previous = previousValue.doubleValue();
double x0;
if (this.useSeriesOffset) {
x0 = domainAxis.getCategorySeriesMiddle(
dataset.getColumnKey(column - 1),
dataset.getRowKey(row), dataset,
this.itemMargin, dataArea,
plot.getDomainAxisEdge());
}
else {
x0 = domainAxis.getCategoryMiddle(column - 1,
getColumnCount(), dataArea,
plot.getDomainAxisEdge());
}
double y0 = rangeAxis.valueToJava2D(previous, dataArea,
plot.getRangeAxisEdge());
Line2D line = null;
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(y0, x0, y1, x1);
}
else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(x0, y0, x1, y1);
}
g2.setPaint(getItemPaint(row, column));
g2.setStroke(getItemStroke(row, column));
g2.draw(line);
}
}
}
if (pass == 1) {
Shape shape = getItemShape(row, column);
if (orientation == PlotOrientation.HORIZONTAL) {
shape = ShapeUtilities.createTranslatedShape(shape, y1, x1);
}
else if (orientation == PlotOrientation.VERTICAL) {
shape = ShapeUtilities.createTranslatedShape(shape, x1, y1);
}
if (getItemShapeVisible(row, column)) {
if (getItemShapeFilled(row, column)) {
if (this.useFillPaint) {
g2.setPaint(getItemFillPaint(row, column));
}
else {
g2.setPaint(getItemPaint(row, column));
}
g2.fill(shape);
}
if (this.drawOutlines) {
if (this.useOutlinePaint) {
g2.setPaint(getItemOutlinePaint(row, column));
}
else {
g2.setPaint(getItemPaint(row, column));
}
g2.setStroke(getItemOutlineStroke(row, column));
g2.draw(shape);
}
}
// draw the item label if there is one...
if (isItemLabelVisible(row, column)) {
if (orientation == PlotOrientation.HORIZONTAL) {
drawItemLabel(g2, orientation, dataset, row, column, y1,
x1, (value < 0.0));
}
else if (orientation == PlotOrientation.VERTICAL) {
drawItemLabel(g2, orientation, dataset, row, column, x1,
y1, (value < 0.0));
}
}
// add an item entity, if this information is being collected
EntityCollection entities = state.getEntityCollection();
if (entities != null) {
addItemEntity(entities, dataset, row, column, shape);
}
}
}
|
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof LineAndShapeRenderer)) {
return false;
}
LineAndShapeRenderer that = (LineAndShapeRenderer) obj;
if (this.baseLinesVisible != that.baseLinesVisible) {
return false;
}
if (!ObjectUtilities.equal(this.seriesLinesVisible,
that.seriesLinesVisible)) {
return false;
}
if (!ObjectUtilities.equal(this.linesVisible, that.linesVisible)) {
return false;
}
if (this.baseShapesVisible != that.baseShapesVisible) {
return false;
}
if (!ObjectUtilities.equal(this.seriesShapesVisible,
that.seriesShapesVisible)) {
return false;
}
if (!ObjectUtilities.equal(this.shapesVisible, that.shapesVisible)) {
return false;
}
if (!ObjectUtilities.equal(this.shapesFilled, that.shapesFilled)) {
return false;
}
if (!ObjectUtilities.equal(this.seriesShapesFilled,
that.seriesShapesFilled)) {
return false;
}
if (this.baseShapesFilled != that.baseShapesFilled) {
return false;
}
if (this.useOutlinePaint != that.useOutlinePaint) {
return false;
}
if (this.useSeriesOffset != that.useSeriesOffset) {
return false;
}
if (this.itemMargin != that.itemMargin) {
return false;
}
return super.equals(obj);
}
Tests this renderer for equality with an arbitrary object. |
public boolean getBaseLinesVisible() {
return this.baseLinesVisible;
}
Returns the base 'lines visible' attribute. |
public boolean getBaseShapesFilled() {
return this.baseShapesFilled;
}
Returns the base 'shape filled' attribute. |
public boolean getBaseShapesVisible() {
return this.baseShapesVisible;
}
Returns the base 'shape visible' attribute. |
public boolean getDrawOutlines() {
return this.drawOutlines;
}
Returns true if outlines should be drawn for shapes, and
false otherwise. |
public boolean getItemLineVisible(int series,
int item) {
Boolean flag = this.linesVisible;
if (flag == null) {
flag = getSeriesLinesVisible(series);
}
if (flag != null) {
return flag.booleanValue();
}
else {
return this.baseLinesVisible;
}
}
Returns the flag used to control whether or not the line for an item is
visible. |
public double getItemMargin() {
return this.itemMargin;
}
Returns the item margin, which is the gap between items within a
category (expressed as a percentage of the overall category width).
This can be used to match the offset alignment with the bars drawn by
a BarRenderer ). |
public boolean getItemShapeFilled(int series,
int item) {
return getSeriesShapesFilled(series);
}
Returns the flag used to control whether or not the shape for an item
is filled. The default implementation passes control to the
getSeriesShapesFilled method. You can override this method
if you require different behaviour. |
public boolean getItemShapeVisible(int series,
int item) {
Boolean flag = this.shapesVisible;
if (flag == null) {
flag = getSeriesShapesVisible(series);
}
if (flag != null) {
return flag.booleanValue();
}
else {
return this.baseShapesVisible;
}
}
Returns the flag used to control whether or not the shape for an item is
visible. |
public LegendItem getLegendItem(int datasetIndex,
int series) {
CategoryPlot cp = getPlot();
if (cp == null) {
return null;
}
if (isSeriesVisible(series) && isSeriesVisibleInLegend(series)) {
CategoryDataset dataset = cp.getDataset(datasetIndex);
String label = getLegendItemLabelGenerator().generateLabel(
dataset, series);
String description = label;
String toolTipText = null;
if (getLegendItemToolTipGenerator() != null) {
toolTipText = getLegendItemToolTipGenerator().generateLabel(
dataset, series);
}
String urlText = null;
if (getLegendItemURLGenerator() != null) {
urlText = getLegendItemURLGenerator().generateLabel(
dataset, series);
}
Shape shape = lookupSeriesShape(series);
Paint paint = lookupSeriesPaint(series);
Paint fillPaint = (this.useFillPaint
? getItemFillPaint(series, 0) : paint);
boolean shapeOutlineVisible = this.drawOutlines;
Paint outlinePaint = (this.useOutlinePaint
? getItemOutlinePaint(series, 0) : paint);
Stroke outlineStroke = lookupSeriesOutlineStroke(series);
boolean lineVisible = getItemLineVisible(series, 0);
boolean shapeVisible = getItemShapeVisible(series, 0);
LegendItem result = new LegendItem(label, description, toolTipText,
urlText, shapeVisible, shape, getItemShapeFilled(series, 0),
fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke,
lineVisible, new Line2D.Double(-7.0, 0.0, 7.0, 0.0),
getItemStroke(series, 0), getItemPaint(series, 0));
result.setDataset(dataset);
result.setDatasetIndex(datasetIndex);
result.setSeriesKey(dataset.getRowKey(series));
result.setSeriesIndex(series);
return result;
}
return null;
}
Returns a legend item for a series. |
public Boolean getLinesVisible() {
return this.linesVisible;
} Deprecated! As - of 1.0.7 (the override facility is unnecessary, just
use the per-series and base (default) settings).
Returns a flag that controls whether or not lines are drawn for ALL
series. If this flag is null, then the "per series"
settings will apply. |
public int getPassCount() {
return 2;
}
This renderer uses two passes to draw the data. |
public Boolean getSeriesLinesVisible(int series) {
return this.seriesLinesVisible.getBoolean(series);
}
Returns the flag used to control whether or not the lines for a series
are visible. |
public boolean getSeriesShapesFilled(int series) {
// return the overall setting, if there is one...
if (this.shapesFilled != null) {
return this.shapesFilled.booleanValue();
}
// otherwise look up the paint table
Boolean flag = this.seriesShapesFilled.getBoolean(series);
if (flag != null) {
return flag.booleanValue();
}
else {
return this.baseShapesFilled;
}
}
Returns the flag used to control whether or not the shapes for a series
are filled. |
public Boolean getSeriesShapesVisible(int series) {
return this.seriesShapesVisible.getBoolean(series);
}
Returns the flag used to control whether or not the shapes for a series
are visible. |
public Boolean getShapesFilled() {
return this.shapesFilled;
} Deprecated! As - of 1.0.7 (the override facility is unnecessary, just
use the per-series and base (default) settings).
Returns the flag that controls whether or not shapes are filled for
ALL series. |
public Boolean getShapesVisible() {
return this.shapesVisible;
} Deprecated! As - of 1.0.7 (the override facility is unnecessary, just
use the per-series and base (default) settings).
Returns the flag that controls whether the shapes are visible for the
items in ALL series. |
public boolean getUseFillPaint() {
return this.useFillPaint;
}
Returns true if the renderer should use the fill paint
setting to fill shapes, and false if it should just
use the regular paint. |
public boolean getUseOutlinePaint() {
return this.useOutlinePaint;
}
Returns the flag that controls whether the outline paint is used for
shape outlines. If not, the regular series paint is used. |
public boolean getUseSeriesOffset() {
return this.useSeriesOffset;
}
Returns the flag that controls whether or not the x-position for each
data item is offset within the category according to the series. |
public void setBaseLinesVisible(boolean flag) {
this.baseLinesVisible = flag;
fireChangeEvent();
}
Sets the base 'lines visible' flag and sends a
RendererChangeEvent to all registered listeners. |
public void setBaseShapesFilled(boolean flag) {
this.baseShapesFilled = flag;
fireChangeEvent();
}
Sets the base 'shapes filled' flag and sends a
RendererChangeEvent to all registered listeners. |
public void setBaseShapesVisible(boolean flag) {
this.baseShapesVisible = flag;
fireChangeEvent();
}
Sets the base 'shapes visible' flag and sends a
RendererChangeEvent to all registered listeners. |
public void setDrawOutlines(boolean flag) {
this.drawOutlines = flag;
fireChangeEvent();
}
Sets the flag that controls whether outlines are drawn for
shapes, and sends a RendererChangeEvent to all registered
listeners.
In some cases, shapes look better if they do NOT have an outline, but
this flag allows you to set your own preference. |
public void setItemMargin(double margin) {
if (margin < 0.0 || margin >= 1.0) {
throw new IllegalArgumentException("Requires 0.0 < = margin < 1.0.");
}
this.itemMargin = margin;
fireChangeEvent();
}
Sets the item margin, which is the gap between items within a category
(expressed as a percentage of the overall category width), and sends
a RendererChangeEvent to all registered listeners. |
public void setLinesVisible(Boolean visible) {
this.linesVisible = visible;
fireChangeEvent();
} Deprecated! As - of 1.0.7 (the override facility is unnecessary, just
use the per-series and base (default) settings).
Sets a flag that controls whether or not lines are drawn between the
items in ALL series, and sends a RendererChangeEvent to all
registered listeners. You need to set this to null if you
want the "per series" settings to apply. |
public void setLinesVisible(boolean visible) {
setLinesVisible(BooleanUtilities.valueOf(visible));
} Deprecated! As - of 1.0.7 (the override facility is unnecessary, just
use the per-series and base (default) settings).
Sets a flag that controls whether or not lines are drawn between the
items in ALL series, and sends a RendererChangeEvent to all
registered listeners. |
public void setSeriesLinesVisible(int series,
Boolean flag) {
this.seriesLinesVisible.setBoolean(series, flag);
fireChangeEvent();
}
Sets the 'lines visible' flag for a series and sends a
RendererChangeEvent to all registered listeners. |
public void setSeriesLinesVisible(int series,
boolean visible) {
setSeriesLinesVisible(series, BooleanUtilities.valueOf(visible));
}
Sets the 'lines visible' flag for a series and sends a
RendererChangeEvent to all registered listeners. |
public void setSeriesShapesFilled(int series,
Boolean filled) {
this.seriesShapesFilled.setBoolean(series, filled);
fireChangeEvent();
}
Sets the 'shapes filled' flag for a series and sends a
RendererChangeEvent to all registered listeners. |
public void setSeriesShapesFilled(int series,
boolean filled) {
// delegate
setSeriesShapesFilled(series, BooleanUtilities.valueOf(filled));
}
Sets the 'shapes filled' flag for a series and sends a
RendererChangeEvent to all registered listeners. |
public void setSeriesShapesVisible(int series,
boolean visible) {
setSeriesShapesVisible(series, BooleanUtilities.valueOf(visible));
}
Sets the 'shapes visible' flag for a series and sends a
RendererChangeEvent to all registered listeners. |
public void setSeriesShapesVisible(int series,
Boolean flag) {
this.seriesShapesVisible.setBoolean(series, flag);
fireChangeEvent();
}
Sets the 'shapes visible' flag for a series and sends a
RendererChangeEvent to all registered listeners. |
public void setShapesFilled(boolean filled) {
if (filled) {
setShapesFilled(Boolean.TRUE);
}
else {
setShapesFilled(Boolean.FALSE);
}
} Deprecated! As - of 1.0.7 (the override facility is unnecessary, just
use the per-series and base (default) settings).
Sets the 'shapes filled' for ALL series and sends a
RendererChangeEvent to all registered listeners. |
public void setShapesFilled(Boolean filled) {
this.shapesFilled = filled;
fireChangeEvent();
} Deprecated! As - of 1.0.7 (the override facility is unnecessary, just
use the per-series and base (default) settings).
Sets the 'shapes filled' for ALL series and sends a
RendererChangeEvent to all registered listeners. |
public void setShapesVisible(Boolean visible) {
this.shapesVisible = visible;
fireChangeEvent();
} Deprecated! As - of 1.0.7 (the override facility is unnecessary, just
use the per-series and base (default) settings).
Sets the 'shapes visible' for ALL series and sends a
RendererChangeEvent to all registered listeners. |
public void setShapesVisible(boolean visible) {
setShapesVisible(BooleanUtilities.valueOf(visible));
} Deprecated! As - of 1.0.7 (the override facility is unnecessary, just
use the per-series and base (default) settings).
Sets the 'shapes visible' for ALL series and sends a
RendererChangeEvent to all registered listeners. |
public void setUseFillPaint(boolean flag) {
this.useFillPaint = flag;
fireChangeEvent();
}
Sets the flag that controls whether the fill paint is used to fill
shapes, and sends a RendererChangeEvent to all
registered listeners. |
public void setUseOutlinePaint(boolean use) {
this.useOutlinePaint = use;
fireChangeEvent();
}
Sets the flag that controls whether the outline paint is used for shape
outlines, and sends a RendererChangeEvent to all registered
listeners. |
public void setUseSeriesOffset(boolean offset) {
this.useSeriesOffset = offset;
fireChangeEvent();
}
Sets the flag that controls whether or not the x-position for each
data item is offset within its category according to the series, and
sends a RendererChangeEvent to all registered listeners. |