lt.monarch.chart.marker
Class LabeledMarker

java.lang.Object
  extended by lt.monarch.chart.marker.AbstractMarker
      extended by lt.monarch.chart.marker.AbstractTextMarker
          extended by lt.monarch.chart.marker.LabeledMarker
All Implemented Interfaces:
java.io.Serializable, Marker, StyleEditorEntity
Direct Known Subclasses:
MiddleLineMarker

public class LabeledMarker
extends AbstractTextMarker

Renders a text label of the associated entity above the marker point. To change connector color set default foreground in PaintStyle. To change label area fill set label background in PaintStyle. To change label area outline set label foreground in PaintStyle.

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
protected  Alignment horizontalLabelAlignment
           
protected  Rectangle2D labelBounds
          Label bounds
protected  Marker nestedMarker
          the nested marker
protected  int offsetX
           
protected  int offsetY
           
protected  boolean useLabelAlignWithOffset
           
protected  Alignment verticalLabelAlignment
           
 
Fields inherited from class lt.monarch.chart.marker.AbstractTextMarker
chart, defaultBackground, painter, textStyle
 
Fields inherited from class lt.monarch.chart.marker.AbstractMarker
dirty, map, metaModel, paintStyle, projectedLocation, style
 
Constructor Summary
Constructor and Description
LabeledMarker(Marker marker, MetaDataModel metaModel)
          Constructs a new LabeledMarker with the specified nested marker.
LabeledMarker(MetaDataModel metaModel)
          Constructs a new LabeledMarker.
 
Method Summary
Modifier and Type Method and Description
 void applyConstraints(MarkerConstraints[] mc, AbstractGraphics g, Projector projector)
          Apply marker constraints
 void dispose()
          Disposes object
 void draw(AbstractGraphics g, SeriesPaintTags tag, Style style)
          Renders the marker on the Graphics context.
protected  void drawConnectionLine(AbstractGraphics g)
          Renders marker connection line.
protected  void drawMarkerText(AbstractGraphics g, Style style)
          Renders marker text.
protected  void drawNestedMarker(AbstractGraphics g, SeriesPaintTags tag, Style style)
          Renders nested marker.
 Rectangle2D getBounds()
          Gets bounds of this marker.
 java.awt.Color getConnectionColor()
          Returns color of line that connect marker and label bounds.
 Alignment getHorizontalLabelAlignment()
          Returns horizontal alignment of label.
 Rectangle2D getLabelBounds()
          Returns bounds of this marker tip.
 Marker getNestedMarker()
          Gets nested marker.
 Alignment getVerticalLabelAlignment()
          Returns vertical alignment of label.
 void prepare(AbstractGraphics g)
          Prepares the marker for drawing.
 void reset()
          Resets the marker after use.
 void setConnectionColor(java.awt.Color color)
          Sets color of line that connects marker and label bounds.
 void setEntity(ChartEntity entity)
          References the entity object, for which the marker is being painted.
 void setLabelAlignment(Alignment hAlign, Alignment vAlign)
          Sets label alignment.
 void setLocation(Projector projector, GeneralPoint npt)
          Sets location of the marker.
 void setOffset(int offsetX, int offsetY)
          Sets horizontal and vertical offsets for this marker.
protected  void setText(java.lang.String text)
          Sets text to paint
 void setTextAlignment(Alignment hAlign, Alignment vAlign)
          Sets text alignment in label.
 
Methods inherited from class lt.monarch.chart.marker.AbstractTextMarker
getPainter, getParent, getStyle, getTextStyle, isAdjustingForNonFittingBars, setAdjustingForNonFittingBars
 
Methods inherited from class lt.monarch.chart.marker.AbstractMarker
clearChartObjectsMap, draw, finalize, getChartObjectBounds, getMetaModel, getPaintStyle, getTransparencyValue, isVisible, mapChartObject, setChartObjectsMap, setMetaModel, setTransparencyValue, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nestedMarker

protected Marker nestedMarker
the nested marker


labelBounds

protected Rectangle2D labelBounds
Label bounds


offsetX

protected int offsetX

offsetY

protected int offsetY

useLabelAlignWithOffset

protected boolean useLabelAlignWithOffset

verticalLabelAlignment

protected Alignment verticalLabelAlignment

horizontalLabelAlignment

protected Alignment horizontalLabelAlignment
Constructor Detail

LabeledMarker

public LabeledMarker(MetaDataModel metaModel)
Constructs a new LabeledMarker. A new NullMarker is used as nested marker.

Parameters:
metaModel - meta data model

