JIDE 3.5.15

com.jidesoft.chart
Class Chart

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.jidesoft.chart.Chart
All Implemented Interfaces:
Animatable, AnimatedChart, ChartModelChangeListener, ChartModelListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener

public class Chart
extends JComponent
implements ChartModelChangeListener, PropertyChangeListener, Animatable, AnimatedChart

The main charting component. By default, used for XY charts, categorical charts, time series charts and bar charts. Also used for pie charts by changing the chartType property.

Author:
swhite@catalysoft.com
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String PROPERTY_ALLOW_TICK_LABEL_OVERLAP
           
static String PROPERTY_ANIMATE_ON_SHOW
           
static String PROPERTY_ANIMATION_POSITION
           
static String PROPERTY_ANTI_ALIASING
           
static String PROPERTY_AUTO_RANGING
           
static String PROPERTY_AXIS_COLOR
           
static String PROPERTY_BAR_GAP
           
static String PROPERTY_BAR_GROUP_GAP
           
static String PROPERTY_BAR_RENDERER
           
static String PROPERTY_BARS_GROUPED
           
static String PROPERTY_CHART_BACKGROUND
           
static String PROPERTY_CHART_BORDER
           
static String PROPERTY_CHART_STYLE
           
static String PROPERTY_CHART_TYPE
           
static String PROPERTY_CURRENT_CHART_POINT
           
static String PROPERTY_GRID_COLOR
           
static String PROPERTY_HIGH_QUALITY
           
static String PROPERTY_HIGHLIGHT_STYLE
           
static String PROPERTY_HORIZONTAL_GRID_LINES_VISIBLE
           
static String PROPERTY_HORIZONTAL_GRID_STROKE
           
static String PROPERTY_HORIZONTAL_MINOR_GRID_LINES_VISIBLE
           
static String PROPERTY_HORIZONTAL_MINOR_GRID_STROKE
           
static String PROPERTY_LABEL_COLOR
           
static String PROPERTY_LABELLING_TRACES
           
static String PROPERTY_LAZY_RENDERING_THRESHOLD
           
static String PROPERTY_LINE_RENDERER
           
static String PROPERTY_MAX_BAR_WIDTH
           
static String PROPERTY_MINOR_GRID_COLOR
           
static String PROPERTY_MINOR_TICK_LENGTH
           
static String PROPERTY_MODEL
           
static String PROPERTY_PANEL_BACKGROUND
           
static String PROPERTY_PIE_DIAMETER
           
static String PROPERTY_PIE_SEGMENT_RENDERER
           
static String PROPERTY_POINT_RENDERER
           
static String PROPERTY_ROLLOVER_VISIBLE
           
static String PROPERTY_SELECTABLE
           
static String PROPERTY_SELECTION_SHOWS_EXPLODED_SEGMENTS
           
static String PROPERTY_SELECTION_SHOWS_OUTLINE
           
static String PROPERTY_SHADOW_RENDERER
           
static String PROPERTY_SHADOW_VISIBILITY
           
static String PROPERTY_SHADOW_VISIBLE
           
static String PROPERTY_TICK_COLOR
           
static String PROPERTY_TICK_FONT
           
static String PROPERTY_TICK_LENGTH
           
static String PROPERTY_TICK_STROKE
           
static String PROPERTY_TITLE
           
static String PROPERTY_TITLE_VISIBLE
           
static String PROPERTY_VERTICAL_GRID_LINES_VISIBLE
           
static String PROPERTY_VERTICAL_GRID_STROKE
           
static String PROPERTY_VERTICAL_GRIDLINES_VISIBLE
          Deprecated. Please use corrected spelling PROPERTY_VERTICAL_GRID_LINES_VISIBLE
static String PROPERTY_VERTICAL_MINOR_GRID_LINES_VISIBLE
           
static String PROPERTY_VERTICAL_MINOR_GRID_STROKE
           
static String PROPERTY_VERTICAL_MINOR_GRIDLINES_VISIBLE
          Deprecated. Please use corrected spelling PROPERTY_VERTICAL_MINOR_GRID_LINES_VISIBLE
static String PROPERTY_X_AXIS
           
static String PROPERTY_Y_AXIS
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Chart()
          Zero-argument Constructor
Chart(ChartModel model)
          Create a chart from the supplied model
Chart(Dimension size)
          Creates a Chart, and sets its size (and preferred size) to be the supplied dimensions.
Chart(String name)
          The idea of this constructor is to encourage the naming of chart components.
 
Method Summary
 void addDoubleClickListener(ActionListener listener)
           
 Chart addDrawable(Drawable d)
          Adds an object that implements the drawable callback method.
 Chart addModel(ChartModel newModel)
          Adds the supplied ChartModel to the Chart so that it is drawn in the chart area.
 Chart addModel(ChartModel model, Axis axis)
          Adds the supplied ChartModel to the Chart, also assigning the model to the supplied axis.
 Chart addModel(ChartModel model, Axis axis, ChartStyle style)
          Adds the supplied ChartModel to the Chart, also assigning the model to the supplied axis.
 Chart addModel(ChartModel model, boolean makeDirty)
          Adds the supplied ChartModel to the Chart, but does not force a repaint.
 Chart addModel(ChartModel model, ChartStyle style)
          Adds the supplied ChartModel to the Chart, also assigning the supplied style to the chart.
 Chart addMousePanner()
          Makes it possible for the user to 'pan' the chart easily by clicking and dragging the mouse.
 Chart addMousePanner(boolean horizontalPan, boolean verticalPan)
          Make it possible for the user to pan the chart easily, but specifying whether panning is allowed in the horizontal and/or vertical axes.
 Chart addMouseZoomer()
          A convenience method for easily adding a mouse wheel zoom facility to a chart
 Chart addMouseZoomer(boolean horizontalZoom, boolean verticalZoom)
          Adds a MouseWheelZoomer to this chart instance, and specifies whether zooming should be enabled in the horizontal and vertical directions.
 Chart addYAxis(Axis newAxis)
          Adds a y axis
 void autoRange()
          Causes the ranges of the chart to be adjusted according to the data.
 int axisWidth(Graphics g, Axis axis)
          Returns the width of the supplied axis due to the rendering of ticks and tick labels (but not the main axis label)
 Point calculatePixelPoint(Point2D userPoint)
          Calculate the pixel coordinates of a point using the default y axis.
 Point calculatePixelPoint(Point2D userPoint, Axis axis)
          Calculate the pixel coordinates of a point using the supplied y axis
 Point calculatePixelPoint(Point2D userPoint, UserToPixelTransform transform)
          Calculates the pixel point using the supplied transform.
 Point2D calculatePixelPoint2D(Point2D userPoint)
          Calculate the pixel coordinates of a point using the default y axis.
 Point2D calculatePixelPoint2D(Point2D userPoint, Axis axis)
          Calculate the pixel coordinates of a point using the supplied y axis
 Point2D calculatePixelPoint2D(Point2D userPoint, UserToPixelTransform transform)
           
 Point2D calculateUserPoint(Point p)
          Calculates the point in the user's coordinate system for the pixel coordinate given by p.
 void chartModelChanged()
          This is the method of the ChartModelListener interface; it is called whenever the chart model has changed and all points need to be updated.
 void chartModelChanged(ChartModelChangeEvent changeEvent)
          This method is called to inform the ChartModelChangeListener of an event that changed the ChartModel to which the listener is attached.
 Chart clearHighlights()
          Removes all known highlights and their associated styles from this class
 PointDescriptor containingBar(Point p)
          You can use this method to test whether the supplied pixel point is contained by the rendering of a bar.
 PointDescriptor containingPoint(Point p)
          Determines whether the supplied pixel point is contained by the rendering of a (model) point in a chart.
 Collection<PointDescriptor> containingPoints(Point p)
          Returns a collection of descriptors for all (model) points rendered at the supplied pixel point
 PointDescriptor containingSegment(Point p)
          Determines whether the supplied pixel point is contained by the rendering of a segment in a pie chart.
 PointDescriptor containingShape(Point p)
          Determines whether there is a shape rendered that contains the supplied pixel point.
 Collection<PointDescriptor> containingShapes(Point p)
          Returns point descriptors for all the Chartables rendered at the specified point
 boolean containsDrawable(Drawable drawable)
          Determines whether this chart object already contains the supplied Drawable.
 boolean containsModel(ChartModel model)
          Returns a boolean to indicate whether the supplied model is known to this Chart instance
 double convertPrimaryToY(double primaryY, Axis yAxis)
          Converts a point scaled against the primary yAxis to its equivalent point on the supplied y Axis Note that this will not work with a logarithmic range
 double convertYToPrimary(double userY, Axis yAxis)
          Converts a point scaled against the supplied yAxis to its equivalent point on the primary y axis.
 JToolTip createToolTip()
          This fixes a painting problem with the shadow rendering code when a tool tip disappears.
static double distance(Point2D point, Chartable chartable)
           
static double distanceSq(Point2D point, Chartable chartable)
           
 void drawInBackground()
          You should not need to call this method often.
protected  boolean drawRotatedStringIfWithinBounds(Graphics g, String s, int x, int y, double rotation)
           
protected  boolean drawStringIfWithinBounds(Graphics g, String s, int x, int y)
          Paints a string but only if the whole of the string will be visible according to the bounds of the component
 void drawXAxisTickLabel(Graphics g, Axis axis, String s, int x, int y)
          Draws a tick label onto the Graphics context.
protected  void drawYAxisTickLabel(Graphics g, Axis yAxis, String s, int x, int y)
           
 double getAnimationPosition()
          Get the current animation position, 0.0 is the start and 1.0 is the end
 AutoRanger getAutoRanger()
          Returns the autoRanger used for setting the ranges of the axes
 Color getAxisColor()
          Returns the color of the axes
 Axis getAxisForModel(ChartModel model)
           
 int getAxisLabelPadding()
          Returns the padding around the axis labels.
 int getBarGap()
           
 int getBarGroupGap()
           
 BarRenderer getBarRenderer()
           
 BarRenderer getBarRenderer(ChartModel model)
          Returns the bar renderer associated with the given model.
 BarResizePolicy getBarResizePolicy()
           
 Paint getChartBackground()
          Returns the background used for the area displaying the chart
 Border getChartBorder()
          Returns the border used to surround the chart area
 int getChartHeight()
           
 ChartType getChartType()
           
 int getChartWidth()
           
 Chartable getCurrentChartPoint()
           
 Collection<Drawable> getDrawables()
          Returns a Collection of Drawable objects known by the Chart
 Color getGridColor()
          Returns the color used for the grid
 ChartStyle getHighlightStyle(Highlight h)
          Retrieves the ChartStyle associated with the supplied highlight
 Stroke getHorizontalGridStroke()
          Returns the Stroke used for the style of horizontal lines of the grid corresponding to major ticks
 Stroke getHorizontalMinorGridStroke()
          Returns the Stroke currently used for horizontal lines of the grid corresponding to minor ticks
 Color getLabelColor()
          Returns the color of the axis labels
 com.jidesoft.chart.LazyRenderer<ChartModel> getLazyChartRenderer()
           
 int getLazyRenderingThreshold()
          Returns the total size that data sets must be before switching to lazy rendering
 LineRenderer getLineRenderer()
           
 LineRenderer getLineRenderer(ChartModel model)
          Returns the line renderer associated with the given model.
 int getMaxBarWidth()
          Get the current maximum bar width.
 Color getMinorGridColor()
          Returns the color used for the minor grid lines
