twaver.gis
Class GisToolkits

java.lang.Object
  extended bytwaver.gis.GisToolkits

public class GisToolkits
extends java.lang.Object

The GisToolkits provides some methods to help developers do some calculation, deal with image object and do some presettings, etc.


Field Summary
static java.awt.Font DEFAULT_FONT
          Default Font used in TWaver GIS.
 
Constructor Summary
GisToolkits()
           
 
Method Summary
static void addLayer(GeographyMap map, java.io.File file)
          Add the specified shape file into a map.
static java.awt.geom.Point2D convertLatLongToScreen(GeographyMap map, double longitude, double latitude)
          Converts geographical coordinate to screen coordinate
static java.awt.geom.Point2D convertLatLongToScreen(GeographyMap map, GeoCoordinate co)
          Converts geographical coordinate to screen coordinate
static GeoCoordinate convertScreenToLatLong(GeographyMap map, double screenX, double screenY)
          Converts screen coordinate to geographical coordinate
static GeoCoordinate convertScreenToLatLong(GeographyMap map, java.awt.geom.Point2D screenPoint)
          Converts screen coordinate to geographical coordinate
static GeographyMap createDefaultMap()
          Creates a GeographyMap object which supports shape files.
static GeographyMap createMap(int type)
          Create a GeographyMap with the specified map type.
static double getDegree(double[] degreeDescription)
           
static java.lang.String getFormatNumber(double value, int decimal)
           
static java.awt.Image getImage(java.lang.String path)
          Gets an Image object according to the specified file path.
static javax.swing.ImageIcon getImageIcon(java.lang.String path)
           
static java.io.InputStream getInputStream(java.lang.String path)
           
static java.awt.Color getRandomColor()
          Gets a random color.
static java.lang.String getString(java.lang.String prefix, java.lang.String key)
           
static double getSynchronizeScale(GeographyMap map)
          Gets the new scale of the network element's size, if you have registered the thresholds into a GeographyMap object, when the scale
static double getSynchronizeScale(int thresholdsNum, double thresholdLevel)
           
static java.awt.Container getTopContainer(javax.swing.JComponent component)
           
static java.awt.geom.Rectangle2D getVisibleElementsBounds(twaver.network.TNetwork network, GeographyMap map)
          Gets the geographical bounds of all visible elements of the network.
static void goBack(twaver.network.TNetwork network, GeographyMap map)
          Redo last operation.
static void locateElement(twaver.Element element, GeographyMap map)
          Locates the element on the screen according to the element's geographical coordinate and the map instance.
static void matchMapWithGridData(twaver.network.TNetwork network, GeographyMap map)
          Match the vector data of the map with the grid data.
static void setGeographicalCoordinate(GeographyMap map, twaver.Element element)
          Sets the value of the element's TWaverGisConst.GEOCOORDINATE client property.
static void showExportSettingDialog(twaver.network.TNetwork network, GeographyMap map)
          Shows out a dialog used to set exporting image options.
static void showPrintDialog(twaver.network.TNetwork network, GeographyMap map, boolean isPreview)
          Shows out a dialog used to set print options.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FONT

public static java.awt.Font DEFAULT_FONT
Default Font used in TWaver GIS.

Constructor Detail

GisToolkits

public GisToolkits()
Method Detail

getRandomColor

public static java.awt.Color getRandomColor()
Gets a random color.

Returns:
a random color

createDefaultMap

public static GeographyMap createDefaultMap()
Creates a GeographyMap object which supports shape files.

Returns:
a GeographyMap object supporting shape files.

createMap

public static GeographyMap createMap(int type)
Create a GeographyMap with the specified map type.

Parameters:
type - the specified map type.
Returns:
a GeographyMap object. If the type is GeographyMap.GEOGRAPHYMAP_TYPE_SHPFILE, a map supporting shape files will be returned, otherwise a map supporting map service will be returned.

getImage

public static final java.awt.Image getImage(java.lang.String path)
Gets an Image object according to the specified file path.

Parameters:
path - the specified file path. Like 'file:/e:/test/a.png' or 'http://www.sss.com/a.png' or '/project/resources/c.png'
Returns:
an Image object relative to the file path.

getFormatNumber

public static java.lang.String getFormatNumber(double value,
                                               int decimal)

getImageIcon

public static final javax.swing.ImageIcon getImageIcon(java.lang.String path)

getInputStream

public static final java.io.InputStream getInputStream(java.lang.String path)

getTopContainer

public static java.awt.Container getTopContainer(javax.swing.JComponent component)

showPrintDialog

public static void showPrintDialog(twaver.network.TNetwork network,
                                   GeographyMap map,
                                   boolean isPreview)
Shows out a dialog used to set print options.

Parameters:
network - the specified TNetwork object
map - the specified GeographyMap object which will be printed
isPreview - the flag decides if the dialog is a print dialog or a print preview dialog. true to display a print preview dialog, and false to display a print dialog.

showExportSettingDialog

public static void showExportSettingDialog(twaver.network.TNetwork network,
                                           GeographyMap map)
Shows out a dialog used to set exporting image options.

Parameters:
network -
map -

matchMapWithGridData

public static void matchMapWithGridData(twaver.network.TNetwork network,
                                        GeographyMap map)
Match the vector data of the map with the grid data.

Parameters:
network -
map -

goBack

public static void goBack(twaver.network.TNetwork network,
                          GeographyMap map)
Redo last operation.

Parameters:
network - the specified TNetwork object.
map - the relative map object.

locateElement

public static void locateElement(twaver.Element element,
                                 GeographyMap map)
Locates the element on the screen according to the element's geographical coordinate and the map instance.

Parameters:
element - an Element object with the client property TWaverGisConst.GEOCOORDINATE.
map - the specified map instance.

getVisibleElementsBounds

public static java.awt.geom.Rectangle2D getVisibleElementsBounds(twaver.network.TNetwork network,
                                                                 GeographyMap map)
Gets the geographical bounds of all visible elements of the network.

Parameters:
network - the network object contains the whole topological datas
map - the reference map
Returns:
the bounds of all the visible topological elements.

getDegree

public static double getDegree(double[] degreeDescription)

addLayer

public static void addLayer(GeographyMap map,
                            java.io.File file)
Add the specified shape file into a map.

Parameters:
map - the target map object
file - the specified shape file object

convertScreenToLatLong

public static GeoCoordinate convertScreenToLatLong(GeographyMap map,
                                                   java.awt.geom.Point2D screenPoint)
Converts screen coordinate to geographical coordinate

Parameters:
map - the map instance according which to convert the coordinates
screenPoint - the location of the point on the screen.
Returns:
the corresponding geographical coordinate

convertScreenToLatLong

public static GeoCoordinate convertScreenToLatLong(GeographyMap map,
                                                   double screenX,
                                                   double screenY)
Converts screen coordinate to geographical coordinate

Parameters:
map - the map instance according which to convert the coordinates.
screenX - the x value of the specified screen coordinate
screenY - the y value of the specified screen coordinate
Returns:
the corresponding geographical coordinate

convertLatLongToScreen

public static java.awt.geom.Point2D convertLatLongToScreen(GeographyMap map,
                                                           double longitude,
                                                           double latitude)
Converts geographical coordinate to screen coordinate

Parameters:
map - the referential map object
longitude - the longitude of the specified geographical point
latitude - the latitude of the specified geographical point
Returns:
the corresponding point on the screen of the specified geographical point

convertLatLongToScreen

public static java.awt.geom.Point2D convertLatLongToScreen(GeographyMap map,
                                                           GeoCoordinate co)
Converts geographical coordinate to screen coordinate

Parameters:
map - the referential map object
co - the geographical point's coordinate
Returns:
the corresponding point on the screen of the specified geographical point

setGeographicalCoordinate

public static void setGeographicalCoordinate(GeographyMap map,
                                             twaver.Element element)
Sets the value of the element's TWaverGisConst.GEOCOORDINATE client property.

Parameters:
map - the referential map object
element - the target which should be located on the correct position of the screen.

getSynchronizeScale

public static double getSynchronizeScale(GeographyMap map)
Gets the new scale of the network element's size, if you have registered the thresholds into a GeographyMap object, when the scale

Parameters:
map - the specified GeographyMap into which the thresholds have been registered.
Returns:
the new scale of the network element's size.

getSynchronizeScale

public static double getSynchronizeScale(int thresholdsNum,
                                         double thresholdLevel)

getString

public static java.lang.String getString(java.lang.String prefix,
                                         java.lang.String key)