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

📄 textbox.java

📁 java 读写word excel ppt
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    valign = TextBox.AnchorMiddle;                    break;                default:                    valign = TextBox.AnchorTop;                    break;            }        } else {            valign = prop.getPropertyValue();        }        return valign;    }    /**     * Sets the type of vertical alignment for the text.     * One of the <code>Anchor*</code> constants defined in this class.     *     * @param align - the type of alignment     */    public void setVerticalAlignment(int align){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        setEscherProperty(opt, EscherProperties.TEXT__ANCHORTEXT, align);    }    /**     * Returns the distance (in points) between the bottom of the text frame     * and the bottom of the inscribed rectangle of the shape that contains the text.     * Default value is 1/20 inch.     *     * @return the botom margin     */    public int getMarginBottom(){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__TEXTBOTTOM);        int val = prop == null ? EMU_PER_INCH/20 : prop.getPropertyValue();        return val/EMU_PER_POINT;    }    /**     * Sets the botom margin.     * @see #getMarginBottom()     *     * @param margin    the bottom margin     */    public void setMarginBottom(int margin){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        setEscherProperty(opt, EscherProperties.TEXT__TEXTBOTTOM, margin*EMU_PER_POINT);    }    /**     *  Returns the distance (in EMUs) between the left edge of the text frame     *  and the left edge of the inscribed rectangle of the shape that contains     *  the text.     *  Default value is 1/10 inch.     *     * @return the left margin     */    public int getMarginLeft(){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__TEXTBOTTOM);        int val = prop == null ? EMU_PER_INCH/10 : prop.getPropertyValue();        return val/EMU_PER_POINT;    }    /**     * Sets the left margin.     * @see #getMarginLeft()     *     * @param margin    the left margin     */    public void setMarginLeft(int margin){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        setEscherProperty(opt, EscherProperties.TEXT__TEXTLEFT, margin*EMU_PER_POINT);    }    /**     *  Returns the distance (in EMUs) between the right edge of the     *  text frame and the right edge of the inscribed rectangle of the shape     *  that contains the text.     *  Default value is 1/10 inch.     *     * @return the right margin     */    public int getMarginRight(){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__TEXTRIGHT);        int val = prop == null ? EMU_PER_INCH/10 : prop.getPropertyValue();        return val/EMU_PER_POINT;    }    /**     * Sets the right margin.     * @see #getMarginRight()     *     * @param margin    the right margin     */    public void setMarginRight(int margin){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        setEscherProperty(opt, EscherProperties.TEXT__TEXTRIGHT, margin*EMU_PER_POINT);    }     /**     *  Returns the distance (in EMUs) between the top of the text frame     *  and the top of the inscribed rectangle of the shape that contains the text.     *  Default value is 1/20 inch.     *     * @return the top margin     */    public int getMarginTop(){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__TEXTTOP);        int val = prop == null ? EMU_PER_INCH/20 : prop.getPropertyValue();        return val/EMU_PER_POINT;    }   /**     * Sets the top margin.     * @see #getMarginTop()     *     * @param margin    the top margin     */    public void setMarginTop(int margin){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        setEscherProperty(opt, EscherProperties.TEXT__TEXTTOP, margin*EMU_PER_POINT);    }    /**     * Returns the value indicating word wrap.     * One of the <code>Wrap*</code> constants defined in this class.     *     * @return the value indicating word wrap     */    public int getWordWrap(){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__WRAPTEXT);        return prop == null ? WrapSquare : prop.getPropertyValue();    }    /**     *  Specifies how the text should be wrapped     *     * @param wrap  the value indicating how the text should be wrapped     */    public void setWordWrap(int wrap){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        setEscherProperty(opt, EscherProperties.TEXT__WRAPTEXT, wrap);    }    /**     * @return id for the text.     */    public int getTextId(){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__TEXTID);        return prop == null ? 0 : prop.getPropertyValue();    }    /**     * Sets text ID     *     * @param id of the text     */    public void setTextId(int id){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        setEscherProperty(opt, EscherProperties.TEXT__TEXTID, id);    }    /**     * The color used to fill this shape.     *     * @param color the background color     */    public void setBackgroundColor(Color color){        EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);        int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 0).getRGB();        setEscherProperty(opt, EscherProperties.FILL__FILLBACKCOLOR, rgb);    }    /**      * @return the TextRun object for this text box      */     public TextRun getTextRun(){         return _txtrun;     }     public void setSheet(Sheet sheet){        _sheet = sheet;        // Initialize _txtrun object.        // (We can't do it in the constructor because the sheet        //  is not assigned then, it's only built once we have        //  all the records)        if(_txtrun == null) initTextRun();        if(_txtrun == null) {        	// No text records found, skip        	_missingTextRecords = true;        	return;        } else {        	_missingTextRecords = false;        }                // Supply the sheet to our child RichTextRuns        _txtrun.setSheet(sheet);        RichTextRun[] rt = _txtrun.getRichTextRuns();        for (int i = 0; i < rt.length; i++) {            rt[i].supplySlideShow(_sheet.getSlideShow());        }    }    private void initTextRun(){        OutlineTextRefAtom ota = null;                // Find the interesting child records         Record[] child = _txtbox.getChildRecords();        for (int i = 0; i < child.length; i++) {            if (child[i] instanceof OutlineTextRefAtom) {                ota = (OutlineTextRefAtom)child[i];                break;            }        }        Sheet sheet = getSheet();        TextRun[] runs = sheet.getTextRuns();        if (ota != null) {            int idx = ota.getTextIndex();            if(idx < runs.length) _txtrun = runs[idx];            if(_txtrun == null) {                logger.log(POILogger.WARN, "text run not found for OutlineTextRefAtom.TextIndex=" + idx);            }        } else {            int shapeId = _escherContainer.getChildById(EscherSpRecord.RECORD_ID).getShapeId();            if(runs != null) for (int i = 0; i < runs.length; i++) {                if(runs[i].getShapeId() == shapeId){                    _txtrun = runs[i];                    break;                }            }            if(_txtrun == null) {                logger.log(POILogger.WARN, "text run not found for shapeId=" + shapeId);            }        }    }}

⌨️ 快捷键说明

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