|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.micropsi.comp.console.worldconsole.WorldRenderer
This class represents all information needed to render a 2D view of the world at a sprecific
resolution. It caches resolution-dependent information and can update parts of it with given
world model data.
It's main service is to render a 2d view of the world to a given graphics context.
Objects of this class have to be disposed after usage using dispose().
| Nested Class Summary | |
class |
WorldRenderer.ObjectPainter
|
class |
WorldRenderer.OverlayInfo
|
| Field Summary | |
protected static double |
baseScale
|
protected java.util.Map |
scaledImageCache
|
| Constructor Summary | |
WorldRenderer(LocalWorld worldController,
EditSession editSession)
Creates a renderer that uses a given world model and - if not null - the given edit session. |
|
WorldRenderer(LocalWorld worldController,
EditSession editSession,
IOverlayChangeNotifier changeNotifier)
Creates a renderer that uses a given world model and - if not null - the given edit session and an object to request redraw. |
|
| Method Summary | |
protected void |
clearImageCache()
|
void |
dispose()
|
Rectangle |
dragObjectPainterBy(WorldRenderer.ObjectPainter objPainter,
int x,
int y)
|
void |
endDragging(WorldRenderer.ObjectPainter objPainter)
|
WorldObject |
getClickedObject(int x,
int y)
|
WorldObject |
getClickedObjectUnderSelected(int x,
int y)
|
Position |
getDragPosition(WorldRenderer.ObjectPainter objPainter,
int x,
int y)
|
protected EditSession |
getEditSession()
|
protected LocalWorld |
getLocalWorld()
|
Rectangle |
getObjectBounds(WorldObject obj)
Returns a rectangle describing the image extends of the given object in screen coordinates. |
protected java.util.Map |
getObjectPainters()
|
protected java.util.Collection |
getObjectPaintersSorted()
|
java.util.Collection |
getObjectsInSelectionRectangle()
|
WorldRenderer.OverlayInfo |
getOverlayInfo(java.lang.String name)
Returns the WorldRenderer.OverlayInfo objects with the given name, null if none exists.
|
java.util.List |
getOverlayInfoList()
Returns a List of WorldRenderer.OverlayInfo objects. |
double |
getScaleX()
|
double |
getScaleY()
|
int |
getScreenX(double x)
|
int |
getScreenX(Position pos)
|
int |
getScreenY(double y)
|
int |
getScreenY(Position pos)
|
java.util.Set |
getSelectedObjectPainters()
|
Rectangle |
getSelectionRectangle()
Gets the rectangle shown while selecting areas. |
Point |
getSizeRenderedWorld()
|
Position |
getWorldHighestCoords()
|
Position |
getWorldLowestCoords()
|
Position |
getWorldPosition(int screenX,
int screenY)
|
protected void |
initOverlayRenderer(LocalWorld world,
EditSession editSession,
IOverlayChangeNotifier changeNotifier)
|
boolean |
isOverlayEnabled(java.lang.String name)
Returns true if the overlay with the given name is enabled, false if it is not or if there is no such overlay. |
protected void |
paintBackground(GC gc,
int offsetX,
int offsetY)
|
protected void |
paintObjects(GC gc,
int offsetX,
int offsetY)
|
protected void |
paintOverlay(GC gc,
int offsetX,
int offsetY,
WorldRenderer.OverlayInfo renderInfo)
|
protected void |
paintSelectionRectangle(GC gc,
int offsetX,
int offsetY)
|
void |
paintWorld(GC gc,
int offsetX,
int offsetY)
Paints part of the current world on the given GC. |
void |
paintWorld(GC gc,
long objectId)
Convenience method. |
void |
paintWorld(GC gc,
Position pos)
Convenience method. |
void |
prepareDragging(WorldRenderer.ObjectPainter objPainter)
|
protected void |
resetObjectPaintersSort()
|
void |
setGroundmapArea(Area2D area)
|
boolean |
setOverlayEnabled(java.lang.String name,
boolean enabled)
Sets the enabled state of the overlay with the given name. |
void |
setScale(double sX,
double sY)
|
void |
setWorldArea(Area2D area)
|
Rectangle |
startDragging(WorldRenderer.ObjectPainter objPainter)
|
void |
updateAllObjects()
|
Rectangle |
updateMultipleObjects(java.util.Collection changedObjects)
Creates or updates resolution specific data for a collection of given world objects. |
Rectangle |
updateObject(WorldObject changedObject)
Creates or updates resolution specific data for a given world object. |
Rectangle |
updateObject(WorldObject changedObject,
boolean forceRefresh)
|
Rectangle |
updateSelectionRectangle(Rectangle selectionRectangle)
Sets the rectangle shown while selecting areas. |
Rectangle |
updateSelectionState(WorldObject obj)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final double baseScale
protected java.util.Map scaledImageCache
| Constructor Detail |
public WorldRenderer(LocalWorld worldController,
EditSession editSession)
dispose().
worldController - - the world model to use.editSession - - an edit session that will be used. May be null.LocalWorld, @see EditSession
public WorldRenderer(LocalWorld worldController,
EditSession editSession,
IOverlayChangeNotifier changeNotifier)
dispose().
worldController - - the world model to use.editSession - - an edit session that will be used. May be null.changeNotifier - - instance for overlays to request redraw of the render target. May be null.LocalWorld, @see EditSession| Method Detail |
protected void initOverlayRenderer(LocalWorld world,
EditSession editSession,
IOverlayChangeNotifier changeNotifier)
public void updateAllObjects()
public Rectangle updateObject(WorldObject changedObject)
changedObject - - the world object whose data should be updated
public Rectangle updateObject(WorldObject changedObject,
boolean forceRefresh)
public Rectangle updateSelectionState(WorldObject obj)
public Rectangle updateMultipleObjects(java.util.Collection changedObjects)
changedObjects - - the world objects whose data should be updated
public void paintWorld(GC gc,
Position pos)
gc - - target GCpos - - Position to be placed in the center of the image
public void paintWorld(GC gc,
long objectId)
gc - - target GCobjectId - - id of object to be placed in the center
public void paintWorld(GC gc,
int offsetX,
int offsetY)
gc - - GC to paint onoffsetX - - x 'screen' coordinate to be placed on the left border of the painted partoffsetY - - y 'screen' coordinate to be placed on the top border of the painted part
protected void paintOverlay(GC gc,
int offsetX,
int offsetY,
WorldRenderer.OverlayInfo renderInfo)
protected void paintObjects(GC gc,
int offsetX,
int offsetY)
protected void paintBackground(GC gc,
int offsetX,
int offsetY)
gc -
protected void paintSelectionRectangle(GC gc,
int offsetX,
int offsetY)
public void setScale(double sX,
double sY)
public WorldObject getClickedObject(int x,
int y)
public WorldObject getClickedObjectUnderSelected(int x,
int y)
public void dispose()
protected void clearImageCache()
public int getScreenX(Position pos)
getScreenX in interface IRenderInfopublic int getScreenX(double x)
getScreenX in interface IRenderInfopublic int getScreenY(Position pos)
getScreenY in interface IRenderInfopublic int getScreenY(double y)
getScreenY in interface IRenderInfo
public Position getWorldPosition(int screenX,
int screenY)
getWorldPosition in interface IRenderInfopublic Rectangle getObjectBounds(WorldObject obj)
IRenderInfo
getObjectBounds in interface IRenderInfoobj - - the object
protected java.util.Collection getObjectPaintersSorted()
protected void resetObjectPaintersSort()
protected LocalWorld getLocalWorld()
protected java.util.Map getObjectPainters()
public Point getSizeRenderedWorld()
getSizeRenderedWorld in interface IRenderInfopublic Position getWorldHighestCoords()
getWorldHighestCoords in interface IRenderInfopublic Position getWorldLowestCoords()
getWorldLowestCoords in interface IRenderInfopublic double getScaleX()
getScaleX in interface IRenderInfopublic double getScaleY()
getScaleY in interface IRenderInfopublic void setWorldArea(Area2D area)
public void setGroundmapArea(Area2D area)
protected EditSession getEditSession()
public Position getDragPosition(WorldRenderer.ObjectPainter objPainter,
int x,
int y)
public void prepareDragging(WorldRenderer.ObjectPainter objPainter)
public Rectangle startDragging(WorldRenderer.ObjectPainter objPainter)
public void endDragging(WorldRenderer.ObjectPainter objPainter)
public Rectangle dragObjectPainterBy(WorldRenderer.ObjectPainter objPainter,
int x,
int y)
public java.util.Set getSelectedObjectPainters()
public Rectangle getSelectionRectangle()
public Rectangle updateSelectionRectangle(Rectangle selectionRectangle)
selectionRectangle - The selectionRectangle to set. May be null.
public java.util.Collection getObjectsInSelectionRectangle()
public java.util.List getOverlayInfoList()
WorldRenderer.OverlayInfo objects. Instances can be modified. Modification
does not trigger redraw.
public WorldRenderer.OverlayInfo getOverlayInfo(java.lang.String name)
WorldRenderer.OverlayInfo objects with the given name, null if none exists.
Instance can be modified. Modification does not trigger redraw.
public boolean isOverlayEnabled(java.lang.String name)
name - - the name of the overlay
public boolean setOverlayEnabled(java.lang.String name,
boolean enabled)
name - - the name of the overlayenabled - - the new state
|
(c) by Micropsi Project: http://www.cognitive-agents.org | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||