GeoSoft API

no.geosoft.cc.graphics
Class GWindow

Object
  extended byGWindow

public class GWindow
extends Object

GWindow is the top level graphics node and holder of GScene nodes (node containing world-to-device transformation). The GWindow is linked to the GUI through its canvas object.

Typical usage:

   // Some Swing component to hold the graphics 
   JPanel panel = new JPanel();
   panel.setLayout (new BorderLayout());
 
   // Create the window and attach to GUI
   GWindow window = new GWindow (Color.WHITE);
   panel.add (window.getCanvas(), BorderLayout.CENTER);
 
GWindow is also the holder of the current "interaction" object communicating mouse events between the back-end AWT component and the client application.

Author:
GeoSoft

Field Summary
static int ABORT
           
static int BUTTON1_DOUBLE_CLICK
           
static int BUTTON1_DOWN
           
static int BUTTON1_DRAG
           
static int BUTTON1_UP
           
static int BUTTON2_DOUBLE_CLICK
           
static int BUTTON2_DOWN
           
static int BUTTON2_DRAG
           
static int BUTTON2_UP
           
static int BUTTON3_DOUBLE_CLICK
           
static int BUTTON3_DOWN
           
static int BUTTON3_DRAG
           
static int BUTTON3_UP
           
static int FOCUS_IN
           
static int FOCUS_OUT
           
static int MOTION
           
 
Constructor Summary
GWindow()
          Create a new graphics window with default background color.
GWindow(Color backgroundColor)
          Create a new graphic window with the specified background color.
 
Method Summary
 GObject find(Object userData)
          Find a GObject based on user data.
 GObject find(String name)
          Find a GObject based on specified name.
 Component getCanvas()
          Return rendering canvas of this window.
 int getHeight()
          Return height of this window.
 GScene getScene()
          Return the first scene of this window (or null if no scenes are attached to this window).
 List getScenes()
          Return all scenes of this window.
 int getWidth()
          Return width of this window.
 boolean print()
          Print the current image.
 void redraw()
          Force a complete redraw of all visible elements.
 void refresh()
          Refresh the graphics scene.
 void saveAsGif(File file)
          Store the current graphic image as a GIF file.
 void saveAsJpg(File file)
          Store the current graphic image as a JPG file.
 void saveAsPng(File file)
          Store the current graphic image as a PNG file.
 void startInteraction(GInteraction interaction)
          Install the specified interaction on this window.
 void stopInteraction()
          Stop the current interaction.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ABORT

public static final int ABORT
See Also:
Constant Field Values

MOTION

public static final int MOTION
See Also:
Constant Field Values

BUTTON1_DOWN

public static final int BUTTON1_DOWN
See Also:
Constant Field Values

BUTTON1_DRAG

public static final int BUTTON1_DRAG
See Also:
Constant Field Values

BUTTON1_UP

public static final int BUTTON1_UP
See Also:
Constant Field Values

BUTTON1_DOUBLE_CLICK

public static final int BUTTON1_DOUBLE_CLICK
See Also:
Constant Field Values

BUTTON2_DOWN

public static final int BUTTON2_DOWN
See Also:
Constant Field Values

BUTTON2_DRAG

public static final int BUTTON2_DRAG
See Also:
Constant Field Values

BUTTON2_UP

public static final int BUTTON2_UP
See Also:
Constant Field Values

BUTTON2_DOUBLE_CLICK

public static final int BUTTON2_DOUBLE_CLICK
See Also:
Constant Field Values

BUTTON3_DOWN

public static final int BUTTON3_DOWN
See Also:
Constant Field Values

BUTTON3_DRAG

public static final int BUTTON3_DRAG
See Also:
Constant Field Values

BUTTON3_UP

public static final int BUTTON3_UP
See Also:
Constant Field Values

BUTTON3_DOUBLE_CLICK

public static final int BUTTON3_DOUBLE_CLICK
See Also:
Constant Field Values

FOCUS_IN

public static final int FOCUS_IN
See Also:
Constant Field Values

FOCUS_OUT

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

GWindow

public GWindow(Color backgroundColor)
Create a new graphic window with the specified background color.

The window contains a JComponent canvas which should be added to a container widget in the GUI.


GWindow

public GWindow()
Create a new graphics window with default background color.

Method Detail

getCanvas

public Component getCanvas()
Return rendering canvas of this window. This is the component that should be added to the client GUI hierarchy.

Returns:
Rendering canvas of this window.

getWidth

public int getWidth()
Return width of this window.

Returns:
Width of this window.

getHeight

public int getHeight()
Return height of this window.

Returns:
Height of this window.

getScenes

public List getScenes()
Return all scenes of this window. If no scenes are attached to this window, an empty (non-null) list is returned.

Returns:
All scenes of this window.

getScene

public GScene getScene()
Return the first scene of this window (or null if no scenes are attached to this window). This method is a convenience where the client application knows that are exactly one scene in the window (which in many practical cases will be the case).

Returns:
The first scene of this window (or null if none).

find

public GObject find(String name)
Find a GObject based on specified name. Search depth first.

Parameters:
name - Name of object to search for.
Returns:
First object with matching name, or null if none found.

find

public GObject find(Object userData)
Find a GObject based on user data. Search depth first.

Returns:
First object with matching user data, or null if none found.

startInteraction

public void startInteraction(GInteraction interaction)
Install the specified interaction on this window. As a window can administrate only one interaction at the time, the current interaction (if any) is first stopped.

Parameters:
interaction - Interaction to install and start.

stopInteraction

public void stopInteraction()
Stop the current interaction. The current interaction will get an ABORT event so it has the possibility to do cleanup. If no interaction is installed, this method has no effect.


redraw

public void redraw()
Force a complete redraw of all visible elements.

Normally this method is called automatically when needed (typically on retransformations). A client application may call this method explicitly if some external factor that influence the graphics has been changed. However, beware of the performance overhead of such an approach, and consider calling GObject.redraw() on the affected objects instead.


refresh

public void refresh()
Refresh the graphics scene. Only elements that has been changed since the last refresh are affected.


print

public boolean print()
Print the current image.

Returns:
True if no exception was caught, false otherwise.

saveAsGif

public void saveAsGif(File file)
               throws IOException
Store the current graphic image as a GIF file.

Parameters:
file - File to store in.
Throws:
IOException

saveAsJpg

public void saveAsJpg(File file)
               throws IOException
Store the current graphic image as a JPG file.

Parameters:
file - File to store in.
Throws:
IOException

saveAsPng

public void saveAsPng(File file)
               throws IOException
Store the current graphic image as a PNG file.

Parameters:
file - File to store in.
Throws:
IOException

GeoSoft API

Copyright © 2004 - Geotechnical Software Services     geosoft.no