Class FlowPlot

    • 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 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 List<ColorgetNodeColorSwatch()
        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​(List<Color> colors)
        Sets the color swatch for the plot.
        Parameters:
        colors - the list of colors (null not permitted).
      • getNodeFillColor

        public 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,
                                     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 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​(Color color)
        Sets the default node color and sends a change event to registered listeners.
        Parameters:
        color - the color (null not permitted).
      • getDefaultNodeLabelFont

        public 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​(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 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​(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).
      • 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​(Graphics2D g2,
                         Rectangle2D area,
                         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 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.
      • equals

        public boolean equals​(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 Object
        Returns:
        A hashcode.