GeoSoft API

no.geosoft.cc.graphics
Class GImage

Object
  extended byGPositional
      extended byGImage

public class GImage
extends GPositional

Wrapper object for images used with GSegments. A GImage represent both predefined images as well as client specified images.

Typical usage:

    GImage image = new GImage (new File (imageFileName),
                               GPosition.SOUTHEAST);
    GSegment anchor = new GSegment();
    anchor.setImage (image);
 

 Images can also be associated with every vertex of a polyline.
 If using one of the predefined images, a typical usage will be:

 
    GImage image = new GImage (SYMBOL_CIRCLE1);
    GSegment segment = new GSegment();
    segment.setVertexImage (image);
 

Author:
GeoSoft

Field Summary
static int SYMBOL_CIRCLE1
           
static int SYMBOL_CIRCLE2
           
static int SYMBOL_CIRCLE3
           
static int SYMBOL_CIRCLE4
           
static int SYMBOL_SQUARE1
           
static int SYMBOL_SQUARE2
           
static int SYMBOL_SQUARE3
           
static int SYMBOL_SQUARE4
           
 
Constructor Summary
GImage(File file)
          Create an image from a file.
GImage(File file, int positionHint)
          Create an image from a file.
GImage(Image image)
          Create a GImage from an AWT Image.
GImage(Image image, int positionHint)
          Create a GImage from an AWT Image.
GImage(int symbolType)
          Create an image of predefined type and with default position hints.
GImage(int symbolType, int positionHint)
          Create image of a predefined type.
GImage(int width, int height, int[] data)
          Create a image based on specified color data.
GImage(int width, int height, int[] data, int positionHint)
          Create a image based on specified color data.
 
Method Summary
 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
 

Field Detail

SYMBOL_SQUARE1

public static final int SYMBOL_SQUARE1
See Also:
Constant Field Values

SYMBOL_SQUARE2

public static final int SYMBOL_SQUARE2
See Also:
Constant Field Values

SYMBOL_SQUARE3

public static final int SYMBOL_SQUARE3
See Also:
Constant Field Values

SYMBOL_SQUARE4

public static final int SYMBOL_SQUARE4
See Also:
Constant Field Values

SYMBOL_CIRCLE1

public static final int SYMBOL_CIRCLE1
See Also:
Constant Field Values

SYMBOL_CIRCLE2

public static final int SYMBOL_CIRCLE2
See Also:
Constant Field Values

SYMBOL_CIRCLE3

public static final int SYMBOL_CIRCLE3
See Also:
Constant Field Values

SYMBOL_CIRCLE4

public static final int SYMBOL_CIRCLE4
See Also:
Constant Field Values
Constructor Detail

GImage

public GImage(int symbolType,
              int positionHint)
Create image of a predefined type.

Parameters:
symbolType - Symbol to create.
positionHint - Position hint.
See Also:
GPositional.setPositionHint(int)

GImage

public GImage(int symbolType)
Create an image of predefined type and with default position hints.

Parameters:
symbolType - Predefined symbol type.

GImage

public GImage(int width,
              int height,
              int[] data,
              int positionHint)
Create a image based on specified color data.

Parameters:
width - Width of image.
height - Height of image.
data - Color values for image.
positionHint - Position hint.
See Also:
GPositional.setPositionHint(int)

GImage

public GImage(int width,
              int height,
              int[] data)
Create a image based on specified color data. Use defult position hints.

Parameters:
width - Width of image.
height - Height of image.
data - Color values for image.

GImage

public GImage(Image image,
              int positionHint)
Create a GImage from an AWT Image.

Parameters:
image - Image.
positionHint - Position hint.
See Also:
GPositional.setPositionHint(int)

GImage

public GImage(Image image)
Create a GImage from an AWT Image. Use default position hints.

Parameters:
image - Image.

GImage

public GImage(File file,
              int positionHint)
Create an image from a file. The following formats are supported:
  • BMP
  • FPX
  • GIF
  • JPEG
  • PNG
  • PNM
  • TIFF

Parameters:
file - Image file.
positionHint - Position hint.
See Also:
GPositional.setPositionHint(int)

GImage

public GImage(File file)
Create an image from a file. Use default position hints.

Parameters:
file - Image file.
Method Detail

setPositionHint

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

Position hints is a or'ed list of:

  • Line position hint - FIRST, LAST, TOP, BOTTON, LEFT, RIGHT
  • Point position hint - CENTER, NORTH, SOUTH, EAST, WEST, NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST
  • Algorithm - STATIC, DYNAMIC

Line position hints are interpreted as follows:

  • GPosition.FIRST - Attach to first polyline point.
  • GPosition.LAST - Attach to last polyline point.
  • GPosition.TOP - Attach to top polyline as it appears on screen when rendered.
  • GPosition.BOTTOM - Attach to bottom polyline as it appears on screen when rendered.
  • GPosition.RIGHT - Attach to right polyline as it appears on screen when rendered.
  • GPosition.LEFT - Attach to left polyline as it appears on screen when rendered.
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:

  • GPosition.CENTER - Put text centered on top of anchor point.
  • GPosition.NORTH - Put text above anchor point.
  • GPosition.SOUTH - Put text below anchor point.
  • GPosition.EAST - Put text to the right of anchor point.
  • GPosition.WEST - Put text to the left of anchor point.
  • GPosition.NORTHEAST - Put text above and right of the anchor point.
  • GPosition.NORTHWEST - Put text above and left of the anchor point.
  • GPosition.SOUTHEAST - Put text below and right of the anchor point.
  • GPosition.SOUTHWEST - Put text below and left of the anchor point.

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