|
GeoSoft API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object GObject GScene
The GScene is the link between a GWindow and the graphics objects.
The GScene defines the viewport and the world extent and holds device-to-world transformation objects. The scene is itself a graphics object (GObject) and as such it may contain geometry.
Typical usage:
// Creating a window GWindow window = new GWindow (Color.WHITE); // Creating a scene within the window GScene scene = new GScene (window); scene.setWorldExtent (0.0, 0.0, 1000.0, 1000.0);Setting world extent is optional. If unset it will have the same extent (in floating point coordinates) as the device.
When geometry is specified (in GSegments), coordinates are specified in either device coordinates or in world coordinates. Integer coordinates are assumed to be device relative, while floating point coordinates are taken to be world extent relative.
Field Summary |
Fields inherited from class GObject |
ANNOTATION_INVISIBLE, ANNOTATION_VISIBLE, DATA_INVISIBLE, DATA_VISIBLE, INVISIBLE, SYMBOLS_INVISIBLE, SYMBOLS_VISIBLE, VISIBLE, WIDGETS_INVISIBLE, WIDGETS_VISIBLE |
Constructor Summary | |
GScene(GWindow window)
Create a nameless scene within the specified window. |
|
GScene(GWindow window,
String name)
Create a scene within the specified window. |
Method Summary | |
GScene |
getScene()
Return the scene of this GObject. |
GTransformer |
getTransformer()
Return the transformation object of this scene. |
GViewport |
getViewport()
Return current viewport. |
GWindow |
getWindow()
Return the window of this scene. |
GWorldExtent |
getWorldExtent()
Return current world extent. |
void |
installScrollHandler(Adjustable hScrollBar,
Adjustable vScrollBar)
Instruct this scene to update and respond to the specified scrollbars during zoom. |
void |
pan(int dx,
int dy)
Pan a specific device distance. |
void |
setViewport(int x0,
int y0,
int width,
int height)
Set viewport to a rectangular area of the screen. |
void |
setViewport(int x0,
int y0,
int x1,
int y1,
int x2,
int y2)
Set viewport for this scene. |
void |
setWorldExtent(double[] w0,
double[] w1,
double[] w2)
Set world extent of this scene. |
void |
setWorldExtent(double x0,
double y0,
double width,
double height)
A convenience method for specifying a orthogonal world extent in the Z=0 plane. |
void |
shouldWorldExtentFitViewport(boolean shouldWorldExtentFitViewport)
Specify wether world extent should always fit the viewport (i.e. have same aspect ratio) during resize. |
void |
shouldZoomOnResize(boolean shouldZoomOnResize)
Specified if one should zoom on resize. |
void |
unzoom()
Unzoom. |
void |
zoom(double zoomFactor)
Zoom a specified amount around center of viewport. |
void |
zoom(double[] w0,
double[] w1,
double[] w2)
Zoom into a specified world area. |
void |
zoom(int x,
int y,
double zoomFactor)
Zoom a specific amount using specified point as fixed. |
void |
zoom(int x0,
int y0,
int x1,
int y1)
Zoom into a specific device area. |
Methods inherited from class GObject |
add, add, addSegment, back, backward, behind, draw, find, find, find, find, findAll, findAll, findAllInside, findInside, findSegment, findSegment, findSegment, findSegmentInside, findSegments, findSegments, findSegmentsInside, forward, front, getChild, getChildren, getName, getNChildren, getNSegments, getObjectBehind, getObjectInFront, getParent, getSegment, getSegment, getSegments, getStyle, getUserData, getVisibility, inFrontOf, isInBack, isInFront, redraw, refresh, remove, remove, removeAll, removeSegment, removeSegment, removeSegments, removeSegments, removeSegments, reposition, setName, setStyle, setUserData, setVisibility, styleChanged, toBack, toFront, toString |
Methods inherited from class Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public GScene(GWindow window, String name)
A default viewport will be established covering the entire window. This is appropriate in most cases.
A default world-extent will be established with coordinates equal to the window device extent. This may be sufficient in many cases if object geometry is specified in device coordinates.
window
- Window to attach this scene to.name
- Name of this scene.public GScene(GWindow window)
window
- Window to acttach this scene to.Method Detail |
public GScene getScene()
getScene
in class GObject
public GWindow getWindow()
getWindow
in class GObject
public GTransformer getTransformer()
getTransformer
in class GObject
public void shouldZoomOnResize(boolean shouldZoomOnResize)
shouldZoomOnResize
- True if world extent should be unchanged
on resize, false otherwise.public void shouldWorldExtentFitViewport(boolean shouldWorldExtentFitViewport)
shouldWorldExtentFitViewport
- True if the world extent should
fit the viewport, false otherwise.public void setViewport(int x0, int y0, int x1, int y1, int x2, int y2)
x0,y0 o-------o x1,y1 | | | x2,y2 oIt is thus possible to create a skewed viewport, which may be handy in some situations.
If the viewport is not set by a client, it will fit the canvas and adjust to it during resize. If it is set by client, it will stay fixed and not adjusted on resize.
public void setViewport(int x0, int y0, int width, int height)
width x0,y0 o-------o | height | | o
x0
- X coordinate of upper left corner of viewport.y0
- Y coordinate of upper left corner of viewport.width
- Width of viewport.height
- Height of viewport.public GViewport getViewport()
public void setWorldExtent(double[] w0, double[] w1, double[] w2)
w2 o | | | w0 o-------o w1Thus w2 is mapped to viewport (x0,y0), w0 is mapped to (x2,y2) and w1 is mapped to lower right corner of viewport.
w0,w1 and w2 are three dimensions, and the world extent can thus be any plane in a 3D space, and the plane may be skewed.
w0
- Point 0 of the new world extent [x,y,z].w1
- Point 1 of the new world extent [x,y,z].w2
- Point 2 of the new world extent [x,y,z].public void setWorldExtent(double x0, double y0, double width, double height)
o | height | | x0,y0 o-------o width
x0
- X coordinate of world extent origin.y0
- Y coordinate of world extent origin.width
- Width of world extent.height
- Height of world extent.public GWorldExtent getWorldExtent()
public void zoom(double zoomFactor)
zoomFactor
- Zoom factor. Zoom in with factor < 1.0 and
out with factor > 1.0.public void zoom(int x, int y, double zoomFactor)
x
- X coordinate of fixed point during zoom.y
- Y coordinate of fixed point during zoom.zoomFactor
- Zoom factor.public void zoom(int x0, int y0, int x1, int y1)
x0
- X value of first corner of zoom rectangle.y0
- Y value of first corner of zoom rectangle.x1
- X value of second corner of zoom rectangle.y1
- Y value of second corner of zoom rectangle.public void zoom(double[] w0, double[] w1, double[] w2)
w0
- First world coordinate of zoom area [x,y,z].w1
- Second world coordinate of zoom area [x,y,z].w2
- Third world coordinate of zoom area [x,y,z].public void unzoom()
public void pan(int dx, int dy)
dx
- Distance to pan in x direction.dy
- Distance to pan in y direction.public void installScrollHandler(Adjustable hScrollBar, Adjustable vScrollBar)
NOTE I: The client application is responsible for laying out the scrollbars in the AWT/Swing GUI. The scrollbars should have no access listeneres nor logic added, as this is controlled by the GScene through the internal GScrollHandler object.
NOTE II: Do not put the graphics panel in a JScrollPane and use the JScrollPane scrollbars as input to this method, as a JScrollPane contains scroll logic that interfer with the internal GScene logic. The correct approach is to create horizontal and vertical JScrollBar explicitly.
Specifying both horizontal and vertical scrollbar as null turns off scroll handling in this scene.
hScrollBar
- Horizontal scrollbar (or null if a horizontal
scrollbar is not used).
|
GeoSoft API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |