org.ka2ddo.yaac.gui.osm
Class OSMLayer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.bbn.openmap.Layer
                  extended by org.ka2ddo.yaac.gui.osm.OSMLayer
All Implemented Interfaces:
MapMouseListener, ProjectionListener, ProjectionPainter, PropertyConsumer, java.awt.event.ActionListener, java.awt.event.ComponentListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.io.Serializable, java.lang.Runnable, java.util.EventListener

public class OSMLayer
extends Layer
implements java.lang.Runnable, java.awt.event.ComponentListener, MapMouseListener

This class implements a rendering Layer for OpenMap that draws street maps on the MapBean based on the binary tiled map data extracted from the OpenStreetMap database.

See Also:
OsmXmlSegmenter, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.awt.Color DEFAULT_BUILDING_COLOR
          The default color used for filling building outlines on the OpenStreetMap layer of the map.
static float MAX_NODE_LABEL_ZOOM
          Maximum value of map scale for rendering the labels of Nodes without either matching a searched-for AmenityType or having an expanded zoom level (due to being a Place).
static float MAX_NODE_ZOOM
          Maximum value of map scale for rendering Nodes without either matching a searched-for AmenityType or having an expanded zoom level (due to being a Place).
 
Fields inherited from class com.bbn.openmap.Layer
addAsBackground, AddAsBackgroundProperty, addToBeanContext, AddToBeanContextProperty, attributes, autoPalette, AutoPaletteProperty, beanContextChildSupport, coordTransform, DataPathPrefixProperty, DisplayPaletteCmd, DisplayPropertiesCmd, doHack, HidePaletteCmd, i18n, localHackList, maxScale, MaxScaleProperty, minScale, MinScaleProperty, palette, paletteListener, PrettyNameProperty, propertyPrefix, RedrawCmd, removable, RemovableProperty, SWING_PACKAGE, TransformProperty, windowSupport
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, 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 com.bbn.openmap.PropertyConsumer
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
OSMLayer()
          Create a layer for the map that renders OpenStreetMap data.
 
Method Summary
 void componentHidden(java.awt.event.ComponentEvent e)
          Invoked when the OSMLayer has been made invisible.
 void componentMoved(java.awt.event.ComponentEvent e)
          Invoked when the OSMLayer's position changes.
 void componentResized(java.awt.event.ComponentEvent e)
          Invoked when the map window's size changes.
 void componentShown(java.awt.event.ComponentEvent e)
          Invoked when the OSMLayer has been made visible.
 void flushFileCache()
          Clear cached pointers to tile files.
 AmenityType getAmenityToShow()
          Report the specific AmenityType being highlighted on the map.
 java.awt.Color getBuildingColor()
          Get the current color used for filling in buildings on the map.
 MapMouseListener getMapMouseListener()
          Specify the object to receive OpenMap mouse events on behalf of the OSM Layer.
 java.lang.String[] getMouseModeServiceList()
          Specify the behavior the MapBean should give to this OSMLayer for mouse input.
 void initializePlaceZoomLevels()
          Load the persisted zoom levels for Place labels from the Preferences backing store.
 boolean isAutoLoadOsmTiles()
          Report whether YAAC is configured to try to auto-download pre-imported OSM tiles that are not currently on the system.
 boolean isShowHighwaySigns()
          Report whether highway signs should be displayed on the map.
 boolean isShowLabelsInEnglish()
          Report whether map labels should be displayed in English if the default name is in some other locale and OpenStreetMap provides an English translation.
 boolean isShowLayer(int index)
          Report whether the identified WayType layer should be rendered on the map.
 boolean isShowMap()
          Report whether the OpenStreetMap map overlay should be displayed.
 boolean isShowPOI()
          Report whether OSM Node points of interest should be displayed.
 boolean isShowUnlabeledWays()
          Report if unlabeled and untyped map features should be displayed.
 boolean mouseClicked(java.awt.event.MouseEvent e)
          Invoked when the mouse button has been clicked (pressed and released) on a component.
 boolean mouseDragged(java.awt.event.MouseEvent mouseEvent)
           
 void mouseEntered(java.awt.event.MouseEvent mouseEvent)
          Invoked when the mouse enters a component.
 void mouseExited(java.awt.event.MouseEvent mouseEvent)
          Invoked when the mouse exits a component.
 void mouseMoved()
           
 boolean mouseMoved(java.awt.event.MouseEvent mouseEvent)
           
 boolean mousePressed(java.awt.event.MouseEvent mouseEvent)
          Invoked when a mouse button has been pressed on a component.
 boolean mouseReleased(java.awt.event.MouseEvent mouseEvent)
          Invoked when a mouse button has been released on a component.