LabeledMarker

public LabeledMarker(Marker marker,
                     MetaDataModel metaModel)
Constructs a new LabeledMarker with the specified nested marker.

Parameters:
marker - the nested marker
metaModel - meta data model
Method Detail

setTextAlignment

public void setTextAlignment(Alignment hAlign,
                             Alignment vAlign)
Sets text alignment in label.

Specified by:
setTextAlignment in interface Marker
Overrides:
setTextAlignment in class AbstractMarker
Parameters:
hAlign - horizontal alignment. Possible alignments: Alignment.CENTER, Alignment.LEFT, Alignment.RIGHT
vAlign - vertical alignment. Possible alignments: Alignment.CENTER, Alignment.TOP, Alignment.BOTTOM
See Also:
TextPainter

setEntity

public void setEntity(ChartEntity entity)
References the entity object, for which the marker is being painted. Short description of the entity is used to create label.

Specified by:
setEntity in interface Marker
Overrides:
setEntity in class AbstractMarker
Parameters:
entity - the referenced chart entity

setText

protected void setText(java.lang.String text)
Sets text to paint

Parameters:
text - text to paint

setLocation

public void setLocation(Projector projector,
                        GeneralPoint npt)
Sets location of the marker.

Specified by:
setLocation in interface Marker
Overrides:
setLocation in class AbstractMarker
Parameters:
projector - projector used to project the normalized point
npt - normalized point that specifies marker position

reset

public void reset()
Resets the marker after use.

Specified by:
reset in interface Marker
Overrides:
reset in class AbstractMarker

prepare

public void prepare(AbstractGraphics g)
Prepares the marker for drawing.

Specified by:
prepare in interface Marker
Overrides:
prepare in class AbstractMarker
Parameters:
g - graphics context

getBounds

public Rectangle2D getBounds()
Gets bounds of this marker.

Returns:
A rectangle indicating this marker's bounds.

getLabelBounds

public Rectangle2D getLabelBounds()
Returns bounds of this marker tip.

Returns:
A rectangle indicating this marker's tip bounds.

draw

public void draw(AbstractGraphics g,
                 SeriesPaintTags tag,
                 Style style)
Description copied from interface: Marker
Renders the marker on the Graphics context. Uses style colors.

Parameters:
g - graphics context
tag - painting tag
style - drawing style

drawConnectionLine

protected void drawConnectionLine(AbstractGraphics g)
Renders marker connection line.

Parameters:
g - graphics context

drawNestedMarker

protected void drawNestedMarker(AbstractGraphics g,
                                SeriesPaintTags tag,
                                Style style)
Renders nested marker.

Parameters:
g - graphics context
tag - painting tag
style - drawing style

drawMarkerText

protected void drawMarkerText(AbstractGraphics g,
                              Style style)
Renders marker text.

Parameters:
g - graphics context
style - drawing style

setOffset

public void setOffset(int offsetX,
                      int offsetY)
Sets horizontal and vertical offsets for this marker. The offset is made from position of the marker.

Parameters:
offsetX - the horizontal offset
offsetY - the vertical offset

getNestedMarker

public Marker getNestedMarker()
Gets nested marker.

Returns:
the nested marker

dispose

public void dispose()
Disposes object

Specified by:
dispose in interface Marker
Overrides:
dispose in class AbstractMarker

setConnectionColor

public void setConnectionColor(java.awt.Color color)
Sets color of line that connects marker and label bounds.

Parameters:
color - Color of connecting line

getConnectionColor

public java.awt.Color getConnectionColor()
Returns color of line that connect marker and label bounds.

Returns:
Color of connecting line

getVerticalLabelAlignment

public Alignment getVerticalLabelAlignment()
Returns vertical alignment of label.

Returns:

getHorizontalLabelAlignment

public Alignment getHorizontalLabelAlignment()
Returns horizontal alignment of label.

Returns:

setLabelAlignment

public void setLabelAlignment(Alignment hAlign,
                              Alignment vAlign)
Sets label alignment.

Parameters:
hAlign - horizontal alignment. Possible alignments: Alignment.CENTER, Alignment.LEFT, Alignment.RIGHT
vAlign - vertical alignment. Possible alignments: Alignment.CENTER, Alignment.TOP, Alignment.BOTTOM

applyConstraints

public void applyConstraints(MarkerConstraints[] mc,
                             AbstractGraphics g,
                             Projector projector)
Apply marker constraints

Overrides:
applyConstraints in class AbstractTextMarker
Parameters:
mc - marker constraints
g - graphics
projector - projector