com.xj.anylogic.engine.analysis
Class Chart

java.lang.Object
  extended by com.xj.anylogic.engine.presentation.Shape
      extended by com.xj.anylogic.engine.presentation.ShapeControl
          extended by com.xj.anylogic.engine.analysis.Chart
All Implemented Interfaces:
com.xj.anylogic.engine.internal.Child, Locatable2D, java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
Chart1D, Chart2D, Histogram, Histogram2D

public abstract class Chart
extends ShapeControl
implements java.awt.event.ActionListener

The base class for all charts. Embeds JPanel with several sub-components. Is responsible for the chart overall layout, and for the chart legend functionality. Delegates the drawing of the chart to its subclasses.
The chart area is divided into two parts: the picture area (where the picture, like plot, pie, bar, histogram, etc. is drawn) and the legend area. The legend can be located on either of the four sides of the chart (NORTH, SOUTH, EAST, WEST), or absent (NONE). The picture can be located at arbitrary position within the picture area, i.e. the part of the chart not occupied by the legend.

Author:
XJ Technologies Company Ltd. www.anylogic.com
See Also:
Serialized Form

Nested Class Summary
static class Chart.Properties
          A data structure containing all specific chart properties (does not include general shape properties like X, Y, width, height, etc.).
 
Field Summary
static java.lang.String DEFAULT_DATE_PATTERN
           
static java.lang.String DEFAULT_DATE_TIME_PATTERN
           
static java.lang.String DEFAULT_TIME_PATTERN
           
static int EAST
           
static int GRID_DEFAULT
           
static int GRID_NONE
           
static int GRID_OPPOSITE
           
static int INTERPOLATION_LINEAR
           
static int INTERPOLATION_STEP
           
static int NONE
           
static int NORTH
           
static int POINT_CIRCLE
           
static int POINT_NONE
           
static int POINT_SQUARE
           
static int POINT_TRIANGLE
           
static int SCALE_100_PERCENT
           
static int SCALE_AUTO
           
static int SCALE_FIXED
           
static int SOUTH
           
static int WEST
           
 
Fields inherited from class com.xj.anylogic.engine.presentation.ShapeControl
TYPE_DOUBLE, TYPE_INT, TYPE_STRING
 
Fields inherited from class com.xj.anylogic.engine.presentation.Shape
UNKNOWN_NAME
 
Constructor Summary
Chart(Presentable p, boolean ispublic, int x, int y, int width, int height, java.awt.Color fillColor, java.awt.Color lineColor, int picOffsetX, int picOffsetY, int picWidth, int picHeight, java.awt.Color picBackgoundColor, java.awt.Color picBorderColor, java.awt.Color legendTextColor, int legendSize, int legendPos, java.util.List<java.lang.String> titles)
          Creates a persistent chart.
Chart(Presentable p, int id, int index)
          Creates a non-persistent chart that will exist only while it is visible.
 
Method Summary
 void action()
          Does nothing: no actions are associated with charts.
 void actionPerformed(java.awt.event.ActionEvent event)
           
 Shape clone()
          Cloning of charts is not supported
(Other shapes except GIS and controls allow cloning)
This method throws UnsupportedOperationException if called
 java.lang.String copyToClipboard()
          Copies all chart data to the system clipboard in text form.
 ChartItem get(int i)
          Returns the chart item (DataItem, DataSet, Histogram, etc.) with the given index.
 int getCount()
          Returns the number of chart items (data items or data sets) currently displayed by this chart.
 javax.swing.JComponent getJComponent()
          Returns the embedded JPanel.
 javax.swing.JPopupMenu getPopupMenu()
           
 int[] getSelectedItemIndices()
          Returns an array with indices of selected chart items
 java.lang.String getTitle(int i)
          Returns the title of chart item (DataItem, DataSet, Histogram, etc.) with the given index.
 void onItemRemoved(int removedIndex, boolean programmatically)
          Executes specific action when user removes chart item.
 void onSelectionChanged(int[] selectedIndices, boolean programmatically)
          Executes specific action when user clicks on legend and selects/deselects chart item(s).
 void refresh()
          Causes the chart to refresh its picture and legend based on the current data values and schedules the component repaint.
 int remove(ChartItem ci)
          Removes the given item (DataItem, DataSet, Histogram, Histogram2DData) from the chart.
 void remove(int i)
          Removes the item (DataItem, DataSet, Histogram, etc.) with the given index from the chart.
 void removeAll()
          Removes all items from the chart.
 void selectItem(int itemIndex, boolean selected)
          Selects/deselects (depending on selected value) chart item with given index
 void setSelectedItemIndices(int[] selectedIndices)
          Selects only chart items with given indices
 void update()
          Refreshes a (non-persistent) chart on each frame.
 void updateData()
          Updates all data items / data sets displayed by this chart.
 
