Java Bit Shift shiftHorizontally(int inkX, int inkXWidth, int textWidth)

Here you can find the source of shiftHorizontally(int inkX, int inkXWidth, int textWidth)

Description

Returns a shift of 'x' coordinate in pixels in order to fit the logical extent horizontally

License

Open Source License

Parameter

Parameter Description
inkX the left bearing of the rendered text
inkXWidth the horizontal width of the rendered text
textWidth The width of the rendered label

Declaration

public static int shiftHorizontally(int inkX, int inkXWidth,
        int textWidth) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//w  ww  .  ja  v a  2 s. c o  m
     * Returns a shift of 'x' coordinate in pixels in order to fit the logical extent horizontally
     * @param inkX the left bearing of the rendered text
     * @param inkXWidth the horizontal width of the rendered text
     * @param textWidth The width of the rendered label
     * @return
     */
    public static int shiftHorizontally(int inkX, int inkXWidth,
            int textWidth) {
        if ((inkX < 0) && (inkXWidth <= textWidth)) {
            return inkX;
        }
        if ((inkX + inkXWidth > textWidth) && (inkXWidth <= textWidth)) {
            return (inkX + inkXWidth - textWidth);
        }
        return 0;
    }
}

Related

  1. shift(String string)
  2. shiftBits(byte b)
  3. shiftByte(byte n, short shift)
  4. shiftCharacter(char c, int offset)
  5. shiftDouble(Object o, double shift, String suffix)
  6. shiftIdentifier(StringBuffer buffer, int posBegin, int posEnd)
  7. shiftKeyword(StringBuffer buffer, int posBegin, int posEnd, String keyword, boolean ignoreCase, boolean wholeWord)
  8. shiftLastAlphabets(String id)
  9. shiftLeft(char ch)