protected  Color getMinorTickColor(Axis axis)
          Finds the minor tick color to use for the supplied axis.
 int getMinorTickLength()
          Returns the length of minor ticks, in pixels
 ChartModel getModel()
           
 ChartModel getModel(int i)
           
 ChartModel getModel(String modelName)
          Returns the model with the specified name; null otherwise
 List<ChartModel> getModels()
           
 Paint getPanelBackground()
          Returns the background used for the area surrounding the main chart area
 Integer getPieDiameter()
          Returns the diameter of the pie chart in pixels, or null if no pixel diameter has been specified.
 PieSegmentRenderer getPieSegmentRenderer()
           
 PointRenderer getPointRenderer()
           
 PointRenderer getPointRenderer(ChartModel model)
          Returns the point renderer associated with the given model.
 ListSelectionModel getSelectionsForModel(ChartModel model)
           
 ShadowRenderer getShadowRenderer()
           
 ShadowVisibility getShadowVisibility()
           
 ChartStyle getStyle(ChartModel model)
          Returns the Chart Style associated with the supplied chart model, or null if there is no style associated with the model.
 Color getTickColor()
          Returns the current tick color
protected  Color getTickColor(Axis axis)
          Returns the tick color to use when painting (a major tick) on an axis.
 Font getTickFont()
          Returns the font used when painting tick labels.
protected  Font getTickFont(Axis axis)
          Returns the font to use for painting tick labels on the supplied axis.
 int getTickLength()
          Returns the length of major ticks, in pixels
 Stroke getTickStroke()
          Returns the stroke used when painting ticks
 AbstractAnnotation getTitle()
          Returns the current title of the chart
 UserToPixelTransform getTransformForAxis(Axis yAxis)
          Returns the Affine Transform associated with the given y axis
 UserToPixelTransform getTransformForModel(ChartModel model)
           
 UserToPixelTransform getUserToPixelTransform()
          Returns the transformation from user coordinates to pixel coordinates
 Stroke getVerticalGridStroke()
          Returns the Stroke currently used for vertical lines of the grid corresponding to major ticks
 Stroke getVerticalMinorGridStroke()
          Returns the Stroke currently used for vertical lines of the grid corresponding to minor ticks
 Axis getXAxis()
          Returns the chart's x axis
 int getXEnd()
           
 int getXStart()
           
 Axis getYAxis()
          Returns the primary y axis.
 Axis getYAxis(int n)
          Returns the nth y axis (indexed from zero)
 int getYAxisCount()
          Returns the number of y axes
 int getYEnd()
           
 int getYStart()
           
 double getYSum(ChartModel model)
           
 Integer getZOrder(ChartModel model)
           
protected  void init()
          Initialise the component by setting defaults and listeners
 int interpolateXForAnimation(int inputX, ChartModel model)
          Transforms an input x value to a value used during the animateOnShow phase
 int interpolateYForAnimation(int inputY, ChartModel model)
          Transforms an input y value to a value used during the animateOnShow phase
 boolean isAllowTickLabelOverlap()
          Returns a value to indicate whether tick label overlaps are currently allowed
 boolean isAnimateOnShow()
          Get if the animation should start when the chart is first drawn to screen.
 boolean isAntiAliasing()
          Returns whether anti-aliasing is currently being used when drawing the main chart
 boolean isAutoRanging()
          Returns whether we currently have auto-ranging switched on
 boolean isBarsGrouped()
           
 boolean isHighQuality()
           
 boolean isHorizontalGridLinesVisible()
          Returns whether the horizontal grid lines corresponding to major ticks on the y axis are visible
 boolean isHorizontalMinorGridLinesVisible()
          Returns whether the horizontal grid lines corresponding to minor ticks on the y axis are visible
 boolean isLabellingTraces()
           
 boolean isLazyRendering()
          Returns a boolean to indicate whether lazy rendering is currently being used
 boolean isPixelPointViewable(int x, int y)
           
 boolean isRecordingShapes()
          Return a boolean to indicate whether we are recording the shapes for points and bars
 boolean isRolloverEnabled()
           
 boolean isSelectionEnabled()
           
 boolean isSelectionShowsExplodedSegments()
           
 boolean isSelectionShowsOutline()
           
 boolean isShadowVisible()
          Returns a boolean to indicate whether shadows are being applied to elements of the chart
 boolean isShadowVisible(ChartModel model)
          Returns a boolean to indicate whether shadows have been applied to the specified model
 boolean isTitleVisible()
          Returns a boolean to indicate whether the chart should display a title
 boolean isUserPointViewable(Point2D userPoint, ChartModel model)
          We need to specify which model the point belongs to, so that we know which axis and therefore which point ranges to apply.
 boolean isVerticalGridLinesVisible()
          Returns whether the vertical lines corresponding to major ticks on the x axis are visible
 boolean isVerticalMinorGridLinesVisible()
          Returns whether the vertical grid lines corresponding to minor ticks on the x axis are visible
 int modelCount()
          The number of chart models currently loaded into the chart component
 ChartModel nearestModel(Point p)
          Note that the current implementation may take some time to execute for larger data sets.
 Pair<Chartable,Double> nearestPoint(Point2D realPoint, ChartModel model)
          Returns the nearest point in a model to the specified real point.
 PointSelection nearestPoint(Point hitPoint, ChartModel model)
          Returns the nearest point to a specified pixel point from a given ChartModel.
 Collection<ChartModel> nearLine(Point p, float radius)
          Determines whether there is a line segment close to p, within a supplied 'radius'.
protected  void paintAnnotations(Graphics2D g)
           
protected  void paintAxes(Graphics2D g)
          Paint all axes
protected  void paintComponent(Graphics g)
           
protected  void paintHorizontalGrid(Graphics g, Axis axis, UserToPixelTransform transform)
           
protected  void paintModels(Graphics2D g, Graphics2D shadowGraphics, Shape clipBounds, Shape chartAreaClip)
           
protected  void paintXAxis(Graphics2D g)
          Paints the X axis onto the Graphics context
protected  void paintXAxisGridLines(Graphics2D g, Tick[] ticks)
           
protected  void paintXAxisTicks(Graphics2D g, Tick[] ticks)
           
protected  void paintYAxis(Graphics2D g, Axis axis, int xPosition)
          Paint a single Y axis
protected  void paintYAxisLabels(Graphics2D g)
          Paint all y axis tick labels
 void paintYAxisTicks(Graphics g, Axis axis, Point midPoint, int xPixelCoord)
           
