com.ijchart.xychart.render.noaxis.pie
Class PieLabelDistributor

java.lang.Object
  extended by com.ijchart.xychart.render.noaxis.pie.PieLabelDistributor
All Implemented Interfaces:
java.io.Serializable

public class PieLabelDistributor
extends java.lang.Object
implements java.io.Serializable

Title: IJChart

Description: a chart library for the Java(tm) platform.

This class distributes the section labels for one side of a pie chart so that they do not overlap.

Copyright: Copyright (c) 2013

Company:

Version:
1.0
Author:
zhang feng min,shanghai china. Contract me by email.
See Also:
Serialized Form

Constructor Summary
PieLabelDistributor()
           Creates a new distributor.
 
Method Summary
 void addPieLabelRecord(PieLabelRecord record)
           Adds a label record.
protected  void adjustDownwards(double minY, double height)
           Any labels that are overlapping are moved down in an attempt to eliminate the overlaps.
protected  void adjustInwards()
           Adjusts the y-coordinate for the labels in towards the center in an attempt to fix overlapping.
protected  void adjustUpwards(double minY, double height)
           Any labels that are overlapping are moved up in an attempt to eliminate the overlaps.
 void clear()
           Clears the list of labels.
 void distributeLabels(double minY, double height)
           Distributes the labels.
 int getItemCount()
           Returns the number of items in the list.
 PieLabelRecord getPieLabelRecord(int index)
           Returns a label record from the list.
 void sort()
           Sorts the label records into ascending order by y-value.
protected  void spreadEvenly(double minY, double height)
           Labels are spaced evenly in the available space in an attempt to eliminate the overlaps..
 java.lang.String toString()
           Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PieLabelDistributor

public PieLabelDistributor()
Creates a new distributor.

Method Detail

getPieLabelRecord

public PieLabelRecord getPieLabelRecord(int index)
Returns a label record from the list.

Parameters:
index - The index.
Returns:
The PieLabelRecord (maybe null).

addPieLabelRecord

public void addPieLabelRecord(PieLabelRecord record)
Adds a label record.

Parameters:
record - The label record (null not permitted).

getItemCount

public int getItemCount()
Returns the number of items in the list.

Returns:
The item count.

clear

public void clear()
Clears the list of labels.


distributeLabels

public void distributeLabels(double minY,
                             double height)
Distributes the labels.

Parameters:
minY - the minimum y-coordinate in Java2D-space.
height - The available height (in Java2D units).

adjustInwards

protected void adjustInwards()
Adjusts the y-coordinate for the labels in towards the center in an attempt to fix overlapping.


adjustDownwards

protected void adjustDownwards(double minY,
                               double height)
Any labels that are overlapping are moved down in an attempt to eliminate the overlaps.

Parameters:
minY - The minimum y value.
height - The height available for all labels.

adjustUpwards

protected void adjustUpwards(double minY,
                             double height)
Any labels that are overlapping are moved up in an attempt to eliminate the overlaps.

Parameters:
minY - The minimum y value.
height - The height available for all labels.

spreadEvenly

protected void spreadEvenly(double minY,
                            double height)
Labels are spaced evenly in the available space in an attempt to eliminate the overlaps..

Parameters:
minY - The minimum y value.
height - The height available for all labels.

sort

public void sort()
Sorts the label records into ascending order by y-value.


toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.