protected  void paintComponent(java.awt.Graphics g)
          Paint the rendered OpenStreetMap data into the map window.
 void projectionChanged(ProjectionEvent e)
          Callback from OpenMap when map projection is changed,
 void regenerateAndRepaint()
          Cause the OSMLayer to recompute its map based on current settings.
 void run()
          DO NOT CALL: background thread to render OpenStreetMap data into a BufferedImage for painting on the map window.
 void setAmenityToShow(AmenityType amenityToShow)
          Specify that Ways and Nodes of the specified AmenityType should be highlighted on the map, regardless of zoom level, or that there is no special type to highlight.
 void setAutoLoadOsmTiles(boolean autoLoadOsmTiles)
          Specify whether auto-download of missing pre-imported OSM tiles should be performed.
 void setBuildingColor(java.awt.Color buildingColor)
          Set the color to be used for filling building outlines on the map.
 void setShowHighwaySigns(boolean showHighwaySigns)
          Specify whether highway signs should be displayed on the map.
 void setShowLabelsInEnglish(boolean showLabelsInEnglish)
          Specify whether map labels should be displayed in English if the default name is in some other locale and OpenStreetMap provides an English translation.
 void setShowLayer(boolean showLayer, int index)
          Specify whether the identified WayType layer should be rendered on the map.
 void setShowMap(boolean showMap)
          Specify whether the OpenStreetMap map overlay should be rendered.
 void setShowPOI(boolean showPOI)
          Specify whether OSM Node points of interest should be displayed.
 void setShowUnlabeledWays(boolean showUnlabeledWays)
          Specify if unlabeled and untyped map features should be displayed.
 void startRegenerate()
          Release the lock against rendering OSM data and start a fresh rendering.
 void stopRegenerate(int offsetX, int offsetY)
          Stop the current re-rendering of the map and set the pixel offsets for painting the last rendering of the OSM data.
 
Methods inherited from class com.bbn.openmap.Layer
actionPerformed, addComponentListener, added, addInfoDisplayListener, addLayerStatusListener, addMouseListener, addVetoableChangeListener, childrenAdded, childrenRemoved, clearListeners, connectToBeanContext, createWindowSupport, disconnectFromBeanContext, dispose, finalize, findAndInit, findAndInit, findAndUndo, fireHideToolTip, firePaletteEvent, fireRequestBrowserContent, fireRequestBrowserContent, fireRequestCursor, fireRequestInfoLine, fireRequestInfoLine, fireRequestInfoLine, fireRequestMessage, fireRequestMessage, fireRequestToolTip, fireRequestToolTip, fireRequestURL, fireRequestURL, fireStatusUpdate, fireStatusUpdate, fireVetoableChange, getAddAsBackground, getAddToBeanContext, getAttribute, getBeanContext, getCoordTransform, getGUI, getIcon, getMaxScale, getMinScale, getPackage, getPalette, getProjection, getProperties, getPropertyInfo, getPropertyPrefix, getWindowSupport, hasGUI, hidePalette, isAutoPalette, isProjectionOK, isRemovable, notifyHideHack, prependDataPathPrefix, putAttribute, removeComponentListener, removeConfirmed, removed, removeInfoDisplayListener, removeLayerStatusListener, removeVetoableChangeListener, renderDataForProjection, repaint, resetPalette, setAddAsBackground, setAddToBeanContext, setAutoPalette, setBeanContext, setCoordTransform, setIcon, setLayerProperties, setMaxScale, setMinScale, setName, setPaletteVisible, setProjection, setProjection, setProperties, setProperties, setPropertyPrefix, setRemovable, setVisible, setWindowSupport, showPalette
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.beans.beancontext.BeanContextChild
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

DEFAULT_BUILDING_COLOR

