prefuse.action.layout
Class AxisLabelLayout

java.lang.Object
  extended by prefuse.activity.Activity
      extended by prefuse.action.Action
          extended by prefuse.action.GroupAction
              extended by prefuse.action.layout.Layout
                  extended by prefuse.action.layout.AxisLabelLayout

public class AxisLabelLayout
extends Layout

Layout Action that positions axis grid lines and labels for a given range model.

Author:
jeffrey heer

Field Summary
static java.lang.String FRAC
           
static java.lang.String LABEL
           
static java.lang.String VALUE
           
 
Fields inherited from class prefuse.action.layout.Layout
m_anchor, m_bounds, m_bpts, m_insets, m_margin, m_tmpa, m_tmpb
 
Fields inherited from class prefuse.action.GroupAction
m_group
 
Fields inherited from class prefuse.action.Action
m_vis
 
Fields inherited from class prefuse.activity.Activity
DEFAULT_STEP_TIME, INFINITY
 
Constructor Summary
AxisLabelLayout(java.lang.String group, AxisLayout layout)
          Create a new AxisLabelLayout layout.
AxisLabelLayout(java.lang.String group, AxisLayout layout, java.awt.geom.Rectangle2D bounds)
          Create a new AxisLabelLayout layout.
AxisLabelLayout(java.lang.String group, AxisLayout layout, java.awt.geom.Rectangle2D bounds, double spacing)
          Create a new AxisLabelLayout layout.
AxisLabelLayout(java.lang.String group, int axis, ValuedRangeModel values)
          Create a new AxisLabelLayout layout.
AxisLabelLayout(java.lang.String group, int axis, ValuedRangeModel values, java.awt.geom.Rectangle2D bounds)
          Create a new AxisLabelLayout layout.
 
Method Summary
protected  double adjust(double v)
          Adjust a value according to the current scale type.
protected  void garbageCollect(VisualTable labels)
          Remove axis labels no longer being used.
protected  double getBreadth(java.awt.geom.Rectangle2D b)
          Get the "breadth" of a rectangle, based on the axis type.
protected  double getLinearStep(double span, double scale)
          Compute a linear step between axis marks.
 java.text.NumberFormat getNumberFormat()
          Get the formatter used to format labels for numerical values.
protected  int getOrdinalStep(double span, double scale)
          Compute an ordinal step between axis marks.
 int getScale()
          Returns the scale type used for the axis.
 double getSpacing()
          Get the required minimum spacing between axis labels.
protected  VisualTable getTable()
          Create a new table for representing axis labels.
 boolean isAscending()
          Indicates if the axis values should be presented in ascending order along the axis.
protected  void linearLayout(VisualTable labels)
          Calculates a quantitative, linearly scaled layout.
protected  void logLayout(VisualTable labels)
          Calculates a quantitative, logarithmically-scaled layout.
protected  void ordinalLayout(VisualTable labels)
          Compute an ordinal layout of axis marks.
protected  void reset(VisualItem item)
          Reset an axis label VisualItem
 void run(double frac)
          Runs this Action, triggering whatever processing this Action performs.
protected  void set(VisualItem item, double xOrY, java.awt.geom.Rectangle2D b)
          Set the layout values for an axis label item.
 void setAscending(boolean asc)
          Sets if the axis values should be presented in ascending order along the axis.
 void setNumberFormat(java.text.NumberFormat nf)
          Set the formatter used to format labels for numerical values.
 void setRangeModel(ValuedRangeModel model)
          Sets the range model used to layout this axis.
 void setScale(int scale)
          Sets the scale type used for the axis.
 void setSpacing(double spacing)
          Set the required minimum spacing between axis labels.
protected  void sqrtLayout(VisualTable labels)
          Calculates a quantitative, square root scaled layout.
 
Methods inherited from class prefuse.action.layout.Layout
getLayoutAnchor, getLayoutBounds, setLayoutAnchor, setLayoutBounds, setMargin, setX, setY
 
Methods inherited from class prefuse.action.GroupAction
getGroup, setGroup
 
Methods inherited from class prefuse.action.Action
getVisualization, run, setVisualization
 
Methods inherited from class prefuse.activity.Activity
addActivityListener, alwaysRunAfter, cancel, fireActivityCancelled, fireActivityFinished, fireActivityScheduled, fireActivityStarted, fireActivityStepped, getDuration, getNextTime, getPace, getPacingFunction, getStartTime, getStepTime, getStopTime, isEnabled, isRunning, isScheduled, removeActivityListener, run, runAfter, runAt, setDuration, setEnabled, setPacingFunction, setStartTime, setStepTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FRAC

public static final java.lang.String FRAC
See Also:
Constant Field Values

LABEL

public static final java.lang.String LABEL
See Also:
Constant Field Values

VALUE

public static final java.lang.String VALUE
See Also:
Constant Field Values
Constructor Detail

AxisLabelLayout

public AxisLabelLayout(java.lang.String group,
                       int axis,
                       ValuedRangeModel values)
Create a new AxisLabelLayout layout.

Parameters:
group - the data group of the axis lines and labels
axis - the axis type, either Constants.X_AXIS or Constants.Y_AXIS.
values - the range model that defines the span of the axis