protected  void paintYAxisTicks(Graphics g, Axis axis, UserToPixelTransform transform, Point midPoint, int xPixelCoord)
           
 int pointCount()
           
 void propertyChange(PropertyChangeEvent pce)
          
 void removeDoubleClickListener(ActionListener listener)
           
 Chart removeDrawable(Drawable d)
          Removes a drawable from the chart (and all references to the Drawable from the chart object too).
 Chart removeDrawables()
          Removes all drawables from the chart
 Chart removeModel(ChartModel model)
          Removes the chart model from the chart.
 Chart removeModels()
          Stops any background drawing, and removes all the known ChartModels by repeated calls to removeModel()
 Chart removeMousePanner()
          Remove the panning ability for this chart.
 Chart removeMouseZoomer()
          Removes any MouseWheelZoomer that was created using one of the addMouseZoomer methods.
 PointDescriptor rendered(Chartable chartable)
           
 Shape renderedAs(Chartable chartable)
          Returns the shape that is being used to render the supplied chartable point, or null if not known.
 Chart replaceModel(ChartModel oldModel, ChartModel newModel)
          Allows you to replace an existing chart model with a new instance with the same model name.
 void setAllowTickLabelOverlap(boolean allowTickLabelOverlap)
          Specify whether tick labels are allowed to overlap.
 void setAnimateOnShow(boolean animateOnShow)
          Specify whether the chart should updateChart the appearance of the chart when first shown
 void setAnimationPosition(double position)
          Specify the animation position as a value from 0 (the initial position) to 1 (the final position).
 void setAntiAliasing(boolean antiAliasing)
          Specify whether to use anti-aliasing when drawing.
 void setAutoRanger(AutoRanger autoRanger)
          Specify the class used to implemented an auto-ranging policy
 void setAutoRanging(boolean autoRanging)
          Specify whether to compute ranges for the axes automatically, based on the data seen.
 void setAxisColor(Color axisColor)
          Specify the color to use for the axes
 void setAxisLabelPadding(int axisLabelPadding)
          Specify the padding around the axis labels measured in pixels.
 void setBackground(Color background)
          Sets the background for a chart.
 void setBarGap(int barGap)
          Specify the pixel gap between bars in a bar chart
 void setBarGroupGap(int barGroupGap)
          Specify the gap (in pixels) between groups of bars in a grouped bar chart
 void setBarGroupGapProportion(Double barGroupGapProportion)
          Specify the size of the group gap as a proportion of the space available to the group.
 void setBarRenderer(BarRenderer barRenderer)
          Specify the bar renderer to use
 void setBarRenderer(ChartModel model, BarRenderer barRenderer)
          Specify the bar renderer to use for the given model.
 void setBarResizePolicy(BarResizePolicy policy)
          Specify the bar resize policy when bars are assigned a width and the space available does not match the widths
 void setBarsGrouped(boolean barsGrouped)
          Specify whether bars should be grouped or stacked when they have the same axis value
 void setChartBackground(Paint chartBackground)
          Specify the paint to use for the main chart area.
 void setChartBorder(Border chartBorder)
          Specify the border to use around the chart area
 void setChartType(ChartType chartType)
          Specify the type of chart, eg.
 void setGridColor(Color gridColor)
          Specify the color to use for the grid
 void setHighlightStyle(Highlight highlight, ChartStyle style)
          Specifies a ChartStyle to be associated with the given Highlight
 void setHighQuality(boolean highQuality)
          Specify whether to invest additional computational effort to try to avoid the possibility of pixel value rounding errors.
 void setHorizontalGridLinesVisible(boolean gridLinesVisible)
          Specify whether horizontal grid lines should be visible
 void setHorizontalGridStroke(Stroke horizontalGridStroke)
          Sets the stroke used for the style of horizontal lines in the grid of an XY chart
 void setHorizontalMinorGridLinesVisible(boolean horizontalMinorGridLinesVisible)
           
 void setHorizontalMinorGridStroke(Stroke stroke)
          Sets the stroke to use when painting horizontal grid lines that correspond to minor ticks
 void setLabelColor(Color labelColor)
          Specify the color to use for the labels of the axes
 void setLabellingTraces(boolean labellingTraces)
           
 void setLazyChartRenderer(com.jidesoft.chart.LazyRenderer<ChartModel> lazyChartRenderer)
          Specify the lazy chart renderer to use
 void setLazyChartRenderer(com.jidesoft.chart.LazyRenderer<ChartModel> lazyChartRenderer, boolean autoRefresh)
           
 void setLazyRenderingThreshold(int lazyRenderingThreshold)
          How large does a data set have to be before we switch into lazy rendering mode?
 void setLineRenderer(ChartModel model, LineRenderer lineRenderer)
          Specify the line renderer to use for the given model.
 void setLineRenderer(LineRenderer lineRenderer)
          Specify the renderer to use for drawing lines in a chart
 void setMaxBarWidth(int maxBarWidth)
          Specify the maximum width for a bar in a bar chart.
 void setMinorGridColor(Color minorGridColor)
           
 void setMinorTickLength(int minorTickLength)
          Specify the length of minor ticks, in pixels
 void setModel(ChartModel model)
          First removes any models held by this object, then sets the supplied model as the single known model.
 void setModel(ChartModel model, ChartStyle style)
          First removes any models held by this object, then sets the supplied model as the single known model with the supplied style
 void setModelAxis(ChartModel model, Axis axis)
          Asserts that the supplied model should be plotted against the supplied axis rather than the default axis
 void setPanelBackground(Paint background)
          Note that we can't call this method setBackground, as that method already exists and expects a Color rather than a Paint.
 void setPieDiameter(Integer diameter)
          Specify the diameter of the pie chart, in pixels.
 void setPieSegmentRenderer(PieSegmentRenderer segmentRenderer)
          Specify the renderer to use for drawing pie charts
 void setPointRenderer(ChartModel model, PointRenderer pointRenderer)
          Specify the point renderer to use for the given model.
 void setPointRenderer(PointRenderer pointRenderer)
          Specify the point renderer to use
 void setRecordingShapes(boolean recordingShapes)
          Specify whether we want to record the shapes that are drawn out by the point and bar renderers.
 void setRolloverEnabled(boolean rollover)
           
 void setSelectionEnabled(boolean selectable)
          Specify whether the displayed chart should respond to selections.
 void setSelectionsForModel(ChartModel chartModel, ListSelectionModel selectionModel)
           
 void setSelectionShowsExplodedSegments(boolean selectionShowsExplodedSegments)
          Specify whether to use an explosion effect to indicate selection of segments
 void setSelectionShowsOutline(boolean selectionShowsOutline)
          Specify whether segment selection should be indicated by an outline on the segment
 void setShadowRenderer(ShadowRenderer shadowRenderer)
           
 void setShadowVisibility(ShadowVisibility shadowVisibility)
          You can use this property to be more selective about which elements in a chart cast a shadow
 void setShadowVisible(boolean shadowVisible)
          Use to specify whether shadows should be drawn under lines, points etc.
 void setShadowVisible(ChartModel model, boolean shadowVisible)
          Marks the specified model with the given shadow visibility.
 void setStyle(ChartModel model, ChartStyle style)
          Applies the supplied chart style to the specified chart model
 void setStyle(ChartModel model, ChartStyle style, boolean makeDirty)
          Applies the supplied chart style to the specified chart model, and additionally allows the caller to specify whether the change should trigger a repaint.
 void setTickColor(Color tickColor)
          Specify the color to use for ticks along the axes
 void setTickFont(Font font)
          Specify the font used for tick labels.
 void setTickLength(int tickLength)
          Specify the length of major ticks, in pixels
 void setTickStroke(Stroke tickStroke)
          Specify the stroke used when painting ticks
 void setTitle(AbstractLabel title)
          Specify the title of the chart
 void setTitle(String title)
          Sets the (optional) title for the chart
 void setTitleVisible(boolean titleVisible)
          Specify whether the chart should display a title
 void setVerticalGridLinesVisible(boolean gridLinesVisible)
          Specify whether the vertical lines of the grid should be painted
 void setVerticalGridStroke(Stroke verticalGridStroke)
          Sets the stroke used for the style of vertical lines in the grid of an XY chart
 void setVerticalMinorGridLinesVisible(boolean verticalMinorGridLinesVisible)
           
 void setVerticalMinorGridStroke(Stroke stroke)
          Specify the Stroke to use when painting vertical grid lines that correspond to minor ticks on the x axis
 void setXAxis(Axis axis)
          Set the x axis
 void setYAxis(Axis newAxis)
          Set the primary y axis
 void setZOrder(ChartModel model, Integer zOrder)
          Specify the z order of a model.
 void startAnimation()
          Explicitly start the animation
 void stopAnimation()
          Explicitly stop the animation
 int titleHeight()
           
 void update()
          Updates margins and coordinate systems according to the size of the component.
protected  void update(boolean canInvokeLazyRenderer)
          Updates margins and coordinate systems according to the size of the component.
 void updateUI()
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_ANIMATE_ON_SHOW

public static final String PROPERTY_ANIMATE_ON_SHOW
See Also:
Constant Field Values

PROPERTY_ANIMATION_POSITION

public static final String PROPERTY_ANIMATION_POSITION
See Also:
Constant Field Values

PROPERTY_ANTI_ALIASING

public static final String PROPERTY_ANTI_ALIASING
See Also:
Constant Field Values

PROPERTY_AUTO_RANGING

public static final String PROPERTY_AUTO_RANGING
See Also:
Constant Field Values

PROPERTY_AXIS_COLOR

public static final String PROPERTY_AXIS_COLOR
See Also:
Constant Field Values

PROPERTY_BAR_RENDERER

public static final String PROPERTY_BAR_RENDERER
See Also:
Constant Field Values

PROPERTY_BAR_GAP

public static final String PROPERTY_BAR_GAP
See Also:
Constant Field Values

PROPERTY_BAR_GROUP_GAP

public static final String PROPERTY_BAR_GROUP_GAP
See Also:
Constant Field Values

PROPERTY_BARS_GROUPED

public static final String PROPERTY_BARS_GROUPED
See Also:
Constant Field Values

PROPERTY_CHART_BACKGROUND

public static final String PROPERTY_CHART_BACKGROUND
See Also:
Constant Field Values

PROPERTY_CHART_BORDER

public static final String PROPERTY_CHART_BORDER
See Also:
Constant Field Values

PROPERTY_CURRENT_CHART_POINT

public static final String PROPERTY_CURRENT_CHART_POINT
See Also:
Constant Field Values

PROPERTY_CHART_TYPE

public static final String PROPERTY_CHART_TYPE
See Also:
Constant Field Values

PROPERTY_GRID_COLOR

public static final String PROPERTY_GRID_COLOR
See Also:
Constant Field Values

PROPERTY_HIGHLIGHT_STYLE

public static final String PROPERTY_HIGHLIGHT_STYLE
See Also:
Constant Field Values

PROPERTY_HIGH_QUALITY

public static final String PROPERTY_HIGH_QUALITY
See Also:
Constant Field Values

PROPERTY_HORIZONTAL_GRID_LINES_VISIBLE

public static final String PROPERTY_HORIZONTAL_GRID_LINES_VISIBLE
See Also:
Constant Field Values

PROPERTY_HORIZONTAL_MINOR_GRID_LINES_VISIBLE

public static final String PROPERTY_HORIZONTAL_MINOR_GRID_LINES_VISIBLE
See Also:
Constant Field Values

PROPERTY_HORIZONTAL_MINOR_GRID_STROKE

public static final String PROPERTY_HORIZONTAL_MINOR_GRID_STROKE
See Also:
Constant Field Values

PROPERTY_HORIZONTAL_GRID_STROKE

public static final String PROPERTY_HORIZONTAL_GRID_STROKE
See Also:
Constant Field Values

PROPERTY_LABEL_COLOR

public static final String PROPERTY_LABEL_COLOR
See Also:
Constant Field Values

PROPERTY_LABELLING_TRACES

public static final String PROPERTY_LABELLING_TRACES
See Also:
Constant Field Values

PROPERTY_LAZY_RENDERING_THRESHOLD

public static final String PROPERTY_LAZY_RENDERING_THRESHOLD
See Also:
Constant Field Values

PROPERTY_LINE_RENDERER

public static final String PROPERTY_LINE_RENDERER
See Also:
Constant Field Values

PROPERTY_MAX_BAR_WIDTH

public static final String PROPERTY_MAX_BAR_WIDTH
See Also:
Constant Field Values

PROPERTY_MINOR_GRID_COLOR

public static final String PROPERTY_MINOR_GRID_COLOR
See Also:
Constant Field Values

PROPERTY_MODEL

public static final String PROPERTY_MODEL
See Also:
Constant Field Values

PROPERTY_PANEL_BACKGROUND

public static final String PROPERTY_PANEL_BACKGROUND
See Also:
Constant Field Values

PROPERTY_PIE_DIAMETER

public static final String PROPERTY_PIE_DIAMETER
See Also:
Constant Field Values

PROPERTY_PIE_SEGMENT_RENDERER

public static final String PROPERTY_PIE_SEGMENT_RENDERER
See Also:
Constant Field Values

PROPERTY_POINT_RENDERER

public static final String PROPERTY_POINT_RENDERER
See Also:
Constant Field Values

PROPERTY_ROLLOVER_VISIBLE

public static final String PROPERTY_ROLLOVER_VISIBLE
See Also:
Constant Field Values

PROPERTY_SELECTABLE

