Class AlignmentContext

  • All Implemented Interfaces:
    Constants

    public class AlignmentContext
    extends java.lang.Object
    implements Constants
    The alignment context is carried within a LayoutContext and as part of the Knuth Inline elements to facilitate proper line building. All measurements are in mpt.
    • Field Detail

      • areaHeight

        private int areaHeight
        The height or BPD of this context.
      • lineHeight

        private int lineHeight
        The computed line-height property value applicable.
      • alignmentPoint

        private int alignmentPoint
        The distance in BPD from the top of the box to the alignmentPoint.
      • baselineShiftValue

        private int baselineShiftValue
        The baseline shift value in effect.
      • alignmentBaselineIdentifier

        private int alignmentBaselineIdentifier
        The computed alignment baseline identifier.
      • xHeight

        private int xHeight
        The x height.
    • Constructor Detail

      • AlignmentContext

        AlignmentContext​(int height,
                         Length alignmentAdjust,
                         int alignmentBaseline,
                         Length baselineShift,
                         int dominantBaseline,
                         AlignmentContext parentAlignmentContext)
        Creates a new instance of AlignmentContext for graphics areas.
        Parameters:
        height - the total height of the area
        alignmentAdjust - the alignment-adjust property
        alignmentBaseline - the alignment-baseline property
        baselineShift - the baseline-shift property
        dominantBaseline - the dominant-baseline property
        parentAlignmentContext - the parent alignment context
      • AlignmentContext

        AlignmentContext​(Font font,
                         int lineHeight,
                         Length alignmentAdjust,
                         int alignmentBaseline,
                         Length baselineShift,
                         int dominantBaseline,
                         AlignmentContext parentAlignmentContext)
        Creates a new instance.
        Parameters:
        font - the font
        lineHeight - the computed value of the lineHeight property
        alignmentAdjust - the alignment-adjust property
        alignmentBaseline - the alignment-baseline property
        baselineShift - the baseline-shift property
        dominantBaseline - the dominant-baseline property
        parentAlignmentContext - the parent alignment context
      • AlignmentContext

        private AlignmentContext​(int altitude,
                                 int depth,
                                 int lineHeight,
                                 int xHeight,
                                 Length alignmentAdjust,
                                 int alignmentBaseline,
                                 Length baselineShift,
                                 int dominantBaseline,
                                 AlignmentContext parentAlignmentContext)
        Creates a new instance of AlignmentContext.
        Parameters:
        altitude - the altitude of the area
        depth - the depth of the area
        lineHeight - the line height
        xHeight - the xHeight
        alignmentAdjust - the alignment-adjust property
        alignmentBaseline - the alignment-baseline property
        baselineShift - the baseline-shift property
        dominantBaseline - the dominant-baseline property
        parentAlignmentContext - the parent alignment context
      • AlignmentContext

        AlignmentContext​(Font font,
                         int lineHeight,
                         WritingMode writingMode)
        Creates a new instance of AlignmentContext based simply on the font and the writing mode.
        Parameters:
        font - the font
        lineHeight - the computed value of the lineHeight property
        writingMode - the current writing mode
    • Method Detail

      • getAlignmentPoint

        public int getAlignmentPoint()
        Returns the alignment point for this context. This is the point on the start edge of the area this context applies to measured from the before edge of the area.
        Returns:
        the default alignment point
      • getBaselineShiftValue

        public int getBaselineShiftValue()
        Returns the current value of baseline shift in effect.
        Returns:
        the baseline shift
      • getAlignmentBaselineIdentifier

        public int getAlignmentBaselineIdentifier()
        Returns the current alignment baseline identifier.
        Returns:
        the alignment baseline identifier
      • setAlignmentBaselineIdentifier

        private void setAlignmentBaselineIdentifier​(int alignmentBaseline,
                                                    int parentDominantBaselineIdentifier)
        Sets the current alignment baseline identifier. For alignment-baseline values of "auto" and "baseline" this method does the conversion into the appropriate computed value assuming script is "auto" and the fo is not fo:character.
        Parameters:
        alignmentBaseline - the alignment-baseline property
        parentDominantBaselineIdentifier - the dominant baseline of the parent fo
      • setAlignmentAdjust

        private void setAlignmentAdjust​(Length alignmentAdjust)
        Sets the current alignment baseline identifer. For alignment-baseline values of "auto" and "baseline" this method does the conversion into the appropriate computed value assuming script is "auto" and the fo is not fo:character.
        Parameters:
        alignmentAdjust - the alignment-adjust property
      • getScaledBaselineTable

        private ScaledBaselineTable getScaledBaselineTable()
        Return the scaled baseline table for this context.
        Returns:
        the scaled baseline table
      • getDominantBaselineIdentifier

        public int getDominantBaselineIdentifier()
        Return the dominant baseline identifier.
        Returns:
        the dominant baseline identifier
      • setBaselineShift

        private void setBaselineShift​(Length baselineShift)
        Calculates the baseline shift value based on the baseline-shift property value.
        Parameters:
        baselineShift - the baseline shift property value
      • getParentAlignmentContext

        public AlignmentContext getParentAlignmentContext()
        Return the parent alignment context.
        Returns:
        the parent alignment context
      • getBaselineOffset

        private int getBaselineOffset()
        Return the offset between the current dominant baseline and the parent dominant baseline.
        Returns:
        the offset in shift direction
      • getTotalBaselineOffset

        private int getTotalBaselineOffset()
        Return the offset between the current dominant baseline and the outermost parent dominant baseline.
        Returns:
        the offset in shift direction
      • getTotalAlignmentBaselineOffset

        public int getTotalAlignmentBaselineOffset()
        Return the offset between the alignment baseline and the outermost parent dominant baseline.
        Returns:
        the offset in shift direction
      • getTotalAlignmentBaselineOffset

        private int getTotalAlignmentBaselineOffset​(int alignmentBaselineId)
        Return the offset between the given alignment baseline and the outermost parent dominant baseline.
        Parameters:
        alignmentBaselineId - the alignment baseline
        Returns:
        the offset
      • getActualBaselineOffset

        private int getActualBaselineOffset​(int baselineIdentifier)
        Return the offset between the dominant baseline and the given actual baseline.
        Parameters:
        baselineIdentifier - the baseline
        Returns:
        the offset
      • getTotalTopOffset

        private int getTotalTopOffset()
        Return the offset the outermost parent dominant baseline and the top of this box.
        Returns:
        the offset
      • getHeight

        public int getHeight()
        Return the total height of the context.
        Returns:
        the height
      • getLineHeight

        private int getLineHeight()
        Return the line height of the context.
        Returns:
        the height
      • getAltitude

        public int getAltitude()
        The altitude of the context that is the height above the alignment point.
        Returns:
        the altitude
      • getDepth

        public int getDepth()
        The depth of the context that is the height below alignment point.
        Returns:
        the altitude
      • getXHeight

        private int getXHeight()
        The x height of the context.
        Returns:
        the x height
      • resizeLine

        public void resizeLine​(int newLineHeight,
                               int newAlignmentPoint)
        Resizes the line as specified. Assumes that the new alignment point is on the dominant baseline, that is this function should be called for line areas only.
        Parameters:
        newLineHeight - the new height of the line
        newAlignmentPoint - the new alignment point
      • getOffset

        public int getOffset()
        Returns the offset from the before-edge of the parent to this context.
        Returns:
        the offset for rendering
      • usesInitialBaselineTable

        public boolean usesInitialBaselineTable()
        Returns an indication if we still use the initial baseline table. The initial baseline table is the table generated by the Line LM.
        Returns:
        true if this is still the initial baseline table
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object