Here you can find the source of pixel2WidthUnits(int pxs)
Parameter | Description |
---|---|
pxs | Pixel value to convert |
static short pixel2WidthUnits(int pxs)
//package com.java2s; /*/*from www.j av a 2 s . c o m*/ * #%L * Vaadin Spreadsheet * %% * Copyright (C) 2013 - 2015 Vaadin Ltd * %% * This program is available under Commercial Vaadin Add-On License 3.0 * (CVALv3). * * See the file license.html distributed with this software for more * information about licensing. * * You should have received a copy of the CVALv3 along with this program. * If not, see <http://vaadin.com/license/cval-3>. * #L% */ public class Main { private static final short EXCEL_COLUMN_WIDTH_FACTOR = 256; private static final int UNIT_OFFSET_LENGTH = 7; private static final int[] UNIT_OFFSET_MAP = new int[] { 0, 36, 73, 109, 146, 182, 219 }; /** * Converts pixel units to Excel width units (one Excel width unit is * 1/256th of a character width) * * @param pxs * Pixel value to convert * @return Value in Excel width units */ static short pixel2WidthUnits(int pxs) { short widthUnits = (short) (EXCEL_COLUMN_WIDTH_FACTOR * (pxs / UNIT_OFFSET_LENGTH)); widthUnits += UNIT_OFFSET_MAP[(pxs % UNIT_OFFSET_LENGTH)]; return widthUnits; } }