public static final String PROPERTY_SELECTABLE
See Also:
Constant Field Values

PROPERTY_SELECTION_SHOWS_EXPLODED_SEGMENTS

public static final String PROPERTY_SELECTION_SHOWS_EXPLODED_SEGMENTS
See Also:
Constant Field Values

PROPERTY_SELECTION_SHOWS_OUTLINE

public static final String PROPERTY_SELECTION_SHOWS_OUTLINE
See Also:
Constant Field Values

PROPERTY_SHADOW_RENDERER

public static final String PROPERTY_SHADOW_RENDERER
See Also:
Constant Field Values

PROPERTY_SHADOW_VISIBLE

public static final String PROPERTY_SHADOW_VISIBLE
See Also:
Constant Field Values

PROPERTY_SHADOW_VISIBILITY

public static final String PROPERTY_SHADOW_VISIBILITY
See Also:
Constant Field Values

PROPERTY_CHART_STYLE

public static final String PROPERTY_CHART_STYLE
See Also:
Constant Field Values

PROPERTY_TICK_COLOR

public static final String PROPERTY_TICK_COLOR
See Also:
Constant Field Values

PROPERTY_TICK_STROKE

public static final String PROPERTY_TICK_STROKE
See Also:
Constant Field Values

PROPERTY_TICK_FONT

public static final String PROPERTY_TICK_FONT
See Also:
Constant Field Values

PROPERTY_TICK_LENGTH

public static final String PROPERTY_TICK_LENGTH
See Also:
Constant Field Values

PROPERTY_MINOR_TICK_LENGTH

public static final String PROPERTY_MINOR_TICK_LENGTH
See Also:
Constant Field Values

PROPERTY_ALLOW_TICK_LABEL_OVERLAP

public static final String PROPERTY_ALLOW_TICK_LABEL_OVERLAP
See Also:
Constant Field Values

PROPERTY_TITLE

public static final String PROPERTY_TITLE
See Also:
Constant Field Values

PROPERTY_TITLE_VISIBLE

public static final String PROPERTY_TITLE_VISIBLE
See Also:
Constant Field Values

PROPERTY_VERTICAL_GRIDLINES_VISIBLE

public static final String PROPERTY_VERTICAL_GRIDLINES_VISIBLE
Deprecated. Please use corrected spelling PROPERTY_VERTICAL_GRID_LINES_VISIBLE
See Also:
Constant Field Values

PROPERTY_VERTICAL_GRID_LINES_VISIBLE

public static final String PROPERTY_VERTICAL_GRID_LINES_VISIBLE
See Also:
Constant Field Values

PROPERTY_VERTICAL_MINOR_GRIDLINES_VISIBLE

public static final String PROPERTY_VERTICAL_MINOR_GRIDLINES_VISIBLE
Deprecated. Please use corrected spelling PROPERTY_VERTICAL_MINOR_GRID_LINES_VISIBLE
See Also:
Constant Field Values

PROPERTY_VERTICAL_MINOR_GRID_LINES_VISIBLE

public static final String PROPERTY_VERTICAL_MINOR_GRID_LINES_VISIBLE
See Also:
Constant Field Values

PROPERTY_VERTICAL_MINOR_GRID_STROKE

public static final String PROPERTY_VERTICAL_MINOR_GRID_STROKE
See Also:
Constant Field Values

PROPERTY_VERTICAL_GRID_STROKE

public static final String PROPERTY_VERTICAL_GRID_STROKE
See Also:
Constant Field Values

PROPERTY_X_AXIS

public static final String PROPERTY_X_AXIS
See Also:
Constant Field Values

PROPERTY_Y_AXIS

public static final String PROPERTY_Y_AXIS
See Also:
Constant Field Values
Constructor Detail

Chart

public Chart()
Zero-argument Constructor


Chart

public Chart(ChartModel model)
Create a chart from the supplied model

Parameters:
model - the model that will be used initially by the Chart

Chart

public Chart(String name)
The idea of this constructor is to encourage the naming of chart components. As a JComponent, it inherits the setName method, but many programmers do not use this method. Naming the chart instance is optional but can help with testing and debugging, especially if you are using more than one chart instance.

Parameters:
name - the name of the Chart instance

Chart

public Chart(Dimension size)
Creates a Chart, and sets its size (and preferred size) to be the supplied dimensions. Note that whether the size settings are respected depends on the layout manager that is used for displaying the chart.

Parameters:
size - the size of the chart
Method Detail

init

protected void init()
Initialise the component by setting defaults and listeners


updateUI

public void updateUI()
Overrides:
updateUI in class JComponent

setZOrder

public void setZOrder(ChartModel model,
                      Integer zOrder)
Specify the z order of a model.

Parameters:
model - the model whose z order we wish to set
zOrder - the z order for the specified model (a positive integer)

getZOrder

public Integer getZOrder(ChartModel model)

getChartType

public ChartType getChartType()
Returns:
the type of chart, eg. whether XY chart or Pie chart

setChartType

public void setChartType(ChartType chartType)
Specify the type of chart, eg. whether XY chart or pie chart. By default this is an XY chart.

Parameters:
chartType - the new chart type

getShadowRenderer

public ShadowRenderer getShadowRenderer()

setShadowRenderer

public void setShadowRenderer(ShadowRenderer shadowRenderer)

getPointRenderer

public PointRenderer getPointRenderer()
Returns:
the renderer object responsible for rendering points

setPointRenderer

public void setPointRenderer(PointRenderer pointRenderer)
Specify the point renderer to use

Parameters:
pointRenderer - the new point renderer

getPointRenderer

public PointRenderer getPointRenderer(ChartModel model)
Returns the point renderer associated with the given model. If no renderer is associated specifically with this model, then the "all-model" renderer is returned instead.

Parameters:
model - the chart model we are interested in
Returns:
the associated PointRenderer

setPointRenderer

public void setPointRenderer(ChartModel model,
                             PointRenderer pointRenderer)
Specify the point renderer to use for the given model. This overrides any point renderer specified by calling setPointRenderer(PointRenderer).

Parameters:
model - the model with which the renderer is associated
pointRenderer - the point renderer

getLineRenderer

public LineRenderer getLineRenderer(ChartModel model)
Returns the line renderer associated with the given model. If no renderer is associated specifically with this model, then the "all-model" renderer is returned instead.

Parameters:
model - the chart model we are interested in
Returns:
the associated LineRenderer

setLineRenderer

public void setLineRenderer(ChartModel model,
                            LineRenderer lineRenderer)
Specify the line renderer to use for the given model. This overrides any line renderer specified by calling setLineRenderer(LineRenderer).

Parameters:
model - the model with which the renderer is associated
lineRenderer - the line renderer

getBarRenderer

public BarRenderer getBarRenderer()
Returns:
the renderer object responsible for rendering bars of a bar chart

setBarRenderer

public void setBarRenderer(BarRenderer barRenderer)
Specify the bar renderer to use

Parameters:
barRenderer - the new bar renderer

getBarRenderer

public BarRenderer getBarRenderer(ChartModel model)
Returns the bar renderer associated with the given model. If no renderer is associated specifically with this model, then the "all-model" renderer is returned instead.

Parameters:
model - the chart model we are interested in
Returns:
the associated BarRenderer

setBarRenderer

public void setBarRenderer(ChartModel model,
                           BarRenderer barRenderer)
Specify the bar renderer to use for the given model. This overrides any bar renderer specified by calling setBarRenderer(BarRenderer).

Parameters:
model - the model with which the renderer is associated
barRenderer - the bar renderer

isRecordingShapes

public boolean isRecordingShapes()
Return a boolean to indicate whether we are recording the shapes for points and bars

Returns:
a boolean to indicate whether we are recording the shapes for points and bars

setRecordingShapes

public void setRecordingShapes(boolean recordingShapes)
Specify whether we want to record the shapes that are drawn out by the point and bar renderers. This is used by the rollover mechanism and is switched on by default. However, if you are using large data sets and not using the rollover mechanism, you may want to switch this off.

Parameters:
recordingShapes - whether to record the shapes for the points and bars

setPieDiameter

public void setPieDiameter(Integer diameter)
Specify the diameter of the pie chart, in pixels. Only used when displaying pie charts. When this property is not set (that is, set to null), a 'best fit' size will be calculated.

Parameters:
diameter - the new diameter of pie charts

getPieDiameter

public Integer getPieDiameter()
Returns the diameter of the pie chart in pixels, or null if no pixel diameter has been specified.

Returns:
the diameter of the pie in a pie chart, in pixels

getHorizontalGridStroke

public Stroke getHorizontalGridStroke()
Returns the Stroke used for the style of horizontal lines of the grid corresponding to major ticks

Returns:
the Stroke used for the style of horizontal lines of the grid corresponding to major ticks

getHorizontalMinorGridStroke

public Stroke getHorizontalMinorGridStroke()
Returns the Stroke currently used for horizontal lines of the grid corresponding to minor ticks

Returns:
the Stroke currently used for horizontal lines of the grid corresponding to minor ticks

setHorizontalMinorGridStroke

public void setHorizontalMinorGridStroke(Stroke stroke)
Sets the stroke to use when painting horizontal grid lines that correspond to minor ticks

Parameters:
stroke - the stroke to use when painting horizontal grid lines that correspond to minor ticks

setHorizontalGridStroke

public void setHorizontalGridStroke(Stroke horizontalGridStroke)
Sets the stroke used for the style of horizontal lines in the grid of an XY chart

Parameters:
horizontalGridStroke - the new Stroke

getVerticalGridStroke

public Stroke getVerticalGridStroke()
Returns the Stroke currently used for vertical lines of the grid corresponding to major ticks

Returns:
the Stroke currently used for vertical lines of the grid corresponding to major ticks

setVerticalGridStroke

public void setVerticalGridStroke(Stroke verticalGridStroke)
Sets the stroke used for the style of vertical lines in the grid of an XY chart

Parameters:
verticalGridStroke - the new Stroke

getVerticalMinorGridStroke

public Stroke getVerticalMinorGridStroke()
Returns the Stroke currently used for vertical lines of the grid corresponding to minor ticks

Returns:
the Stroke currently used for vertical lines of the grid corresponding to minor ticks

setVerticalMinorGridStroke

public void setVerticalMinorGridStroke(Stroke stroke)
Specify the Stroke to use when painting vertical grid lines that correspond to minor ticks on the x axis

Parameters:
stroke - the stroke to use when painting vertical grid lines corresponding to minor ticks on the x axis

