⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textrecord.java

📁 Office格式转换代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The Apache Software Foundation.  All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. The end-user documentation included with the redistribution, *    if any, must include the following acknowledgment: *       "This product includes software developed by the *        Apache Software Foundation (http://www.apache.org/)." *    Alternately, this acknowledgment may appear in the software itself, *    if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and *    "Apache POI" must not be used to endorse or promote products *    derived from this software without prior written permission. For *    written permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", *    "Apache POI", nor may "Apache" appear in their name, without *    prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation.  For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */package org.apache.poi.hssf.record;import org.apache.poi.util.*;/** * The text record is used to define text stored on a chart. * NOTE: This source is automatically generated please do not modify this file.  Either subclass or *       remove the record in src/records/definitions. * @author Glen Stampoultzis (glens at apache.org) */public class TextRecord    extends Record{    public final static short      sid                             = 0x1025;    private  byte       field_1_horizontalAlignment;    public final static byte        HORIZONTAL_ALIGNMENT_LEFT      = 1;    public final static byte        HORIZONTAL_ALIGNMENT_CENTER    = 2;    public final static byte        HORIZONTAL_ALIGNMENT_BOTTOM    = 3;    public final static byte        HORIZONTAL_ALIGNMENT_JUSTIFY   = 4;    private  byte       field_2_verticalAlignment;    public final static byte        VERTICAL_ALIGNMENT_TOP         = 1;    public final static byte        VERTICAL_ALIGNMENT_CENTER      = 2;    public final static byte        VERTICAL_ALIGNMENT_BOTTOM      = 3;    public final static byte        VERTICAL_ALIGNMENT_JUSTIFY     = 4;    private  short      field_3_displayMode;    public final static short       DISPLAY_MODE_TRANSPARENT       = 1;    public final static short       DISPLAY_MODE_OPAQUE            = 2;    private  int        field_4_rgbColor;    private  int        field_5_x;    private  int        field_6_y;    private  int        field_7_width;    private  int        field_8_height;    private  short      field_9_options1;    private  BitField   autoColor                                   = new BitField(0x1);    private  BitField   showKey                                     = new BitField(0x2);    private  BitField   showValue                                   = new BitField(0x4);    private  BitField   vertical                                    = new BitField(0x8);    private  BitField   autoGeneratedText                           = new BitField(0x10);    private  BitField   generated                                   = new BitField(0x20);    private  BitField   autoLabelDeleted                            = new BitField(0x40);    private  BitField   autoBackground                              = new BitField(0x80);    private BitField   rotation                                   = new BitField(0x0700);    public final static short  ROTATION_NONE                  = 0;    public final static short  ROTATION_TOP_TO_BOTTOM         = 1;    public final static short  ROTATION_ROTATED_90_DEGREES    = 2;    public final static short  ROTATION_ROTATED_90_DEGREES_CLOCKWISE = 3;    private  BitField   showCategoryLabelAsPercentage               = new BitField(0x800);    private  BitField   showValueAsPercentage                       = new BitField(0x1000);    private  BitField   showBubbleSizes                             = new BitField(0x2000);    private  BitField   showLabel                                   = new BitField(0x4000);    private  short      field_10_indexOfColorValue;    private  short      field_11_options2;    private BitField   dataLabelPlacement                         = new BitField(0x000F);    public final static short  DATA_LABEL_PLACEMENT_CHART_DEPENDENT = 0;    public final static short  DATA_LABEL_PLACEMENT_OUTSIDE   = 1;    public final static short  DATA_LABEL_PLACEMENT_INSIDE    = 2;    public final static short  DATA_LABEL_PLACEMENT_CENTER    = 3;    public final static short  DATA_LABEL_PLACEMENT_AXIS      = 4;    public final static short  DATA_LABEL_PLACEMENT_ABOVE     = 5;    public final static short  DATA_LABEL_PLACEMENT_BELOW     = 6;    public final static short  DATA_LABEL_PLACEMENT_LEFT      = 7;    public final static short  DATA_LABEL_PLACEMENT_RIGHT     = 8;    public final static short  DATA_LABEL_PLACEMENT_AUTO      = 9;    public final static short  DATA_LABEL_PLACEMENT_USER_MOVED = 10;    private  short      field_12_textRotation;    public TextRecord()    {    }    /**     * Constructs a Text record and sets its fields appropriately.     *     * @param id    id must be 0x1025 or an exception     *              will be throw upon validation     * @param size  size the size of the data area of the record     * @param data  data of the record (should not contain sid/len)     */    public TextRecord(short id, short size, byte [] data)    {        super(id, size, data);        }    /**     * Constructs a Text record and sets its fields appropriately.     *     * @param id    id must be 0x1025 or an exception     *              will be throw upon validation     * @param size  size the size of the data area of the record     * @param data  data of the record (should not contain sid/len)     * @param offset of the record's data     */    public TextRecord(short id, short size, byte [] data, int offset)    {        super(id, size, data, offset);        }    /**     * Checks the sid matches the expected side for this record     *     * @param id   the expected sid.     */    protected void validateSid(short id)    {        if (id != sid)        {            throw new RecordFormatException("Not a Text record");        }    }    protected void fillFields(byte [] data, short size, int offset)    {        int pos = 0;        field_1_horizontalAlignment    = data[ pos + 0x0 + offset ];        field_2_verticalAlignment      = data[ pos + 0x1 + offset ];        field_3_displayMode            = LittleEndian.getShort(data, pos + 0x2 + offset);        field_4_rgbColor               = LittleEndian.getInt(data, pos + 0x4 + offset);        field_5_x                      = LittleEndian.getInt(data, pos + 0x8 + offset);        field_6_y                      = LittleEndian.getInt(data, pos + 0xc + offset);        field_7_width                  = LittleEndian.getInt(data, pos + 0x10 + offset);        field_8_height                 = LittleEndian.getInt(data, pos + 0x14 + offset);        field_9_options1               = LittleEndian.getShort(data, pos + 0x18 + offset);        field_10_indexOfColorValue     = LittleEndian.getShort(data, pos + 0x1a + offset);        field_11_options2              = LittleEndian.getShort(data, pos + 0x1c + offset);        field_12_textRotation          = LittleEndian.getShort(data, pos + 0x1e + offset);    }    public String toString()    {        StringBuffer buffer = new StringBuffer();        buffer.append("[TEXT]\n");        buffer.append("    .horizontalAlignment  = ")            .append("0x").append(HexDump.toHex(  getHorizontalAlignment ()))            .append(" (").append( getHorizontalAlignment() ).append(" )");        buffer.append(System.getProperty("line.separator"));         buffer.append("    .verticalAlignment    = ")            .append("0x").append(HexDump.toHex(  getVerticalAlignment ()))            .append(" (").append( getVerticalAlignment() ).append(" )");        buffer.append(System.getProperty("line.separator"));         buffer.append("    .displayMode          = ")            .append("0x").append(HexDump.toHex(  getDisplayMode ()))            .append(" (").append( getDisplayMode() ).append(" )");        buffer.append(System.getProperty("line.separator"));         buffer.append("    .rgbColor             = ")            .append("0x").append(HexDump.toHex(  getRgbColor ()))            .append(" (").append( getRgbColor() ).append(" )");        buffer.append(System.getProperty("line.separator"));         buffer.append("    .x                    = ")            .append("0x").append(HexDump.toHex(  getX ()))            .append(" (").append( getX() ).append(" )");        buffer.append(System.getProperty("line.separator"));         buffer.append("    .y                    = ")            .append("0x").append(HexDump.toHex(  getY ()))            .append(" (").append( getY() ).append(" )");        buffer.append(System.getProperty("line.separator"));         buffer.append("    .width                = ")            .append("0x").append(HexDump.toHex(  getWidth ()))            .append(" (").append( getWidth() ).append(" )");        buffer.append(System.getProperty("line.separator"));         buffer.append("    .height               = ")            .append("0x").append(HexDump.toHex(  getHeight ()))            .append(" (").append( getHeight() ).append(" )");        buffer.append(System.getProperty("line.separator"));         buffer.append("    .options1             = ")            .append("0x").append(HexDump.toHex(  getOptions1 ()))            .append(" (").append( getOptions1() ).append(" )");        buffer.append(System.getProperty("line.separator"));         buffer.append("         .autoColor                = ").append(isAutoColor()).append('\n');         buffer.append("         .showKey                  = ").append(isShowKey()).append('\n');         buffer.append("         .showValue                = ").append(isShowValue()).append('\n');         buffer.append("         .vertical                 = ").append(isVertical()).append('\n');         buffer.append("         .autoGeneratedText        = ").append(isAutoGeneratedText()).append('\n');         buffer.append("         .generated                = ").append(isGenerated()).append('\n');         buffer.append("         .autoLabelDeleted         = ").append(isAutoLabelDeleted()).append('\n');         buffer.append("         .autoBackground           = ").append(isAutoBackground()).append('\n');             buffer.append("         .rotation                 = ").append(getRotation()).append('\n');         buffer.append("         .showCategoryLabelAsPercentage     = ").append(isShowCategoryLabelAsPercentage()).append('\n');         buffer.append("         .showValueAsPercentage     = ").append(isShowValueAsPercentage()).append('\n');         buffer.append("         .showBubbleSizes          = ").append(isShowBubbleSizes()).append('\n');         buffer.append("         .showLabel                = ").append(isShowLabel()).append('\n');         buffer.append("    .indexOfColorValue    = ")            .append("0x").append(HexDump.toHex(  getIndexOfColorValue ()))            .append(" (").append( getIndexOfColorValue() ).append(" )");        buffer.append(System.getProperty("line.separator"));         buffer.append("    .options2             = ")            .append("0x").append(HexDump.toHex(  getOptions2 ()))            .append(" (").append( getOptions2() ).append(" )");        buffer.append(System.getProperty("line.separator"));             buffer.append("         .dataLabelPlacement       = ").append(getDataLabelPlacement()).append('\n');         buffer.append("    .textRotation         = ")            .append("0x").append(HexDump.toHex(  getTextRotation ()))            .append(" (").append( getTextRotation() ).append(" )");        buffer.append(System.getProperty("line.separator"));         buffer.append("[/TEXT]\n");        return buffer.toString();    }    public int serialize(int offset, byte[] data)    {        int pos = 0;        LittleEndian.putShort(data, 0 + offset, sid);        LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));        data[ 4 + offset + pos ] = field_1_horizontalAlignment;        data[ 5 + offset + pos ] = field_2_verticalAlignment;        LittleEndian.putShort(data, 6 + offset + pos, field_3_displayMode);        LittleEndian.putInt(data, 8 + offset + pos, field_4_rgbColor);        LittleEndian.putInt(data, 12 + offset + pos, field_5_x);        LittleEndian.putInt(data, 16 + offset + pos, field_6_y);        LittleEndian.putInt(data, 20 + offset + pos, field_7_width);        LittleEndian.putInt(data, 24 + offset + pos, field_8_height);        LittleEndian.putShort(data, 28 + offset + pos, field_9_options1);        LittleEndian.putShort(data, 30 + offset + pos, field_10_indexOfColorValue);        LittleEndian.putShort(data, 32 + offset + pos, field_11_options2);        LittleEndian.putShort(data, 34 + offset + pos, field_12_textRotation);        return getRecordSize();    }    /**     * Size of record (exluding 4 byte header)     */    public int getRecordSize()    {        return 4  + 1 + 1 + 2 + 4 + 4 + 4 + 4 + 4 + 2 + 2 + 2 + 2;    }    public short getSid()    {        return this.sid;    }    public Object clone() {        TextRecord rec = new TextRecord();            rec.field_1_horizontalAlignment = field_1_horizontalAlignment;        rec.field_2_verticalAlignment = field_2_verticalAlignment;        rec.field_3_displayMode = field_3_displayMode;        rec.field_4_rgbColor = field_4_rgbColor;        rec.field_5_x = field_5_x;        rec.field_6_y = field_6_y;        rec.field_7_width = field_7_width;        rec.field_8_height = field_8_height;        rec.field_9_options1 = field_9_options1;        rec.field_10_indexOfColorValue = field_10_indexOfColorValue;        rec.field_11_options2 = field_11_options2;        rec.field_12_textRotation = field_12_textRotation;        return rec;    }    /**     * Get the horizontal alignment field for the Text record.     *     * @return  One of      *        HORIZONTAL_ALIGNMENT_LEFT     *        HORIZONTAL_ALIGNMENT_CENTER     *        HORIZONTAL_ALIGNMENT_BOTTOM     *        HORIZONTAL_ALIGNMENT_JUSTIFY     */    public byte getHorizontalAlignment()    {        return field_1_horizontalAlignment;    }    /**     * Set the horizontal alignment field for the Text record.     *     * @param field_1_horizontalAlignment     *        One of      *        HORIZONTAL_ALIGNMENT_LEFT     *        HORIZONTAL_ALIGNMENT_CENTER     *        HORIZONTAL_ALIGNMENT_BOTTOM     *        HORIZONTAL_ALIGNMENT_JUSTIFY     */    public void setHorizontalAlignment(byte field_1_horizontalAlignment)    {        this.field_1_horizontalAlignment = field_1_horizontalAlignment;    }    /**     * Get the vertical alignment field for the Text record.     *     * @return  One of      *        VERTICAL_ALIGNMENT_TOP     *        VERTICAL_ALIGNMENT_CENTER     *        VERTICAL_ALIGNMENT_BOTTOM     *        VERTICAL_ALIGNMENT_JUSTIFY     */    public byte getVerticalAlignment()    {        return field_2_verticalAlignment;    }    /**     * Set the vertical alignment field for the Text record.     *     * @param field_2_verticalAlignment     *        One of      *        VERTICAL_ALIGNMENT_TOP     *        VERTICAL_ALIGNMENT_CENTER     *        VERTICAL_ALIGNMENT_BOTTOM     *        VERTICAL_ALIGNMENT_JUSTIFY     */    public void setVerticalAlignment(byte field_2_verticalAlignment)    {        this.field_2_verticalAlignment = field_2_verticalAlignment;    }    /**     * Get the display mode field for the Text record.     *     * @return  One of      *        DISPLAY_MODE_TRANSPARENT     *        DISPLAY_MODE_OPAQUE     */    public short getDisplayMode()    {        return field_3_displayMode;    }    /**     * Set the display mode field for the Text record.     *     * @param field_3_displayMode     *        One of      *        DISPLAY_MODE_TRANSPARENT     *        DISPLAY_MODE_OPAQUE     */    public void setDisplayMode(short field_3_displayMode)    {        this.field_3_displayMode = field_3_displayMode;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -