use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPointerAnnotation method draw.
/**
* Draws the annotation.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the data area.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
*/
@Override
public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis) {
PlotOrientation orientation = plot.getOrientation();
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation);
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation);
CategoryDataset dataset = plot.getDataset();
int catIndex = dataset.getColumnIndex(getCategory());
int catCount = dataset.getColumnCount();
double j2DX = domainAxis.getCategoryMiddle(catIndex, catCount, dataArea, domainEdge);
double j2DY = rangeAxis.valueToJava2D(getValue(), dataArea, rangeEdge);
if (orientation == PlotOrientation.HORIZONTAL) {
double temp = j2DX;
j2DX = j2DY;
j2DY = temp;
}
double startX = j2DX + Math.cos(this.angle) * this.baseRadius;
double startY = j2DY + Math.sin(this.angle) * this.baseRadius;
double endX = j2DX + Math.cos(this.angle) * this.tipRadius;
double endY = j2DY + Math.sin(this.angle) * this.tipRadius;
double arrowBaseX = endX + Math.cos(this.angle) * this.arrowLength;
double arrowBaseY = endY + Math.sin(this.angle) * this.arrowLength;
double arrowLeftX = arrowBaseX + Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth;
double arrowLeftY = arrowBaseY + Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth;
double arrowRightX = arrowBaseX - Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth;
double arrowRightY = arrowBaseY - Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth;
GeneralPath arrow = new GeneralPath();
arrow.moveTo((float) endX, (float) endY);
arrow.lineTo((float) arrowLeftX, (float) arrowLeftY);
arrow.lineTo((float) arrowRightX, (float) arrowRightY);
arrow.closePath();
g2.setStroke(this.arrowStroke);
g2.setPaint(this.arrowPaint);
Line2D line = new Line2D.Double(startX, startY, arrowBaseX, arrowBaseY);
g2.draw(line);
g2.fill(arrow);
// draw the label
g2.setFont(getFont());
g2.setPaint(getPaint());
double labelX = j2DX + Math.cos(this.angle) * (this.baseRadius + this.labelOffset);
double labelY = j2DY + Math.sin(this.angle) * (this.baseRadius + this.labelOffset);
/* Rectangle2D hotspot = */
TextUtilities.drawAlignedString(getText(), g2, (float) labelX, (float) labelY, getTextAnchor());
// TODO: implement the entity for the annotation
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryLineAnnotation method draw.
/**
* Draws the annotation.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the data area.
* @param domainAxis the domain axis.
* @param rangeAxis the range axis.
*/
@Override
public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, CategoryAxis domainAxis, ValueAxis rangeAxis) {
CategoryDataset dataset = plot.getDataset();
int catIndex1 = dataset.getColumnIndex(this.category1);
int catIndex2 = dataset.getColumnIndex(this.category2);
int catCount = dataset.getColumnCount();
double lineX1 = 0.0f;
double lineY1 = 0.0f;
double lineX2 = 0.0f;
double lineY2 = 0.0f;
PlotOrientation orientation = plot.getOrientation();
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation);
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation);
if (orientation == PlotOrientation.HORIZONTAL) {
lineY1 = domainAxis.getCategoryJava2DCoordinate(CategoryAnchor.MIDDLE, catIndex1, catCount, dataArea, domainEdge);
lineX1 = rangeAxis.valueToJava2D(this.value1, dataArea, rangeEdge);
lineY2 = domainAxis.getCategoryJava2DCoordinate(CategoryAnchor.MIDDLE, catIndex2, catCount, dataArea, domainEdge);
lineX2 = rangeAxis.valueToJava2D(this.value2, dataArea, rangeEdge);
} else if (orientation == PlotOrientation.VERTICAL) {
lineX1 = domainAxis.getCategoryJava2DCoordinate(CategoryAnchor.MIDDLE, catIndex1, catCount, dataArea, domainEdge);
lineY1 = rangeAxis.valueToJava2D(this.value1, dataArea, rangeEdge);
lineX2 = domainAxis.getCategoryJava2DCoordinate(CategoryAnchor.MIDDLE, catIndex2, catCount, dataArea, domainEdge);
lineY2 = rangeAxis.valueToJava2D(this.value2, dataArea, rangeEdge);
}
g2.setPaint(this.paint);
g2.setStroke(this.stroke);
g2.drawLine((int) lineX1, (int) lineY1, (int) lineX2, (int) lineY2);
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlot method getCategoriesForAxis.
/**
* Returns a list of the categories that should be displayed for the
* specified axis.
*
* @param axis the axis (<code>null</code> not permitted)
*
* @return The categories.
*
* @since 1.0.3
*/
public List getCategoriesForAxis(CategoryAxis axis) {
List result = new ArrayList();
int axisIndex = getDomainAxisIndex(axis);
for (CategoryDataset dataset : datasetsMappedToDomainAxis(axisIndex)) {
// add the unique categories from this dataset
for (int i = 0; i < dataset.getColumnCount(); i++) {
Comparable category = dataset.getColumnKey(i);
if (!result.contains(category)) {
result.add(category);
}
}
}
return result;
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlot method getLegendItems.
/**
* Returns the legend items for the plot. By default, this method creates
* a legend item for each series in each of the datasets. You can change
* this behaviour by overriding this method.
*
* @return The legend items.
*/
@Override
public LegendItemCollection getLegendItems() {
if (this.fixedLegendItems != null) {
return this.fixedLegendItems;
}
LegendItemCollection result = new LegendItemCollection();
// get the legend items for the datasets...
for (CategoryDataset dataset : this.datasets.values()) {
if (dataset != null) {
int datasetIndex = indexOf(dataset);
CategoryItemRenderer renderer = getRenderer(datasetIndex);
if (renderer != null) {
result.addAll(renderer.getLegendItems());
}
}
}
return result;
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlot method readObject.
/**
* Provides serialization support.
*
* @param stream the input stream.
*
* @throws IOException if there is an I/O error.
* @throws ClassNotFoundException if there is a classpath problem.
*/
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
this.domainGridlineStroke = SerialUtilities.readStroke(stream);
this.domainGridlinePaint = SerialUtilities.readPaint(stream);
this.rangeGridlineStroke = SerialUtilities.readStroke(stream);
this.rangeGridlinePaint = SerialUtilities.readPaint(stream);
this.rangeCrosshairStroke = SerialUtilities.readStroke(stream);
this.rangeCrosshairPaint = SerialUtilities.readPaint(stream);
this.domainCrosshairStroke = SerialUtilities.readStroke(stream);
this.domainCrosshairPaint = SerialUtilities.readPaint(stream);
this.rangeMinorGridlineStroke = SerialUtilities.readStroke(stream);
this.rangeMinorGridlinePaint = SerialUtilities.readPaint(stream);
this.rangeZeroBaselineStroke = SerialUtilities.readStroke(stream);
this.rangeZeroBaselinePaint = SerialUtilities.readPaint(stream);
for (CategoryAxis xAxis : this.domainAxes.values()) {
if (xAxis != null) {
xAxis.setPlot(this);
xAxis.addChangeListener(this);
}
}
for (ValueAxis yAxis : this.rangeAxes.values()) {
if (yAxis != null) {
yAxis.setPlot(this);
yAxis.addChangeListener(this);
}
}
for (CategoryDataset dataset : this.datasets.values()) {
if (dataset != null) {
dataset.addChangeListener(this);
}
}
for (CategoryItemRenderer renderer : this.renderers.values()) {
if (renderer != null) {
renderer.addChangeListener(this);
}
}
}
Aggregations