Class DefaultFlowChartModel
java.lang.Object
com.arbergashi.charts.model.DefaultFlowChartModel
- All Implemented Interfaces:
ChartModel, FlowChartModel
Default implementation for a flow-based chart model.
- Since:
- 2025-06-01
- Version:
- 1.0.0
- Author:
- Arber Gashi
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classNested classes/interfaces inherited from interface ChartModel
ChartModel.ChartModelListenerNested classes/interfaces inherited from interface FlowChartModel
FlowChartModel.Link, FlowChartModel.Node -
Field Summary
Fields inherited from interface ChartModel
EMPTY_DOUBLE -
Constructor Summary
ConstructorsConstructorDescriptionDefaultFlowChartModel(List<DefaultFlowChartModel.DefaultNode> nodes, List<DefaultFlowChartModel.DefaultLink> links) -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a listener for data changes.voidaddPoint(ChartPoint point) voidaddPoints(List<ChartPoint> points) voidclear()getColor()Optional visual color for a series; default is null.List<? extends FlowChartModel.Link> getLinks()Returns the list of all links connecting the nodes.getName()Returns the title of the data series.List<? extends FlowChartModel.Node> getNodes()Returns the list of all nodes in the diagram.intReturns the number of data points.longOptional timestamp for model updates; default 0 for simple models.doublegetX(int index) Returns the X value at the given index.double[]getXData()Direct access to the X-coordinate array.doublegetY(int index) Returns the Y value at the given index.double[]getYData()Direct access to the Y-coordinate array.voidRemoves a listener.voidOptional setter for a visual color; default no-op.voidvoidsetPoints(List<ChartPoint> points) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChartModel
getDataRange, getHighData, getLabel, getLowData, getMax, getMin, getOpenData, getValue, getWeight, getWeightData, getY, isEmpty
-
Constructor Details
-
DefaultFlowChartModel
public DefaultFlowChartModel(List<DefaultFlowChartModel.DefaultNode> nodes, List<DefaultFlowChartModel.DefaultLink> links)
-
-
Method Details
-
getNodes
Description copied from interface:FlowChartModelReturns the list of all nodes in the diagram.- Specified by:
getNodesin interfaceFlowChartModel
-
getLinks
Description copied from interface:FlowChartModelReturns the list of all links connecting the nodes.- Specified by:
getLinksin interfaceFlowChartModel
-
getName
Description copied from interface:ChartModelReturns the title of the data series.- Specified by:
getNamein interfaceChartModel- Returns:
- Name of the series
-
setName
-
getColor
Description copied from interface:ChartModelOptional visual color for a series; default is null.- Specified by:
getColorin interfaceChartModel
-
setColor
Description copied from interface:ChartModelOptional setter for a visual color; default no-op.- Specified by:
setColorin interfaceChartModel
-
getUpdateStamp
public long getUpdateStamp()Description copied from interface:ChartModelOptional timestamp for model updates; default 0 for simple models.- Specified by:
getUpdateStampin interfaceChartModel
-
getPointCount
public int getPointCount()Description copied from interface:ChartModelReturns the number of data points.- Specified by:
getPointCountin interfaceChartModel- Returns:
- count
-
getX
public double getX(int index) Description copied from interface:ChartModelReturns the X value at the given index.- Specified by:
getXin interfaceChartModel- Parameters:
index- data point index- Returns:
- X value or 0.0 if out of range
-
getY
public double getY(int index) Description copied from interface:ChartModelReturns the Y value at the given index.- Specified by:
getYin interfaceChartModel- Parameters:
index- data point index- Returns:
- Y value or 0.0 if out of range
-
addPoint
-
addPoints
-
setPoints
-
clear
public void clear() -
addChangeListener
Description copied from interface:ChartModelRegisters a listener for data changes.- Specified by:
addChangeListenerin interfaceChartModel- Parameters:
listener- The listener
-
removeChangeListener
Description copied from interface:ChartModelRemoves a listener.- Specified by:
removeChangeListenerin interfaceChartModel- Parameters:
listener- The listener
-
getXData
public double[] getXData()Description copied from interface:ChartModelDirect access to the X-coordinate array.Framework contract: Implementations may return either:
- a defensive copy sized to
ChartModel.getPointCount()(safe, but potentially slower), or - a backing array with a capacity larger than
ChartModel.getPointCount()(fast, zero-allocation).
Consumers must never assume
getXData().length == getPointCount(). Always bound iteration by the logical size:int n = Math.min(model.getPointCount(), model.getXData().length);
Performance note: If you need strict size and immutability semantics, use a model implementation that returns copies (e.g.
DefaultChartModel).- Specified by:
getXDatain interfaceChartModel- Returns:
- X values array (may be larger than logical size)
- a defensive copy sized to
-
getYData
public double[] getYData()Description copied from interface:ChartModelDirect access to the Y-coordinate array.Warning: For performance reasons, the internal array is often returned. Do not modify!
- Specified by:
getYDatain interfaceChartModel- Returns:
- double array of Y values
-