Methods inherited from class com.xj.anylogic.engine.presentation.ShapeControl
contains, draw, getHeight, getPresentable, getWidth, isEnabled, onClickAt, restoreOwner, setEnabled, setHeight, setValueToDefault, setWidth
 
Methods inherited from class com.xj.anylogic.engine.presentation.Shape
canHandleClick, getGroup, getName, getRotation, getScaleX, getScaleY, getX, getY, isVisible, onClick, setPos, setRotation, setScale, setScale, setScaleX, setScaleY, setVisible, setX, setY
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
See Also:
Constant Field Values

SOUTH

public static final int SOUTH
See Also:
Constant Field Values

WEST

public static final int WEST
See Also:
Constant Field Values

EAST

public static final int EAST
See Also:
Constant Field Values

NORTH

public static final int NORTH
See Also:
Constant Field Values

GRID_NONE

public static final int GRID_NONE
See Also:
Constant Field Values

GRID_DEFAULT

public static final int GRID_DEFAULT
See Also:
Constant Field Values

GRID_OPPOSITE

public static final int GRID_OPPOSITE
See Also:
Constant Field Values

SCALE_AUTO

public static final int SCALE_AUTO
See Also:
Constant Field Values

SCALE_FIXED

public static final int SCALE_FIXED
See Also:
Constant Field Values

SCALE_100_PERCENT

public static final int SCALE_100_PERCENT
See Also:
Constant Field Values

POINT_NONE

public static final int POINT_NONE
See Also:
Constant Field Values

POINT_SQUARE

public static final int POINT_SQUARE
See Also:
Constant Field Values

POINT_CIRCLE

public static final int POINT_CIRCLE
See Also:
Constant Field Values

POINT_TRIANGLE

public static final int POINT_TRIANGLE
See Also:
Constant Field Values

INTERPOLATION_STEP

public static final int INTERPOLATION_STEP
See Also:
Constant Field Values

INTERPOLATION_LINEAR

public static final int INTERPOLATION_LINEAR
See Also:
Constant Field Values

DEFAULT_TIME_PATTERN

public static final java.lang.String DEFAULT_TIME_PATTERN

DEFAULT_DATE_PATTERN

public static final java.lang.String DEFAULT_DATE_PATTERN

DEFAULT_DATE_TIME_PATTERN

public static final java.lang.String DEFAULT_DATE_TIME_PATTERN
Constructor Detail

Chart

public Chart(Presentable p,
             boolean ispublic,
             int x,
             int y,
             int width,
             int height,
             java.awt.Color fillColor,
             java.awt.Color lineColor,
             int picOffsetX,
             int picOffsetY,
             int picWidth,
             int picHeight,
             java.awt.Color picBackgoundColor,
             java.awt.Color picBorderColor,
             java.awt.Color legendTextColor,
             int legendSize,
             int legendPos,
             java.util.List<java.lang.String> titles)
Creates a persistent chart.

Parameters:
p - the presentable object owning this chart
ispublic - if true, the chart is visible on container's presentation
x - the x coordinate of the chart
y - the y coordinate of the chart
width - the width of the whole chart
height - the height of the whole chart
fillColor - the background color of the whole chart
lineColor - the line border color of the whole chart
picOffsetX - the x offset of the picture from the top left corner of the picture area
picOffsetY - the y offset of the picture from the top left corner of the picture area
picWidth - the width of the picture
picHeight - the height of the picture
picBackgoundColor - the background color of the picture, null for none (transparent)
picBorderColor - the border color of the picture, null for no border
legendTextColor - the color of the legend text
legendSize - the size of the legend area: width if legendPos is EAST or WEST, height if NORTH or SOUTH
legendPos - the legend position (NONE, SOUTH, NORTH, EAST, WEST)
titles - the collection of chart item titles, or null

Chart

public Chart(Presentable p,
             int id,
             int index)
Creates a non-persistent chart that will exist only while it is visible.

Parameters:
p - the Presentable object owning this chart
id - the id of the chart
index - the index of the chart (for replicated charts)
Method Detail

refresh

public void refresh()
Causes the chart to refresh its picture and legend based on the current data values and schedules the component repaint. This method needs to be extended in subclasses by doing some work before calling super.refresh()


getCount

public final int getCount()
Returns the number of chart items (data items or data sets) currently displayed by this chart.

Returns:
the number of chart items

get

public final ChartItem get(int i)
Returns the chart item (DataItem, DataSet, Histogram, etc.) with the given index.

Parameters:
i - index of the item
Returns:
the chart item with the given index

getTitle

public final java.lang.String getTitle(int i)
Returns the title of chart item (DataItem, DataSet, Histogram, etc.) with the given index.

Parameters:
i - index of the item
Returns:
the title of the chart item with the given index

remove

public final int remove(ChartItem ci)
Removes the given item (DataItem, DataSet, Histogram, Histogram2DData) from the chart. If the item is not present, does nothing.

Parameters:
ci - the chart item to remove
Returns:
the index of the item

remove

public final void remove(int i)
Removes the item (DataItem, DataSet, Histogram, etc.) with the given index from the chart.

Parameters:
i - the index of item to remove

removeAll

public void removeAll()
Removes all items from the chart.


updateData

public void updateData()
Updates all data items / data sets displayed by this chart. In contrast with update(), this method only updates the data, but does not update the chart visual appearance.


copyToClipboard

public java.lang.String copyToClipboard()
Copies all chart data to the system clipboard in text form.

Returns:
the text representation of all chart data

update

public void update()
Refreshes a (non-persistent) chart on each frame.

Overrides:
update in class ShapeControl

action

public void action()
Does nothing: no actions are associated with charts.

Specified by:
action in class ShapeControl

getJComponent

public javax.swing.JComponent getJComponent()
Returns the embedded JPanel.

Specified by:
getJComponent in class ShapeControl

clone

public final Shape clone()
Cloning of charts is not supported
(Other shapes except GIS and controls allow cloning)
This method throws UnsupportedOperationException if called

Overrides:
clone in class ShapeControl

getSelectedItemIndices

public int[] getSelectedItemIndices()
Returns an array with indices of selected chart items

Returns:
an array with indices of selected chart items

setSelectedItemIndices

public void setSelectedItemIndices(int[] selectedIndices)
Selects only chart items with given indices

Parameters:
selectedIndices - an array with indices of chart items to be selected (other chart items will be deselected)

selectItem

public void selectItem(int itemIndex,
                       boolean selected)
Selects/deselects (depending on selected value) chart item with given index

Parameters:
itemIndex - the index of chart item shown on the chart
selected - whether select this chart item or deselect it

onSelectionChanged

public void onSelectionChanged(int[] selectedIndices,
                               boolean programmatically)
Executes specific action when user clicks on legend and selects/deselects chart item(s).
This method must be overridden for persistent charts they have any on-selection-changed activity.

Parameters:
selectedIndices - the array of currently selected indices (never null; may be empty)
programmatically - defines either selection was changed programmatically (via selectItem(int, boolean) and setSelectedItemIndices(int[])) or by user mouse-click

onItemRemoved

public void onItemRemoved(int removedIndex,
                          boolean programmatically)
Executes specific action when user removes chart item.
This method must be overridden for persistent charts to provide any on-chart-item-removed activity.
If several items are removed simultaneously, the sequence of such actions is executed

Parameters:
removedIndex - the index of removed chart item
programmatically - defines either chart item was removed programmatically (via remove(ChartItem), remove(int) or removeAll()) or by user choice in the chart legend context menu

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

getPopupMenu

public javax.swing.JPopupMenu getPopupMenu()


Copyright © 1991-2008 XJ Technlogies. All Rights Reserved.