| Method from org.jfree.chart.axis.Axis Detail: |
public void addChangeListener(AxisChangeListener listener) {
this.listenerList.add(AxisChangeListener.class, listener);
}
Registers an object for notification of changes to the axis. |
public Object clone() throws CloneNotSupportedException {
Axis clone = (Axis) super.clone();
// It's up to the plot which clones up to restore the correct references
clone.plot = null;
clone.listenerList = new EventListenerList();
return clone;
}
Returns a clone of the axis. |
abstract public void configure()
Configures the axis to work with the current plot. Override this method
to perform any special processing (such as auto-rescaling). |
abstract public AxisState draw(Graphics2D g2,
double cursor,
Rectangle2D plotArea,
Rectangle2D dataArea,
RectangleEdge edge,
PlotRenderingInfo plotState)
Draws the axis on a Java 2D graphics device (such as the screen or a
printer). |
protected void drawAxisLine(Graphics2D g2,
double cursor,
Rectangle2D dataArea,
RectangleEdge edge) {
Line2D axisLine = null;
if (edge == RectangleEdge.TOP) {
axisLine = new Line2D.Double(dataArea.getX(), cursor,
dataArea.getMaxX(), cursor);
}
else if (edge == RectangleEdge.BOTTOM) {
axisLine = new Line2D.Double(dataArea.getX(), cursor,
dataArea.getMaxX(), cursor);
}
else if (edge == RectangleEdge.LEFT) {
axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor,
dataArea.getMaxY());
}
else if (edge == RectangleEdge.RIGHT) {
axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor,
dataArea.getMaxY());
}
g2.setPaint(this.axisLinePaint);
g2.setStroke(this.axisLineStroke);
g2.draw(axisLine);
}
Draws an axis line at the current cursor position and edge. |
protected AxisState drawLabel(String label,
Graphics2D g2,
Rectangle2D plotArea,
Rectangle2D dataArea,
RectangleEdge edge,
AxisState state) {
// it is unlikely that 'state' will be null, but check anyway...
if (state == null) {
throw new IllegalArgumentException("Null 'state' argument.");
}
if ((label == null) || (label.equals(""))) {
return state;
}
Font font = getLabelFont();
RectangleInsets insets = getLabelInsets();
g2.setFont(font);
g2.setPaint(getLabelPaint());
FontMetrics fm = g2.getFontMetrics();
Rectangle2D labelBounds = TextUtilities.getTextBounds(label, g2, fm);
if (edge == RectangleEdge.TOP) {
AffineTransform t = AffineTransform.getRotateInstance(
getLabelAngle(), labelBounds.getCenterX(),
labelBounds.getCenterY());
Shape rotatedLabelBounds = t.createTransformedShape(labelBounds);
labelBounds = rotatedLabelBounds.getBounds2D();
double labelx = dataArea.getCenterX();
double labely = state.getCursor() - insets.getBottom()
- labelBounds.getHeight() / 2.0;
TextUtilities.drawRotatedString(label, g2, (float) labelx,
(float) labely, TextAnchor.CENTER, getLabelAngle(),
TextAnchor.CENTER);
state.cursorUp(insets.getTop() + labelBounds.getHeight()
+ insets.getBottom());
}
else if (edge == RectangleEdge.BOTTOM) {
AffineTransform t = AffineTransform.getRotateInstance(
getLabelAngle(), labelBounds.getCenterX(),
labelBounds.getCenterY());
Shape rotatedLabelBounds = t.createTransformedShape(labelBounds);
labelBounds = rotatedLabelBounds.getBounds2D();
double labelx = dataArea.getCenterX();
double labely = state.getCursor()
+ insets.getTop() + labelBounds.getHeight() / 2.0;
TextUtilities.drawRotatedString(label, g2, (float) labelx,
(float) labely, TextAnchor.CENTER, getLabelAngle(),
TextAnchor.CENTER);
state.cursorDown(insets.getTop() + labelBounds.getHeight()
+ insets.getBottom());
}
else if (edge == RectangleEdge.LEFT) {
AffineTransform t = AffineTransform.getRotateInstance(
getLabelAngle() - Math.PI / 2.0, labelBounds.getCenterX(),
labelBounds.getCenterY());
Shape rotatedLabelBounds = t.createTransformedShape(labelBounds);
labelBounds = rotatedLabelBounds.getBounds2D();
double labelx = state.getCursor()
- insets.getRight() - labelBounds.getWidth() / 2.0;
double labely = dataArea.getCenterY();
TextUtilities.drawRotatedString(label, g2, (float) labelx,
(float) labely, TextAnchor.CENTER,
getLabelAngle() - Math.PI / 2.0, TextAnchor.CENTER);
state.cursorLeft(insets.getLeft() + labelBounds.getWidth()
+ insets.getRight());
}
else if (edge == RectangleEdge.RIGHT) {
AffineTransform t = AffineTransform.getRotateInstance(
getLabelAngle() + Math.PI / 2.0,
labelBounds.getCenterX(), labelBounds.getCenterY());
Shape rotatedLabelBounds = t.createTransformedShape(labelBounds);
labelBounds = rotatedLabelBounds.getBounds2D();
double labelx = state.getCursor()
+ insets.getLeft() + labelBounds.getWidth() / 2.0;
double labely = dataArea.getY() + dataArea.getHeight() / 2.0;
TextUtilities.drawRotatedString(label, g2, (float) labelx,
(float) labely, TextAnchor.CENTER,
getLabelAngle() + Math.PI / 2.0, TextAnchor.CENTER);
state.cursorRight(insets.getLeft() + labelBounds.getWidth()
+ insets.getRight());
}
return state;
}
|
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Axis)) {
return false;
}
Axis that = (Axis) obj;
if (this.visible != that.visible) {
return false;
}
if (!ObjectUtilities.equal(this.label, that.label)) {
return false;
}
if (!ObjectUtilities.equal(this.labelFont, that.labelFont)) {
return false;
}
if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) {
return false;
}
if (!ObjectUtilities.equal(this.labelInsets, that.labelInsets)) {
return false;
}
if (this.labelAngle != that.labelAngle) {
return false;
}
if (this.axisLineVisible != that.axisLineVisible) {
return false;
}
if (!ObjectUtilities.equal(this.axisLineStroke, that.axisLineStroke)) {
return false;
}
if (!PaintUtilities.equal(this.axisLinePaint, that.axisLinePaint)) {
return false;
}
if (this.tickLabelsVisible != that.tickLabelsVisible) {
return false;
}
if (!ObjectUtilities.equal(this.tickLabelFont, that.tickLabelFont)) {
return false;
}
if (!PaintUtilities.equal(this.tickLabelPaint, that.tickLabelPaint)) {
return false;
}
if (!ObjectUtilities.equal(
this.tickLabelInsets, that.tickLabelInsets
)) {
return false;
}
if (this.tickMarksVisible != that.tickMarksVisible) {
return false;
}
if (this.tickMarkInsideLength != that.tickMarkInsideLength) {
return false;
}
if (this.tickMarkOutsideLength != that.tickMarkOutsideLength) {
return false;
}
if (!PaintUtilities.equal(this.tickMarkPaint, that.tickMarkPaint)) {
return false;
}
if (!ObjectUtilities.equal(this.tickMarkStroke, that.tickMarkStroke)) {
return false;
}
if (this.fixedDimension != that.fixedDimension) {
return false;
}
return true;
}
Tests this axis for equality with another object. |
public Paint getAxisLinePaint() {
return this.axisLinePaint;
}
Returns the paint used to draw the axis line. |
public Stroke getAxisLineStroke() {
return this.axisLineStroke;
}
Returns the stroke used to draw the axis line. |
public double getFixedDimension() {
return this.fixedDimension;
}
Returns the fixed dimension for the axis. |
public String getLabel() {
return this.label;
}
Returns the label for the axis. |
public double getLabelAngle() {
return this.labelAngle;
}
Returns the angle of the axis label. |
protected Rectangle2D getLabelEnclosure(Graphics2D g2,
RectangleEdge edge) {
Rectangle2D result = new Rectangle2D.Double();
String axisLabel = getLabel();
if (axisLabel != null && !axisLabel.equals("")) {
FontMetrics fm = g2.getFontMetrics(getLabelFont());
Rectangle2D bounds = TextUtilities.getTextBounds(axisLabel, g2, fm);
RectangleInsets insets = getLabelInsets();
bounds = insets.createOutsetRectangle(bounds);
double angle = getLabelAngle();
if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) {
angle = angle - Math.PI / 2.0;
}
double x = bounds.getCenterX();
double y = bounds.getCenterY();
AffineTransform transformer
= AffineTransform.getRotateInstance(angle, x, y);
Shape labelBounds = transformer.createTransformedShape(bounds);
result = labelBounds.getBounds2D();
}
return result;
}
Returns a rectangle that encloses the axis label. This is typically
used for layout purposes (it gives the maximum dimensions of the label). |
public Font getLabelFont() {
return this.labelFont;
}
Returns the font for the axis label. |
public RectangleInsets getLabelInsets() {
return this.labelInsets;
}
Returns the insets for the label (that is, the amount of blank space
that should be left around the label). |
public Paint getLabelPaint() {
return this.labelPaint;
}
Returns the color/shade used to draw the axis label. |
public Plot getPlot() {
return this.plot;
}
Returns the plot that the axis is assigned to. This method will return
null if the axis is not currently assigned to a plot. |
public Font getTickLabelFont() {
return this.tickLabelFont;
}
Returns the font used for the tick labels (if showing). |
public RectangleInsets getTickLabelInsets() {
return this.tickLabelInsets;
}
Returns the insets for the tick labels. |
public Paint getTickLabelPaint() {
return this.tickLabelPaint;
}
Returns the color/shade used for the tick labels. |
public float getTickMarkInsideLength() {
return this.tickMarkInsideLength;
}
Returns the inside length of the tick marks. |
public float getTickMarkOutsideLength() {
return this.tickMarkOutsideLength;
}
Returns the outside length of the tick marks. |
public Paint getTickMarkPaint() {
return this.tickMarkPaint;
}
Returns the paint used to draw tick marks (if they are showing). |
public Stroke getTickMarkStroke() {
return this.tickMarkStroke;
}
Returns the stroke used to draw tick marks. |
public boolean hasListener(EventListener listener) {
List list = Arrays.asList(this.listenerList.getListenerList());
return list.contains(listener);
}
Returns true if the specified object is registered with
the dataset as a listener. Most applications won't need to call this
method, it exists mainly for use by unit testing code. |
public boolean isAxisLineVisible() {
return this.axisLineVisible;
}
A flag that controls whether or not the axis line is drawn. |
public boolean isTickLabelsVisible() {
return this.tickLabelsVisible;
}
Returns a flag indicating whether or not the tick labels are visible. |
public boolean isTickMarksVisible() {
return this.tickMarksVisible;
}
Returns the flag that indicates whether or not the tick marks are
showing. |
public boolean isVisible() {
return this.visible;
}
Returns true if the axis is visible, and
false otherwise. |
protected void notifyListeners(AxisChangeEvent event) {
Object[] listeners = this.listenerList.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == AxisChangeListener.class) {
((AxisChangeListener) listeners[i + 1]).axisChanged(event);
}
}
}
Notifies all registered listeners that the axis has changed.
The AxisChangeEvent provides information about the change. |
abstract public List refreshTicks(Graphics2D g2,
AxisState state,
Rectangle2D dataArea,
RectangleEdge edge)
Calculates the positions of the ticks for the axis, storing the results
in the tick list (ready for drawing). |
public void removeChangeListener(AxisChangeListener listener) {
this.listenerList.remove(AxisChangeListener.class, listener);
}
Deregisters an object for notification of changes to the axis. |
abstract public AxisSpace reserveSpace(Graphics2D g2,
Plot plot,
Rectangle2D plotArea,
RectangleEdge edge,
AxisSpace space)
Estimates the space (height or width) required to draw the axis. |
public void setAxisLinePaint(Paint paint) {
if (paint == null) {
throw new IllegalArgumentException("Null 'paint' argument.");
}
this.axisLinePaint = paint;
notifyListeners(new AxisChangeEvent(this));
}
Sets the paint used to draw the axis line and sends an
AxisChangeEvent to all registered listeners. |
public void setAxisLineStroke(Stroke stroke) {
if (stroke == null) {
throw new IllegalArgumentException("Null 'stroke' argument.");
}
this.axisLineStroke = stroke;
notifyListeners(new AxisChangeEvent(this));
}
Sets the stroke used to draw the axis line and sends an
AxisChangeEvent to all registered listeners. |
public void setAxisLineVisible(boolean visible) {
this.axisLineVisible = visible;
notifyListeners(new AxisChangeEvent(this));
}
Sets a flag that controls whether or not the axis line is visible and
sends an AxisChangeEvent to all registered listeners. |
public void setFixedDimension(double dimension) {
this.fixedDimension = dimension;
}
Sets the fixed dimension for the axis.
This is used when combining more than one plot on a chart. In this case,
there may be several axes that need to have the same height or width so
that they are aligned. This method is used to fix a dimension for the
axis (the context determines whether the dimension is horizontal or
vertical). |
public void setLabel(String label) {
String existing = this.label;
if (existing != null) {
if (!existing.equals(label)) {
this.label = label;
notifyListeners(new AxisChangeEvent(this));
}
}
else {
if (label != null) {
this.label = label;
notifyListeners(new AxisChangeEvent(this));
}
}
}
Sets the label for the axis and sends an AxisChangeEvent to all
registered listeners. |
public void setLabelAngle(double angle) {
this.labelAngle = angle;
notifyListeners(new AxisChangeEvent(this));
}
Sets the angle for the label and sends an AxisChangeEvent to all
registered listeners. |
public void setLabelFont(Font font) {
if (font == null) {
throw new IllegalArgumentException("Null 'font' argument.");
}
if (!this.labelFont.equals(font)) {
this.labelFont = font;
notifyListeners(new AxisChangeEvent(this));
}
}
Sets the font for the axis label and sends an AxisChangeEvent
to all registered listeners. |
public void setLabelInsets(RectangleInsets insets) {
setLabelInsets(insets, true);
}
Sets the insets for the axis label, and sends an AxisChangeEvent
to all registered listeners. |
public void setLabelInsets(RectangleInsets insets,
boolean notify) {
if (insets == null) {
throw new IllegalArgumentException("Null 'insets' argument.");
}
if (!insets.equals(this.labelInsets)) {
this.labelInsets = insets;
if (notify) {
notifyListeners(new AxisChangeEvent(this));
}
}
}
Sets the insets for the axis label, and sends an AxisChangeEvent
to all registered listeners. |
public void setLabelPaint(Paint paint) {
if (paint == null) {
throw new IllegalArgumentException("Null 'paint' argument.");
}
this.labelPaint = paint;
notifyListeners(new AxisChangeEvent(this));
}
Sets the paint used to draw the axis label and sends an
AxisChangeEvent to all registered listeners. |
public void setPlot(Plot plot) {
this.plot = plot;
configure();
}
Sets a reference to the plot that the axis is assigned to.
This method is used internally, you shouldn't need to call it yourself. |
public void setTickLabelFont(Font font) {
if (font == null) {
throw new IllegalArgumentException("Null 'font' argument.");
}
if (!this.tickLabelFont.equals(font)) {
this.tickLabelFont = font;
notifyListeners(new AxisChangeEvent(this));
}
}
Sets the font for the tick labels and sends an AxisChangeEvent
to all registered listeners. |
public void setTickLabelInsets(RectangleInsets insets) {
if (insets == null) {
throw new IllegalArgumentException("Null 'insets' argument.");
}
if (!this.tickLabelInsets.equals(insets)) {
this.tickLabelInsets = insets;
notifyListeners(new AxisChangeEvent(this));
}
}
Sets the insets for the tick labels and sends an AxisChangeEvent
to all registered listeners. |
public void setTickLabelPaint(Paint paint) {
if (paint == null) {
throw new IllegalArgumentException("Null 'paint' argument.");
}
this.tickLabelPaint = paint;
notifyListeners(new AxisChangeEvent(this));
}
Sets the paint used to draw tick labels (if they are showing) and
sends an AxisChangeEvent to all registered listeners. |
public void setTickLabelsVisible(boolean flag) {
if (flag != this.tickLabelsVisible) {
this.tickLabelsVisible = flag;
notifyListeners(new AxisChangeEvent(this));
}
}
Sets the flag that determines whether or not the tick labels are
visible and sends an AxisChangeEvent to all registered
listeners. |
public void setTickMarkInsideLength(float length) {
this.tickMarkInsideLength = length;
notifyListeners(new AxisChangeEvent(this));
}
Sets the inside length of the tick marks and sends
an AxisChangeEvent to all registered listeners. |
public void setTickMarkOutsideLength(float length) {
this.tickMarkOutsideLength = length;
notifyListeners(new AxisChangeEvent(this));
}
Sets the outside length of the tick marks and sends
an AxisChangeEvent to all registered listeners. |
public void setTickMarkPaint(Paint paint) {
if (paint == null) {
throw new IllegalArgumentException("Null 'paint' argument.");
}
this.tickMarkPaint = paint;
notifyListeners(new AxisChangeEvent(this));
}
Sets the paint used to draw tick marks and sends an
AxisChangeEvent to all registered listeners. |
public void setTickMarkStroke(Stroke stroke) {
if (stroke == null) {
throw new IllegalArgumentException("Null 'stroke' argument.");
}
if (!this.tickMarkStroke.equals(stroke)) {
this.tickMarkStroke = stroke;
notifyListeners(new AxisChangeEvent(this));
}
}
Sets the stroke used to draw tick marks and sends
an AxisChangeEvent to all registered listeners. |
public void setTickMarksVisible(boolean flag) {
if (flag != this.tickMarksVisible) {
this.tickMarksVisible = flag;
notifyListeners(new AxisChangeEvent(this));
}
}
Sets the flag that indicates whether or not the tick marks are showing
and sends an AxisChangeEvent to all registered listeners. |
public void setVisible(boolean flag) {
if (flag != this.visible) {
this.visible = flag;
notifyListeners(new AxisChangeEvent(this));
}
}
Sets a flag that controls whether or not the axis is visible and sends
an AxisChangeEvent to all registered listeners. |