|
GeoSoft API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object GSegment
Class for holding a polyline. GSegments are contained by GObjects. They can have its own rendering style (GStyle) or inherit style from its parent GObject if not specified.
Example usage:
public class Box extends GObject { private double x0_, y0_, width_, height_; private GSegment border_; public Box (double x0, double y0, double width, double height) { // Store the abstract representation of the box x0_ = x0; y0_ = y0; width_ = width; height_ = height; // Prepare the graphics representation of the box border_ = new GSegment(); addSegment (border_); } public void draw() { // Complete the graphics representation of the box double[] xy = new double {x0_, y0_, x0_ + width_, y0_, x0_ + width_, y0_ + height_, x0_, y0_ + height_, x0_, y0} border_.setGeometry (xy); } }A typical GObject will have many GSegments and sub-GObjects. Some of these can be created in the constructor while others may need to be created within the draw method as they depend ont external factors such as zoom etc.
For efficiency, G does not store world coordinates internally but converts these to device coordinates in the rendering step. It is therfore essential that geometry is provided in the draw() method which is called by G on retransformations (zoom/resize etc.).
Constructor Summary | |
GSegment()
Create a GSegment. |
Method Summary | |
void |
addComponent(GComponent component)
Add a AWT component to this segment. |
void |
addImage(GImage image)
Add an image to this segment. |
void |
addText(GText text)
Add a text element to this segment. |
Collection |
getComponents()
Return all AWT components of this segment. |
Collection |
getImages()
Return all images associated with this segment. |
GObject |
getOwner()
Return the owner GObject of this GSegment. |
GStyle |
getStyle()
Return style for this segment. |
GText |
getText()
Return the first text element of this segment. |
List |
getTexts()
Return all text elements of this segment. |
Object |
getUserData()
Return user data of this GSegment. |
GImage |
getVertexImage()
Return the image that is to be associated with all vertices of this GSegment. |
void |
removeComponents()
Remove all AWT components from this GSegment. |
void |
removeImages()
Remove all images from this GSegment. |
void |
removeText()
Remove all text elements set on this segment. |
void |
setComponent(GComponent component)
Set component of this segment. |
void |
setGeometry(double[] xyz)
Set polyline world coordinate geometry. |
void |
setGeometry(double[] x,
double[] y)
Set polyline world coordinate geometry. |
void |
setGeometry(double[] x,
double[] y,
double[] z)
Set polyline world coordinate geometry. |
void |
setGeometry(double x,
double y)
Set single point world coordinate geometry. |
void |
setGeometry(double x,
double y,
double z)
Set single point world coordinate geometry. |
void |
setGeometry(double x0,
double y0,
double x1,
double y1)
Set two point (line) world coordinate geometry. |
void |
setGeometry(double x0,
double y0,
double z0,
double x1,
double y1,
double z1)
Set two point (line) world coordinate geometry. |
void |
setGeometry(int[] xy)
Set polyline device coordinate geometry. |
void |
setGeometry(int[] x,
int[] y)
Set polyline device coordinate geometry. |
void |
setGeometry(int x,
int y)
Set single point device coordinate geometry. |
void |
setGeometry(int x0,
int y0,
int x1,
int y1)
Set two point (line) device coordinate geometry. |
void |
setGeometryXy(double[] xy)
Set polyline world coordinate geometry. |
void |
setImage(GImage image)
Set image of this segment. |
void |
setStyle(GStyle style)
Set new style for this segment. |
void |
setText(GText text)
Set text element of this segment. |
void |
setUserData(Object userData)
Set user data of this GSegment. |
void |
setVertexImage(GImage image)
Set image to associate with every vertex of this GSegment. |
void |
styleChanged(GStyle style)
Called when the style of this object is changed. |
void |
translate(int dx,
int dy)
Translate this segment in device. |
Methods inherited from class Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GSegment()
Method Detail |
public GObject getOwner()
public void setUserData(Object userData)
userData
- User data of this GSegment.public Object getUserData()
public void setGeometry(int x, int y)
x
- X coordinate.y
- Y coordinate.public void setGeometry(int x0, int y0, int x1, int y1)
x0
- X coordinate of first end point.y0
- Y coordinate of first end point.x1
- X coordinate of second end point.y1
- Y coordinate of second end point.public void setGeometry(int[] x, int[] y)
x
- X coordinates.y
- Y coordinates.public void setGeometry(int[] xy)
xy
- Polyline geometry [x,y,x,y,...]. null can be specified
to indicate that the present geometry should be removed.public void setGeometry(double x, double y, double z)
x
- X coordinate.y
- Y coordinate.z
- Z coordinate.public void setGeometry(double x, double y)
x
- X coordinate.y
- Y coordinate.public void setGeometry(double x0, double y0, double z0, double x1, double y1, double z1)
x0
- X coordinate of first end point.y0
- Y coordinate of first end point.z0
- Z coordinate of first end point.x1
- X coordinate of second end point.y1
- Y coordinate of second end point.z1
- Z coordinate of second end point.public void setGeometry(double x0, double y0, double x1, double y1)
x0
- X coordinate of first end point.y0
- Y coordinate of first end point.x1
- X coordinate of second end point.y1
- Y coordinate of second end point.public void setGeometry(double[] x, double[] y, double[] z)
public void setGeometry(double[] x, double[] y)
x
- X coordinates.y
- Y coordinates.public void setGeometry(double[] xyz)
xyz
- Polyline geometry [x,y,z,x,y,z,...].public void setGeometryXy(double[] xy)
xy
- Polyline geometry [x,y,x,y,...].public void translate(int dx, int dy)
dx
- Translation in x direction.dy
- Translation in Y direction.public void setStyle(GStyle style)
style
- Style for this segment (or null if the intent is to
unset the current style).public GStyle getStyle()
public void addText(GText text)
Text elements without line position hint will be associated with the n'th segment coordinate according to the number of texts added.
text
- Text element to add.public void setText(GText text)
text
- Text element to set.public List getTexts()
public GText getText()
public void removeText()
public void addImage(GImage image)
image
- Image to add.public void setImage(GImage image)
image
- Image to set.public Collection getImages()
public void removeImages()
public void setVertexImage(GImage image)
image
- Image to decorate every vertex of this
polyline (or null to turn off this feature).public GImage getVertexImage()
public void addComponent(GComponent component)
component
- Component to add.public void setComponent(GComponent component)
component
- Component to set.public Collection getComponents()
public void removeComponents()
public void styleChanged(GStyle style)
styleChanged
in interface GStyleListener
style
- Style that has changed.
|
GeoSoft API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |