Package org.eclipse.gef.rulers
Class RulerProvider
java.lang.Object
org.eclipse.gef.rulers.RulerProvider
This class provides an interface to interact with the ruler/guide feature
 provided in GEF. A 
RulerProvider represents a ruler (and the
 guides contained within), and provides the necessary information about them.
 Clients wishing to utilize this GEF feature should do the following:
- Extend this class and override the necessary methods. Also provide a
 notification mechanism to notify registered RulerChangeListeners of changes in ruler properties.
- Set instances of that class as properties on the diagram's graphical viewer (PROPERTY_HORIZONTAL_RULER and/or PROPERTY_VERTICAL_RULER)
- Set PROPERTY_RULER_VISIBILITY to be trueon the graphical viewer.
- Since:
- 3.0
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected List<RulerChangeListener> A list ofRulerChangeListeners that have to be notified of changes in ruler/guide properties.static final StringThe following property should be set on the graphical viewer.static final StringThe following property should be set on the graphical viewer.static final StringThe following property should be set on the graphical viewer.static final intConstant indicating that the ruler should display centimeters.static final intConstant indicating that the ruler should display a custom unit per pixel count.static final intConstant indicating that the ruler should display inches.static final intConstant indicating that the ruler should display pixel count.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddRulerChangeListener(RulerChangeListener listener) The given listener will be notified of changes in ruler properties.voidgetAccGuideDescription(AccessibleEvent e, Object guide) Return the description of the control or specified child in theresultfield of the event object.voidgetAccGuideName(AccessibleEvent e, Object guide) Return the given guide's name/label in theresultfield of the given event.voidgetAccGuideValue(AccessibleControlEvent e, Object guide) Return the guide's position in theresultfield of the given event.getAttachedEditParts(Object guide, GraphicalViewer viewer) Returns a List of EditParts that are attached to the given guide.getAttachedModelObjects(Object guide) Returns a List of model objects that are attached to the given guide.getCreateGuideCommand(int position) Clients should override this method to return a Command to create a new guide at the given position.intWhen the unit to be used for the ruler isUNIT_CUSTOMclients need to override this method to return the pixel dots per unit to be used for this ruler.getDeleteGuideCommand(Object guide) Clients should override this method to return a Command to delete the given guide.getGuideAt(int position) In most cases, there should be no need for clients to override this method.intgetGuidePosition(Object guide) Clients should override this method to return the position (in pixels) of the given guide.int[]Clients should override this method to return an array of all the positions of all the guides on this ruler.Clients should override this method to return a list of all the guides set on this ruler.getMoveGuideCommand(Object guide, int positionDelta) Clients should override this method to return a Command to move the given guide by the given amount.getRuler()Clients should override this method to return a model representation of the ruler.intgetUnit()Clients should override this method to return the units that the ruler should display: one of UNIT_INCHES, UNIT_CENTIMETERS, UNIT_PIXELS.voidremoveRulerChangeListener(RulerChangeListener listener) The given listener will not be notified of changes in the ruler anymore.voidsetUnit(int newUnit) This method will be invoked when the user requests that the ruler display a different measurement.
- 
Field Details- 
PROPERTY_HORIZONTAL_RULERThe following property should be set on the graphical viewer. PROPERTY_HORIZONTAL_RULER should have a RulerProvider as its value.- See Also:
 
- 
PROPERTY_RULER_VISIBILITYThe following property should be set on the graphical viewer. PROPERTY_RULER_VISIBILITY should have a Boolean value.- See Also:
 
- 
PROPERTY_VERTICAL_RULERThe following property should be set on the graphical viewer. PROPERTY_VERTICAL_RULER should have a RulerProvider as its value.- See Also:
 
- 
UNIT_CENTIMETERSpublic static final int UNIT_CENTIMETERSConstant indicating that the ruler should display centimeters. Note that this setting does not affect how a guide's position is interpreted (it is always taken as pixels).- See Also:
 
- 
UNIT_INCHESpublic static final int UNIT_INCHESConstant indicating that the ruler should display inches. Note that this setting does not affect how a guide's position is interpreted (it is always taken as pixels).- See Also:
 
- 
UNIT_PIXELSpublic static final int UNIT_PIXELSConstant indicating that the ruler should display pixel count.- See Also:
 