AxisLabelLayout

public AxisLabelLayout(java.lang.String group,
                       int axis,
                       ValuedRangeModel values,
                       java.awt.geom.Rectangle2D bounds)
Create a new AxisLabelLayout layout.

Parameters:
group - the data group of the axis lines and labels
axis - the axis type, either Constants.X_AXIS or Constants.Y_AXIS.
values - the range model that defines the span of the axis
bounds - the layout bounds within which to place the axis marks

AxisLabelLayout

public AxisLabelLayout(java.lang.String group,
                       AxisLayout layout)
Create a new AxisLabelLayout layout.

Parameters:
group - the data group of the axis lines and labels
layout - an AxisLayout instance to model this layout after. The axis type and range model of the provided instance will be used.

AxisLabelLayout

public AxisLabelLayout(java.lang.String group,
                       AxisLayout layout,
                       java.awt.geom.Rectangle2D bounds)
Create a new AxisLabelLayout layout.

Parameters:
group - the data group of the axis lines and labels
layout - an AxisLayout instance to model this layout after. The axis type and range model of the provided instance will be used.
bounds - the layout bounds within which to place the axis marks

AxisLabelLayout

public AxisLabelLayout(java.lang.String group,
                       AxisLayout layout,
                       java.awt.geom.Rectangle2D bounds,
                       double spacing)
Create a new AxisLabelLayout layout.

Parameters:
group - the data group of the axis lines and labels
layout - an AxisLayout instance to model this layout after. The axis type and range model of the provided instance will be used.
bounds - the layout bounds within which to place the axis marks
spacing - the minimum spacing between axis labels
Method Detail

getNumberFormat

public java.text.NumberFormat getNumberFormat()
Get the formatter used to format labels for numerical values.

Returns:
the NumberFormat used to format numerical labels.

setNumberFormat

public void setNumberFormat(java.text.NumberFormat nf)
Set the formatter used to format labels for numerical values.

Parameters:
nf - the NumberFormat used to format numerical labels.

getSpacing

public double getSpacing()
Get the required minimum spacing between axis labels.

Returns:
the axis label spacing

setSpacing

public void setSpacing(double spacing)
Set the required minimum spacing between axis labels.

Parameters:
spacing - the axis label spacing to use

getScale

public int getScale()
Returns the scale type used for the axis. This setting only applies for numerical data types (i.e., when axis values are from a NumberValuedRange).

Returns:
the scale type. One of Constants.LINEAR_SCALE, Constants.SQRT_SCALE, or Constants.LOG_SCALE.

setScale

public void setScale(int scale)
Sets the scale type used for the axis. This setting only applies for numerical data types (i.e., when axis values are from a NumberValuedRange).

Parameters:
scale - the scale type. One of Constants.LINEAR_SCALE, Constants.SQRT_SCALE, or Constants.LOG_SCALE.

isAscending

public boolean isAscending()
Indicates if the axis values should be presented in ascending order along the axis.

Returns:
true if data values increase as pixel coordinates increase, false if data values decrease as pixel coordinates increase.

setAscending

public void setAscending(boolean asc)
Sets if the axis values should be presented in ascending order along the axis.

Parameters:
asc - true if data values should increase as pixel coordinates increase, false if data values should decrease as pixel coordinates increase.

setRangeModel

public void setRangeModel(ValuedRangeModel model)
Sets the range model used to layout this axis.

Parameters:
model - the range model

run

public void run(double frac)
Description copied from class: Action
Runs this Action, triggering whatever processing this Action performs. Subclass this method to create custom Actions.

Specified by:
run in class GroupAction
Parameters:
frac - the fraction of this Action's duration that has elapsed.
See Also:
GroupAction.run(double)

linearLayout

protected void linearLayout(VisualTable labels)
Calculates a quantitative, linearly scaled layout.


sqrtLayout

protected void sqrtLayout(VisualTable labels)
Calculates a quantitative, square root scaled layout.


logLayout

protected void logLayout(VisualTable labels)
Calculates a quantitative, logarithmically-scaled layout. TODO: This method is currently not working correctly.


getBreadth

protected double getBreadth(java.awt.geom.Rectangle2D b)
Get the "breadth" of a rectangle, based on the axis type.


adjust

protected double adjust(double v)
Adjust a value according to the current scale type.


getLinearStep

protected double getLinearStep(double span,
                               double scale)
Compute a linear step between axis marks.


ordinalLayout

protected void ordinalLayout(VisualTable labels)
Compute an ordinal layout of axis marks.


getOrdinalStep

protected int getOrdinalStep(double span,
                             double scale)
Compute an ordinal step between axis marks.


set

protected void set(VisualItem item,
                   double xOrY,
                   java.awt.geom.Rectangle2D b)
Set the layout values for an axis label item.


reset

protected void reset(VisualItem item)
Reset an axis label VisualItem


garbageCollect

protected void garbageCollect(VisualTable labels)
Remove axis labels no longer being used.


getTable

protected VisualTable getTable()
Create a new table for representing axis labels.



Copyright © 2007 Regents of the University of California