Package worldBuilder

Class Map

  • All Implemented Interfaces:
    java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

    public class Map
    extends javax.swing.JPanel
    implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener
    the displayable, resizeable, 2D representation of a mesh and the attributes of its points.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Map.Selection
      selection types: points, line, rectangle, ...
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.BaselineResizeBehavior
    • Field Summary

      Fields 
      Modifier and Type Field Description
      Drainage drainage  
      java.awt.Color[] faunaColors  
      java.lang.String[] faunaNames  
      java.awt.Color[] floraColors  
      java.lang.String[] floraNames  
      java.awt.image.BufferedImage[] iconImages  
      boolean isSubRegion
      current map is a subRegion of a larger map
      double max_deposition
      results of hydrological computation
      double max_erosion
      results of hydrological computation
      double max_flux
      results of hydrological computation
      double max_height
      results of hydrological computation
      double max_rain
      rainfall
      double max_slope
      results of hydrological computation
      double max_velocity
      results of hydrological computation
      Mesh mesh
      underlying Mesh of Voronoi points
      double min_flux
      results of hydrological computation
      double min_height
      results of hydrological computation
      double min_rain
      rainfall
      double min_slope
      results of hydrological computation
      double min_velocity
      results of hydrological computation
      java.awt.Color[] rockColors  
      java.lang.String[] rockNames  
      static int SHOW_ALL
      options for enabled display types
      static int SHOW_CITY
      options for enabled display types
      static int SHOW_ERODE
      options for enabled display types
      static int SHOW_FAUNA
      options for enabled display types
      static int SHOW_FLORA
      options for enabled display types
      static int SHOW_MESH
      options for enabled display types
      static int SHOW_POINTS
      options for enabled display types
      static int SHOW_RAIN
      options for enabled display types
      static int SHOW_ROCKS
      options for enabled display types
      static int SHOW_TOPO
      options for enabled display types
      static int SHOW_WATER
      options for enabled display types
      WaterFlow waterflow  
      • Fields inherited from class javax.swing.JComponent

        TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
      • Fields inherited from class java.awt.Component

        BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Constructor Summary

      Constructors 
      Constructor Description
      Map​(int width, int height)
      instantiate a displayable map widget
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addMapListener​(MapListener interested)
      register a listener for selection events
      void addName​(java.lang.String name, double x, double y)
      assoicate a name with the MeshPoint nearest
      void addPOI​(POI point)
      add a POI
      boolean checkSelection​(Map.Selection type)
      see if a selection has already been made and call listener
      MeshPoint choosePoint​(int screen_x, int screen_y)
      find the mesh point closest to a screen location
      Cartesian getCartesian​(Cartesian.vicinity type)
      return MeshPoint to Cartesian translation matrix param type (NEIGBORS, POLOGYON, NEAREST)
      Drainage getDrainage()
      return reference to the Drainage calculator
      double[] getErodeMap()
      return array of net erosion/deposition at each mesh point
      java.awt.Color[] getFaunaColors()
      return map from flora types into preview colors
      double[] getFaunaMap()
      return map of flora types for the current mesh
      java.lang.String[] getFaunaNames()
      return ID-> mineral name map
      int getFaunaType​(java.lang.String name)
      return type ID of a specified flora type
      java.awt.Color[] getFloraColors()
      return map from flora types into preview colors
      double[] getFloraMap()
      return map of flora types for the current mesh
      int getFloraType​(java.lang.String name)
      return type ID of a specified flora type
      double[] getFluxMap()
      return array of water flow through each mesh point
      double[] getHeightMap()
      return heightmap (pre-erosion Z values) for the current mesh
      double[] getIncoming()
      return incoming off-map rivers
      Mesh getMesh()
      return the Mesh underlying the current map
      java.awt.Dimension getMinimumSize()
      return minimum acceptable canvas size
      java.lang.String[] getNameMap()
      return the list of per-point names/descriptions
      java.util.LinkedList<POI> getPOI()
      return the list of Points of Interest
      java.awt.Dimension getPreferredSize()
      return preferred canvas size
      double[] getRainMap()
      return rainMap (cm of rainfall) for the current mesh
      java.awt.Color[] getRockColors()
      return ID-> mineral preview color map
      java.lang.String[] getRockNames()
      return ID-> mineral name map
      double getSeaLevel()
      return the current sea level Z-value
      double[] getSoilMap()
      return map of soil type for the current mesh
      int getSoilType​(java.lang.String name)
      return type ID of a specified mineral/soil name
      double[][] getTileDepths()
      return reference to the per-tile depths (in meters)
      double[][] getTileHeights()
      return reference to the per-tile heights (not valid until paint)
      double[] getWaterLevel()
      return array of nearest water level to each mesh point
      void highlight​(double x, double y)
      highlight non-mesh point
      void highlight​(int point, java.awt.Color c)
      highlight points (typically for diagnostic purposes
      boolean inTheBox​(double x, double y)
      return whether or not Map coordinates are within a selected box
      static double linear​(int min, int max, double value)
      linear interpolation of a (color) value within a range
      static double logarithmic​(int min, int max, double value, double base)
      logarithmic interpolation of a (color) value within a range
      int map_col​(double x)
      return the Cartesian Map column for a Map Y coordinate
      double map_height​(int y_pixels)
      return height (in map units) of a number of pixels
      int map_row​(double y)
      return the Cartesian Map column for a Map Y coordinate
      double map_width​(int x_pixels)
      return width (in map units) of a number of pixels
      double map_x​(int screen_x)
      return map (-0.5 to 0.5) x position for a screen column
      double map_y​(int screen_y)
      return map (-0.5 to 0.5) y position for a screen row
      void mouseClicked​(java.awt.event.MouseEvent e)
      mouse click at an on-map location
      void mouseDragged​(java.awt.event.MouseEvent e)
      extend/alter the region being selected
      void mouseEntered​(java.awt.event.MouseEvent e)
      (perfunctory)
      void mouseExited​(java.awt.event.MouseEvent e)
      (perfunctory)
      void mouseMoved​(java.awt.event.MouseEvent e)
      (perfunctory)
      void mousePressed​(java.awt.event.MouseEvent e)
      start the definition of region selection
      void mouseReleased​(java.awt.event.MouseEvent e)
      end the definition of a region selection
      boolean on_screen​(double x, double y)
      is a map position within the current display window
      void paintComponent​(java.awt.Graphics g)
      repaint the entire displayed map pane
      java.lang.String pointName​(int point)
      return a descriptive name string for a chosen point
      void read​(java.lang.String filename)
      read a saved map in from a file
      void region_stats()
      summarize the world topography and hydrology
      void removeMapListener​(MapListener which)
      un-register a selection event listener
      int screen_x​(double x)
      return pixel column for a given map x position
      int screen_y​(double y)
      return pixel row for a given map y position
      void selectLine​(int x0, int y0, int x1, int y1)
      highlight a line on the displayed map
      void selectMode​(Map.Selection type)
      tell map-selection tool what kind of selection we expect
      void selectPoints​(int x0, int y0, int x1, int y1, boolean add)
      highlight points in rectangular selection on the displayed map
      void selectRect​(int x0, int y0, int x1, int y1)
      highlight a rectangular selection on the displayed map
      int setDisplay​(int view, boolean on)
      enable/disable display elements
      void setFaunaColors​(java.awt.Color[] newColors)
      update the mapping from flora types to preview colors
      double[] setFaunaMap​(double[] newFauna)
      update the flora map for the current mesh
      void setFaunaNames​(java.lang.String[] newNames)
      update the mapping from flora types to names
      void setFloraColors​(java.awt.Color[] newColors)
      update the mapping from flora types to preview colors
      double[] setFloraMap​(double[] newFlora)
      update the flora map for the current mesh
      void setFloraNames​(java.lang.String[] newNames)
      update the mapping from flora types to names
      double[] setHeightMap​(double[] newHeight)
      update the height map for the current mesth * @param newHeight new set of Z values
      void setIncoming​(double[] new_map)
      update the water-flow after a change to the incoming arterial river
      void setMesh​(Mesh mesh)
      create a map around a new Mesh
      double[] setRainMap​(double[] newRain)
      update the rainfall map for the current mesth
      void setRockColors​(java.awt.Color[] newColors)
      update the mapping from rock types to preview colors
      void setRockNames​(java.lang.String[] newNames)
      update the mapping from mineral types to names
      void setSeaLevel​(double z_value)
      record a change in sea level
      double[] setSoilMap​(double[] newSoil)
      update the soil map for the current mesh
      void setWindow​(double x0, double y0, double x1, double y1)  
      void subregion​(int numpoints)
      create a new sub-region map
      java.util.LinkedList<TradeRoute> tradeRoutes()
      return list of trade routes
      void tradeRoutes​(java.util.LinkedList<TradeRoute> routes)
      set the list of trade routes
      boolean write​(java.lang.String filename)
      write a mesh of MapPoints out to a file
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, setUI, updateUI
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • SHOW_ALL

        public static final int SHOW_ALL
        options for enabled display types
        See Also:
        Constant Field Values
      • SHOW_POINTS

        public static final int SHOW_POINTS
        options for enabled display types
        See Also:
        Constant Field Values
      • SHOW_MESH

        public static final int SHOW_MESH
        options for enabled display types
        See Also:
        Constant Field Values
      • SHOW_TOPO

        public static final int SHOW_TOPO
        options for enabled display types
        See Also:
        Constant Field Values
      • SHOW_RAIN

        public static final int SHOW_RAIN
        options for enabled display types
        See Also:
        Constant Field Values
      • SHOW_WATER

        public static final int SHOW_WATER
        options for enabled display types
        See Also:
        Constant Field Values
      • SHOW_ERODE

        public static final int SHOW_ERODE
        options for enabled display types
        See Also:
        Constant Field Values
      • SHOW_ROCKS

        public static final int SHOW_ROCKS
        options for enabled display types
        See Also:
        Constant Field Values
      • SHOW_FLORA

        public static final int SHOW_FLORA
        options for enabled display types
        See Also:
        Constant Field Values
      • SHOW_FAUNA

        public static final int SHOW_FAUNA
        options for enabled display types
        See Also:
        Constant Field Values
      • SHOW_CITY

        public static final int SHOW_CITY
        options for enabled display types
        See Also:
        Constant Field Values
      • isSubRegion

        public boolean isSubRegion
        current map is a subRegion of a larger map
      • mesh

        public Mesh mesh
        underlying Mesh of Voronoi points
      • floraColors

        public java.awt.Color[] floraColors
      • rockColors

        public java.awt.Color[] rockColors
      • faunaColors

        public java.awt.Color[] faunaColors
      • floraNames

        public java.lang.String[] floraNames
      • rockNames

        public java.lang.String[] rockNames
      • faunaNames

        public java.lang.String[] faunaNames
      • max_height

        public double max_height
        results of hydrological computation
      • min_height

        public double min_height
        results of hydrological computation
      • min_slope

        public double min_slope
        results of hydrological computation
      • max_slope

        public double max_slope
        results of hydrological computation
      • min_flux

        public double min_flux
        results of hydrological computation
      • max_flux

        public double max_flux
        results of hydrological computation
      • min_velocity

        public double min_velocity
        results of hydrological computation
      • max_velocity

        public double max_velocity
        results of hydrological computation
      • max_erosion

        public double max_erosion
        results of hydrological computation
      • max_deposition

        public double max_deposition
        results of hydrological computation
      • min_rain

        public double min_rain
        rainfall
      • max_rain

        public double max_rain
        rainfall
      • iconImages

        public java.awt.image.BufferedImage[] iconImages
    • Constructor Detail

      • Map

        public Map​(int width,
                   int height)
        instantiate a displayable map widget
        Parameters:
        width - ... preferred width (in pixels)
        height - ... perferred height 9in pixels)
    • Method Detail

      • subregion

        public void subregion​(int numpoints)
        create a new sub-region map
        Parameters:
        numpoints - ... number of desired points in new Mesh
      • read

        public void read​(java.lang.String filename)
        read a saved map in from a file
        Parameters:
        filename - - of input file
      • region_stats

        public void region_stats()
        summarize the world topography and hydrology
      • write

        public boolean write​(java.lang.String filename)
        write a mesh of MapPoints out to a file
        Parameters:
        filename - - of the file to be (re)written
      • getMesh

        public Mesh getMesh()
        return the Mesh underlying the current map
      • setMesh

        public void setMesh​(Mesh mesh)
        create a map around a new Mesh
        Parameters:
        mesh - to be used
      • getHeightMap

        public double[] getHeightMap()
        return heightmap (pre-erosion Z values) for the current mesh
      • setHeightMap

        public double[] setHeightMap​(double[] newHeight)
        update the height map for the current mesth * @param newHeight new set of Z values
      • getRainMap

        public double[] getRainMap()
        return rainMap (cm of rainfall) for the current mesh
      • setRainMap

        public double[] setRainMap​(double[] newRain)
        update the rainfall map for the current mesth
        Parameters:
        newRain - new set of rainfall values
      • setSeaLevel

        public void setSeaLevel​(double z_value)
        record a change in sea level
        Parameters:
        z_value - new sea level
      • getSeaLevel

        public double getSeaLevel()
        return the current sea level Z-value
      • setIncoming

        public void setIncoming​(double[] new_map)
        update the water-flow after a change to the incoming arterial river
        Parameters:
        new_map - new incoming flux per point
      • getIncoming

        public double[] getIncoming()
        return incoming off-map rivers
      • getSoilMap

        public double[] getSoilMap()
        return map of soil type for the current mesh
      • setSoilMap

        public double[] setSoilMap​(double[] newSoil)
        update the soil map for the current mesh
        Parameters:
        newSoil - new set of soil types
      • getSoilType

        public int getSoilType​(java.lang.String name)
        return type ID of a specified mineral/soil name
      • getRockColors

        public java.awt.Color[] getRockColors()
        return ID-> mineral preview color map
      • getRockNames

        public java.lang.String[] getRockNames()
        return ID-> mineral name map
      • setRockColors

        public void setRockColors​(java.awt.Color[] newColors)
        update the mapping from rock types to preview colors
        Parameters:
        newColors -
      • setRockNames

        public void setRockNames​(java.lang.String[] newNames)
        update the mapping from mineral types to names
        Parameters:
        newNames -
      • getFloraMap

        public double[] getFloraMap()
        return map of flora types for the current mesh
      • setFloraMap

        public double[] setFloraMap​(double[] newFlora)
        update the flora map for the current mesh
        Parameters:
        newFlora - new set of flora types
        Returns:
        previous flora map
      • getFloraType

        public int getFloraType​(java.lang.String name)
        return type ID of a specified flora type
      • setFloraColors

        public void setFloraColors​(java.awt.Color[] newColors)
        update the mapping from flora types to preview colors
        Parameters:
        newColors -
      • setFloraNames

        public void setFloraNames​(java.lang.String[] newNames)
        update the mapping from flora types to names
        Parameters:
        newNames -
      • setFaunaMap

        public double[] setFaunaMap​(double[] newFauna)
        update the flora map for the current mesh
        Parameters:
        newFlora - new set of flora types
        Returns:
        previous flora map
      • getFaunaMap

        public double[] getFaunaMap()
        return map of flora types for the current mesh
      • getFaunaNames

        public java.lang.String[] getFaunaNames()
        return ID-> mineral name map
      • getFaunaType

        public int getFaunaType​(java.lang.String name)
        return type ID of a specified flora type
      • setFaunaColors

        public void setFaunaColors​(java.awt.Color[] newColors)
        update the mapping from flora types to preview colors
        Parameters:
        newColors -
      • setFaunaNames

        public void setFaunaNames​(java.lang.String[] newNames)
        update the mapping from flora types to names
        Parameters:
        newNames -
      • getNameMap

        public java.lang.String[] getNameMap()
        return the list of per-point names/descriptions
      • pointName

        public java.lang.String pointName​(int point)
        return a descriptive name string for a chosen point
      • tradeRoutes

        public java.util.LinkedList<TradeRoute> tradeRoutes()
        return list of trade routes
      • tradeRoutes

        public void tradeRoutes​(java.util.LinkedList<TradeRoute> routes)
        set the list of trade routes
      • addName

        public void addName​(java.lang.String name,
                            double x,
                            double y)
        assoicate a name with the MeshPoint nearest
        Parameters:
        name - new name string
        x - (map) x coordinate
        y - (map) y coordinate
      • getPOI

        public java.util.LinkedList<POI> getPOI()
        return the list of Points of Interest
      • addPOI

        public void addPOI​(POI point)
        add a POI
        Parameters:
        point - new POI to be added
      • getFluxMap

        public double[] getFluxMap()
        return array of water flow through each mesh point
      • getErodeMap

        public double[] getErodeMap()
        return array of net erosion/deposition at each mesh point
      • getWaterLevel

        public double[] getWaterLevel()
        return array of nearest water level to each mesh point
      • getFloraColors

        public java.awt.Color[] getFloraColors()
        return map from flora types into preview colors
      • getFaunaColors

        public java.awt.Color[] getFaunaColors()
        return map from flora types into preview colors
      • getDrainage

        public Drainage getDrainage()
        return reference to the Drainage calculator
      • getTileHeights

        public double[][] getTileHeights()
        return reference to the per-tile heights (not valid until paint)
      • getTileDepths

        public double[][] getTileDepths()
        return reference to the per-tile depths (in meters)
      • getCartesian

        public Cartesian getCartesian​(Cartesian.vicinity type)
        return MeshPoint to Cartesian translation matrix param type (NEIGBORS, POLOGYON, NEAREST)
      • setDisplay

        public int setDisplay​(int view,
                              boolean on)
        enable/disable display elements
        Parameters:
        view - to be enabled/disabled
        on - ... should this be enabled or disabled
        Returns:
        current sense of that view
      • map_x

        public double map_x​(int screen_x)
        return map (-0.5 to 0.5) x position for a screen column
      • map_y

        public double map_y​(int screen_y)
        return map (-0.5 to 0.5) y position for a screen row
      • map_width

        public double map_width​(int x_pixels)
        return width (in map units) of a number of pixels
      • map_height

        public double map_height​(int y_pixels)
        return height (in map units) of a number of pixels
      • map_col

        public int map_col​(double x)
        return the Cartesian Map column for a Map Y coordinate
      • map_row

        public int map_row​(double y)
        return the Cartesian Map column for a Map Y coordinate
      • screen_x

        public int screen_x​(double x)
        return pixel column for a given map x position
      • screen_y

        public int screen_y​(double y)
        return pixel row for a given map y position
      • on_screen

        public boolean on_screen​(double x,
                                 double y)
        is a map position within the current display window
        Parameters:
        x - coordinate (e.g. -0.5 to 0.5)
        y - coordinate (e.g. -0.5 to 0.5)
        Returns:
        boolean ... are those coordinates in the display window
      • addMapListener

        public void addMapListener​(MapListener interested)
        register a listener for selection events
        Parameters:
        interested - class to receive call-backs
      • removeMapListener

        public void removeMapListener​(MapListener which)
        un-register a selection event listener
        Parameters:
        which - class to be removed
      • selectMode

        public void selectMode​(Map.Selection type)
        tell map-selection tool what kind of selection we expect
        Parameters:
        type - (RECTANGLE, POINT, LINE, ...)
      • checkSelection

        public boolean checkSelection​(Map.Selection type)
        see if a selection has already been made and call listener
        Parameters:
        type - desired type of selection
        Returns:
        boolean whether or not selection is in place
      • mouseClicked

        public void mouseClicked​(java.awt.event.MouseEvent e)
        mouse click at an on-map location
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent e)
        start the definition of region selection
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent e)
        extend/alter the region being selected
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent e)
        end the definition of a region selection
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent e)
        (perfunctory)
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent e)
        (perfunctory)
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent e)
        (perfunctory)
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
      • selectLine

        public void selectLine​(int x0,
                               int y0,
                               int x1,
                               int y1)
        highlight a line on the displayed map
        Parameters:
        x0 - screen x
        y0 - screen y
        x1 - screen x
        y1 - screen y
      • selectRect

        public void selectRect​(int x0,
                               int y0,
                               int x1,
                               int y1)
        highlight a rectangular selection on the displayed map
        Parameters:
        x0 - screen x
        y0 - screen y
        x1 - screen x
        y1 - screen y
      • selectPoints

        public void selectPoints​(int x0,
                                 int y0,
                                 int x1,
                                 int y1,
                                 boolean add)
        highlight points in rectangular selection on the displayed map
        Parameters:
        x0 - screen x
        y0 - screen y
        x1 - screen x
        y1 - screen y
        add - add these to already selected points
      • inTheBox

        public boolean inTheBox​(double x,
                                double y)
        return whether or not Map coordinates are within a selected box
      • highlight

        public void highlight​(int point,
                              java.awt.Color c)
        highlight points (typically for diagnostic purposes
        Parameters:
        point - number (-1 = reset)
        c - Color for highlighing
      • highlight

        public void highlight​(double x,
                              double y)
        highlight non-mesh point
        Parameters:
        x - - map X coordinate
        y - - map Y coordinate
        c - - color for highlighting
      • choosePoint

        public MeshPoint choosePoint​(int screen_x,
                                     int screen_y)
        find the mesh point closest to a screen location
        Parameters:
        screen_x -
        screen_y -
        Returns:
        nearest MeshPoint
      • setWindow

        public void setWindow​(double x0,
                              double y0,
                              double x1,
                              double y1)
      • paintComponent

        public void paintComponent​(java.awt.Graphics g)
        repaint the entire displayed map pane
        Parameters:
        g - - Graphics component (pane) for displayed map Note: order of painting is carefully chosen to enable layering of some things atop others
      • linear

        public static double linear​(int min,
                                    int max,
                                    double value)
        linear interpolation of a (color) value within a range
        Parameters:
        min - value in desired range
        max - value in desired range
        value - (0.0-1.0) to be scaled # @return interpolated value between min and max
      • logarithmic

        public static double logarithmic​(int min,
                                         int max,
                                         double value,
                                         double base)
        logarithmic interpolation of a (color) value within a range
        Parameters:
        min - value in desired range
        max - value in desired range
        value - (0.0-1.0) to be scaled
        base - - fraction of value corresponding to half of range # @return interpolated value between min and max
      • getMinimumSize

        public java.awt.Dimension getMinimumSize()
        return minimum acceptable canvas size
        Overrides:
        getMinimumSize in class javax.swing.JComponent
      • getPreferredSize

        public java.awt.Dimension getPreferredSize()
        return preferred canvas size
        Overrides:
        getPreferredSize in class javax.swing.JComponent