Class FlowPlot

    • Field Detail

      • dataset

        private FlowDataset dataset
        The source of data.
      • nodeWidth

        private double nodeWidth
        The node width in Java 2D user-space units.
      • nodeMargin

        private double nodeMargin
        The gap between nodes (expressed as a percentage of the plot height).
      • flowMargin

        private double flowMargin
        The percentage of the plot width to assign to a gap between the nodes and the flow representation.
      • nodeColorMap

        private java.util.Map<NodeKey,​java.awt.Color> nodeColorMap
        Stores colors for specific nodes - if there isn't a color in here for the node, the default node color will be used (unless the color swatch is active).
      • nodeColorSwatch

        private java.util.List<java.awt.Color> nodeColorSwatch
      • nodeColorSwatchPointer

        private int nodeColorSwatchPointer
        A pointer into the color swatch.
      • defaultNodeColor

        private java.awt.Color defaultNodeColor
        The default node color if nothing is defined in the nodeColorMap.
      • defaultNodeLabelFont

        private java.awt.Font defaultNodeLabelFont
      • defaultNodeLabelPaint

        private java.awt.Paint defaultNodeLabelPaint
      • nodeLabelOffsetX

        private double nodeLabelOffsetX
        The x-offset for node labels.
      • nodeLabelOffsetY

        private double nodeLabelOffsetY
        The y-offset for node labels.
      • toolTipGenerator

        private FlowLabelGenerator toolTipGenerator
        The tool tip generator - if null, no tool tips will be displayed.
    • Constructor Detail

      • FlowPlot

        public FlowPlot​(FlowDataset dataset)
        Creates a new instance that will source data from the specified dataset.
        Parameters:
        dataset - the dataset.
    • Method Detail

      • getPlotType

        public java.lang.String getPlotType()
        Returns a string identifying the plot type.
        Specified by:
        getPlotType in class Plot
        Returns:
        A string identifying the plot type.
      • getDataset

        public FlowDataset getDataset()
        Returns a reference to the dataset.
        Returns:
        A reference to the dataset (possibly null).
      • setDataset

        public void setDataset​(FlowDataset dataset)
        Sets the dataset for the plot and sends a change notification to all registered listeners.
        Parameters:
        dataset - the dataset (null permitted).
      • getNodeMargin

        public double getNodeMargin()
        Returns the node margin (expressed as a percentage of the available plotting space) which is the gap between nodes (sources or destinations). The initial (default) value is 0.01 (1 percent).
        Returns:
        The node margin.
      • setNodeMargin

        public void setNodeMargin​(double margin)
        Sets the node margin and sends a change notification to all registered listeners.
        Parameters:
        margin - the margin (expressed as a percentage).
      • getFlowMargin

        public double getFlowMargin()
        Returns the flow margin. This determines the gap between the graphic representation of the nodes (sources and destinations) and the curved flow representation. This is expressed as a percentage of the plot width so that it remains proportional as the plot is resized. The initial (default) value is 0.005 (0.5 percent).
        Returns:
        The flow margin.
      • setFlowMargin

        public void setFlowMargin​(double margin)
        Sets the flow margin and sends a change notification to all registered listeners.
        Parameters:
        margin - the margin (must be 0.0 or higher).
      • getNodeWidth

        public double getNodeWidth()
        Returns the width of the source and destination nodes, expressed in Java2D user-space units. The initial (default) value is 20.0.
        Returns:
        The width.
      • setNodeWidth

        public void setNodeWidth​(double width)
        Sets the width for the source and destination nodes and sends a change notification to all registered listeners.
        Parameters:
        width - the width.
      • getNodeColorSwatch

        public java.util.List<java.awt.Color> getNodeColorSwatch()
        Returns the list of colors that will be used to auto-populate the node colors when they are first rendered. If the list is empty, no color will be assigned to the node so, unless it is manually set, the default color will apply. This method returns a copy of the list, modifying the returned list will not affect the plot.
        Returns:
        The list of colors (possibly empty, but never null).
      • setNodeColorSwatch

        public void setNodeColorSwatch​(java.util.List<java.awt.Color> colors)
        Sets the color swatch for the plot.
        Parameters:
        colors - the list of colors (null not permitted).
      • getNodeFillColor

        public java.awt.Color getNodeFillColor​(NodeKey nodeKey)
        Returns the fill color for the specified node.
        Parameters:
        nodeKey - the node key (null not permitted).
        Returns:
        The fill color (possibly null).
      • setNodeFillColor

        public void setNodeFillColor​(NodeKey nodeKey,
                                     java.awt.Color color)
        Sets the fill color for the specified node and sends a change notification to all registered listeners.
        Parameters:
        nodeKey - the node key (null not permitted).
        color - the fill color (null permitted).
      • getDefaultNodeColor

        public java.awt.Color getDefaultNodeColor()
        Returns the default node color. This is used when no specific node color has been specified. The initial (default) value is Color.GRAY.
        Returns:
        The default node color (never null).
      • setDefaultNodeColor

        public void setDefaultNodeColor​(java.awt.Color color)
        Sets the default node color and sends a change event to registered listeners.
        Parameters:
        color - the color (null not permitted).
      • getDefaultNodeLabelFont

        public java.awt.Font getDefaultNodeLabelFont()
        Returns the default font used to display labels for the source and destination nodes. The initial (default) value is Font(Font.DIALOG, Font.BOLD, 12).
        Returns:
        The default font (never null).
      • setDefaultNodeLabelFont

        public void setDefaultNodeLabelFont​(java.awt.Font font)
        Sets the default font used to display labels for the source and destination nodes and sends a change notification to all registered listeners.
        Parameters:
        font - the font (null not permitted).
      • getDefaultNodeLabelPaint

        public java.awt.Paint getDefaultNodeLabelPaint()
        Returns the default paint used to display labels for the source and destination nodes. The initial (default) value is Color.BLACK.
        Returns:
        The default paint (never null).
      • setDefaultNodeLabelPaint

        public void setDefaultNodeLabelPaint​(java.awt.Paint paint)
        Sets the default paint used to display labels for the source and destination nodes and sends a change notification to all registered listeners.
        Parameters:
        paint - the paint (null not permitted).
      • getNodeLabelAlignment

        public VerticalAlignment getNodeLabelAlignment()
        Returns the vertical alignment of the node labels relative to the node. The initial (default) value is VerticalAlignment.CENTER.
        Returns:
        The alignment (never null).
      • setNodeLabelAlignment

        public void setNodeLabelAlignment​(VerticalAlignment alignment)
        Sets the vertical alignment of the node labels and sends a change notification to all registered listeners.
        Parameters:
        alignment - the new alignment (null not permitted).
      • getNodeLabelOffsetX

        public double getNodeLabelOffsetX()
        Returns the x-offset for the node labels.
        Returns:
        The x-offset for the node labels.
      • setNodeLabelOffsetX

        public void setNodeLabelOffsetX​(double offsetX)
        Sets the x-offset for the node labels and sends a change notification to all registered listeners.
        Parameters:
        offsetX - the node label x-offset in Java2D units.
      • getNodeLabelOffsetY

        public double getNodeLabelOffsetY()
        Returns the y-offset for the node labels.
        Returns:
        The y-offset for the node labels.
      • setNodeLabelOffsetY

        public void setNodeLabelOffsetY​(double offsetY)
        Sets the y-offset for the node labels and sends a change notification to all registered listeners.
        Parameters:
        offsetY - the node label y-offset in Java2D units.
      • getToolTipGenerator

        public FlowLabelGenerator getToolTipGenerator()
        Returns the tool tip generator that creates the strings that are displayed as tool tips for the flows displayed in the plot.
        Returns:
        The tool tip generator (possibly null).
      • setToolTipGenerator

        public void setToolTipGenerator​(FlowLabelGenerator generator)
        Sets the tool tip generator and sends a change notification to all registered listeners. If the generator is set to null, no tool tips will be displayed for the flows.
        Parameters:
        generator - the new generator (null permitted).
      • draw

        public void draw​(java.awt.Graphics2D g2,
                         java.awt.geom.Rectangle2D area,
                         java.awt.geom.Point2D anchor,
                         PlotState parentState,
                         PlotRenderingInfo info)
        Draws the flow plot within the specified area of the supplied graphics target g2.
        Specified by:
        draw in class Plot
        Parameters:
        g2 - the graphics target (null not permitted).
        area - the plot area (null not permitted).
        anchor - the anchor point (ignored).
        parentState - the parent state (ignored).
        info - the plot rendering info.
      • lookupNodeColor

        protected java.awt.Color lookupNodeColor​(NodeKey nodeKey)
        Performs a lookup on the color for the specified node.
        Parameters:
        nodeKey - the node key (null not permitted).
        Returns:
        The node color.
      • labelY

        private double labelY​(java.awt.geom.Rectangle2D r)
        Computes the y-coordinate for a node label taking into account the current alignment settings.
        Parameters:
        r - the node rectangle.
        Returns:
        The y-coordinate for the label.
      • equals

        public boolean equals​(java.lang.Object obj)
        Tests this plot for equality with an arbitrary object. Note that, for the purposes of this equality test, the dataset is ignored.
        Overrides:
        equals in class Plot
        Parameters:
        obj - the object (null permitted).
        Returns:
        A boolean.
      • hashCode

        public int hashCode()
        Returns a hashcode for this instance.
        Overrides:
        hashCode in class Plot
        Returns:
        A hashcode.
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Returns an independent copy of this FlowPlot instance (note, however, that the dataset is NOT cloned).
        Specified by:
        clone in interface PublicCloneable
        Overrides:
        clone in class Plot
        Returns:
        A close of this instance.
        Throws:
        java.lang.CloneNotSupportedException