org.eclipse.birt.chart.computation
Class LabelLimiter

java.lang.Object
  extended by org.eclipse.birt.chart.computation.LabelLimiter

public class LabelLimiter
extends java.lang.Object

Helper class to limit the size of a label by wrapping its text or shorten its text with ellipsis.


Nested Class Summary
static class LabelLimiter.Option
          Options used by method limitLabelSize.
 
Constructor Summary
LabelLimiter(double maxWidth, double maxHeight, double wrapping)
          Constructor
 
Method Summary
 double computeWrapping(IDisplayServer xs, Label la)
           
static double computeWrapping(IDisplayServer xs, Label la, LabelLimiter lbLimit)
          Compute the wrapping with maxWidth, maxHeight.
 BoundingBox getBounding(BoundingBox bb)
          Returns a bounding box using maxWidth and maxHeight
 double getMaxHeight()
           
 double getMaxWidth()
           
 double getWrapping()
           
 boolean isSuccessed()
           
 LabelLimiter limitLabelSize(IChartComputation cComp, IDisplayServer xs, Label la)
          modify the text of la to fit the limit size.
 LabelLimiter limitLabelSize(IChartComputation cComp, IDisplayServer xs, Label la, java.util.EnumSet<LabelLimiter.Option> options)
          modify the text of la to fit the limit size.
static LabelLimiter limitLabelSize(IChartComputation cComp, IDisplayServer xs, Label la, LabelLimiter lbLimit, java.util.EnumSet<LabelLimiter.Option> options)
          To compute the text of the label with a limited size, the label text will be wrapped and shortened with ellipsis if required, the size of the label bound will be returned.
 void setMaxHeight(double maxHeight)
           
 void setMaxWidth(double maxWidth)
           
 void setWrapping(double wrapping)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelLimiter

public LabelLimiter(double maxWidth,
                    double maxHeight,
                    double wrapping)
Constructor

Parameters:
maxWidth -
maxHeight -
wrapping -
Method Detail

computeWrapping

public double computeWrapping(IDisplayServer xs,
                              Label la)

getBounding

public BoundingBox getBounding(BoundingBox bb)
Returns a bounding box using maxWidth and maxHeight

Parameters:
bb - will be updated and returned if not null, otherwise a new bounding box will be created.
Returns:

computeWrapping

public static final double computeWrapping(IDisplayServer xs,
                                           Label la,
                                           LabelLimiter lbLimit)
Compute the wrapping with maxWidth, maxHeight. If the wrapping is set to 0, namely auto, this method should be called before calling limitLabelSize.

Parameters:
xs -
la -
lbLimit -
Returns:

limitLabelSize

public LabelLimiter limitLabelSize(IChartComputation cComp,
                                   IDisplayServer xs,
                                   Label la)
                            throws ChartException
modify the text of la to fit the limit size.

Parameters:
xs -
la -
Returns:
Throws:
ChartException

limitLabelSize

public LabelLimiter limitLabelSize(IChartComputation cComp,
                                   IDisplayServer xs,
                                   Label la,
                                   java.util.EnumSet<LabelLimiter.Option> options)
                            throws ChartException
modify the text of la to fit the limit size.

Parameters:
xs -
la -
options -
Returns:
Throws:
ChartException

limitLabelSize

public static final LabelLimiter limitLabelSize(IChartComputation cComp,
                                                IDisplayServer xs,
                                                Label la,
                                                LabelLimiter lbLimit,
                                                java.util.EnumSet<LabelLimiter.Option> options)
                                         throws ChartException
To compute the text of the label with a limited size, the label text will be wrapped and shortened with ellipsis if required, the size of the label bound will be returned.

Parameters:
xs -
la -
maxSize -
lbLimit -
options -
Returns:
Throws:
ChartException

getMaxWidth

public final double getMaxWidth()
Returns:
Returns the maxWidth.

setMaxWidth

public final void setMaxWidth(double maxWidth)
Parameters:
maxWidth - The maxWidth to set.

getMaxHeight

public final double getMaxHeight()
Returns:
Returns the maxHeight.

setMaxHeight

public final void setMaxHeight(double maxHeight)
Parameters:
maxHeight - The maxHeight to set.

getWrapping

public final double getWrapping()
Returns:
Returns the wrapping.

setWrapping

public final void setWrapping(double wrapping)
Parameters:
wrapping - The wrapping to set.

isSuccessed

public final boolean isSuccessed()
Returns:
Returns the bSuccessed.


Copyright © 2005-2008 Actuate Corp. All rights reserved.