Eclipse Platform
2.1

org.eclipse.jface.text
Class CoordinatesTranslator

java.lang.Object
  |
  +--org.eclipse.jface.text.CoordinatesTranslator
All Implemented Interfaces:
IDocumentInformationMapping

public class CoordinatesTranslator
extends Object
implements IDocumentInformationMapping

Implementation of IDocumentInformationMapping matching ProjectionDocument and ProjectionDocumentManager. The parent document is considered the original document, the projection document is considered the image document.

This class is for internal use only.

Since:
2.1

Constructor Summary
CoordinatesTranslator(IDocument parent, String parentCategory, ProjectionDocument projection, String projectionCategory)
          Creates a new mapping between the given parent document and the given projection document.
 
Method Summary
 IRegion getCoverage()
          Returns the minimal region of the original document that completely comprises all of the image document or null if there is no such region.
 int toClosestImageLine(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.
 int toImageLine(int originLine)
          Returns the line of the image document that corresponds to the given line of the original document or -1 if there is no such line.
 int toImageOffset(int originOffset)
          Returns the offset in the image document that corresponds to the given offset in the original document or -1 if there is no such offset
 IRegion toImageRegion(IRegion originRegion)
          Returns the minimal region of the image document that completely comprises the given region of the original document or null if there is no such region.
 int toOriginLine(int imageLine)
          Returns the line of the original document that corresponds to the given line of the image document or -1 if there is no such line.
 IRegion toOriginLines(int imageLine)
          Returns the range of lines of the original document that corresponds to the given line of the image document or null if there are no such lines.
 int toOriginOffset(int imageOffset)
          Returns the offset in the original document that corresponds to the given offset in the image document or -1 if there is no such offset
 IRegion toOriginRegion(IRegion imageRegion)
          Returns the minimal region of the original document that completely comprises the given region of the image document or null if there is no such region.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoordinatesTranslator

public CoordinatesTranslator(IDocument parent,
                             String parentCategory,
                             ProjectionDocument projection,
                             String projectionCategory)
Creates a new mapping between the given parent document and the given projection document.
Parameters:
parent - the parent document
parentCategory - the position category of the parent document used to manage the projected regions
projection - the projection document
projectionCategory - the position category of the projection document used to manage the fragments
Method Detail

toOriginOffset

public int toOriginOffset(int imageOffset)
                   throws BadLocationException
Description copied from interface: IDocumentInformationMapping
Returns the offset in the original document that corresponds to the given offset in the image document or -1 if there is no such offset
Specified by:
toOriginOffset in interface IDocumentInformationMapping
Following copied from interface: org.eclipse.jface.text.IDocumentInformationMapping
Parameters:
imageOffset - the offset in the image document
Returns:
the corresponding offset in the original document or -1
Throws:
BadLocationException - if imageOffset is not a valid offset in the image document

toOriginRegion

public IRegion toOriginRegion(IRegion imageRegion)
                       throws BadLocationException
Description copied from interface: IDocumentInformationMapping
Returns the minimal region of the original document that completely comprises the given region of the image document or null if there is no such region.
Specified by:
toOriginRegion in interface IDocumentInformationMapping
Following copied from interface: org.eclipse.jface.text.IDocumentInformationMapping
Parameters:
imageRegion - the region of the image document
Returns:
the minimal region of the original document comprising the given region of the image document
Throws:
BadLocationException - if imageRegion is not a valid region of the image document

toOriginLines

public IRegion toOriginLines(int imageLine)
                      throws BadLocationException
Description copied from interface: IDocumentInformationMapping
Returns the range of lines of the original document that corresponds to the given line of the image document or null if there are no such lines.
Specified by:
toOriginLines in interface IDocumentInformationMapping
Following copied from interface: org.eclipse.jface.text.IDocumentInformationMapping
Parameters:
imageLine - the line of the image document
Returns:
the corresponding lines of the original document or null
Throws:
BadLocationException - if imageLine is not a valid line number in the image document

toOriginLine

public int toOriginLine(int imageLine)
                 throws BadLocationException
Description copied from interface: IDocumentInformationMapping
Returns the line of the original document that corresponds to the given line of the image document or -1 if there is no such line.
Specified by:
toOriginLine in interface IDocumentInformationMapping
Following copied from interface: org.eclipse.jface.text.IDocumentInformationMapping
Parameters:
imageLine - the line of the image document
Returns:
the corresponding line of the original document or -1
Throws:
BadLocationException - if imageLine is not a valid line number in the image document

toImageOffset

public int toImageOffset(int originOffset)
                  throws BadLocationException
Description copied from interface: IDocumentInformationMapping
Returns the offset in the image document that corresponds to the given offset in the original document or -1 if there is no such offset
Specified by:
toImageOffset in interface IDocumentInformationMapping
Following copied from interface: org.eclipse.jface.text.IDocumentInformationMapping
Parameters:
originOffset - the offset in the original document
Returns:
the corresponding offset in the image document or -1
Throws:
BadLocationException - if originOffset is not a valid offset in the original document

toImageRegion

public IRegion toImageRegion(IRegion originRegion)
                      throws BadLocationException
Description copied from interface: IDocumentInformationMapping
Returns the minimal region of the image document that completely comprises the given region of the original document or null if there is no such region.
Specified by:
toImageRegion in interface IDocumentInformationMapping
Following copied from interface: org.eclipse.jface.text.IDocumentInformationMapping
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 - if originRegion is not a valid region of the original document

toImageLine

public int toImageLine(int originLine)
                throws BadLocationException
Description copied from interface: IDocumentInformationMapping
Returns the line of the image document that corresponds to the given line of the original document or -1 if there is no such line.
Specified by:
toImageLine in interface IDocumentInformationMapping
Following copied from interface: org.eclipse.jface.text.IDocumentInformationMapping
Parameters:
originLine - the line of the original document
Returns:
the corresponding line of the image document or -1
Throws:
BadLocationException - if originLine is not a valid line number in the original document

getCoverage

public IRegion getCoverage()
Description copied from interface: IDocumentInformationMapping
Returns the minimal region of the original document that completely comprises all of the image document or null if there is no such region.
Specified by:
getCoverage in interface IDocumentInformationMapping
Following copied from interface: org.eclipse.jface.text.IDocumentInformationMapping
Returns:
the minimal region of the original document comprising the image document or null

toClosestImageLine

public int toClosestImageLine(int originLine)
                       throws BadLocationException
Description copied from interface: IDocumentInformationMapping
Returns 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:
toClosestImageLine in interface IDocumentInformationMapping
Following copied from interface: org.eclipse.jface.text.IDocumentInformationMapping
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 - if originLineis not a valid line in the original document

Eclipse Platform
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.