- 
UNIT_CUSTOMpublic static final int UNIT_CUSTOMConstant indicating that the ruler should display a custom unit per pixel count. The unit per pixel count shall be provided viagetCustomRulerDPU().- Since:
- 3.20
- See Also:
 
- 
listenersA list ofRulerChangeListeners that have to be notified of changes in ruler/guide properties.
 
- 
- 
Constructor Details- 
RulerProviderpublic RulerProvider()
 
- 
- 
Method Details- 
addRulerChangeListenerThe given listener will be notified of changes in ruler properties.- Parameters:
- listener- the listener that is to be notified of changes in ruler properties
 
- 
getAccGuideDescriptionReturn the description of the control or specified child in theresultfield of the event object. Returning an empty string tells the client that the control or child does not have a description, and returning null tells the client to use the platform description.- Parameters:
- e- AccessibleEvent
- guide- The guide whose accessibility information is requested
- See Also:
 
- 
getAccGuideNameReturn the given guide's name/label in theresultfield of the given event.- Parameters:
- e- AccessibleEvent
- guide- The guide whose accessibility information is requested
- See Also:
 
- 
getAccGuideValueReturn the guide's position in theresultfield of the given event.- Parameters:
- e- AccessibleEvent
- guide- The guide whose accessibility information is requested
- See Also:
 
- 
getAttachedModelObjectsReturns a List of model objects that are attached to the given guide.- Parameters:
- guide- the guide to which the model parts are attached.
- Returns:
- list of attached model objects
 
- 
getAttachedEditPartsReturns a List of EditParts that are attached to the given guide.- Parameters:
- guide- the guide to which the EditParts are attached.
- viewer- the GraphicalViewer in which these EditParts are shown.
- Returns:
- list of attached edit parts
 
- 
getCreateGuideCommandClients should override this method to return a Command to create a new guide at the given position.- Parameters:
- position- The pixel position where the new guide is to be created
- Returns:
- UnexecutableCommand
 
- 
getCustomRulerDPUpublic int getCustomRulerDPU()When the unit to be used for the ruler isUNIT_CUSTOMclients need to override this method to return the pixel dots per unit to be used for this ruler. Clients should override this method to return- Returns:
- the dots per unit for the ruler, default is 1 which is equal to use
         UNIT_PIXELS.
- Since:
- 3.20
 
- 
getDeleteGuideCommandClients should override this method to return a Command to delete the given guide.- Parameters:
- guide- The guide that is to be deleted
- Returns:
- UnexecutableCommand
 
- 
getGuideAtIn most cases, there should be no need for clients to override this method.- Parameters:
- position- The position of the guide that is to be found
- Returns:
- The guide object at the given position; nullif no guide exists at the given position
 
- 
getMoveGuideCommandClients should override this method to return a Command to move the given guide by the given amount.- Parameters:
- guide- The guide that is to be moved
- positionDelta- The amount by which the guide is to be moved
- Returns:
- UnexecutableCommand
 
- 
getGuidesClients should override this method to return a list of all the guides set on this ruler.- Returns:
- an empty list
 
- 
getGuidePositionspublic int[] getGuidePositions()Clients should override this method to return an array of all the positions of all the guides on this ruler.- Returns:
- an empty array
 
- 
getGuidePositionClients should override this method to return the position (in pixels) of the given guide.- Parameters:
- guide- The guide whose position is to be determined
- Returns:
- Integer.MIN_VALUE
 
- 
getRulerClients should override this method to return a model representation of the ruler.- Returns:
- null
 
- 
getUnitpublic int getUnit()Clients should override this method to return the units that the ruler should display: one of UNIT_INCHES, UNIT_CENTIMETERS, UNIT_PIXELS.- Returns:
- UNIT_INCHES
 
- 
removeRulerChangeListenerThe given listener will not be notified of changes in the ruler anymore.- Parameters:
- listener- the listener that is to be removed
 
- 
setUnitpublic void setUnit(int newUnit) This method will be invoked when the user requests that the ruler display a different measurement. The default implementation ignores the user's request.- Parameters:
- newUnit- the new unit of measurement; will be one of- UNIT_CENTIMETERS,- UNIT_INCHES, or- UNIT_PIXELS
 
 
-