GeoSoft API

no.geosoft.cc.graphics
Class GComponent

Object
  extended byGPositional
      extended byGComponent

public class GComponent
extends GPositional

An AWT component with position hints for integration in the graphics.

Typical usage:

    // Create an AWT component that should be integrated
    JButton button = new JButton ("Start");
    button.addActionListener (this);

    // Create the GComponent wrapper w/positioning hint
    GComponent gbutton = new GComponent (button, GPosition.TOP);

    // Create the GSegment the component is attached to
    GSegment segment = new GSegment();
    segment.setComponent (gbutton);
 
The component will be positioned in the canvas according to the location of its owner GSegment and th position hint.

Author:
GeoSoft

Constructor Summary
GComponent(Component component)
          Create an AWT component wrapper suitable for integration in the graphics and with default position hints.
GComponent(Component component, int positionHint)
          Create an AWT component wrapper suitable for integration in the graphics.
 
Method Summary
 Component getComponent()
          Return the AWT component of this GComponent.
 int getPositionHint()
          Return position hint of this positional.
 GStyle getStyle()
          Get style of this GText.
 void setPositionHint(int positionHint)
          Set position hint for this positional.
 void setStyle(GStyle style)
          Set new style for this object.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GComponent

public GComponent(Component component,
                  int positionHint)
Create an AWT component wrapper suitable for integration in the graphics.

Parameters:
component - AWT component.
positionHint - Position hints.
See Also:
GPositional.setPositionHint(int), GPosition

GComponent

public GComponent(Component component)
Create an AWT component wrapper suitable for integration in the graphics and with default position hints.

Parameters:
component - AWT component.
Method Detail

getComponent

public Component getComponent()
Return the AWT component of this GComponent.

Returns:
AWT component of this GComponent.

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