org.opengis.go.display.canvas
Interface Canvas
-
public interface CanvasCanvasdefines a common abstraction for implementations that manage the display and user manipulation ofGraphicinstances. ACanvaswith an XY (Cartesian) display field should support the following properties:- pixelWidth
- pixelHeight
- center
- width
- scale
- envelope
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description Graphicadd(Graphic graphic)Adds the givenGraphicto thisCanvas.GraphicaddAsEditable(Graphic graphic)Adds the givenGraphicto thisCanvas, immediately placing theGraphicin an editing/drawing mode, as defined by theCanvasimplementation.voidaddCanvasListener(CanvasListener listener)Adds the given listener that will be notified when the state of thisCanvashas changed.voidaddEventManager(EventManager eventManager)Adds theEventManagersubinterface if it not currently in theCanvas's collection ofEventManagers.voiddispose()Method that may be called when aCanvasis no longer needed.voiddisposeEventManagers()Method that may be called when theEventManagers of aCanvasare no longer needed.voidenableCanvasHandler(CanvasHandler handler)Enables the givenCanvasHandler, removing the current handler (if any).EventManagerfindEventManager(java.lang.Class eventManagerClass)Returns the EventManager subinterface, based on the class type.CanvasHandlergetActiveCanvasHandler()Returns the currently activeCanvasHandleror null if no handler is active.CoordinateReferenceSystemgetDisplayCoordinateReferenceSystem()Returns the Coordinate Reference System associated with the display of thisCanvas.MathTransformgetDisplayToObjectiveTransform()Returns the coordinate transformation object for thisCanvas.DisplayFactorygetFactory()Returns theDisplayFactoryassociated with thisCanvas.Graphic[]getGraphicsAt(DirectPosition directPosition)Returns theGraphics that occupy the givenDirectPosition.Graphic[]getGraphicsIn(Envelope bounds)Returns theGraphics that occupy the givenEnvelope.java.lang.ObjectgetImplHint(java.lang.String hintName)Returns the rendering hint associated with the hint name.CoordinateReferenceSystemgetObjectiveCoordinateReferenceSystem()Returns the objective Coordinate Reference System (e.g.MathTransformgetObjectiveToDisplayTransform()Returns the coordinate transformation object for thisCanvas.CanvasStategetState()Returns a copy of the current state of thisCanvas.java.lang.StringgetTitle()Returns the title assigned to thisCanvas.GraphicgetTopGraphicAt(DirectPosition directPosition)Returns the top-mostGraphicthat occupies givenDirectPosition.java.lang.StringgetUID()Returns the unique identifier of thisCanvas, which is assigned by the implementation.booleanisVisible(DirectPosition coordinate)Returns true if the given coordinate is visible on thisCanvas.voidremove(Graphic graphic)Removes the givenGraphicfrom thisCanvas.voidremoveCanvasHandler(CanvasHandler handler)Removes the givenCanvasHandlerfrom thisCanvas.voidremoveCanvasListener(CanvasListener listener)Removes the given listener.voidsetImplHint(java.lang.String hintName, java.lang.Object hint)Sets a rendering hint for implementation or platform specific rendering information.voidsetObjectiveCoordinateReferenceSystem(CoordinateReferenceSystem crs)Sets the objective Coordinate Reference System (e.g.voidsetObjectiveCoordinateReferenceSystem(CoordinateReferenceSystem crs, MathTransform objectiveToDisplay, MathTransform displayToObjective)Sets the objective Coordinate Reference System (e.g.voidsetTitle(java.lang.String title)Sets the title of thisCanvas.
-
-
-
Method Detail
-
dispose
void dispose()
Method that may be called when aCanvasis no longer needed. Implementations may use this method to release resources or to return the object to an object pool. It is an error to reference aCanvasafter its dispose method has been called.
-
disposeEventManagers
void disposeEventManagers()
Method that may be called when theEventManagers of aCanvasare no longer needed. Implementations may use this method to release resources or to return the object to an object pool. It is an error to reference anyEventManagers of aCanvasafter this method has been called.
-
getUID
java.lang.String getUID()
Returns the unique identifier of thisCanvas, which is assigned by the implementation. The UID is immutable and may be used to retrieve a particularCanvasfrom theGraphicFactory.- Returns:
- the UID of this
Canvas.
-
setTitle
void setTitle(java.lang.String title)
Sets the title of thisCanvas. The title of aCanvasmay or may not be displayed on the titlebar of an application's window.- Parameters:
title- the new title for thisCanvas.
-
getTitle
java.lang.String getTitle()
Returns the title assigned to thisCanvas.- Returns:
- the title of this
Canvas.
-
getFactory
DisplayFactory getFactory()
Returns theDisplayFactoryassociated with thisCanvas.- Returns:
- the
DisplayFactory.
-
getState
CanvasState getState()
Returns a copy of the current state of thisCanvas. The object returned will implementCanvasStateor one of its subinterfaces, depending on the type of Canvas.
-
isVisible
boolean isVisible(DirectPosition coordinate)
Returns true if the given coordinate is visible on thisCanvas.
-
add
Graphic add(Graphic graphic)
Adds the givenGraphicto thisCanvas. Implementations should respect the zOrder retrieved by callingGraphic.getGraphicStyle().getZOrderHint(). When two addedGraphics have the same zOrder, the most recently added one should be on top.- Parameters:
graphic- theGraphicto add.
-
addAsEditable
Graphic addAsEditable(Graphic graphic)
Adds the givenGraphicto thisCanvas, immediately placing theGraphicin an editing/drawing mode, as defined by theCanvasimplementation. AGraphicadded as editable may or may not be visible when it is added, as it may wait for user input to define theGraphic's values through mouse gestures or key input.- Parameters:
graphic- theGraphicto add as editable.
-
remove
void remove(Graphic graphic)
Removes the givenGraphicfrom thisCanvas.- Parameters:
graphic- theGraphicto remove.
-
findEventManager
EventManager findEventManager(java.lang.Class eventManagerClass)
Returns the EventManager subinterface, based on the class type.Note: While the class implementing
Canvasmay additionally implementEventManagersubinterface(s). While this design is simple, it limits theCanvasobject to the input mechanisms supported by to those particularEventManagersubinterface(s), and thus is discouraged.If the class implementing Canvas does not implement the particular
EventManagersubinterface, then this method can look up theEventManagervia an implementation-specific mechanism. Otherwise, if the class implementing Canvas does implement the particularEventManagersubinterface, this method can return thethisreference.- Parameters:
eventManagerClass- the class type of the EventManager subinterface.- Returns:
- a class that implements the requested EventManager subinterface, or null if there is no implementing class.
-
addEventManager
void addEventManager(EventManager eventManager)
Adds theEventManagersubinterface if it not currently in theCanvas's collection ofEventManagers.- Parameters:
eventManager- theEventManagertype to be added to theCanvas's collection.
-
getTopGraphicAt
Graphic getTopGraphicAt(DirectPosition directPosition)
Returns the top-mostGraphicthat occupies givenDirectPosition. The top-mostGraphicwill have the highest zOrder.- Parameters:
directPosition- theDirectPositionat which to look forGraphics.- Returns:
- the top-most
Graphicat the givenDirectPosition.
-
getGraphicsAt
Graphic[] getGraphicsAt(DirectPosition directPosition)
Returns theGraphics that occupy the givenDirectPosition. The order is implementation-specific.- Parameters:
directPosition- theDirectPositionat which to look forGraphics.- Returns:
- the array of
Graphics at the givenDirectPosition.
-
getGraphicsIn
Graphic[] getGraphicsIn(Envelope bounds)
Returns theGraphics that occupy the givenEnvelope. The order is implementation-specific.- Parameters:
bounds- theEnvelopein which to look forGraphics.- Returns:
- the array of
Graphics in the givenEnvelope.
-
addCanvasListener
void addCanvasListener(CanvasListener listener)
Adds the given listener that will be notified when the state of thisCanvashas changed.
-
removeCanvasListener
void removeCanvasListener(CanvasListener listener)
Removes the given listener.
-
enableCanvasHandler
void enableCanvasHandler(CanvasHandler handler)
Enables the givenCanvasHandler, removing the current handler (if any). The new handler'shandlerEnabled(CanvasController)method is called, passing in a new, activeCanvasControllerthat will allow the programmer to modify theCanvas's properties. Implementation suggestion:public void enableCanvasHandler(CanvasHandler handler) { if (handler != activeHandler) { if (activeHandler != null) { removeCanvasHandler(activeHandler); } activeHandler = handler; activeController = new CanvasController(this); activeHandler.handlerEnabled(activeController); } }
-
removeCanvasHandler
void removeCanvasHandler(CanvasHandler handler)
Removes the givenCanvasHandlerfrom thisCanvas.
-
getActiveCanvasHandler
CanvasHandler getActiveCanvasHandler()
Returns the currently activeCanvasHandleror null if no handler is active.
-
setImplHint
void setImplHint(java.lang.String hintName, java.lang.Object hint)Sets a rendering hint for implementation or platform specific rendering information.- Parameters:
hintName- the name of the hint.hint- the rendering hint.
-
getImplHint
java.lang.Object getImplHint(java.lang.String hintName)
Returns the rendering hint associated with the hint name.- Parameters:
hintName- the name of the hint.- Returns:
- the rendering hint.
-
getDisplayCoordinateReferenceSystem
CoordinateReferenceSystem getDisplayCoordinateReferenceSystem()
Returns the Coordinate Reference System associated with the display of thisCanvas. The display Coordinate Reference System corresponds to the geometry of the display device (e.g. video monitor = Cartesian, planetarium = Spherical).- Returns:
- the display Coordinate Reference System
-
getObjectiveCoordinateReferenceSystem
CoordinateReferenceSystem getObjectiveCoordinateReferenceSystem()
Returns the objective Coordinate Reference System (e.g. the projection of a georeferenced Coordinate Reference System) for thisCanvas. This is the default objective Coordinate Reference System for thisCanvas.- Returns:
- the objective Coordinate Reference System
-
setObjectiveCoordinateReferenceSystem
void setObjectiveCoordinateReferenceSystem(CoordinateReferenceSystem crs)
Sets the objective Coordinate Reference System (e.g. the projection of a georeferenced Coordinate Reference System) for thisCanvas. This is the default objective Coordinate Reference System for thisCanvas.- Parameters:
crs- the objective Coordinate Reference System- Throws:
IncompatibleOperationException- when the specified transformation does not apply to either the objective or the display Coordinate Reference Systems.
-
setObjectiveCoordinateReferenceSystem
void setObjectiveCoordinateReferenceSystem(CoordinateReferenceSystem crs, MathTransform objectiveToDisplay, MathTransform displayToObjective) throws IncompatibleOperationException
Sets the objective Coordinate Reference System (e.g. the projection of a georeferenced Coordinate Reference System) for thisCanvas. This is the default objective Coordinate Reference System for thisCanvas.- Parameters:
crs- the objective Coordinate Reference SystemobjectiveToDisplay- the trasformation that converts between this objective Coordinate Reference System and the Canvas display Coordinate Reference System.displayToObjective- the trasformation that converts between the Canvas display Coordinate Reference System and this objective Coordinate Reference System.- Throws:
IncompatibleOperationException- when the specified transformation does not apply to either the objective or the display Coordinate Reference Systems.
-
getObjectiveToDisplayTransform
MathTransform getObjectiveToDisplayTransform()
Returns the coordinate transformation object for thisCanvas. This allows theCanvasto resolve conversions of coordinates between the objective and display Coordinate Reference Systems.- Returns:
- the coordinate transformation object
-
getDisplayToObjectiveTransform
MathTransform getDisplayToObjectiveTransform()
Returns the coordinate transformation object for thisCanvas. This allows theCanvasto resolve conversions of coordinates between the display and objective Coordinate Reference Systems.- Returns:
- the coordinate transformation object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG