All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.monitorenter.gui.chart.IAxis Maven / Gradle / Ivy

Go to download

JChart2D is an easy to use component for displaying two- dimensional traces in a coordinate system written in Java.

The newest version!
/*
 *  IAxis.java of project jchart2d, interface for an axis of the 
 *  Chart2D.
 *  Copyright (C) 2004 - 2011 Achim Westermann.
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA*
 *  If you modify or optimize the code in a useful way please let me know.
 *  [email protected]
 *
 */
package info.monitorenter.gui.chart;

import info.monitorenter.gui.chart.axis.AAxis;
import info.monitorenter.gui.chart.axistitlepainters.AxisTitlePainterDefault;
import info.monitorenter.util.Range;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Set;

/**
 * Interface for an axis of the {@link info.monitorenter.gui.chart.Chart2D}.
 * 

* * @param * Subtypes may be more picky which scale policies the accept to * disallow incorrect scales: This supports it (see * {@link IAxis#setAxisScalePolicy(IAxisScalePolicy)}). * * @author Achim Westermann * @version $Revision: 1.39 $ */ public interface IAxis extends Serializable { /** * Represents a title of an axis. *

* * @author Achim Westermann * @version $Revision: 1.39 $ * @since 3.0.0 */ public final class AxisTitle implements Cloneable, Serializable { /** * Constant for a {@link java.beans.PropertyChangeEvent} of the * title font. */ public static final String PROPERTY_TITLE = "IAxis.AxisTitle.PROPERTY_TITLE"; /** * Constant for a {@link java.beans.PropertyChangeEvent} of the * title font. */ public static final String PROPERTY_TITLECOLOR = "IAxis.AxisTitle.PROPERTY_TITLECOLOR"; /** * Constant for a {@link java.beans.PropertyChangeEvent} of the * title font. */ public static final String PROPERTY_TITLEFONT = "IAxis.AxisTitle.PROPERTY_TITLEFONT"; /** * Constant for a {@link java.beans.PropertyChangeEvent} of the * title font. */ public static final String PROPERTY_TITLEPAINTER = "IAxis.AxisTitle.PROPERTY_TITLEPAINTER"; /** Generated serialVersionUID. */ private static final long serialVersionUID = -7734801964168791096L; /** Internal support for property change management. */ private PropertyChangeSupport m_propertyChangeSupport = new PropertyChangeSupport(this); /** The title. */ private String m_title; /** The title color to use, defaults to {@link Color#BLACK}. */ private Color m_titleColor = Color.BLACK; /** The optional title font to use - null by default. */ private Font m_titleFont; /** The painter of this axis title. */ private IAxisTitlePainter m_titlePainter; /** * Creates an instance with the given title backed by a * {@link AxisTitlePainterDefault}. *

* * @param title * the title to use. */ public AxisTitle(final String title) { this(title, new AxisTitlePainterDefault()); } /** * Creates an instance with the given title backed by the given painter. *

* * @param title * the title to use. * @param painter * the painter to use. */ public AxisTitle(final String title, final IAxisTitlePainter painter) { this.m_title = title; this.m_titlePainter = painter; } /** * Add a listener for the given property. *

* The following {@link java.beans.PropertyChangeEvent} types * should be fired to listeners:
*

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
getPropertyName()getSource()getOldValue()getNewValue()
{@link IAxis.AxisTitle#PROPERTY_TITLE}{@link IAxis.AxisTitle} that changed{@link String}, the old value.{@link String}, the new value.
{@link IAxis.AxisTitle#PROPERTY_TITLEFONT}{@link IAxis.AxisTitle} that changed{@link Font}, the old value.{@link Font}, the new value.
{@link IAxis.AxisTitle#PROPERTY_TITLEPAINTER}{@link IAxis.AxisTitle} that changed{@link IAxisTitlePainter}, the old value.{@link IAxisTitlePainter}, the new value.
{@link IAxis.AxisTitle#PROPERTY_TITLECOLOR}{@link IAxis.AxisTitle} that changed{@link Color}, the old value.{@link Color}, the new value.
*

* * * * @param propertyName * the property to be informed about changes. * @param listener * the listener that will be informed. */ public void addPropertyChangeListener(final String propertyName, final PropertyChangeListener listener) { this.m_propertyChangeSupport.addPropertyChangeListener(propertyName, listener); } /** * @see java.lang.Object#clone() */ @Override protected Object clone() throws CloneNotSupportedException { Object result = super.clone(); return result; } /** * Returns the height of this axis title in px with respect to the current * title of the given axis. *

* * @param axis * the instance this title painter is working for. * @param g2d * needed for size informations (e.g. font widths). * @return the height of this axis title in px with respect to the current * title of the given axis. */ public int getHeight(final IAxis axis, final Graphics2D g2d) { return this.m_titlePainter.getHeight(axis, g2d); } /** * Returns an array of all the listeners that were added to the this * instance with * {@link #addPropertyChangeListener(String, PropertyChangeListener)}. *

* * @return an array of all the listeners that were added to the this * instance with * {@link #addPropertyChangeListener(String, PropertyChangeListener)} * . * @param propertyName * The name of the property being listened to. * @see java.beans.PropertyChangeSupport#getPropertyChangeListeners(java.lang.String) */ public PropertyChangeListener[] getPropertyChangeListeners(final String propertyName) { return this.m_propertyChangeSupport.getPropertyChangeListeners(propertyName); } /** * Returns the title or null if there was no title configured * before. *

* * @return the title or null if there was no title configured * before. */ public final String getTitle() { return this.m_title; } /** * Returns the color used for painting the title. *

* Default is {@link Color#BLACK}. *

* * @return the color used for painting the title. */ public Color getTitleColor() { return this.m_titleColor; } /** * Returns the optional font used for painting the title or null if not * configured. *

* * @return the font used for painting the title or null if not configured. */ public Font getTitleFont() { return this.m_titleFont; } /** * Returns the titlePainter. *

* * @return the titlePainter */ public final IAxisTitlePainter getTitlePainter() { return this.m_titlePainter; } /** * Returns the width of this axis title in px with respect to the current * title of the given axis. *

* * @param axis * the instance this title painter is working for. * @param g2d * needed for size informations (e.g. font widths). * @return the width of this axis title in px with respect to the current * title of the given axis. */ public int getWidth(final IAxis axis, final Graphics2D g2d) { return this.m_titlePainter.getWidth(axis, g2d); } /** * Remove a PropertyChangeListener for a specific property. If * listener was added more than once to the same event source * for the specified property, it will be notified one less time after being * removed. If propertyName is null, no exception is thrown and * no action is taken. If listener is null, or was never added * for the specified property, no exception is thrown and no action is * taken. * * @param property * The name of the property that was listened on. * @param listener * The PropertyChangeListener to be removed. * @see java.beans.PropertyChangeSupport#removePropertyChangeListener(java.lang.String, * java.beans.PropertyChangeListener) */ public void removePropertyChangeListener(final String property, final PropertyChangeListener listener) { this.m_propertyChangeSupport.removePropertyChangeListener(property, listener); } /** * Sets the title or null if there should be no title. *

* * @param title * the title or null if no title should be used. * @return the previous title or null if there was none before. */ public final String setTitle(final String title) { String old = this.m_title; this.m_title = title; this.m_propertyChangeSupport.firePropertyChange(AxisTitle.PROPERTY_TITLE, old, this.m_title); return old; } /** * Sets the title color to use. *

* Default is {@link Color#BLACK}. *

* * @param color * the color to use for the title. */ public void setTitleColor(final Color color) { Color old = this.m_titleColor; this.m_titleColor = color; this.m_propertyChangeSupport.firePropertyChange(AxisTitle.PROPERTY_TITLECOLOR, old, this.m_titleColor); } /** * Sets the optional title font to use. *

* * @param font * the font to use for the title. */ public void setTitleFont(final Font font) { Font old = this.m_titleFont; this.m_titleFont = font; this.m_propertyChangeSupport.firePropertyChange(AxisTitle.PROPERTY_TITLEFONT, old, this.m_titleFont); } /** * Sets the titlePainter. *

* * @param titlePainter * the titlePainter to set. * @return the previous title painter or null if there was none before. */ public final IAxisTitlePainter setTitlePainter(final IAxisTitlePainter titlePainter) { IAxisTitlePainter old = this.m_titlePainter; this.m_titlePainter = titlePainter; this.m_propertyChangeSupport.firePropertyChange(AxisTitle.PROPERTY_TITLEPAINTER, old, this.m_titlePainter); return old; } } /** * The bean property constant identifying a change of the * internal set of {@link ITrace2D} instances. *

* Use this constant to register a {@link java.beans.PropertyChangeListener} * with the IAxis. *

* See {@link #addPropertyChangeListener(String, PropertyChangeListener)} for property change events fired. */ public static final String PROPERTY_ADD_REMOVE_TRACE = "IAxis.PROPERTY_ADD_REMOVE_TRACE"; /** * The bean property constant identifying a change of the * axis scale policy. *

* Use this constant to register a {@link java.beans.PropertyChangeListener} * with the IAxis. *

* See {@link #addPropertyChangeListener(String, PropertyChangeListener)} for property change events fired. */ public static final String PROPERTY_AXIS_SCALE_POLICY_CHANGED = "IAxis.PROPERTY_AXIS_SCALE_POLICY_CHANGED"; /** * Constant for a {@link java.beans.PropertyChangeEvent} of the * {@link IAxisTitlePainter}. */ public static final String PROPERTY_LABELFORMATTER = "IAxis.PROPERTY_LABELFORMATTER"; /** * Constant for a {@link java.beans.PropertyChangeEvent} of the * paint grid flag. */ public static final String PROPERTY_PAINTGRID = "IAxis.PROPERTY_PAINTGRID"; /** * Constant for a {@link java.beans.PropertyChangeEvent} of the * paint scale flag. */ public static final String PROPERTY_PAINTSCALE = "IAxis.PROPERTY_PAINTSCALE"; /** * Constant for a {@link java.beans.PropertyChangeEvent} of the * range policy. */ public static final String PROPERTY_RANGEPOLICY = "IAxis.PROPERTY_RANGEPOLICY"; /** * Add a listener for the given property. *

* The following {@link java.beans.PropertyChangeEvent} types should be fired * to listeners:
*

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
getPropertyName()getSource()getOldValue()getNewValue()
* {@link info.monitorenter.gui.chart.IAxis#PROPERTY_ADD_REMOVE_TRACE} * {@link IAxis} that changednull - a new trace was added.{@link ITrace2D}, the new trace.
* {@link info.monitorenter.gui.chart.IAxis#PROPERTY_ADD_REMOVE_TRACE} * {@link IAxis} that changed{@link ITrace2D}, the old trace.null - the trace was removed.
* {@link info.monitorenter.gui.chart.IAxis#PROPERTY_RANGEPOLICY} * {@link IAxis} that changed{@link IRangePolicy}, the old value.{@link IRangePolicy}, the new value.
* {@link info.monitorenter.gui.chart.IAxis#PROPERTY_PAINTGRID}{@link IAxis} that changed{@link Boolean}, the old value.{@link Boolean}, the new value.
* {@link info.monitorenter.gui.chart.IAxis#PROPERTY_LABELFORMATTER} * {@link IAxis} that changed{@link IAxisLabelFormatter}, the old value or null if * there was no formatter before.{@link IAxisLabelFormatter}, the new value.
{@link IAxis#PROPERTY_AXIS_SCALE_POLICY_CHANGED}{@link IAxis} that changed{@link IAxisScalePolicy}, the old value.{@link IAxisScalePolicy}, the new value.
*

* * @param propertyName * the property to be informed about changes. * @param listener * the listener that will be informed. */ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener); /** * Adds a trace that belongs to this axis. *

* * Adding a trace that is already contained may be problematic, so an * exception should be raised in that case to warn you that your code is doing * unnecessary to malicious operations. *

* * @param trace * the trace to add. * @return true if the trace was added, false else. */ public boolean addTrace(ITrace2D trace); /** * Returns the accessor to the chart. *

* * @return the accessor to the chart. */ public abstract AAxis.AChart2DDataAccessor getAccessor(); /** * Returns the constant for the position of this axis for the chart. *

* * @return {@link Chart2D#CHART_POSITION_LEFT}, * {@link Chart2D#CHART_POSITION_RIGHT}, * {@link Chart2D#CHART_POSITION_TOP}, * {@link Chart2D#CHART_POSITION_BOTTOM} or -1 if this axis is not * assigned to a chart. */ public int getAxisPosition(); /** * Returns the title of this axis. *

* * @return the axis title used. */ public IAxis.AxisTitle getAxisTitle(); /** * Removes the title of this axis. *

* * Prefer this method instead of {@link #getAxisTitle()} if you * want to drop the axis title as this method also "unlistens" this axis from * it's title. *

* * @return the removed title. */ public IAxis.AxisTitle removeAxisTitle(); /** * Returns the constant for the dimension this axis stands for in the chart. *

* * @return {@link Chart2D#X}, {@link Chart2D#Y} or -1 if this axis is not * assigned to a chart. */ public int getDimension(); /** * Returns the String constant for the dimension this axis stands for in the chart. *

* * @return "X", "Y" or null if not assigned to a {@link Chart2D}. **/ public String getDimensionString(); /** * Returns the formatter for labels. *

* * @return the formatter for labels. */ public abstract IAxisLabelFormatter getFormatter(); /** * Returns the height in pixel this axis needs to paint itself. *

* This includes the axis line, it's ticks and labels and it's title. *

* Note:
For an y axis the hight only includes the overhang it * needs on the upper edge for painting a complete lable, not the complete * space it needs for the complete line. *

* * @param g2d * needed for font metric information. * @return the height in pixel this axis needs to paint itself. */ public int getHeight(Graphics g2d); /** * Get the major tick spacing for label generation. *

* * @return the major tick spacing for label generation. * @see #setMajorTickSpacing(double) */ public abstract double getMajorTickSpacing(); /** * Returns the maximum value from all traces of this axis with respect to the * installed range policy. *

* * @return the maximum value from all traces of this axis with respect to the * installed range policy. */ public double getMax(); /** * Returns the maximum value of all * {@link info.monitorenter.gui.chart.TracePoint2D} instances in * all {@link ITrace2D} instances in this axis regardless of the * configured {@link IRangePolicy} (see * {@link IAxis#setRangePolicy(IRangePolicy)}). The returned * value is either in x or y dimension - depending on the dimension this axis * is working in for the chart. *

* * @return the maximum value of all * {@link info.monitorenter.gui.chart.TracePoint2D} instances * in all {@link ITrace2D} instances in this axis * regardless of the configured {@link IRangePolicy} (see * {@link IAxis#setRangePolicy(IRangePolicy)}). */ public double getMaxValue(); /** * Returns the minimum value of all traces of this axis with respect to the * installed range policy. *

* * @return the minimum value of all traces of this axis with respect to the * installed range policy. */ public double getMin(); /** * Get the minor tick spacing for label generation. *

* * @return the minor tick spacing for label generation. * @see #setMinorTickSpacing(double) */ public abstract double getMinorTickSpacing(); /** * Returns the minimum value of all * {@link info.monitorenter.gui.chart.TracePoint2D} instances in * all {@link ITrace2D} instances in this axis regardless of the * configured {@link IRangePolicy} (see * {@link IAxis#setRangePolicy(IRangePolicy)}). The returned * value is either in x or y dimension - depending on the dimension this axis * is working in for the chart. *

* * @return the minimum value of all * {@link info.monitorenter.gui.chart.TracePoint2D} instances * in all {@link ITrace2D} instances in this axis * regardless of the configured {@link IRangePolicy} (see * {@link IAxis#setRangePolicy(IRangePolicy)}). */ public double getMinValue(); /** * Returns the left pixel of this axis coordinate in the graphic context of * the current paint operation. *

* Note that this value is only valid throughout a * {@link Chart2D#paint(java.awt.Graphics)} invocation. * * @return the left pixel coordinate of this axis in the graphic context of * the current paint operation. */ public int getPixelXLeft(); /** * Returns the right pixel coordinate of this axis in the graphic context of * the current paint operation. *

* Note that this value is only valid throughout a * {@link Chart2D#paint(java.awt.Graphics)} invocation. * * @return the right pixel coordinate of this axis in the graphic context of * the current paint operation. */ public int getPixelXRight(); /** * Returns the bottom pixel coordinate of this axis in the graphic context of * the current paint operation. *

* Note that this value is only valid throughout a * {@link Chart2D#paint(java.awt.Graphics)} invocation. * * @return the bottom pixel coordinate of this axis in the graphic context of * the current paint operation. */ public int getPixelYBottom(); /** * Returns the top pixel coordinate of this axis in the graphic context of the * current paint operation. *

* Note that this value is only valid throughout a * {@link Chart2D#paint(java.awt.Graphics)} invocation. * * @return the top pixel coordinate of this axis in the graphic context of the * current paint operation. */ public int getPixelYTop(); /** * Returns an array of all the listeners that were added to the this instance * with {@link #addPropertyChangeListener(String, PropertyChangeListener)}. *

* * @return an array of all the listeners that were added to the this instance * with * {@link #addPropertyChangeListener(String, PropertyChangeListener)}. * @param propertyName * The name of the property being listened to. * @see java.beans.PropertyChangeSupport#getPropertyChangeListeners(java.lang.String) */ public PropertyChangeListener[] getPropertyChangeListeners(String propertyName); /** * Returns the range lasting from {@link IAxis#getMin()} to * {@link IAxis#getMax()}. *

* This method is used by the Chart2D to scale it's values during painting. *

* Caution: This method does not necessarily return the Range configured with * {@link #setRange(Range)}. The internal {@link IRangePolicy} is taken into * account. *

* * @return the range corresponding to the upper and lower bound of the values * that will be displayable on this Axis of the Chart2D. * @see #setRangePolicy(IRangePolicy) */ public abstract Range getRange(); /** * Returns the range policy of this axis. *

* * @return the range policy of this axis. */ public IRangePolicy getRangePolicy(); /** * Scales the given absolute value into a value between 0 and 1.0 (if it is in * the range of the data). *

* If the given absolute value is not in the display- range of the * Chart2D, negative values or values greater than 1.0 may * result. *

* * @param absolute * a value in the real value range of the corresponding chart. * @return a value between 0.0 and 1.0 that is mapped to a position within the * chart. */ public abstract double getScaledValue(final double absolute); /** * Returns the axis scale policy which controls the position and distance of the ticks to draw. *

* * @return the axis scale policy which controls the position and distance of the ticks to draw. */ public IAxisScalePolicy getAxisScalePolicy(); /** * Sets the axis scale policy which controls the position and distance of the * ticks to draw. *

* * @param axisScalePolicy * the axis scale policy which controls the position and distance of * the ticks to draw to use. * * @return the previous axis scale policy that was used before. */ public IAxisScalePolicy setAxisScalePolicy(T axisScalePolicy); /** * Returns the title or null if there was no title configured * before. *

* * @return the title or null if there was no title configured * before. * @see #getTitlePainter() * @deprecated use {@link #getAxisTitle()} and on the result * {@link IAxis.AxisTitle#getTitle()}. */ @Deprecated public String getTitle(); /** * Returns the instance that will paint the title of this axis. *

* * @deprecated this method might be dropped because the painter should be of * no concern. * @return the instance that will paint the title of this axis. */ @Deprecated public IAxisTitlePainter getTitlePainter(); /** * Returns a {@link Set}<{@link ITrace2D}> with all traces covered by * this axis. *

* Caution!
* The original internal modifiable set is returned for performance reasons * and by contract (to allow removing traces) so do not mess with it to avoid * ugly unpredictable side effects! *

* * @return a {@link Set}<{@link ITrace2D}> with all traces * covered by this axis. */ public Set getTraces(); /** * Returns the width in pixel this axis needs to paint itself. *

* This includes the axis line, it's ticks and labels and it's title. *

* Note:
For an x axis the width only includes the overhang it * needs on the right edge for painting a complete label, not the complete * space it needs for the complete line. *

* * @param g2d * needed for font metric information. * @return the width in pixel this axis needs to paint itself. */ public int getWidth(Graphics g2d); /** * Returns true if this axis is responsible for rendering the scale of the * given trace ({@link IAxis#addTrace(ITrace2D)} was called on * this instance with the given trace). *

* * @param trace * the trace to check for containment. * @return true if this axis is responsible for rendering the scale of the * given trace ({@link IAxis#addTrace(ITrace2D)} was * called on this instance with the given trace). */ public boolean hasTrace(ITrace2D trace); /** * Allows to perform expensive calculations for various values that are used * by many calls throughout a paint iterations. *

* These values are constant throughout a paint iteration by the contract that * no point is added removed or changed in this period. Because these values * are used from many methods it is impossible to calculate them at a * "transparent" method that may perform this caching over a paint period * without knowledge from outside. The first method called in a paint * iteration is called several further times in the iteration. So this is the * common hook to invoke before painting a chart. *

*/ public void initPaintIteration(); /** * Returns true if the bounds in the given dimension of all * {@link info.monitorenter.gui.chart.TracePoint2D} instances of all internal * {@link ITrace2D} instances have changed since all points have been * normalized to a value between 0 and 1 or true if this axis has different * range since the last call to {@link IAxis#scale()}. *

* * @return true if the bounds in the given dimension of all * {@link info.monitorenter.gui.chart.TracePoint2D} instances of all * internal {@link ITrace2D} instances have changed since all points * have been normalized to a value between 0 and 1 or true if this * axis has different range since the last call to * {@link IAxis#scale()}. */ public boolean isDirtyScaling(); /** * Returns wether the x grid is painted or not. *

* * @return wether the x grid is painted or not. */ public abstract boolean isPaintGrid(); /** * Returns whether the scale for this axis should be painted or not. *

* * @return whether the scale for this axis should be painted or not. */ public abstract boolean isPaintScale(); /** * Check wether scale values are started from major ticks. *

* * @return true if scale values start from major ticks. * @see info.monitorenter.gui.chart.axis.AAxis#setMajorTickSpacing(double) */ public abstract boolean isStartMajorTick(); /** * Check whether this axis is visible, i.e. needs to be painted on the chart * * @return the visibility state of this axis */ public boolean isVisible(); /** * Renders the axis line along with title, scale, scale labels and unit label. *

* This should only be called from {@link Chart2D}, all other * uses may cause damaged UI or deadlocks. *

* * @param g2d * the graphics context to use. */ public void paint(final Graphics g2d); /** * Routine for painting the title of this axis. *

* Intended for {@link Chart2D} only!!! * * @param g2d * needed for painting. * @return the width consumed in pixel for y axis, the height consumed in * pixel for x axis. */ public int paintTitle(final Graphics g2d); /** * Convenience method for removing all contained {@link ITrace2D} * instances of this axis. *

* Implementations should fire a * {@link java.beans.PropertyChangeEvent} for the * {@link java.beans.PropertyChangeEvent#getPropertyName()} * {@link IAxis#PROPERTY_ADD_REMOVE_TRACE} for every single trace * removed. This is done best by delegating this call to several calls to * {@link #removeTrace(ITrace2D)}. *

* * @return a shallow copy of the set of traces that were contained before. */ public Set removeAllTraces(); /** * Remove a PropertyChangeListener for a specific property. If * listener was added more than once to the same event source for * the specified property, it will be notified one less time after being * removed. If propertyName is null, no exception is thrown and * no action is taken. If listener is null, or was never added * for the specified property, no exception is thrown and no action is taken. * * @param property * The name of the property that was listened on. * @param listener * The PropertyChangeListener to be removed. * @see java.beans.PropertyChangeSupport#removePropertyChangeListener(java.lang.String, * java.beans.PropertyChangeListener) */ public void removePropertyChangeListener(String property, PropertyChangeListener listener); /** * Removes the given trace from this axis. *

* A {@link java.beans.PropertyChangeEvent} for the * {@link java.beans.PropertyChangeEvent#getPropertyName()} * {@link IAxis#PROPERTY_ADD_REMOVE_TRACE} has to be fired on the * registered {@link PropertyChangeListener} for the trace * removed. *

* * @param trace * the trace to remove from this axis. * @return true if the given trace could be removed from this axis, false * else. */ public boolean removeTrace(ITrace2D trace); /** * Scales all {@link ITrace2D} instances in the dimension * represented by this axis. *

* This method is not deadlock - safe and should be called by the * {@link Chart2D} only! *

*/ public void scale(); /** * Scales the given {@link ITrace2D} in the dimension represented * by this axis. *

* This method is not deadlock - safe and should be called by the * {@link Chart2D} only! *

* * @param trace * the trace to scale. */ public void scaleTrace(final ITrace2D trace); /** * Sets the title of this axis. *

* * @param axisTitle * the axis title to use. */ public void setAxisTitle(final IAxis.AxisTitle axisTitle); /** * Sets the formatter to use for labels. *

* * @param formatter * The formatter to set. */ public abstract void setFormatter(final IAxisLabelFormatter formatter); /** * This method sets the major tick spacing for label generation. *

* Only values between 0.0 and 100.0 are allowed. *

* The number that is passed in represents the distance, measured in values, * between each major tick mark. If you have a trace with a range from 0 to 50 * and the major tick spacing is set to 10, you will get major ticks next to * the following values: 0, 10, 20, 30, 40, 50. *

* Note:
* Ticks are free of any multiples of 1000. If the chart contains values * between 0 an 1000 and configured a tick of 2 the values 0, 200, 400, 600, * 800 and 1000 will highly probable to be displayed. This depends on the size * (in pixels) of the Chart2D<. Of course there is a difference: * ticks are used in divisions and multiplications: If the internal values are * very low and the ticks are very high, huge rounding errors might occur * (division by ticks results in very low values a double cannot hit exactly. * So prefer setting ticks between 0 an 10 or - if you know your values are * very small (e.g. in nano range [10 -9 ]) use a small value (e.g. * 2*10 -9 ). *

* * @param majorTickSpacing * the major tick spacing for label generation. */ public abstract void setMajorTickSpacing(final double majorTickSpacing); /** * This method sets the minor tick spacing for label generation. *

* The number that is passed-in represents the distance, measured in values, * between each minor tick mark. If you have a trace with a range from 0 to 10 * and the minor tick spacing is set to 2, you will get major ticks next to * the following values: 0, 2, 4, 6, 8, 10. If a major tick hits the same * values the tick will be a major ticks. For this example: if a major tick * spacing is set to 5 you will only get minor ticks for: 2, 4, 6, 8. *

* Note:
* Ticks are free of any powers of 10. There is no difference between setting * a tick to 2, 200 or 20000 because ticks cannot break the rule that every * scale label has to be visible. If the chart contains values between 0 an * 1000 and configured a tick of 2 the values 0, 200, 400, 600, 800 and 1000 * will highly probable to be displayed. This depends on the size (in pixels) * of the Chart2D<. Of course there is a difference: ticks are * used in divisions and multiplications: If the internal values are very low * and the ticks are very high, huge rounding errors might occur (division by * ticks results in very low values a double cannot hit exactly. So prefer * setting ticks between 0 an 10 or - if you know your values are very small * (e.g. in nano range [10 -9 ]) use a small value (e.g. 2*10 * -9 ). *

* * @param minorTickSpacing * the minor tick spacing to set. */ public abstract void setMinorTickSpacing(final double minorTickSpacing); /** * Set wether the grid in this dimension should be painted or not. *

* A repaint operation for the chart is triggered. *

* * @param grid * true if the grid should be painted or false if not. */ public abstract void setPaintGrid(boolean grid); /** * Set if the scale for this axis should be shown. *

* * @param show * true if the scale on this axis should be shown, false else. */ public abstract void setPaintScale(final boolean show); /** * Sets a Range to use for filtering the view to the the connected Axis. Note * that it's effect will be affected by the internal {@link IRangePolicy}. *

* This must only be called from the {@link Chart2D} itself! *

* * @param pixel * the left pixel coordinate of this axis in the graphic context of * the current paint operation. */ public void setPixelXLeft(int pixel); /** * Sets the right pixel of this axis coordinate in the graphic context of the * current paint operation. *

* This must only be called from the {@link Chart2D} itself! *

* * @param pixel * the right pixel coordinate of this axis in the graphic context of * the current paint operation. */ public void setPixelXRight(int pixel); /** * Sets the bottom pixel of this axis coordinate in the graphic context of the * current paint operation. *

* This must only be called from the {@link Chart2D} itself! *

* * @param pixel * the bottom pixel coordinate of this axis in the graphic context of * the current paint operation. */ public void setPixelYBottom(int pixel); /** * Sets the top pixel of this axis coordinate in the graphic context of the * current paint operation. *

* This must only be called from the {@link Chart2D} itself! *

* * @param pixel * the top pixel coordinate of this axis in the graphic context of * the current paint operation. */ public void setPixelYTop(int pixel); /** * Sets a Range to use for filtering the view to the the connected Axis. Note * that it's effect will be affected by the internal {@link IRangePolicy}. *

* To get full control use:
* setRangePolicy(new <AnARangePolicy>(range); *

* * @param range * Range to use for filtering the view to the the connected Axis. * @see #getRangePolicy() * @see IRangePolicy#setRange(Range) */ public abstract void setRange(final Range range); /** * Sets the RangePolicy. *

* If the given RangePolicy has an unconfigured internal Range ( * {@link Range#RANGE_UNBOUNDED}) the old internal RangePolicy is taken into * account:
* If the old RangePolicy has a configured Range this is transferred to the * new RangePolicy. *

* * @param rangePolicy * The rangePolicy to set. */ public abstract void setRangePolicy(final IRangePolicy rangePolicy); /** * Set wether scale values are started from major ticks. *

* * @param majorTick * true if scale values shall start with a major tick. * @see info.monitorenter.gui.chart.axis.AAxis#setMajorTickSpacing(double) */ public abstract void setStartMajorTick(final boolean majorTick); /** * Sets the title of this axis will be painted by the * {IAxisTitlePainter} of this instance. *

* * @param title * the title to set. * @return the previous Title or null if there was no title * configured before. * @see #setTitlePainter(IAxisTitlePainter) * @deprecated use {@link #getAxisTitle()} and on the result * {@link AxisTitle#setTitle(String)} */ @Deprecated public String setTitle(String title); /** * Sets the title painter that will paint the title of this axis. *

* * @param painter * the instance that will paint the title of this axis. * @return the previous title painter of this axis or null if there was none * configured before. * @deprecated use {@link #getAxisTitle()} and on the result * {@link IAxis.AxisTitle#setTitlePainter(IAxisTitlePainter)}. */ @Deprecated public IAxisTitlePainter setTitlePainter(final IAxisTitlePainter painter); /** * Show/hide this axis. *

* * @param visible * true to paint axis, false to hide. */ public void setVisible(boolean visible); /** * Transforms the given pixel value (which has to be a awt value like * {@link java.awt.event.MouseEvent#getY()} into the chart value. *

* Internal use only, the interface does not guarantee that the pixel * corresponds to any valid awt pixel value within the chart component. *

* * @param pixel * a pixel value of the chart component as used by awt. * @return the awt pixel value transformed to the chart value. */ public double translatePxToValue(final int pixel); /** * Transforms the given chart data value into the corresponding awt pixel * value for the chart. *

* * @param value * a chart data value. * @return the awt pixel value corresponding to the chart data value. */ public int translateValueToPx(final double value); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy