Package mgui.interfaces.maps
Class Map2D
java.lang.Object
mgui.interfaces.AbstractInterfaceObject
mgui.interfaces.maps.Map
mgui.interfaces.maps.Map2D
- All Implemented Interfaces:
InterfaceObject,NamedObject,TreeObject,CleanableObject,XMLObject
public class Map2D extends Map
Maps from a given coordinate system to the screen
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType -
Field Summary
Fields Modifier and Type Field Description java.awt.Dimensionboundsdoublemax_zoomdoublemin_zoomorg.jogamp.vecmath.Point2foriginprotected doublezoomWidthFields inherited from class mgui.interfaces.AbstractInterfaceObject
isDestroyed, tree_nodes -
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidcenterOnPoint(org.jogamp.vecmath.Point2f centerPt)java.awt.DimensiongetBounds()java.lang.StringgetDTD()Returns the Data Type Declaration (DTD) for this object's XML representationjava.lang.StringgetLocalName()Returns the local name associated with this XML object.Rect2DgetMapBounds()org.jogamp.vecmath.Point2fgetMapCenterPt()floatgetMapDist(double thisDist)floatgetMapDist(int thisDist)org.jogamp.vecmath.Point2fgetMapPoint(java.awt.Point thisPt)Get the map coordinate of the screen pointjava.awt.RectanglegetScreenBounds(Rect2D thisBounds)intgetScreenDist(double thisDist)java.awt.PointgetScreenPoint(org.jogamp.vecmath.Point2f p)Mapspfrom model space to screen space.intgetScreenWidth()java.lang.StringgetShortXML(int tab)Returns a short XML representation of this object.java.awt.geom.AffineTransformgetTransform()Returns a transform corresponding to this map.intgetType()java.lang.StringgetXML()Returns this object's XML representation as a single string.java.lang.StringgetXML(int tab)Returns this object's XML representation as a single string.java.lang.StringgetXMLSchema()Returns the XML schema for this object's XML representationdoublegetZoom()voidhandleXMLElementEnd(java.lang.String localName)Handles the end of an XML element.voidhandleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)Handles the start of an XML element.voidhandleXMLString(java.lang.String s)Handles a string within an XML element.voidsetOrigin(float x, float y)voidsetScreenBounds(int width, int height)voidsetScreenBounds(java.awt.Dimension d)voidsetZoom(double z)voidsetZoom(double z, boolean center)Sets the zoom; ifcenter = true, maintains the window center pointvoidwriteXML(int tab, java.io.Writer writer)Writes the XML representation of this object to file.voidwriteXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar)Writes the XML representation of this object to file, asXMLType.Normal.voidwriteXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar)Writes the XML representation of this object to file.voidzoomToMapWindow(Rect2D window)Methods inherited from class mgui.interfaces.maps.Map
addMapListener, fireMapListeners, removeMapListenerMethods inherited from class mgui.interfaces.AbstractInterfaceObject
clean, destroy, getName, getTreeLabel, isDestroyed, issueTreeNode, setName, setTreeNode, updateTreeNodesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
zoomWidth
protected double zoomWidth -
bounds
public java.awt.Dimension bounds -
origin
public org.jogamp.vecmath.Point2f origin -
min_zoom
public double min_zoom -
max_zoom
public double max_zoom
-
-
Constructor Details
-
Map2D
public Map2D() -
Map2D
public Map2D(java.awt.Dimension theBounds, double theZoom, org.jogamp.vecmath.Point2f theOrigin)
-
-
Method Details
-
getBounds
public java.awt.Dimension getBounds() -
getMapBounds
-
getTransform
public java.awt.geom.AffineTransform getTransform()Returns a transform corresponding to this map.- Returns:
-
setScreenBounds
public void setScreenBounds(java.awt.Dimension d) -
setScreenBounds
public void setScreenBounds(int width, int height) -
setOrigin
public void setOrigin(float x, float y) -
getScreenPoint
public java.awt.Point getScreenPoint(org.jogamp.vecmath.Point2f p)Mapspfrom model space to screen space.- Parameters:
thisPt-- Returns:
-
getScreenDist
public int getScreenDist(double thisDist) -
getMapDist
public float getMapDist(int thisDist) -
getMapDist
public float getMapDist(double thisDist) -
getMapPoint
public org.jogamp.vecmath.Point2f getMapPoint(java.awt.Point thisPt)Get the map coordinate of the screen point- Parameters:
thisPt-- Returns:
-
centerOnPoint
public void centerOnPoint(org.jogamp.vecmath.Point2f centerPt) -
getMapCenterPt
public org.jogamp.vecmath.Point2f getMapCenterPt() -
getScreenWidth
public int getScreenWidth() -
getScreenBounds
-
zoomToMapWindow
-
getType
public int getType() -
getZoom
public double getZoom() -
setZoom
public void setZoom(double z) -
setZoom
public void setZoom(double z, boolean center)Sets the zoom; ifcenter = true, maintains the window center point- Parameters:
z-center-
-
getDTD
public java.lang.String getDTD()Description copied from interface:XMLObjectReturns the Data Type Declaration (DTD) for this object's XML representationSee http://en.wikipedia.org/wiki/Document_Type_Definition for a description.
- Returns:
-
getXMLSchema
public java.lang.String getXMLSchema()Description copied from interface:XMLObjectReturns the XML schema for this object's XML representation- Returns:
-
getXML
public java.lang.String getXML()Description copied from interface:XMLObjectReturns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)functions to write larger objects to file.- Returns:
-
getXML
public java.lang.String getXML(int tab)Description copied from interface:XMLObjectReturns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)functions to write larger objects to file.- Parameters:
tab- The number of tabs to place before the opening XML wrapper- Returns:
-
handleXMLElementStart
public void handleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type) throws org.xml.sax.SAXExceptionDescription copied from interface:XMLObjectHandles the start of an XML element.- Parameters:
localName- Local name of the elementattributes- Set of element attributestype- TheXMLTypeof this element- Throws:
org.xml.sax.SAXException
-
handleXMLElementEnd
public void handleXMLElementEnd(java.lang.String localName) throws org.xml.sax.SAXExceptionDescription copied from interface:XMLObjectHandles the end of an XML element.- Parameters:
localName- Local name of the element- Throws:
org.xml.sax.SAXException
-
handleXMLString
public void handleXMLString(java.lang.String s) throws org.xml.sax.SAXExceptionDescription copied from interface:XMLObjectHandles a string within an XML element.- Parameters:
s- String to handle- Throws:
org.xml.sax.SAXException
-
getLocalName
public java.lang.String getLocalName()Description copied from interface:XMLObjectReturns the local name associated with this XML object.- Returns:
-
writeXML
public void writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format ofXMLFormat.Asciiwill be used.- Parameters:
tab- The number of tabs to place before the XML textwriter- The writeroptions- XMLOutputOptions defining the write parametersprogress_bar- Optional progress updater (may benull)- Throws:
java.io.IOException
-
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites the XML representation of this object to file, asXMLType.Normal. The default format ofXMLFormat.Asciiwill be used. The basic contract for this method is that it should not write a newline character at its start or end.- Parameters:
tab- The number of tabs to place before the XML textwriter- The writerprogress_bar- Optional progress updater (may benull)- Throws:
java.io.IOException
-
writeXML
public void writeXML(int tab, java.io.Writer writer) throws java.io.IOExceptionDescription copied from interface:XMLObjectWrites the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format ofXMLFormat.Asciiwill be used.- Parameters:
tab- The number of tabs to place before the XML textwriter- The writer- Throws:
java.io.IOException
-
getShortXML
public java.lang.String getShortXML(int tab)Description copied from interface:XMLObjectReturns a short XML representation of this object.- Returns:
-