GeoSoft API

no.geosoft.cc.graphics
Class GText

Object
  extended byGPositional
      extended byGText

public class GText
extends GPositional

Class for representing text within graphics.

Text is not added directly to coordinates in the canvas, but associated with geometric elements of the scene and positioned through rendering hints. GText objects can have their own style, but will inherit unset style elements from their segment owner.

Typical usage:

    GSegment segment = new GSegment();
    segment.setText (new GText ("Revenue", GPosition.TOP | GPosition.WEST));
 
Note that a text is typically associated with a GSegment at a time where the GSegment is without geometry. The text position is not determined until the rendering step anyway.

Author:
GeoSoft

Constructor Summary
GText()
          Create empty text object with default position hint.
GText(String text)
          Create text object with default position hint.
GText(String text, int positionHint)
          Create text object with specified position hint.
 
Method Summary
 int getPositionHint()
          Return position hint of this positional.
 GStyle getStyle()
          Get style of this GText.
 String getText()
          Return text content of this text element.
 void setPositionHint(int positionHint)
          Set position hint for this positional.
 void setStyle(GStyle style)
          Set new style for this object.
 void setText(String text)
          Set text content of this text element.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GText

public GText(String text,
             int positionHint)
Create text object with specified position hint.

Parameters:
text - Text string to associate with text. Can be null or empty.
positionHint - Position preferences.
See Also:
GPositional.setPositionHint(int)

GText

public GText(String text)
Create text object with default position hint.

Parameters:
text - Text string to associate with text. Can be null or empty.

GText

public GText()
Create empty text object with default position hint.

Method Detail

setText

public void setText(String text)
Set text content of this text element.

Parameters:
text - Text content. Can be null or empty.

getText

public String getText()
Return text content of this text element.

Returns:
Text content of this text element.

setPositionHint

public void setPositionHint(int positionHint)
Set position hint for this positional.

Position hints is a or'ed list of:

Line position hints are interpreted as follows:

If a line position hint is not given, the text is attached to the n'th point of the polyline according to when it was added to the segment, i.e, the first text added is attached to the first coordinate, the second text added is attatched to the second coordinate and so on. This is convenient if there is a text associated with each line vertex.

For the above, the given point becomes the initial approach for positioning. If this initial position is outside the window (and position hint not explicitly set to GPosition.STATIC) the text is moved along the polyline till it becomes fully visible.

If text position hint is GPosition.MIDDLE, the initial position is the center of the polyline bounding box. If this point is not visble the text is not rendered.

At this point an anchor point is found for the text. Now the point positioning text hints are examined:

If a point positioing hint is not given, the defualt is GPosition.CENTER unless line position hint is GPosition.TOP (implying GPosition.NORTH), GPosition.BOTTOM (implying GPosition.SOUTH), GPosition.LEFT (implying GPosition.WEST) or GPosition:RIGHT (implying GPosition.EAST).

Now, if the text in this location overlap an already positioned text, it is further adjusted (unless position hint is not explicitly set to GPosition.STATIC as discussed above). It is again moved along the polyline till a free location is found. If this cannot be acheived, the text is not rendered

Parameters:
positionHint - Position hint for this positional.
See Also:
GPosition

getPositionHint

public int getPositionHint()
Return position hint of this positional.

Returns:
Position hint of this positional.
See Also:
GPositional.setPositionHint(int).

setStyle

public void setStyle(GStyle style)
Set new style for this object. Style elements not explicitly set within this GStyle object are inherited from parent objects. Child objects without explicit set style will inherit from this style object.

Parameters:
style - Style for this object.

getStyle

public GStyle getStyle()
Get style of this GText. This is the style set by setStyle() and not necesserily the style as it appears on screen as unset style elements are inherited from parents.

Returns:
Style of this object.

GeoSoft API

Copyright © 2004 - Geotechnical Software Services     geosoft.no