Class ProjectionMapping
- java.lang.Object
-
- org.eclipse.jface.text.projection.ProjectionMapping
-
- All Implemented Interfaces:
IDocumentInformationMapping,IDocumentInformationMappingExtension,IDocumentInformationMappingExtension2
public class ProjectionMapping extends Object implements IDocumentInformationMapping, IDocumentInformationMappingExtension, IDocumentInformationMappingExtension2
Internal class. Do not use. Only public for testing purposes.Implementation of
IDocumentInformationMappingfor the projection mapping between a master and a slave document.- Since:
- 3.0
- Restriction:
- This class is not intended to be subclassed by clients.
- Restriction:
- This class is not intended to be instantiated by clients.
-
-
Constructor Summary
Constructors Constructor Description ProjectionMapping(IDocument masterDocument, String fragmentsCategory, IDocument slaveDocument, String segmentsCategory)Creates a new mapping between the given parent document and the given projection document.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IRegiongetCoverage()Returns the minimal region of the original document that completely comprises all of the image document ornullif there is no such region.IRegion[]getExactCoverage(IRegion originRegion)Returns the maximal sub-regions of the given origin region which are completely covered.intgetImageLength()Returns the length of the image document.voidprojectionChanged()Notifies this projection mapping that there was a projection change.inttoClosestImageLine(int originLine)Returns the line of the image document whose corresponding line in the original document is closest to the given line in the original document.IRegiontoClosestImageRegion(IRegion originRegion)Returns the minimal region of the image document that completely comprises the given region of the original document.IRegiontoExactImageRegion(IRegion originRegion)Adheres tooriginRegion=toOriginRegion(toExactImageRegion(originRegion)), iftoExactImageRegion(originRegion) !IRegion[]toExactImageRegions(IRegion originRegion)Returns the segments of the image document that exactly correspond to the given region of the original document.IRegion[]toExactOriginRegions(IRegion imageRegion)Returns the fragments of the original document that exactly correspond to the given region of the image document.inttoImageLine(int originLine)Returns the line of the image document that corresponds to the given line of the original document or-1if there is no such line.inttoImageOffset(int originOffset)Returns the offset in the image document that corresponds to the given offset in the original document or-1if there is no such offsetIRegiontoImageRegion(IRegion originRegion)Returns the minimal region of the image document that completely comprises the given region of the original document ornullif there is no such region.inttoOriginLine(int imageLine)Returns the line of the original document that corresponds to the given line of the image document or-1if there is no such line.IRegiontoOriginLines(int imageLine)Returns the range of lines of the original document that corresponds to the given line of the image document ornullif there are no such lines.inttoOriginOffset(int imageOffset)Returns the offset in the original document that corresponds to the given offset in the image document or-1if there is no such offsetIRegiontoOriginRegion(IRegion imageRegion)Returns the minimal region of the original document that completely comprises the given region of the image document ornullif there is no such region.
-
-
-
Constructor Detail
-
ProjectionMapping
public ProjectionMapping(IDocument masterDocument, String fragmentsCategory, IDocument slaveDocument, String segmentsCategory)
Creates a new mapping between the given parent document and the given projection document.- Parameters:
masterDocument- the master documentfragmentsCategory- the position category of the parent document used to manage the projected regionsslaveDocument- the slave documentsegmentsCategory- the position category of the projection document used to manage the fragments
-
-
Method Detail
-
projectionChanged
public void projectionChanged()
Notifies this projection mapping that there was a projection change.
-
getCoverage
public IRegion getCoverage()
Description copied from interface:IDocumentInformationMappingReturns the minimal region of the original document that completely comprises all of the image document ornullif there is no such region.- Specified by:
getCoveragein interfaceIDocumentInformationMapping- Returns:
- the minimal region of the original document comprising the image document or
null
-
toOriginOffset
public int toOriginOffset(int imageOffset) throws BadLocationExceptionDescription copied from interface:IDocumentInformationMappingReturns the offset in the original document that corresponds to the given offset in the image document or-1if there is no such offset- Specified by:
toOriginOffsetin interfaceIDocumentInformationMapping- Parameters:
imageOffset- the offset in the image document- Returns:
- the corresponding offset in the original document or
-1 - Throws:
BadLocationException- ifimageOffsetis not a valid offset in the image document
-
toOriginRegion
public IRegion toOriginRegion(IRegion imageRegion) throws BadLocationException
Description copied from interface:IDocumentInformationMappingReturns the minimal region of the original document that completely comprises the given region of the image document ornullif there is no such region.- Specified by:
toOriginRegionin interfaceIDocumentInformationMapping- Parameters:
imageRegion- the region of the image document- Returns:
- the minimal region of the original document comprising the given region of the image document or
null - Throws:
BadLocationException- ifimageRegionis not a valid region of the image document
-
toOriginLines
public IRegion toOriginLines(int imageLine) throws BadLocationException
Description copied from interface:IDocumentInformationMappingReturns the range of lines of the original document that corresponds to the given line of the image document ornullif there are no such lines.- Specified by:
toOriginLinesin interfaceIDocumentInformationMapping- Parameters:
imageLine- the line of the image document- Returns:
- the corresponding lines of the original document or
null - Throws:
BadLocationException- ifimageLineis not a valid line number in the image document
-
toOriginLine
public int toOriginLine(int imageLine) throws BadLocationExceptionDescription copied from interface:IDocumentInformationMappingReturns the line of the original document that corresponds to the given line of the image document or-1if there is no such line.- Specified by:
toOriginLinein interfaceIDocumentInformationMapping- Parameters:
imageLine- the line of the image document- Returns:
- the corresponding line of the original document or
-1 - Throws:
BadLocationException- ifimageLineis not a valid line number in the image document
-
toImageOffset
public int toImageOffset(int originOffset) throws BadLocationExceptionDescription copied from interface:IDocumentInformationMappingReturns the offset in the image document that corresponds to the given offset in the original document or-1if there is no such offset- Specified by:
toImageOffsetin interfaceIDocumentInformationMapping- Parameters:
originOffset- the offset in the original document- Returns:
- the corresponding offset in the image document or
-1 - Throws:
BadLocationException- iforiginOffsetis not a valid offset in the original document
-
toExactImageRegion
public IRegion toExactImageRegion(IRegion originRegion) throws BadLocationException
Description copied from interface:IDocumentInformationMappingExtensionAdheres tooriginRegion=toOriginRegion(toExactImageRegion(originRegion)), iftoExactImageRegion(originRegion) != null. Returnsnullif there is no image for the given origin region.- Specified by:
toExactImageRegionin interfaceIDocumentInformationMappingExtension- Parameters:
originRegion- the origin region- Returns:
- the exact image region or
null - Throws:
BadLocationException- if origin region is not a valid region in the origin document
-
toImageRegion
public IRegion toImageRegion(IRegion originRegion) throws BadLocationException
Description copied from interface:IDocumentInformationMappingReturns the minimal region of the image document that completely comprises the given region of the original document ornullif there is no such region.- Specified by:
toImageRegionin interfaceIDocumentInformationMapping- Parameters:
originRegion- the region of the original document- Returns:
- the minimal region of the image document comprising the given region of the original document or
null - Throws:
BadLocationException- iforiginRegionis not a valid region of the original document
-
toClosestImageRegion
public IRegion toClosestImageRegion(IRegion originRegion) throws BadLocationException
Description copied from interface:IDocumentInformationMappingExtension2Returns the minimal region of the image document that completely comprises the given region of the original document. The difference toIDocumentInformationMapping.toImageRegion(IRegion)is that this method will always return an image region for a valid origin region. IforiginRegionhas no corresponding image region, the zero-length region at the offset between its surrounding fragments is returned.- Specified by:
toClosestImageRegionin interfaceIDocumentInformationMappingExtension2- Parameters:
originRegion- the region of the original document- Returns:
- the minimal region of the image document comprising the given region of the original document
- Throws:
BadLocationException- iforiginRegionis not a valid region of the original document
-
toImageLine
public int toImageLine(int originLine) throws BadLocationExceptionDescription copied from interface:IDocumentInformationMappingReturns the line of the image document that corresponds to the given line of the original document or-1if there is no such line.- Specified by:
toImageLinein interfaceIDocumentInformationMapping- Parameters:
originLine- the line of the original document- Returns:
- the corresponding line of the image document or
-1 - Throws:
BadLocationException- iforiginLineis not a valid line number in the original document
-
toClosestImageLine
public int toClosestImageLine(int originLine) throws BadLocationExceptionDescription copied from interface:IDocumentInformationMappingReturns the line of the image document whose corresponding line in the original document is closest to the given line in the original document.- Specified by:
toClosestImageLinein interfaceIDocumentInformationMapping- Parameters:
originLine- the line in the original document- Returns:
- the line in the image document that corresponds best to the given line in the original document
- Throws:
BadLocationException- iforiginLineis not a valid line in the original document
-
toExactOriginRegions
public IRegion[] toExactOriginRegions(IRegion imageRegion) throws BadLocationException
Description copied from interface:IDocumentInformationMappingExtensionReturns the fragments of the original document that exactly correspond to the given region of the image document.- Specified by:
toExactOriginRegionsin interfaceIDocumentInformationMappingExtension- Parameters:
imageRegion- the region in the image document- Returns:
- the fragments in the origin document
- Throws:
BadLocationException- in case the given image region is not valid in the image document
-
getImageLength
public int getImageLength()
Description copied from interface:IDocumentInformationMappingExtensionReturns the length of the image document.- Specified by:
getImageLengthin interfaceIDocumentInformationMappingExtension- Returns:
- the length of the image document
-
toExactImageRegions
public IRegion[] toExactImageRegions(IRegion originRegion) throws BadLocationException
Description copied from interface:IDocumentInformationMappingExtensionReturns the segments of the image document that exactly correspond to the given region of the original document. Returnsnullif there are no such image regions.- Specified by:
toExactImageRegionsin interfaceIDocumentInformationMappingExtension- Parameters:
originRegion- the region in the origin document- Returns:
- the segments in the image document or
null - Throws:
BadLocationException- in case the given origin region is not valid in the original document
-
getExactCoverage
public IRegion[] getExactCoverage(IRegion originRegion) throws BadLocationException
Description copied from interface:IDocumentInformationMappingExtensionReturns the maximal sub-regions of the given origin region which are completely covered. I.e. each offset in a sub-region has a corresponding image offset. Returnsnullif there are no such sub-regions.- Specified by:
getExactCoveragein interfaceIDocumentInformationMappingExtension- Parameters:
originRegion- the region in the origin document- Returns:
- the sub-regions with complete coverage or
null - Throws:
BadLocationException- in case the given origin region is not valid in the original document
-
-