getCurrentChartPoint

public Chartable getCurrentChartPoint()
Returns:
the point corresponding to the shape under the mouse cursor

renderedAs

public Shape renderedAs(Chartable chartable)
Returns the shape that is being used to render the supplied chartable point, or null if not known. Note that any enquiry about the shape used for pie segments will work only if the PieSegmentRenderer is an extension of the AbstractPieSegmentRenderer. All pie segment renderers provided as part of this product satisfy this constraint, so it is a concern only if your have written your own custom PieSegmentRenderer.

Parameters:
chartable - the point in the model for which we would like to know the rendered shape
Returns:
the rendered shape, or null if not known (or not rendered)

rendered

public PointDescriptor rendered(Chartable chartable)

containingShape

public PointDescriptor containingShape(Point p)
Determines whether there is a shape rendered that contains the supplied pixel point. If so, a descriptor is returned for the corresponding point in the chart model.

Parameters:
p - a coordinate in pixel space
Returns:
a point descriptor for the corresponding point in the chart model, if any; otherwise null.

containingShapes

public Collection<PointDescriptor> containingShapes(Point p)
Returns point descriptors for all the Chartables rendered at the specified point

Parameters:
p - the specified pixel point
Returns:
a Collection of the PointDescriptors relevant to the supplied point

containingBar

public PointDescriptor containingBar(Point p)
You can use this method to test whether the supplied pixel point is contained by the rendering of a bar.

Parameters:
p - the point to be tested
Returns:
the model point corresponding to the bar, or null if the point is not over a bar

containingSegment

public PointDescriptor containingSegment(Point p)
Determines whether the supplied pixel point is contained by the rendering of a segment in a pie chart.

Parameters:
p - a coordinate in pixel space
Returns:
a point descriptor for the corresponding point in the chart model, if any; otherwise null.

nearLine

public Collection<ChartModel> nearLine(Point p,
                                       float radius)
Determines whether there is a line segment close to p, within a supplied 'radius'. Strictly speaking this is not really a radius, because a circumscribing rectangle is constructed around the point of interest rather than a circle, but for most purposes this difference does not matter as the distances that we are using for testing proximity to a line are small.

Parameters:
p - the point of interest
radius - the allowed distance from a line at which the line is said to 'contain' the point
Returns:
a Collection of ChartModels found near the point

containingPoint

public PointDescriptor containingPoint(Point p)
Determines whether the supplied pixel point is contained by the rendering of a (model) point in a chart.

Parameters:
p - a coordinate in pixel space
Returns:
a point descriptor for the corresponding point in the chart model, if any; otherwise null.

containingPoints

public Collection<PointDescriptor> containingPoints(Point p)
Returns a collection of descriptors for all (model) points rendered at the supplied pixel point

Parameters:
p - a coordinate in pixel space
Returns:
a collection of point descriptors for chartables found at the given pixel position

getPieSegmentRenderer

public PieSegmentRenderer getPieSegmentRenderer()
Returns:
the renderer used for rendering the segments of a pie chart

setPieSegmentRenderer

public void setPieSegmentRenderer(PieSegmentRenderer segmentRenderer)
Specify the renderer to use for drawing pie charts

Parameters:
segmentRenderer - the new pie segment renderer

getLineRenderer

public LineRenderer getLineRenderer()
Returns:
the renderer to use for drawing lines in a chart

setLineRenderer

public void setLineRenderer(LineRenderer lineRenderer)
Specify the renderer to use for drawing lines in a chart

Parameters:
lineRenderer - the new line renderer

setBarGap

public void setBarGap(int barGap)
Specify the pixel gap between bars in a bar chart

Parameters:
barGap - the new pixel gap

getBarGap

public int getBarGap()
Returns:
the pixel gap between bars in a bar chart

setMaxBarWidth

public void setMaxBarWidth(int maxBarWidth)
Specify the maximum width for a bar in a bar chart. If the maximum width is set to a negative number then no limit applies.

Parameters:
maxBarWidth - the new maximum width

getMaxBarWidth

public int getMaxBarWidth()
Get the current maximum bar width.

Returns:
the current maximum bar width

getBarGroupGap

public int getBarGroupGap()

setBarGroupGap

public void setBarGroupGap(int barGroupGap)
Specify the gap (in pixels) between groups of bars in a grouped bar chart

Parameters:
barGroupGap - the new gap between groups of bars

setBarGroupGapProportion

public void setBarGroupGapProportion(Double barGroupGapProportion)
Specify the size of the group gap as a proportion of the space available to the group. If you set the groupGapProportion to null, then the absolute number of pixels (specified by calling setBarGroupGap) will be used instead.

Parameters:
barGroupGapProportion - the size of the group gap as a proportion of the space available to the group

setBarsGrouped

public void setBarsGrouped(boolean barsGrouped)
Specify whether bars should be grouped or stacked when they have the same axis value

Parameters:
barsGrouped - whether bars should be grouped (if not grouped they are stacked)

isBarsGrouped

public boolean isBarsGrouped()
Returns:
whether bars are grouped

setBarResizePolicy

public void setBarResizePolicy(BarResizePolicy policy)
Specify the bar resize policy when bars are assigned a width and the space available does not match the widths

Parameters:
policy - the bar resize policy

getBarResizePolicy

public BarResizePolicy getBarResizePolicy()
Returns:
the current bar resize policy

isHighQuality

public boolean isHighQuality()

setHighQuality

public void setHighQuality(boolean highQuality)
Specify whether to invest additional computational effort to try to avoid the possibility of pixel value rounding errors. This is false by default and you should not normally need to set it to true.

Parameters:
highQuality - whether to try to avoid pixel value rounding errors

isVerticalGridLinesVisible

public boolean isVerticalGridLinesVisible()
Returns whether the vertical lines corresponding to major ticks on the x axis are visible

Returns:
whether the vertical lines corresponding to major ticks on the x axis are visible

isVerticalMinorGridLinesVisible

public boolean isVerticalMinorGridLinesVisible()
Returns whether the vertical grid lines corresponding to minor ticks on the x axis are visible

Returns:
whether the vertical grid lines corresponding to minor ticks on the x axis are visible

setVerticalMinorGridLinesVisible

public void setVerticalMinorGridLinesVisible(boolean verticalMinorGridLinesVisible)

setVerticalGridLinesVisible

public void setVerticalGridLinesVisible(boolean gridLinesVisible)
Specify whether the vertical lines of the grid should be painted

Parameters:
gridLinesVisible - should the lines be painted?

isHorizontalGridLinesVisible

public boolean isHorizontalGridLinesVisible()
Returns whether the horizontal grid lines corresponding to major ticks on the y axis are visible

Returns:
whether the horizontal grid lines corresponding to major ticks on the y axis are visible

isHorizontalMinorGridLinesVisible

public boolean isHorizontalMinorGridLinesVisible()
Returns whether the horizontal grid lines corresponding to minor ticks on the y axis are visible

Returns:
whether the horizontal grid lines corresponding to minor ticks on the y axis are visible

setHorizontalGridLinesVisible

public void setHorizontalGridLinesVisible(boolean gridLinesVisible)
Specify whether horizontal grid lines should be visible

Parameters:
gridLinesVisible - whether horizontal grid lines are to be visible

setHorizontalMinorGridLinesVisible

public void setHorizontalMinorGridLinesVisible(boolean horizontalMinorGridLinesVisible)

isTitleVisible

public boolean isTitleVisible()
Returns a boolean to indicate whether the chart should display a title

Returns:
whether the chart should display a title

setTitleVisible

public void setTitleVisible(boolean titleVisible)
Specify whether the chart should display a title

Parameters:
titleVisible - whether to display a title for the chart

getTickFont

public Font getTickFont()
Returns the font used when painting tick labels. The tickFont property has been moved to the axis class so that fonts can be specified differently for each axis. Calling this method now returns the tickFont associated with the x axis. Calling setTickFont() adjusts the tick font for both axes, but must be called after the axes have been configured on the chart.

Returns:
the font used for tick labels

getTickFont

protected Font getTickFont(Axis axis)
Returns the font to use for painting tick labels on the supplied axis. The axis has its own tick font property which overrides the value held by this class.

Parameters:
axis - the axis of interest
Returns:
the Font to use for painting tick labels on the axis

setTickFont

public void setTickFont(Font font)
Specify the font used for tick labels. Note that if a font has been set on an axis then that font value will override any value set here.

Parameters:
font - the font to be used for tick labels

getTickStroke

public Stroke getTickStroke()
Returns the stroke used when painting ticks

Returns:
the stroke used when painting ticks

setTickStroke

public void setTickStroke(Stroke tickStroke)
Specify the stroke used when painting ticks

Parameters:
tickStroke - the stroke to use when painting ticks

getAxisColor

public Color getAxisColor()
Returns the color of the axes

Returns:
the color of the axes

setAxisColor

public void setAxisColor(Color axisColor)
Specify the color to use for the axes

Parameters:
axisColor - the new axis color

getGridColor

public Color getGridColor()
Returns the color used for the grid

Returns:
the color used for the grid

setGridColor

public void setGridColor(Color gridColor)
Specify the color to use for the grid

Parameters:
gridColor - the new color for the grid lines

getMinorGridColor

public Color getMinorGridColor()
Returns the color used for the minor grid lines

Returns:
the color used for the minor grid lines

setMinorGridColor

public void setMinorGridColor(Color minorGridColor)

getPanelBackground

public Paint getPanelBackground()
Returns the background used for the area surrounding the main chart area

Returns:
The background used for the area surrounding the main chart area
See Also:
getChartBackground()

setPanelBackground

public void setPanelBackground(Paint background)
Note that we can't call this method setBackground, as that method already exists and expects a Color rather than a Paint. That's OK for the setter but we can't override the getter. For consistency, this method calls super.setBackground() internally if the value supplied is a Color.

See Also:
setBackground(java.awt.Color), setChartBackground(java.awt.Paint)

setBackground

public void setBackground(Color background)
Sets the background for a chart. More precisely, sets the background color for the chart. Note that calling this method has the same effect as calling setPanelBackground() with the same color value.

Overrides:
setBackground in class JComponent
Parameters:
background - the background color of the chart.
See Also:
setChartBackground(java.awt.Paint)

getChartBackground

public Paint getChartBackground()
Returns the background used for the area displaying the chart

Returns:
the background used for the area displaying the chart
See Also:
getPanelBackground()

setChartBackground

