📄 lineandshaperenderer.java
字号:
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.defaultShapesFilled.booleanValue();
}
}
/**
* Returns the flag that controls whether or not shapes are filled for ALL series.
*
* @return A Boolean.
*/
public Boolean getShapesFilled() {
return this.shapesFilled;
}
/**
* Sets the 'shapes filled' for ALL series.
*
* @param filled the flag.
*/
public void setShapesFilled(boolean filled) {
if (filled) {
setShapesFilled(Boolean.TRUE);
}
else {
setShapesFilled(Boolean.FALSE);
}
}
/**
* Sets the 'shapes filled' for ALL series.
*
* @param filled the flag (<code>null</code> permitted).
*/
public void setShapesFilled(Boolean filled) {
this.shapesFilled = filled;
}
/**
* Sets the 'shapes filled' flag for a series.
*
* @param series the series index (zero-based).
* @param filled the flag.
*/
public void setSeriesShapesFilled(int series, Boolean filled) {
this.seriesShapesFilled.setBoolean(series, filled);
}
/**
* Sets the 'shapes filled' flag for a series.
*
* @param series the series index (zero-based).
* @param filled the flag.
*/
public void setSeriesShapesFilled(int series, boolean filled) {
this.seriesShapesFilled.setBoolean(series, new Boolean(filled));
}
/**
* Returns the default 'shape filled' attribute.
*
* @return The default flag.
*/
public Boolean getDefaultShapesFilled() {
return this.defaultShapesFilled;
}
/**
* Sets the default 'shapes filled' flag.
*
* @param flag the flag.
*/
public void setDefaultShapesFilled(Boolean flag) {
this.defaultShapesFilled = flag;
}
/**
* Sets the default 'shapes filled' flag.
*
* @param flag the flag.
*/
public void setDefaultShapesFilled(boolean flag) {
setDefaultShapesFilled(new Boolean(flag));
}
/**
* Draw a single data item.
*
* @param g2 the graphics device.
* @param state the renderer state.
* @param dataArea the area in which the data is drawn.
* @param plot the plot.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
* @param dataset the dataset.
* @param row the row index (zero-based).
* @param column the column index (zero-based).
*/
public void drawItem(Graphics2D g2,
CategoryItemRendererState state,
Rectangle2D dataArea,
CategoryPlot plot,
CategoryAxis domainAxis,
ValueAxis rangeAxis,
CategoryDataset dataset,
int row,
int column) {
// nothing is drawn for null...
Number v = dataset.getValue(row, column);
if (v == null) {
return;
}
PlotOrientation orientation = plot.getOrientation();
// current data point...
double x1 = domainAxis.getCategoryMiddle(
column, getColumnCount(), dataArea, plot.getDomainAxisEdge()
);
double value = v.doubleValue();
double y1 = rangeAxis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
Shape shape = getItemShape(row, column);
if (orientation == PlotOrientation.HORIZONTAL) {
shape = createTransformedShape(shape, y1, x1);
}
else if (orientation == PlotOrientation.VERTICAL) {
shape = createTransformedShape(shape, x1, y1);
}
if (isDrawShapes()) {
if (getItemShapeFilled(row, column)) {
g2.setPaint(getItemPaint(row, column));
g2.fill(shape);
}
else {
if (this.useFillPaintForShapeOutline) {
g2.setPaint(getItemPaint(row, column));
}
else {
g2.setPaint(getItemOutlinePaint(row, column));
}
g2.setStroke(getItemOutlineStroke(row, column));
g2.draw(shape);
}
}
if (isDrawLines()) {
if (column != 0) {
Number previousValue = dataset.getValue(row, column - 1);
if (previousValue != null) {
// previous data point...
double previous = previousValue.doubleValue();
double 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);
}
}
}
// 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));
}
}
// collect entity and tool tip information...
if (state.getInfo() != null) {
EntityCollection entities = state.getInfo().getOwner().getEntityCollection();
if (entities != null && shape != null) {
String tip = null;
CategoryToolTipGenerator tipster = getToolTipGenerator(row, column);
if (tipster != null) {
tip = tipster.generateToolTip(dataset, row, column);
}
String url = null;
if (getItemURLGenerator(row, column) != null) {
url = getItemURLGenerator(row, column).generateURL(dataset, row, column);
}
CategoryItemEntity entity = new CategoryItemEntity(
shape, tip, url, dataset, row, dataset.getColumnKey(column), column
);
entities.addEntity(entity);
}
}
}
/**
* Tests this renderer for equality with another object.
*
* @param obj the object.
*
* @return <code>true</code> or <code>false</code>.
*/
public boolean equals(Object obj) {
boolean result = super.equals(obj);
if (obj instanceof LineAndShapeRenderer) {
LineAndShapeRenderer r = (LineAndShapeRenderer) obj;
boolean b0 = (r.drawLines == this.drawLines);
boolean b1 = (r.drawShapes == this.drawShapes);
boolean b2 = ObjectUtils.equal(r.shapesFilled, this.shapesFilled);
boolean b3 = ObjectUtils.equal(r.seriesShapesFilled, this.seriesShapesFilled);
boolean b4 = ObjectUtils.equal(r.defaultShapesFilled, this.defaultShapesFilled);
result = result && b0 && b1 && b2 && b3 && b4;
}
return result;
}
/**
* Returns an independent copy of the renderer.
*
* @return A clone.
*
* @throws CloneNotSupportedException should not happen.
*/
public Object clone() throws CloneNotSupportedException {
LineAndShapeRenderer clone = (LineAndShapeRenderer) super.clone();
clone.seriesShapesFilled = (BooleanList) this.seriesShapesFilled.clone();
return clone;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -