use of org.jfree.ui.RectangleAnchor in project SIMVA-SoS by SESoS.
the class Crosshair method setLabelAnchor.
/**
* Sets the label anchor point and sends a property change event (with the
* name 'labelAnchor') to all registered listeners.
*
* @param anchor the anchor (<code>null</code> not permitted).
*
* @see #getLabelAnchor()
*/
public void setLabelAnchor(RectangleAnchor anchor) {
RectangleAnchor old = this.labelAnchor;
this.labelAnchor = anchor;
this.pcs.firePropertyChange("labelAnchor", old, anchor);
}
use of org.jfree.ui.RectangleAnchor in project SIMVA-SoS by SESoS.
the class AbstractCategoryItemRenderer method drawDomainMarker.
/**
* Draws a marker for the domain axis.
*
* @param g2 the graphics device (not <code>null</code>).
* @param plot the plot (not <code>null</code>).
* @param axis the range axis (not <code>null</code>).
* @param marker the marker to be drawn (not <code>null</code>).
* @param dataArea the area inside the axes (not <code>null</code>).
*
* @see #drawRangeMarker(Graphics2D, CategoryPlot, ValueAxis, Marker,
* Rectangle2D)
*/
@Override
public void drawDomainMarker(Graphics2D g2, CategoryPlot plot, CategoryAxis axis, CategoryMarker marker, Rectangle2D dataArea) {
Comparable category = marker.getKey();
CategoryDataset dataset = plot.getDataset(plot.getIndexOf(this));
int columnIndex = dataset.getColumnIndex(category);
if (columnIndex < 0) {
return;
}
final Composite savedComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, marker.getAlpha()));
PlotOrientation orientation = plot.getOrientation();
Rectangle2D bounds;
if (marker.getDrawAsLine()) {
double v = axis.getCategoryMiddle(columnIndex, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge());
Line2D line = null;
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
} else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
} else {
throw new IllegalStateException();
}
g2.setPaint(marker.getPaint());
g2.setStroke(marker.getStroke());
g2.draw(line);
bounds = line.getBounds2D();
} else {
double v0 = axis.getCategoryStart(columnIndex, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge());
double v1 = axis.getCategoryEnd(columnIndex, dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge());
Rectangle2D area = null;
if (orientation == PlotOrientation.HORIZONTAL) {
area = new Rectangle2D.Double(dataArea.getMinX(), v0, dataArea.getWidth(), (v1 - v0));
} else if (orientation == PlotOrientation.VERTICAL) {
area = new Rectangle2D.Double(v0, dataArea.getMinY(), (v1 - v0), dataArea.getHeight());
}
g2.setPaint(marker.getPaint());
g2.fill(area);
bounds = area;
}
String label = marker.getLabel();
RectangleAnchor anchor = marker.getLabelAnchor();
if (label != null) {
Font labelFont = marker.getLabelFont();
g2.setFont(labelFont);
g2.setPaint(marker.getLabelPaint());
Point2D coordinates = calculateDomainMarkerTextAnchorPoint(g2, orientation, dataArea, bounds, marker.getLabelOffset(), marker.getLabelOffsetType(), anchor);
TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(), marker.getLabelTextAnchor());
}
g2.setComposite(savedComposite);
}
use of org.jfree.ui.RectangleAnchor in project SIMVA-SoS by SESoS.
the class BarRenderer3D method drawRangeMarker.
/**
* Draws a range marker.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param axis the value axis.
* @param marker the marker.
* @param dataArea the area for plotting data (not including 3D effect).
*/
@Override
public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, ValueAxis axis, Marker marker, Rectangle2D dataArea) {
Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset());
if (marker instanceof ValueMarker) {
ValueMarker vm = (ValueMarker) marker;
double value = vm.getValue();
Range range = axis.getRange();
if (!range.contains(value)) {
return;
}
GeneralPath path = null;
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
float x = (float) axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge());
float y = (float) adjusted.getMaxY();
path = new GeneralPath();
path.moveTo(x, y);
path.lineTo((float) (x + getXOffset()), y - (float) getYOffset());
path.lineTo((float) (x + getXOffset()), (float) (adjusted.getMinY() - getYOffset()));
path.lineTo(x, (float) adjusted.getMinY());
path.closePath();
} else if (orientation == PlotOrientation.VERTICAL) {
float y = (float) axis.valueToJava2D(value, adjusted, plot.getRangeAxisEdge());
float x = (float) dataArea.getX();
path = new GeneralPath();
path.moveTo(x, y);
path.lineTo(x + (float) this.xOffset, y - (float) this.yOffset);
path.lineTo((float) (adjusted.getMaxX() + this.xOffset), y - (float) this.yOffset);
path.lineTo((float) (adjusted.getMaxX()), y);
path.closePath();
} else {
throw new IllegalStateException();
}
g2.setPaint(marker.getPaint());
g2.fill(path);
g2.setPaint(marker.getOutlinePaint());
g2.draw(path);
String label = marker.getLabel();
RectangleAnchor anchor = marker.getLabelAnchor();
if (label != null) {
Font labelFont = marker.getLabelFont();
g2.setFont(labelFont);
g2.setPaint(marker.getLabelPaint());
Point2D coordinates = calculateRangeMarkerTextAnchorPoint(g2, orientation, dataArea, path.getBounds2D(), marker.getLabelOffset(), LengthAdjustmentType.EXPAND, anchor);
TextUtilities.drawAlignedString(label, g2, (float) coordinates.getX(), (float) coordinates.getY(), marker.getLabelTextAnchor());
}
} else {
super.drawRangeMarker(g2, plot, axis, marker, adjusted);
// TODO: draw the interval marker with a 3D effect
}
}
Aggregations