public void setChartBackground(Paint chartBackground)
Specify the paint to use for the main chart area. This can be a java.awt.Color or it can be something more complex, like a gradient fill, an image or a textured paint.

Parameters:
chartBackground - the new paint to use
See Also:
setPanelBackground(java.awt.Paint)

getChartBorder

public Border getChartBorder()
Returns the border used to surround the chart area

Returns:
the border around the chart area, or null if not set

setChartBorder

public void setChartBorder(Border chartBorder)
Specify the border to use around the chart area

Parameters:
chartBorder - the border for the chart area

getUserToPixelTransform

public UserToPixelTransform getUserToPixelTransform()
Returns the transformation from user coordinates to pixel coordinates

Returns:
the transformation from user coordinates to pixel coordinates

isAntiAliasing

public boolean isAntiAliasing()
Returns whether anti-aliasing is currently being used when drawing the main chart

Returns:
whether anti-aliasing is currently being used

setAntiAliasing

public void setAntiAliasing(boolean antiAliasing)
Specify whether to use anti-aliasing when drawing. By default this is true. Charts usually look better with it switched on, but a step chart might look better with it switched off. (Another possible reason you might want to switch it off is for performance reasons).

Parameters:
antiAliasing - whether to use anti-aliasing

isAllowTickLabelOverlap

public boolean isAllowTickLabelOverlap()
Returns a value to indicate whether tick label overlaps are currently allowed

Returns:
a boolean to indicate whether tick label overlaps are currently allowed

setAllowTickLabelOverlap

public void setAllowTickLabelOverlap(boolean allowTickLabelOverlap)
Specify whether tick labels are allowed to overlap. If this is set to false (the default) then bounds checking will be applied and measures will be taken (such as not displaying some labels) in order to avoid overlapping labels.

Parameters:
allowTickLabelOverlap - whether to allow tick labels to overlap

isAutoRanging

public boolean isAutoRanging()
Returns whether we currently have auto-ranging switched on

Returns:
a boolean to indicate whether ranges for the axes are automatically computed

setAutoRanging

public void setAutoRanging(boolean autoRanging)
Specify whether to compute ranges for the axes automatically, based on the data seen.

Parameters:
autoRanging - a boolean to specify whether auto-ranging should be switched on

setAutoRanger

public void setAutoRanger(AutoRanger autoRanger)
Specify the class used to implemented an auto-ranging policy

Parameters:
autoRanger - the class that implements the auto-ranging policy

getAutoRanger

public AutoRanger getAutoRanger()
Returns the autoRanger used for setting the ranges of the axes

Returns:
the AutoRanger instance used by this class

isLabellingTraces

public boolean isLabellingTraces()

setLabellingTraces

public void setLabellingTraces(boolean labellingTraces)

addMouseZoomer

public Chart addMouseZoomer()
A convenience method for easily adding a mouse wheel zoom facility to a chart

Returns:
this Chart instance

addMouseZoomer

public Chart addMouseZoomer(boolean horizontalZoom,
                            boolean verticalZoom)
Adds a MouseWheelZoomer to this chart instance, and specifies whether zooming should be enabled in the horizontal and vertical directions. It is quite common to specify a zoom that operates only in the horizontal direction, particularly when displaying time series data.

Parameters:
horizontalZoom - whether the zoom operates along the x axis
verticalZoom - whether the zoom operates along the y axis
Returns:
this Chart instance

removeMouseZoomer

public Chart removeMouseZoomer()
Removes any MouseWheelZoomer that was created using one of the addMouseZoomer methods.

Returns:
this Chart instance

addMousePanner

public Chart addMousePanner()
Makes it possible for the user to 'pan' the chart easily by clicking and dragging the mouse. Panning is a translation of the chart domain, but it is very natural when this is done with a click and drag action of the mouse.

Returns:
this chart instance (so you can chain method calls)

addMousePanner

public Chart addMousePanner(boolean horizontalPan,
                            boolean verticalPan)
Make it possible for the user to pan the chart easily, but specifying whether panning is allowed in the horizontal and/or vertical axes.

Parameters:
horizontalPan - do we allow horizontal panning
verticalPan - do we allow vertical panning
Returns:
this Chart instance (so you can chain method calls)

removeMousePanner

public Chart removeMousePanner()
Remove the panning ability for this chart.

Returns:
this chart instance (so you can chain method calls)

setRolloverEnabled

public void setRolloverEnabled(boolean rollover)

isRolloverEnabled

public boolean isRolloverEnabled()

setSelectionEnabled

public void setSelectionEnabled(boolean selectable)
Specify whether the displayed chart should respond to selections. By default selection is switched off.

Parameters:
selectable - whether selection is switched on

isSelectionEnabled

public boolean isSelectionEnabled()

isSelectionShowsExplodedSegments

public boolean isSelectionShowsExplodedSegments()
Returns:
Are we currently using an explosion effect to indicate selection of segments?

setSelectionShowsExplodedSegments

public void setSelectionShowsExplodedSegments(boolean selectionShowsExplodedSegments)
Specify whether to use an explosion effect to indicate selection of segments

Parameters:
selectionShowsExplodedSegments - used to specify whether selecting segments of a pie chart will show those segments as 'exploded' away from the rest of the pie

isSelectionShowsOutline

public boolean isSelectionShowsOutline()
Returns:
are selection outlines currently shown?

setSelectionShowsOutline

public void setSelectionShowsOutline(boolean selectionShowsOutline)
Specify whether segment selection should be indicated by an outline on the segment

Parameters:
selectionShowsOutline - should selection outlines be visible?

addDoubleClickListener

public void addDoubleClickListener(ActionListener listener)

removeDoubleClickListener

public void removeDoubleClickListener(ActionListener listener)

chartModelChanged

public void chartModelChanged()
This is the method of the ChartModelListener interface; it is called whenever the chart model has changed and all points need to be updated.

Specified by:
chartModelChanged in interface ChartModelListener

chartModelChanged

public void chartModelChanged(ChartModelChangeEvent changeEvent)
This method is called to inform the ChartModelChangeListener of an event that changed the ChartModel to which the listener is attached.

Specified by:
chartModelChanged in interface ChartModelChangeListener
Parameters:
changeEvent - the ChartModelChangeEvent

isShadowVisible

public boolean isShadowVisible()
Returns a boolean to indicate whether shadows are being applied to elements of the chart

Returns:
whether shadows are being applied to elements of the chart

setShadowVisible

public void setShadowVisible(boolean shadowVisible)
Use to specify whether shadows should be drawn under lines, points etc. on the chart. Note that setShadowVisible(true) is equivalent to setShadowVisibility(ShadowVisibility.ALL); and setShadowVisible(false) is equivalent to setShadowVisibility(ShadowVisibility.NONE).

Parameters:
shadowVisible - boolean to indicate whether shadows should be drawn

getShadowVisibility

public ShadowVisibility getShadowVisibility()

setShadowVisibility

public void setShadowVisibility(ShadowVisibility shadowVisibility)
You can use this property to be more selective about which elements in a chart cast a shadow


setShadowVisible

public void setShadowVisible(ChartModel model,
                             boolean shadowVisible)
Marks the specified model with the given shadow visibility. At the time of writing, this is not supported for lazy rendering but it may be supported in a future release.

Parameters:
model - the model for which we wish to mark the shadow's visibility
shadowVisible - whether the shadow is visible

isShadowVisible

public boolean isShadowVisible(ChartModel model)
Returns a boolean to indicate whether shadows have been applied to the specified model

Parameters:
model - the chart model
Returns:
a boolean to indicate whether shadows have been applied to this model

autoRange

public void autoRange()
Causes the ranges of the chart to be adjusted according to the data. If you add a model to the chart you will probably want to call this afterwards to ensure that the axes are adjusted to accommodate the new data.


update

public void update()
Updates margins and coordinate systems according to the size of the component. This method is used internally and it is rare that you should have to call this. (A possible exception is forcing an update to the component prior to painting to a different graphics canvas.)


update

protected void update(boolean canInvokeLazyRenderer)
Updates margins and coordinate systems according to the size of the component.

Parameters:
canInvokeLazyRenderer - specify whether this method is allowed to explicitly invoke an update on the lazy renderer. Use with caution as wrong usage can cause recursive event loops.

drawInBackground

public void drawInBackground()
You should not need to call this method often. It uses lazy rendering for drawing and starts the background drawing immediately. If this gets called too often it could damage performance rather than improve it, so take care at what point this is invoked.


propertyChange

public void propertyChange(PropertyChangeEvent pce)

Specified by:
propertyChange in interface PropertyChangeListener

addDrawable

public Chart addDrawable(Drawable d)
Adds an object that implements the drawable callback method. Use this method to add custom shapes to a chart.

Parameters:
d - the Drawable to add
Returns:
this chart object (so calls to this method can be cascaded)

removeDrawable

public Chart removeDrawable(Drawable d)
Removes a drawable from the chart (and all references to the Drawable from the chart object too).

Note: Make sure your Drawables have good implementations of equals() and hashCode()

Parameters:
d - the Drawable to remove
Returns:
this chart object

removeDrawables

public Chart removeDrawables()
Removes all drawables from the chart

Returns:
this chart object

containsDrawable

public boolean containsDrawable(Drawable drawable)
Determines whether this chart object already contains the supplied Drawable. For this method to work as expected, the Drawable is expected to have a good implementation of equals() and hashCode()

Parameters:
drawable - the Drawable object to test
Returns:
this Chart object

getDrawables

public Collection<Drawable> getDrawables()
Returns a Collection of Drawable objects known by the Chart

Returns:
a Collection of drawable objects known by the Chart

getAxisLabelPadding

public int getAxisLabelPadding()
Returns the padding around the axis labels. Use this to keep the axis label far from the tick labels or to bring them close together.

Returns:
the gap between the tick labels and the axis label

setAxisLabelPadding

public void setAxisLabelPadding(int axisLabelPadding)
Specify the padding around the axis labels measured in pixels.

Parameters:
axisLabelPadding - the gap between the axis label and the tick labels and the axis label and the edge of the chart (or next axis)

axisWidth

public int axisWidth(Graphics g,
                     Axis axis)
Returns the width of the supplied axis due to the rendering of ticks and tick labels (but not the main axis label)

Returns:
the width of the supplied axis due to rendering of ticks and labels

titleHeight

public int titleHeight()

getXStart

public int getXStart()
Returns:
the pixel x coordinate start of the drawing area relative to the canvas on which it is painted

getXEnd

public int getXEnd()
Returns:
the pixel x coordinate end of the drawing area relative to the canvas on which it is painted

