lt.monarch.chart.chart2D.axis.layouters
Class SimpleLinearLabelLayouter

java.lang.Object
  extended by lt.monarch.chart.chart2D.axis.layouters.SimpleLinearLabelLayouter
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, LinearLabelLayouter
Direct Known Subclasses:
DefaultLinearLabelLayouter

public class SimpleLinearLabelLayouter
extends java.lang.Object
implements LinearLabelLayouter, java.io.Serializable

Eliminates labels, falling outside the visible axis range. Does not handle overlapping labels in any way.

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
protected  boolean calculatePreferredDimensions
          Shows cleanup preferred dimmensions
protected  int levels
          number of label levels
protected  double prefferedHeight
          Preferred height of the labels
protected  double prefferedWidth
          Preferred width of the labels
protected  boolean sparseMode
          specifies whether sparse mode is set to this layouter
protected  double start
          start of the visible range
protected  double stop
          end of the visible range
protected  Area titleArea
          Axis titles
 
Constructor Summary
Constructor and Description
SimpleLinearLabelLayouter()
          Constructs a new SimpleLinearLabelLayouter.
 
Method Summary
Modifier and Type Method and Description
 java.lang.Object clone()
          Returns a copy of the layouter.
protected  int compareLabels(AbstractAxisLabel l1, AbstractAxisLabel l2)
          Compares positions of the specified labels.
 void dispose()
          Disposes layouter
protected  void eliminateOutbound(AbstractAxisLabel[] labels)
          Eliminates labels, falling outside the visible axis range.
protected  int findMaxLevel(AbstractAxisLabel[] labels)
          Finds the maximum level of labels in the specified array.
 int getMaxLevel()
          Returns the maximum level of layouted labels.
 double getPreferredHeight()
          Non-API method. Returns height required to layout labels.
 double getPreferredWidth()
          Non-API method. Returns width required to layout labels.
 void layout(AbstractAxisLabel[] labels)
          Layouts specified labels.
 void prepare(AbstractAxisLabel[] labels)
          Non-API method. Calculates preferred size of all visible labels (maximum size of all labels).
 void setSparseMode(boolean sparseMode)
          Enables sparse mode (true - enabled, false - disabled).
 void setTitleArea(Area title)
          Adds title area
 void setVisibleRange(double start, double stop)
          Sets the visible range for the layouter.
protected  void sort(AbstractAxisLabel[] labels)
          Sorts the labels
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

start

protected double start
start of the visible range


stop

protected double stop
end of the visible range


levels

protected int levels
number of label levels


titleArea

protected Area titleArea
Axis titles


sparseMode

protected boolean sparseMode
specifies whether sparse mode is set to this layouter


prefferedHeight

protected double prefferedHeight
Preferred height of the labels


prefferedWidth

protected double prefferedWidth
Preferred width of the labels


calculatePreferredDimensions

protected boolean calculatePreferredDimensions
Shows cleanup preferred dimmensions

Constructor Detail

SimpleLinearLabelLayouter

public SimpleLinearLabelLayouter()
Constructs a new SimpleLinearLabelLayouter. The value of levels is set to Integer.MAX_VALUE.

Method Detail

setTitleArea

public void setTitleArea(Area title)
Adds title area

Specified by:
setTitleArea in interface LinearLabelLayouter
Parameters:
title - title area

clone

public java.lang.Object clone()
Returns a copy of the layouter.

Specified by:
clone in interface LinearLabelLayouter
Overrides:
clone in class java.lang.Object
Returns:
copy of the layouter

setVisibleRange

public void setVisibleRange(double start,
                            double stop)
Sets the visible range for the layouter. All labels falling outside the range will be eliminated.

Specified by:
setVisibleRange in interface LinearLabelLayouter
Parameters:
start - the start of the range
stop - the end of the range

setSparseMode

public void setSparseMode(boolean sparseMode)
Enables sparse mode (true - enabled, false - disabled).

Specified by:
setSparseMode in interface LinearLabelLayouter
Parameters:
sparseMode - enable sparse mode permit

getMaxLevel

public int getMaxLevel()
Returns the maximum level of layouted labels.

Specified by:
getMaxLevel in interface LinearLabelLayouter
Returns:
maximum level of layouted labels

findMaxLevel

protected int findMaxLevel(AbstractAxisLabel[] labels)
Finds the maximum level of labels in the specified array.

Parameters:
labels - the labels array
Returns:
the maximum level of specified labels

layout

public void layout(AbstractAxisLabel[] labels)
Layouts specified labels. Eliminates labels, falling outside the visible axis range. Eliminated labels are set to null.

Specified by:
layout in interface LinearLabelLayouter
Parameters:
labels - labels to layout

eliminateOutbound

protected void eliminateOutbound(AbstractAxisLabel[] labels)
Eliminates labels, falling outside the visible axis range.

Parameters:
labels - labels to layout

sort

protected void sort(AbstractAxisLabel[] labels)
Sorts the labels

Parameters:
labels - AxisLabel array

compareLabels

protected int compareLabels(AbstractAxisLabel l1,
                            AbstractAxisLabel l2)
Compares positions of the specified labels.

Parameters:
l1 - the first label to compare
l2 - the second label to compare
Returns:
negative integer if position of l1 is less than position of l2; 0 if positions of these labels are equal; positive integer if position position of l1 is greater than position of l2.

dispose

public void dispose()
Description copied from interface: LinearLabelLayouter
Disposes layouter

Specified by:
dispose in interface LinearLabelLayouter

prepare

public void prepare(AbstractAxisLabel[] labels)
Description copied from interface: LinearLabelLayouter
Non-API method. Calculates preferred size of all visible labels (maximum size of all labels).

Specified by:
prepare in interface LinearLabelLayouter
Parameters:
labels - label array

getPreferredHeight

public double getPreferredHeight()
Description copied from interface: LinearLabelLayouter
Non-API method. Returns height required to layout labels. Value is valid after the prepare(AbstractAxisLabel[] labels) or layout(AbstractAxisLabel[] labels) method is already called.

Specified by:
getPreferredHeight in interface LinearLabelLayouter
Returns:
height of layout

getPreferredWidth

public double getPreferredWidth()
Description copied from interface: LinearLabelLayouter
Non-API method. Returns width required to layout labels. Value is valid after the prepare(AbstractAxisLabel[] labels) or layout(AbstractAxisLabel[] labels) method is already called.

Specified by:
getPreferredWidth in interface LinearLabelLayouter
Returns:
height of layout