public static final java.awt.Color DEFAULT_BUILDING_COLOR
The default color used for filling building outlines on the OpenStreetMap layer of the map.


MAX_NODE_ZOOM

public static final float MAX_NODE_ZOOM
Maximum value of map scale for rendering Nodes without either matching a searched-for AmenityType or having an expanded zoom level (due to being a Place).

See Also:
setAmenityToShow(org.ka2ddo.yaac.osm.AmenityType), Constant Field Values

MAX_NODE_LABEL_ZOOM

public static final float MAX_NODE_LABEL_ZOOM
Maximum value of map scale for rendering the labels of Nodes without either matching a searched-for AmenityType or having an expanded zoom level (due to being a Place).

See Also:
Constant Field Values
Constructor Detail

OSMLayer

public OSMLayer()
Create a layer for the map that renders OpenStreetMap data.

Method Detail

initializePlaceZoomLevels

public void initializePlaceZoomLevels()
Load the persisted zoom levels for Place labels from the Preferences backing store.


isShowMap

public final boolean isShowMap()
Report whether the OpenStreetMap map overlay should be displayed.

Returns:
boolean true if OpenStreetMap overlay is displayed

setShowMap

public void setShowMap(boolean showMap)
Specify whether the OpenStreetMap map overlay should be rendered. Note this is independent of whether there actually is any OpenStreetMap data to render.

Parameters:
showMap - boolean true if OpenStreetMap layer should be rendered

isShowLayer

public final boolean isShowLayer(int index)
Report whether the identified WayType layer should be rendered on the map.

Parameters:
index - WayType enumeration ordinal of type being queried
Returns:
boolean true if ways of the specified WayType should be rendered

setShowLayer

public void setShowLayer(boolean showLayer,
                         int index)
Specify whether the identified WayType layer should be rendered on the map.

Parameters:
showLayer - boolean true if ways of the specified WayType should be rendered
index - WayType enumeration ordinal of type being specified

isShowHighwaySigns

public boolean isShowHighwaySigns()
Report whether highway signs should be displayed on the map.

Returns:
boolean true if highways signs should be displayed

setShowHighwaySigns

public void setShowHighwaySigns(boolean showHighwaySigns)
Specify whether highway signs should be displayed on the map.

Parameters:
showHighwaySigns - boolean true if highways signs should be displayed

isShowPOI

public boolean isShowPOI()
Report whether OSM Node points of interest should be displayed.

Returns:
boolean true if points of interest should be rendered on the map

setShowPOI

public void setShowPOI(boolean showPOI)
Specify whether OSM Node points of interest should be displayed.

Parameters:
showPOI - boolean true if points of interest should be rendered on the map

isShowUnlabeledWays

public boolean isShowUnlabeledWays()
Report if unlabeled and untyped map features should be displayed.

Returns:
boolean true if unlabeled/untyped map elements should be plotted

setShowUnlabeledWays

public void setShowUnlabeledWays(boolean showUnlabeledWays)
Specify if unlabeled and untyped map features should be displayed.

Parameters:
showUnlabeledWays - boolean true if unlabeled/untyped map elements should be plotted

isAutoLoadOsmTiles

public boolean isAutoLoadOsmTiles()
Report whether YAAC is configured to try to auto-download pre-imported OSM tiles that are not currently on the system.

Returns:
boolean true if auto-download is enabled

setAutoLoadOsmTiles

public void setAutoLoadOsmTiles(boolean autoLoadOsmTiles)
Specify whether auto-download of missing pre-imported OSM tiles should be performed.

Parameters:
autoLoadOsmTiles - boolean true if auto-download should be enabled

isShowLabelsInEnglish

public boolean isShowLabelsInEnglish()
Report whether map labels should be displayed in English if the default name is in some other locale and OpenStreetMap provides an English translation.

Returns:
boolean true if English labels should be used

setShowLabelsInEnglish

public void setShowLabelsInEnglish(boolean showLabelsInEnglish)
Specify whether map labels should be displayed in English if the default name is in some other locale and OpenStreetMap provides an English translation.

Parameters:
showLabelsInEnglish - boolean true if English labels should be used

getAmenityToShow

public AmenityType getAmenityToShow()
Report the specific AmenityType being highlighted on the map.

Returns:
the currently highlighted AmenityType, or null for no highlighting

setAmenityToShow

public void setAmenityToShow(AmenityType amenityToShow)
Specify that Ways and Nodes of the specified AmenityType should be highlighted on the map, regardless of zoom level, or that there is no special type to highlight.

Parameters:
amenityToShow - AmenityType to highlight, or null for no special highlighting

getBuildingColor

public java.awt.Color getBuildingColor()
Get the current color used for filling in buildings on the map.

Returns:
Color of building fill

setBuildingColor

public void setBuildingColor(java.awt.Color buildingColor)
Set the color to be used for filling building outlines on the map.

Parameters:
buildingColor - Color for building fill

regenerateAndRepaint

public void regenerateAndRepaint()
Cause the OSMLayer to recompute its map based on current settings.


projectionChanged

public void projectionChanged(ProjectionEvent e)
Callback from OpenMap when map projection is changed,

Specified by:
projectionChanged in interface ProjectionListener
Parameters:
e - ProjectionEvent identifying new projection

paintComponent

protected void paintComponent(java.awt.Graphics g)
Paint the rendered OpenStreetMap data into the map window.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - Graphics object to use for painting

stopRegenerate

public void stopRegenerate(int offsetX,
                           int offsetY)
Stop the current re-rendering of the map and set the pixel offsets for painting the last rendering of the OSM data. Typically used when map is being panned rapidly to allow the user to still see some map data without thrashing the system with aborted re-rendering for different re-centering and/or re-zooming of the map.

Parameters:
offsetX - int horizontal pixel offset for painting the last render of the OSM data onto the map
offsetY - int vertical pixel offset for painting the last render of the OSM data onto the map

startRegenerate

public void startRegenerate()
Release the lock against rendering OSM data and start a fresh rendering.


run

public final void run()
DO NOT CALL: background thread to render OpenStreetMap data into a BufferedImage for painting on the map window.

Specified by:
run in interface java.lang.Runnable

flushFileCache

public void flushFileCache()
Clear cached pointers to tile files. This is called when the configuration dialog changes the tile root directory path.


componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Invoked when the OSMLayer has been made invisible.

Specified by:
componentHidden in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Invoked when the OSMLayer's position changes.

Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Invoked when the map window's size changes.

Specified by:
componentResized in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Invoked when the OSMLayer has been made visible.

Specified by:
componentShown in interface java.awt.event.ComponentListener

getMapMouseListener

public MapMouseListener getMapMouseListener()
Specify the object to receive OpenMap mouse events on behalf of the OSM Layer.

Overrides:
getMapMouseListener in class Layer
Returns:
the OSMLayer object itself

getMouseModeServiceList

public java.lang.String[] getMouseModeServiceList()
Specify the behavior the MapBean should give to this OSMLayer for mouse input.

Specified by:
getMouseModeServiceList in interface MapMouseListener
Returns:
the SELECT_MOUSE_MODE constant to specify selecting items with the mouse

mouseClicked

public boolean mouseClicked(java.awt.event.MouseEvent e)
Invoked when the mouse button has been clicked (pressed and released) on a component.

Specified by:
mouseClicked in interface MapMouseListener

mousePressed

public boolean mousePressed(java.awt.event.MouseEvent mouseEvent)
Invoked when a mouse button has been pressed on a component.

Specified by:
mousePressed in interface MapMouseListener

mouseReleased

public boolean mouseReleased(java.awt.event.MouseEvent mouseEvent)
Invoked when a mouse button has been released on a component.

Specified by:
mouseReleased in interface MapMouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent mouseEvent)
Invoked when the mouse enters a component.

Specified by:
mouseEntered in interface MapMouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent mouseEvent)
Invoked when the mouse exits a component.

Specified by:
mouseExited in interface MapMouseListener

mouseDragged

public boolean mouseDragged(java.awt.event.MouseEvent mouseEvent)
Specified by:
mouseDragged in interface MapMouseListener

mouseMoved

public boolean mouseMoved(java.awt.event.MouseEvent mouseEvent)
Specified by:
mouseMoved in interface MapMouseListener

mouseMoved

public void mouseMoved()
Specified by:
mouseMoved in interface MapMouseListener