getChartWidth

public int getChartWidth()
Returns:
the width of the drawing area in pixels

getYStart

public int getYStart()
Returns:
the y coordinate start of the drawing area relative to the canvas on which it is painted.

For the y axis, the 'start' is the bottom of the chart region and therefore has a numeric value greater than or equal to the yEnd property


getYEnd

public int getYEnd()
Returns:
the y coordinate end of the drawing area relative to the canvas on which it is painted.

For the y axis, the 'end' is at the top of the chart region


getChartHeight

public int getChartHeight()

getYSum

public double getYSum(ChartModel model)
Parameters:
model - the model for which we wish to compute the sum of the y values
Returns:
the sum of the y values of the supplied ChartModel

getTickLength

public int getTickLength()
Returns the length of major ticks, in pixels

Returns:
the length of major ticks, in pixels

setTickLength

public void setTickLength(int tickLength)
Specify the length of major ticks, in pixels

Parameters:
tickLength - the new length for major ticks

getMinorTickLength

public int getMinorTickLength()
Returns the length of minor ticks, in pixels

Returns:
the length of minor ticks, in pixels

setMinorTickLength

public void setMinorTickLength(int minorTickLength)
Specify the length of minor ticks, in pixels

Parameters:
minorTickLength - the new length for minor ticks

getTickColor

public Color getTickColor()
Returns the current tick color

Returns:
the current tick color

setTickColor

public void setTickColor(Color tickColor)
Specify the color to use for ticks along the axes

Parameters:
tickColor - the new tick color

getLabelColor

public Color getLabelColor()
Returns the color of the axis labels

Returns:
the color of the axis labels

setLabelColor

public void setLabelColor(Color labelColor)
Specify the color to use for the labels of the axes

Parameters:
labelColor - the color to use for the labels of the axes

setXAxis

public void setXAxis(Axis axis)
Set the x axis

Parameters:
axis - the new x axis

getXAxis

public Axis getXAxis()
Returns the chart's x axis

Returns:
the chart's x axis

setYAxis

public void setYAxis(Axis newAxis)
Set the primary y axis

Parameters:
newAxis - the new y axis

addYAxis

public Chart addYAxis(Axis newAxis)
Adds a y axis

Parameters:
newAxis - the new y axis
Returns:
this Chart object

getYAxis

public Axis getYAxis()
Returns the primary y axis. The primary y axis is the first one that was added.

Returns:
the primary y axis

getYAxis

public Axis getYAxis(int n)
Returns the nth y axis (indexed from zero)

Parameters:
n - the index of the axis to return
Returns:
the nth axis

getYAxisCount

public int getYAxisCount()
Returns the number of y axes

Returns:
the number of y axes

setTitle

public void setTitle(String title)
Sets the (optional) title for the chart

Parameters:
title - the new title of the chart

getTitle

public AbstractAnnotation getTitle()
Returns the current title of the chart

Returns:
the current title of the chart

setTitle

public void setTitle(AbstractLabel title)
Specify the title of the chart

Parameters:
title - the new title label for the chart

getLazyRenderingThreshold

public int getLazyRenderingThreshold()
Returns the total size that data sets must be before switching to lazy rendering

Returns:
the lazy rendering total

setLazyRenderingThreshold

public void setLazyRenderingThreshold(int lazyRenderingThreshold)
How large does a data set have to be before we switch into lazy rendering mode?

Parameters:
lazyRenderingThreshold - the total number of points in all the loaded chart models before Chart starts using lazy rendering. If this value is set to zero, then Chart automatically uses lazy rendering.

getLazyChartRenderer

public com.jidesoft.chart.LazyRenderer<ChartModel> getLazyChartRenderer()

setLazyChartRenderer

public void setLazyChartRenderer(com.jidesoft.chart.LazyRenderer<ChartModel> lazyChartRenderer)
Specify the lazy chart renderer to use

Parameters:
lazyChartRenderer - the lazy renderer of charts

setLazyChartRenderer

public void setLazyChartRenderer(com.jidesoft.chart.LazyRenderer<ChartModel> lazyChartRenderer,
                                 boolean autoRefresh)

isLazyRendering

public boolean isLazyRendering()
Returns a boolean to indicate whether lazy rendering is currently being used

Returns:
a boolean to indicate whether lazy rendering is currently being used

setModel

public void setModel(ChartModel model)
First removes any models held by this object, then sets the supplied model as the single known model. You can still add more models by calling addModel

Parameters:
model - the model to add

setModel

public void setModel(ChartModel model,
                     ChartStyle style)
First removes any models held by this object, then sets the supplied model as the single known model with the supplied style

Parameters:
model - the model to add
style - the style of the model

addModel

public Chart addModel(ChartModel newModel)
Adds the supplied ChartModel to the Chart so that it is drawn in the chart area.

The Chart instance should not already contain the supplied ChartModel.

Parameters:
newModel - the ChartModel being added

addModel

public Chart addModel(ChartModel model,
                      boolean makeDirty)
Adds the supplied ChartModel to the Chart, but does not force a repaint. This means that multiple models can be added to the chart and we can perform an update after they have all been added.

Parameters:
model - the model to add to the chart
makeDirty - a boolean flag to indicate whether the chart should be marked as 'dirty' and in need of a repaint

addModel

public Chart addModel(ChartModel model,
                      ChartStyle style)
Adds the supplied ChartModel to the Chart, also assigning the supplied style to the chart.

Note that storing the style directly without making a separate call to setStyle potentially saves a screen update, as setStyle causes a repaint() itself.

Parameters:
model - the new ChartModel to display
style - the style of the added ChartModel
Returns:
the Chart

addModel

public Chart addModel(ChartModel model,
                      Axis axis)
Adds the supplied ChartModel to the Chart, also assigning the model to the supplied axis. This means that the model will be rescaled whenever the axis is rescaled.

Parameters:
model - the model to add to the Chart
axis - the (y) axis to which the model is assigned
Returns:
the Chart

addModel

public Chart addModel(ChartModel model,
                      Axis axis,
                      ChartStyle style)
Adds the supplied ChartModel to the Chart, also assigning the model to the supplied axis. This means that the model will be rescaled whenever the axis is rescaled.

Note that storing the style directly without making a separate call to setStyle potentially saves a screen update, as setStyle causes a repaint() itself.

Parameters:
model - the model to add to the chart
axis - the (y) axis to which the model is assigned
style - the style with which to paint the chart
Returns:
the Chart

getModel

public ChartModel getModel()
Returns:
the first ChartModel. Useful when we can safely assume that there is only one. Returns null if there are no ChartModels.

getModel

public ChartModel getModel(int i)
Parameters:
i - - zero based index
Returns:
the ith ChartModel

getModel

public ChartModel getModel(String modelName)
Returns the model with the specified name; null otherwise

Parameters:
modelName - the name of the chart model to retrieve
Returns:
the ChartModel with the specified name

getModels

public List<ChartModel> getModels()

modelCount

public int modelCount()
The number of chart models currently loaded into the chart component

Returns:
the number of models

pointCount

public int pointCount()
Returns:
the total number of points contained in all the known models

setModelAxis

public void setModelAxis(ChartModel model,
                         Axis axis)
Asserts that the supplied model should be plotted against the supplied axis rather than the default axis

Parameters:
model - the model whose axis we are setting
axis - the (y) axis to associate with the model

getAxisForModel

public Axis getAxisForModel(ChartModel model)

getSelectionsForModel

public ListSelectionModel getSelectionsForModel(ChartModel model)

setSelectionsForModel

public void setSelectionsForModel(ChartModel chartModel,
                                  ListSelectionModel selectionModel)

getTransformForModel

public UserToPixelTransform getTransformForModel(ChartModel model)

setStyle

public void setStyle(ChartModel model,
                     ChartStyle style)
Applies the supplied chart style to the specified chart model

Parameters:
model - the chart model
style - the chart style to apply to the model

setStyle

public void setStyle(ChartModel model,
                     ChartStyle style,
                     boolean makeDirty)
Applies the supplied chart style to the specified chart model, and additionally allows the caller to specify whether the change should trigger a repaint.

Parameters:
model - the chart model
style - the chart style to apply to the model
makeDirty - whether the component should become 'dirty' and therefore in need of a repaint

getStyle

public ChartStyle getStyle(ChartModel model)
Returns the Chart Style associated with the supplied chart model, or null if there is no style associated with the model. The ChartModel must have a non-null name; otherwise a NullPointerException i

Parameters:
model - the chart model
Returns:
a Chart Style
Throws:
NullPointerException - if the supplied chart model is null or the name of the model is null

setHighlightStyle

public void setHighlightStyle(Highlight highlight,
                              ChartStyle style)
Specifies a ChartStyle to be associated with the given Highlight

Parameters:
highlight - the highlight to which we are attaching a ChartStyle
style - the ChartStyle associated with the Highlight

getHighlightStyle

public ChartStyle getHighlightStyle(Highlight h)
Retrieves the ChartStyle associated with the supplied highlight

Parameters:
h - the highlight of interest
Returns:
the ChartStyle associated with the highlight, or null if none present

clearHighlights

public Chart clearHighlights()
Removes all known highlights and their associated styles from this class

Returns:
this Chart instance

containsModel

public boolean containsModel(ChartModel model)
Returns a boolean to indicate whether the supplied model is known to this Chart instance

Parameters:
model - the model of interest
Returns:
a boolean to indicate whether the supplied model is known

removeModel

public Chart removeModel(ChartModel model)

Removes the chart model from the chart.

Note that for this to work successfully, the hashCode() and equals() methods on the ChartModel class must be correctly implemented so if you notice your models are not being properly removed, this would be the first thing to check for.

Parameters:
model - the model to remove

replaceModel

public Chart replaceModel(ChartModel oldModel,
                          ChartModel newModel)
Allows you to replace an existing chart model with a new instance with the same model name. This can be used to quickly swap one model for another; for example when changing the resolution of a data set as part of a drill down operation.

Parameters:
oldModel - the old model
newModel - the new model

removeModels

public Chart removeModels()
Stops any background drawing, and removes all the known ChartModels by repeated calls to removeModel()


paintComponent

protected void paintComponent(Graphics g)
Overrides:
paintComponent in class JComponent

createToolTip

public JToolTip createToolTip()
This fixes a painting problem with the shadow rendering code when a tool tip disappears. We issue a repaint request when the tool tip disappears. See forum posting from Fri Jan 08, 2010

Overrides:
createToolTip in class JComponent

paintYAxisTicks

public void paintYAxisTicks(Graphics g,
                            Axis axis,
                            Point midPoint,
                            int xPixelCoord)

paintHorizontalGrid

protected void paintHorizontalGrid(Graphics g,
                                   Axis axis,
                                   UserToPixelTransform transform)

paintYAxisTicks

protected void paintYAxisTicks(Graphics g,
                               Axis axis,
                               UserToPixelTransform transform,
                               Point midPoint,
                               int xPixelCoord)

drawStringIfWithinBounds

protected boolean drawStringIfWithinBounds(Graphics g,
                                           String s,
                                           int x,
                                           int y)
Paints a string but only if the whole of the string will be visible according to the bounds of the component

Parameters:
g - the Graphics context
s - the string to draw
x - the bottom left x coordinate of the drawn string
y - the bottom left y coordinate of the drawn string
Returns:
a boolean to indicate whether the string was actually drawn

drawRotatedStringIfWithinBounds

protected boolean drawRotatedStringIfWithinBounds(Graphics g,
                                                  String s,
                                                  int x,
                                                  int y,
                                                  double rotation)
Parameters:
g - the Graphics context into which to draw
s - the string to draw
x - the x coordinate of the centre of where the string should be drawn
y - the y coordinate of the centre of where the string should be drawn
rotation - the rotation to use, in radians
Returns:
a boolean to indicate whether the string was drawn

drawXAxisTickLabel

public void drawXAxisTickLabel(Graphics g,
                               Axis axis,
                               String s,
                               int x,
                               int y)
Draws a tick label onto the Graphics context. You should not need to call this method directly.

Parameters:
g - the Graphics context into which to draw
axis - the Axis from which the tick comes. This is needed so we can find out the orientation and placement for the text
s - the text string to draw
x - the x coordinate of the tick
y - the y coordinate of the tick

paintYAxis

protected void paintYAxis(Graphics2D g,
                          Axis axis,
                          int xPosition)
Paint a single Y axis

Parameters:
g - the Graphics context
axis - the y axis to paint
xPosition - the xPosition at which to paint the axis

paintXAxis

protected void paintXAxis(Graphics2D g)
Paints the X axis onto the Graphics context

Parameters:
g - the graphics context

getTickColor

protected Color getTickColor(Axis axis)
Returns the tick color to use when painting (a major tick) on an axis. This color is given by the tick color property unless it has been overridden by the tickColor property of the given axis. If the tick color property is null this method returns a default color of darkGray.

Parameters:
axis - the axis whose tick color is to be determined
Returns:
the Color to use for ticks of the supplied axis

getMinorTickColor

protected Color getMinorTickColor(Axis axis)
Finds the minor tick color to use for the supplied axis. If the axis does not explicitly set a minor tick color, then the major tick color is used instead.

Parameters:
axis - the axis whose minor tick color is to be determined
Returns:
the Color to use for minor ticks of the supplied axis

paintXAxisTicks

protected void paintXAxisTicks(Graphics2D g,
                               Tick[] ticks)

paintXAxisGridLines

protected void paintXAxisGridLines(Graphics2D g,
                                   Tick[] ticks)

paintAxes

protected void paintAxes(Graphics2D g)
Paint all axes

Parameters:
g - the Graphics context onto which the axis will be painted The axis width needs to be calculated as the width of a tick plus the width of a tick label

paintYAxisLabels

protected void paintYAxisLabels(Graphics2D g)
Paint all y axis tick labels

Parameters:
g - the Graphics context onto which the axis will be painted The axis width needs to be calculated as the width of a tick plus the width of a tick label

drawYAxisTickLabel

protected void drawYAxisTickLabel(Graphics g,
                                  Axis yAxis,
                                  String s,
                                  int x,
                                  int y)

nearestPoint

public PointSelection nearestPoint(Point hitPoint,
                                   ChartModel model)
Returns the nearest point to a specified pixel point from a given ChartModel. To find the nearest point we need only to compute the distance squared to each of the other points - no need to take the square root

Parameters:
hitPoint - the pixel point of interest
model - the ChartModel of interest
Returns:
the nearest point in a model to the specified pixel point, or null if a nearest point could not be found

nearestModel

public ChartModel nearestModel(Point p)
Note that the current implementation may take some time to execute for larger data sets. This will be optimized in a future release.

Returns:
the nearest model to the last known cursor point, or null if a nearest model could not be found.

isUserPointViewable

public boolean isUserPointViewable(Point2D userPoint,
                                   ChartModel model)
We need to specify which model the point belongs to, so that we know which axis and therefore which point ranges to apply.

Returns:
whether the point is within the viewable region of the chart

isPixelPointViewable

public boolean isPixelPointViewable(int x,
                                    int y)

nearestPoint

public Pair<Chartable,Double> nearestPoint(Point2D realPoint,
                                           ChartModel model)
Returns the nearest point in a model to the specified real point. Note that this calculates the nearest point in user coordinates rather than pixel coordinates and therefore, depending on the scaling of the axes, may produce correct, but unexpected, results. Consider using nearestPoint(Point, ChartModel) instead.

Parameters:
realPoint - the position of the point of interest in user coordinates
model - the ChartModel of interest
Returns:
the nearest point

distanceSq

public static double distanceSq(Point2D point,
                                Chartable chartable)

distance

public static double distance(Point2D point,
                              Chartable chartable)

calculatePixelPoint

public Point calculatePixelPoint(Point2D userPoint)
Calculate the pixel coordinates of a point using the default y axis.

Returns:
the Point calculated in pixel space (i.e., pixel coordinates) or null if the point cannot be calculated.

calculatePixelPoint2D

public Point2D calculatePixelPoint2D(Point2D userPoint)
Calculate the pixel coordinates of a point using the default y axis.

Returns:
the Point2D calculated in pixel space (i.e., pixel coordinates) or null if the point cannot be calculated.

calculatePixelPoint

public Point calculatePixelPoint(Point2D userPoint,
                                 Axis axis)
Calculate the pixel coordinates of a point using the supplied y axis

Parameters:
userPoint - the point in user coordinates
axis - the y axis used for the y value
Returns:
a pixel point

calculatePixelPoint2D

public Point2D calculatePixelPoint2D(Point2D userPoint,
                                     Axis axis)
Calculate the pixel coordinates of a point using the supplied y axis

Parameters:
userPoint - the point in user coordinates
axis - the y axis used for the y value
Returns:
a pixel point

calculatePixelPoint

public Point calculatePixelPoint(Point2D userPoint,
                                 UserToPixelTransform transform)
Calculates the pixel point using the supplied transform. There is a transform associated with each y axis and you can retrieve it using getTransformForAxis() or getTransformForModel(ChartModel model).

Parameters:
userPoint - the point in user coordinates
transform - the transform used for the calculation. You do not create these, but retrieve them using the supplied methods (see above).
Returns:
a pixel point, or null if the pixel point cannot be computed

calculatePixelPoint2D

public Point2D calculatePixelPoint2D(Point2D userPoint,
                                     UserToPixelTransform transform)

calculateUserPoint

public Point2D calculateUserPoint(Point p)
Calculates the point in the user's coordinate system for the pixel coordinate given by p. TODO: We probably need a version of this method that accepts an axis, and uses the conversion appropriate for that axis.

Parameters:
p - the point in pixel coordinates
Returns:
the point calculated in user space; or null if this cannot be computed

convertYToPrimary

public double convertYToPrimary(double userY,
                                Axis yAxis)
Converts a point scaled against the supplied yAxis to its equivalent point on the primary y axis. Note that this will not work with a logarithmic range

Parameters:
userY - the point scaled on the supplied y axis
yAxis - the y axis used for the supplied user point
Returns:
the equivalent point on the primary y axis

convertPrimaryToY

public double convertPrimaryToY(double primaryY,
                                Axis yAxis)
Converts a point scaled against the primary yAxis to its equivalent point on the supplied y Axis Note that this will not work with a logarithmic range

Parameters:
primaryY - the value on the primary y axis
yAxis - the axis to which we need to convert the value
Returns:
the converted value

paintModels

protected void paintModels(Graphics2D g,
                           Graphics2D shadowGraphics,
                           Shape clipBounds,
                           Shape chartAreaClip)

getTransformForAxis

public UserToPixelTransform getTransformForAxis(Axis yAxis)
Returns the Affine Transform associated with the given y axis

Parameters:
yAxis - the y axis for which we are retrieving the transform
Returns:
the AffineTransform associated with the given y axis

paintAnnotations

protected void paintAnnotations(Graphics2D g)

getAnimationPosition

public double getAnimationPosition()
Description copied from interface: Animatable
Get the current animation position, 0.0 is the start and 1.0 is the end

Specified by:
getAnimationPosition in interface Animatable
Returns:
the current animation position. A value of 1.0 indicates that animation has finished.

setAnimationPosition

public void setAnimationPosition(double position)
Specify the animation position as a value from 0 (the initial position) to 1 (the final position). You don't need to call this method, except if you want to implement a custom animation strategy.

Specified by:
setAnimationPosition in interface Animatable

isAnimateOnShow

public boolean isAnimateOnShow()
Description copied from interface: AnimatedChart
Get if the animation should start when the chart is first drawn to screen. If FALSE the animation will only run when startAnimation() is called.

Specified by:
isAnimateOnShow in interface AnimatedChart
Returns:
a boolean to indicate whether animation is currently switched on

setAnimateOnShow

public void setAnimateOnShow(boolean animateOnShow)
Specify whether the chart should updateChart the appearance of the chart when first shown

Specified by:
setAnimateOnShow in interface AnimatedChart
Parameters:
animateOnShow - If TRUE the chart will start animating on first draw

startAnimation

public void startAnimation()
Explicitly start the animation

Specified by:
startAnimation in interface AnimatedChart

stopAnimation

public void stopAnimation()
Explicitly stop the animation

Specified by:
stopAnimation in interface AnimatedChart

interpolateXForAnimation

public int interpolateXForAnimation(int inputX,
                                    ChartModel model)
Transforms an input x value to a value used during the animateOnShow phase

Parameters:
inputX - a pixel x coordinate
model - the chart model that uses the x coordinate
Returns:
the interpolated x value

interpolateYForAnimation

public int interpolateYForAnimation(int inputY,
                                    ChartModel model)
Transforms an input y value to a value used during the animateOnShow phase

Parameters:
inputY - a pixel y coordinate
model - the chart model that uses the y coordinate
Returns:
the interpolated y value

JIDE 3.5.15