You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by ba...@apache.org on 2006/12/22 21:56:06 UTC
svn commit: r489760 [4/8] - in /jakarta/poi/trunk/src:
java/org/apache/poi/hssf/record/ java/org/apache/poi/hssf/record/formula/
java/org/apache/poi/hssf/util/ scratchpad/src/org/apache/poi/hslf/blip/
scratchpad/src/org/apache/poi/hslf/extractor/ scrat...
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java?view=diff&rev=489760&r1=489759&r2=489760
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeGroup.java Fri Dec 22 12:56:04 2006
@@ -1,180 +1,180 @@
-/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.model;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.util.LittleEndian;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Represents a group of shapes.
- *
- * @author Yegor Kozlov
- */
-public class ShapeGroup extends Shape{
-
- /**
- * Create a new ShapeGroup. This constructor is used when a new shape is created.
- *
- */
- public ShapeGroup(){
- this(null, null);
- _escherContainer = createSpContainer(false);
- }
-
- /**
- * Create a ShapeGroup object and initilize it from the supplied Record container.
- *
- * @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
- * @param parent the parent of the shape
- */
- protected ShapeGroup(EscherContainerRecord escherRecord, Shape parent){
- super(escherRecord, parent);
- }
-
- /**
- * @return the shapes contained in this group container
- */
- public Shape[] getShapes() {
- // Out escher container record should contain serveral
- // SpContainers, the first of which is the group shape itself
- List lst = _escherContainer.getChildRecords();
-
- ArrayList shapeList = new ArrayList();
- // Don't include the first SpContainer, it is always NotPrimitive
- for (int i = 1; i < lst.size(); i++){
- EscherRecord r = (EscherRecord)lst.get(i);
- if(r instanceof EscherContainerRecord) {
- // Create the Shape for it
- EscherContainerRecord container = (EscherContainerRecord)r;
- Shape shape = ShapeFactory.createShape(container, this);
- shapeList.add( shape );
- } else {
- // Should we do anything special with these non
- // Container records?
- System.err.println("Shape contained non container escher record, was " + r.getClass().getName());
- }
- }
-
- // Put the shapes into an array, and return
- Shape[] shapes = (Shape[])shapeList.toArray(new Shape[shapeList.size()]);
- return shapes;
- }
-
- /**
- * Sets the anchor (the bounding box rectangle) of this shape.
- * All coordinates should be expressed in Master units (576 dpi).
- *
- * @param anchor new anchor
- */
- public void setAnchor(java.awt.Rectangle anchor){
-
- EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChildRecords().get(0);
-
- EscherClientAnchorRecord clientAnchor = (EscherClientAnchorRecord)getEscherChild(spContainer, EscherClientAnchorRecord.RECORD_ID);
- //hack. internal variable EscherClientAnchorRecord.shortRecord can be
- //initialized only in fillFields(). We need to set shortRecord=false;
- byte[] header = new byte[16];
- LittleEndian.putUShort(header, 0, 0);
- LittleEndian.putUShort(header, 2, 0);
- LittleEndian.putInt(header, 4, 8);
- clientAnchor.fillFields(header, 0, null);
-
- clientAnchor.setFlag((short)(anchor.y*MASTER_DPI/POINT_DPI));
- clientAnchor.setCol1((short)(anchor.x*MASTER_DPI/POINT_DPI));
- clientAnchor.setDx1((short)((anchor.width + anchor.x)*MASTER_DPI/POINT_DPI));
- clientAnchor.setRow1((short)((anchor.height + anchor.y)*MASTER_DPI/POINT_DPI));
-
- EscherSpgrRecord spgr = (EscherSpgrRecord)getEscherChild(spContainer, EscherSpgrRecord.RECORD_ID);
-
- spgr.setRectX1(anchor.x*MASTER_DPI/POINT_DPI);
- spgr.setRectY1(anchor.y*MASTER_DPI/POINT_DPI);
- spgr.setRectX2((anchor.x + anchor.width)*MASTER_DPI/POINT_DPI);
- spgr.setRectY2((anchor.y + anchor.height)*MASTER_DPI/POINT_DPI);
- }
-
- /**
- * Create a new ShapeGroup and create an instance of <code>EscherSpgrContainer</code> which represents a group of shapes
- */
- protected EscherContainerRecord createSpContainer(boolean isChild) {
- EscherContainerRecord spgr = new EscherContainerRecord();
- spgr.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
- spgr.setOptions((short)15);
-
- //The group itself is a shape, and always appears as the first EscherSpContainer in the group container.
- EscherContainerRecord spcont = new EscherContainerRecord();
- spcont.setRecordId(EscherContainerRecord.SP_CONTAINER);
- spcont.setOptions((short)15);
-
- EscherSpgrRecord spg = new EscherSpgrRecord();
- spg.setOptions((short)1);
- spcont.addChildRecord(spg);
-
- EscherSpRecord sp = new EscherSpRecord();
- short type = (ShapeTypes.NotPrimitive << 4) + 2;
- sp.setOptions(type);
- sp.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_GROUP);
- spcont.addChildRecord(sp);
-
- EscherClientAnchorRecord anchor = new EscherClientAnchorRecord();
- spcont.addChildRecord(anchor);
-
- spgr.addChildRecord(spcont);
- return spgr;
- }
-
- /**
- * Add a shape to this group.
- *
- * @param shape - the Shape to add
- */
- public void addShape(Shape shape){
- _escherContainer.addChildRecord(shape.getSpContainer());
-
- Sheet sheet = getSheet();
- shape.setSheet(sheet);
- shape.afterInsert(sheet);
-
- if(shape instanceof TextBox) {
- TextBox tbox = (TextBox)shape;
- getSheet().getPPDrawing().addTextboxWrapper(tbox._txtbox);
- }
- }
-
- /**
- * Moves this <code>ShapeGroup</code> to the specified location.
- * <p>
- * @param x the x coordinate of the top left corner of the shape in new location
- * @param y the y coordinate of the top left corner of the shape in new location
- */
- public void moveTo(int x, int y){
- java.awt.Rectangle anchor = getAnchor();
- int dx = x - anchor.x;
- int dy = y - anchor.y;
- anchor.translate(dx, dy);
- setAnchor(anchor);
-
- Shape[] shape = getShapes();
- for (int i = 0; i < shape.length; i++) {
- java.awt.Rectangle chanchor = shape[i].getAnchor();
- chanchor.translate(dx, dy);
- shape[i].setAnchor(chanchor);
- }
- }
-
-}
+/* ====================================================================
+ Copyright 2002-2004 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.hslf.model;
+
+import org.apache.poi.ddf.*;
+import org.apache.poi.util.LittleEndian;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a group of shapes.
+ *
+ * @author Yegor Kozlov
+ */
+public class ShapeGroup extends Shape{
+
+ /**
+ * Create a new ShapeGroup. This constructor is used when a new shape is created.
+ *
+ */
+ public ShapeGroup(){
+ this(null, null);
+ _escherContainer = createSpContainer(false);
+ }
+
+ /**
+ * Create a ShapeGroup object and initilize it from the supplied Record container.
+ *
+ * @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
+ * @param parent the parent of the shape
+ */
+ protected ShapeGroup(EscherContainerRecord escherRecord, Shape parent){
+ super(escherRecord, parent);
+ }
+
+ /**
+ * @return the shapes contained in this group container
+ */
+ public Shape[] getShapes() {
+ // Out escher container record should contain serveral
+ // SpContainers, the first of which is the group shape itself
+ List lst = _escherContainer.getChildRecords();
+
+ ArrayList shapeList = new ArrayList();
+ // Don't include the first SpContainer, it is always NotPrimitive
+ for (int i = 1; i < lst.size(); i++){
+ EscherRecord r = (EscherRecord)lst.get(i);
+ if(r instanceof EscherContainerRecord) {
+ // Create the Shape for it
+ EscherContainerRecord container = (EscherContainerRecord)r;
+ Shape shape = ShapeFactory.createShape(container, this);
+ shapeList.add( shape );
+ } else {
+ // Should we do anything special with these non
+ // Container records?
+ System.err.println("Shape contained non container escher record, was " + r.getClass().getName());
+ }
+ }
+
+ // Put the shapes into an array, and return
+ Shape[] shapes = (Shape[])shapeList.toArray(new Shape[shapeList.size()]);
+ return shapes;
+ }
+
+ /**
+ * Sets the anchor (the bounding box rectangle) of this shape.
+ * All coordinates should be expressed in Master units (576 dpi).
+ *
+ * @param anchor new anchor
+ */
+ public void setAnchor(java.awt.Rectangle anchor){
+
+ EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChildRecords().get(0);
+
+ EscherClientAnchorRecord clientAnchor = (EscherClientAnchorRecord)getEscherChild(spContainer, EscherClientAnchorRecord.RECORD_ID);
+ //hack. internal variable EscherClientAnchorRecord.shortRecord can be
+ //initialized only in fillFields(). We need to set shortRecord=false;
+ byte[] header = new byte[16];
+ LittleEndian.putUShort(header, 0, 0);
+ LittleEndian.putUShort(header, 2, 0);
+ LittleEndian.putInt(header, 4, 8);
+ clientAnchor.fillFields(header, 0, null);
+
+ clientAnchor.setFlag((short)(anchor.y*MASTER_DPI/POINT_DPI));
+ clientAnchor.setCol1((short)(anchor.x*MASTER_DPI/POINT_DPI));
+ clientAnchor.setDx1((short)((anchor.width + anchor.x)*MASTER_DPI/POINT_DPI));
+ clientAnchor.setRow1((short)((anchor.height + anchor.y)*MASTER_DPI/POINT_DPI));
+
+ EscherSpgrRecord spgr = (EscherSpgrRecord)getEscherChild(spContainer, EscherSpgrRecord.RECORD_ID);
+
+ spgr.setRectX1(anchor.x*MASTER_DPI/POINT_DPI);
+ spgr.setRectY1(anchor.y*MASTER_DPI/POINT_DPI);
+ spgr.setRectX2((anchor.x + anchor.width)*MASTER_DPI/POINT_DPI);
+ spgr.setRectY2((anchor.y + anchor.height)*MASTER_DPI/POINT_DPI);
+ }
+
+ /**
+ * Create a new ShapeGroup and create an instance of <code>EscherSpgrContainer</code> which represents a group of shapes
+ */
+ protected EscherContainerRecord createSpContainer(boolean isChild) {
+ EscherContainerRecord spgr = new EscherContainerRecord();
+ spgr.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
+ spgr.setOptions((short)15);
+
+ //The group itself is a shape, and always appears as the first EscherSpContainer in the group container.
+ EscherContainerRecord spcont = new EscherContainerRecord();
+ spcont.setRecordId(EscherContainerRecord.SP_CONTAINER);
+ spcont.setOptions((short)15);
+
+ EscherSpgrRecord spg = new EscherSpgrRecord();
+ spg.setOptions((short)1);
+ spcont.addChildRecord(spg);
+
+ EscherSpRecord sp = new EscherSpRecord();
+ short type = (ShapeTypes.NotPrimitive << 4) + 2;
+ sp.setOptions(type);
+ sp.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_GROUP);
+ spcont.addChildRecord(sp);
+
+ EscherClientAnchorRecord anchor = new EscherClientAnchorRecord();
+ spcont.addChildRecord(anchor);
+
+ spgr.addChildRecord(spcont);
+ return spgr;
+ }
+
+ /**
+ * Add a shape to this group.
+ *
+ * @param shape - the Shape to add
+ */
+ public void addShape(Shape shape){
+ _escherContainer.addChildRecord(shape.getSpContainer());
+
+ Sheet sheet = getSheet();
+ shape.setSheet(sheet);
+ shape.afterInsert(sheet);
+
+ if(shape instanceof TextBox) {
+ TextBox tbox = (TextBox)shape;
+ getSheet().getPPDrawing().addTextboxWrapper(tbox._txtbox);
+ }
+ }
+
+ /**
+ * Moves this <code>ShapeGroup</code> to the specified location.
+ * <p>
+ * @param x the x coordinate of the top left corner of the shape in new location
+ * @param y the y coordinate of the top left corner of the shape in new location
+ */
+ public void moveTo(int x, int y){
+ java.awt.Rectangle anchor = getAnchor();
+ int dx = x - anchor.x;
+ int dy = y - anchor.y;
+ anchor.translate(dx, dy);
+ setAnchor(anchor);
+
+ Shape[] shape = getShapes();
+ for (int i = 0; i < shape.length; i++) {
+ java.awt.Rectangle chanchor = shape[i].getAnchor();
+ chanchor.translate(dx, dy);
+ shape[i].setAnchor(chanchor);
+ }
+ }
+
+}
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java?view=diff&rev=489760&r1=489759&r2=489760
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/ShapeTypes.java Fri Dec 22 12:56:04 2006
@@ -1,257 +1,257 @@
-/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.model;
-
-import java.util.HashMap;
-import java.lang.reflect.Field;
-
-/**
- * Contains all known shape types in PowerPoint
- *
- * @author Yegor Kozlov
- */
-public class ShapeTypes {
- public static final int NotPrimitive = 0;
- public static final int Rectangle = 1;
- public static final int RoundRectangle = 2;
- public static final int Ellipse = 3;
- public static final int Diamond = 4;
- public static final int IsocelesTriangle = 5;
- public static final int RightTriangle = 6;
- public static final int Parallelogram = 7;
- public static final int Trapezoid = 8;
- public static final int Hexagon = 9;
- public static final int Octagon = 10;
- public static final int Plus = 11;
- public static final int Star = 12;
- public static final int Arrow = 13;
- public static final int ThickArrow = 14;
- public static final int HomePlate = 15;
- public static final int Cube = 16;
- public static final int Balloon = 17;
- public static final int Seal = 18;
- public static final int Arc = 19;
- public static final int Line = 20;
- public static final int Plaque = 21;
- public static final int Can = 22;
- public static final int Donut = 23;
- public static final int TextSimple = 24;
- public static final int TextOctagon = 25;
- public static final int TextHexagon = 26;
- public static final int TextCurve = 27;
- public static final int TextWave = 28;
- public static final int TextRing = 29;
- public static final int TextOnCurve = 30;
- public static final int TextOnRing = 31;
- public static final int StraightConnector1 = 32;
- public static final int BentConnector2 = 33;
- public static final int BentConnector3 = 34;
- public static final int BentConnector4 = 35;
- public static final int BentConnector5 = 36;
- public static final int CurvedConnector2 = 37;
- public static final int CurvedConnector3 = 38;
- public static final int CurvedConnector4 = 39;
- public static final int CurvedConnector5 = 40;
- public static final int Callout1 = 41;
- public static final int Callout2 = 42;
- public static final int Callout3 = 43;
- public static final int AccentCallout1 = 44;
- public static final int AccentCallout2 = 45;
- public static final int AccentCallout3 = 46;
- public static final int BorderCallout1 = 47;
- public static final int BorderCallout2 = 48;
- public static final int BorderCallout3 = 49;
- public static final int AccentBorderCallout1 = 50;
- public static final int AccentBorderCallout2 = 51;
- public static final int AccentBorderCallout3 = 52;
- public static final int Ribbon = 53;
- public static final int Ribbon2 = 54;
- public static final int Chevron = 55;
- public static final int Pentagon = 56;
- public static final int NoSmoking = 57;
- public static final int Star8 = 58;
- public static final int Star16 = 59;
- public static final int Star32 = 60;
- public static final int WedgeRectCallout = 61;
- public static final int WedgeRRectCallout = 62;
- public static final int WedgeEllipseCallout = 63;
- public static final int Wave = 64;
- public static final int FoldedCorner = 65;
- public static final int LeftArrow = 66;
- public static final int DownArrow = 67;
- public static final int UpArrow = 68;
- public static final int LeftRightArrow = 69;
- public static final int UpDownArrow = 70;
- public static final int IrregularSeal1 = 71;
- public static final int IrregularSeal2 = 72;
- public static final int LightningBolt = 73;
- public static final int Heart = 74;
- public static final int PictureFrame = 75;
- public static final int QuadArrow = 76;
- public static final int LeftArrowCallout = 77;
- public static final int RightArrowCallout = 78;
- public static final int UpArrowCallout = 79;
- public static final int DownArrowCallout = 80;
- public static final int LeftRightArrowCallout = 81;
- public static final int UpDownArrowCallout = 82;
- public static final int QuadArrowCallout = 83;
- public static final int Bevel = 84;
- public static final int LeftBracket = 85;
- public static final int RightBracket = 86;
- public static final int LeftBrace = 87;
- public static final int RightBrace = 88;
- public static final int LeftUpArrow = 89;
- public static final int BentUpArrow = 90;
- public static final int BentArrow = 91;
- public static final int Star24 = 92;
- public static final int StripedRightArrow = 93;
- public static final int NotchedRightArrow = 94;
- public static final int BlockArc = 95;
- public static final int SmileyFace = 96;
- public static final int VerticalScroll = 97;
- public static final int HorizontalScroll = 98;
- public static final int CircularArrow = 99;
- public static final int NotchedCircularArrow = 100;
- public static final int UturnArrow = 101;
- public static final int CurvedRightArrow = 102;
- public static final int CurvedLeftArrow = 103;
- public static final int CurvedUpArrow = 104;
- public static final int CurvedDownArrow = 105;
- public static final int CloudCallout = 106;
- public static final int EllipseRibbon = 107;
- public static final int EllipseRibbon2 = 108;
- public static final int FlowChartProcess = 109;
- public static final int FlowChartDecision = 110;
- public static final int FlowChartInputOutput = 111;
- public static final int FlowChartPredefinedProcess = 112;
- public static final int FlowChartInternalStorage = 113;
- public static final int FlowChartDocument = 114;
- public static final int FlowChartMultidocument = 115;
- public static final int FlowChartTerminator = 116;
- public static final int FlowChartPreparation = 117;
- public static final int FlowChartManualInput = 118;
- public static final int FlowChartManualOperation = 119;
- public static final int FlowChartConnector = 120;
- public static final int FlowChartPunchedCard = 121;
- public static final int FlowChartPunchedTape = 122;
- public static final int FlowChartSummingJunction = 123;
- public static final int FlowChartOr = 124;
- public static final int FlowChartCollate = 125;
- public static final int FlowChartSort = 126;
- public static final int FlowChartExtract = 127;
- public static final int FlowChartMerge = 128;
- public static final int FlowChartOfflineStorage = 129;
- public static final int FlowChartOnlineStorage = 130;
- public static final int FlowChartMagneticTape = 131;
- public static final int FlowChartMagneticDisk = 132;
- public static final int FlowChartMagneticDrum = 133;
- public static final int FlowChartDisplay = 134;
- public static final int FlowChartDelay = 135;
- public static final int TextPlainText = 136;
- public static final int TextStop = 137;
- public static final int TextTriangle = 138;
- public static final int TextTriangleInverted = 139;
- public static final int TextChevron = 140;
- public static final int TextChevronInverted = 141;
- public static final int TextRingInside = 142;
- public static final int TextRingOutside = 143;
- public static final int TextArchUpCurve = 144;
- public static final int TextArchDownCurve = 145;
- public static final int TextCircleCurve = 146;
- public static final int TextButtonCurve = 147;
- public static final int TextArchUpPour = 148;
- public static final int TextArchDownPour = 149;
- public static final int TextCirclePour = 150;
- public static final int TextButtonPour = 151;
- public static final int TextCurveUp = 152;
- public static final int TextCurveDown = 153;
- public static final int TextCascadeUp = 154;
- public static final int TextCascadeDown = 155;
- public static final int TextWave1 = 156;
- public static final int TextWave2 = 157;
- public static final int TextWave3 = 158;
- public static final int TextWave4 = 159;
- public static final int TextInflate = 160;
- public static final int TextDeflate = 161;
- public static final int TextInflateBottom = 162;
- public static final int TextDeflateBottom = 163;
- public static final int TextInflateTop = 164;
- public static final int TextDeflateTop = 165;
- public static final int TextDeflateInflate = 166;
- public static final int TextDeflateInflateDeflate = 167;
- public static final int TextFadeRight = 168;
- public static final int TextFadeLeft = 169;
- public static final int TextFadeUp = 170;
- public static final int TextFadeDown = 171;
- public static final int TextSlantUp = 172;
- public static final int TextSlantDown = 173;
- public static final int TextCanUp = 174;
- public static final int TextCanDown = 175;
- public static final int FlowChartAlternateProcess = 176;
- public static final int FlowChartOffpageConnector = 177;
- public static final int Callout90 = 178;
- public static final int AccentCallout90 = 179;
- public static final int BorderCallout90 = 180;
- public static final int AccentBorderCallout90 = 181;
- public static final int LeftRightUpArrow = 182;
- public static final int Sun = 183;
- public static final int Moon = 184;
- public static final int BracketPair = 185;
- public static final int BracePair = 186;
- public static final int Star4 = 187;
- public static final int DoubleWave = 188;
- public static final int ActionButtonBlank = 189;
- public static final int ActionButtonHome = 190;
- public static final int ActionButtonHelp = 191;
- public static final int ActionButtonInformation = 192;
- public static final int ActionButtonForwardNext = 193;
- public static final int ActionButtonBackPrevious = 194;
- public static final int ActionButtonEnd = 195;
- public static final int ActionButtonBeginning = 196;
- public static final int ActionButtonReturn = 197;
- public static final int ActionButtonDocument = 198;
- public static final int ActionButtonSound = 199;
- public static final int ActionButtonMovie = 200;
- public static final int HostControl = 201;
- public static final int TextBox = 202;
-
- /**
- * Return name of the shape by id
- * @param type - the id of the shape, one of the static constants defined in this class
- * @return the name of the shape
- */
- public static String typeName(int type) {
- String name = (String)types.get(new Integer(type));
- return name;
- }
-
- public static HashMap types;
- static {
- types = new HashMap();
- try {
- Field[] f = ShapeTypes.class.getFields();
- for (int i = 0; i < f.length; i++){
- Object val = f[i].get(null);
- if (val instanceof Integer) {
- types.put(val, f[i].getName());
- }
- }
- } catch (IllegalAccessException e){
- throw new RuntimeException("Failed to initialize shape types");
- }
- }
-
-}
+/* ====================================================================
+ Copyright 2002-2004 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+package org.apache.poi.hslf.model;
+
+import java.util.HashMap;
+import java.lang.reflect.Field;
+
+/**
+ * Contains all known shape types in PowerPoint
+ *
+ * @author Yegor Kozlov
+ */
+public class ShapeTypes {
+ public static final int NotPrimitive = 0;
+ public static final int Rectangle = 1;
+ public static final int RoundRectangle = 2;
+ public static final int Ellipse = 3;
+ public static final int Diamond = 4;
+ public static final int IsocelesTriangle = 5;
+ public static final int RightTriangle = 6;
+ public static final int Parallelogram = 7;
+ public static final int Trapezoid = 8;
+ public static final int Hexagon = 9;
+ public static final int Octagon = 10;
+ public static final int Plus = 11;
+ public static final int Star = 12;
+ public static final int Arrow = 13;
+ public static final int ThickArrow = 14;
+ public static final int HomePlate = 15;
+ public static final int Cube = 16;
+ public static final int Balloon = 17;
+ public static final int Seal = 18;
+ public static final int Arc = 19;
+ public static final int Line = 20;
+ public static final int Plaque = 21;
+ public static final int Can = 22;
+ public static final int Donut = 23;
+ public static final int TextSimple = 24;
+ public static final int TextOctagon = 25;
+ public static final int TextHexagon = 26;
+ public static final int TextCurve = 27;
+ public static final int TextWave = 28;
+ public static final int TextRing = 29;
+ public static final int TextOnCurve = 30;
+ public static final int TextOnRing = 31;
+ public static final int StraightConnector1 = 32;
+ public static final int BentConnector2 = 33;
+ public static final int BentConnector3 = 34;
+ public static final int BentConnector4 = 35;
+ public static final int BentConnector5 = 36;
+ public static final int CurvedConnector2 = 37;
+ public static final int CurvedConnector3 = 38;
+ public static final int CurvedConnector4 = 39;
+ public static final int CurvedConnector5 = 40;
+ public static final int Callout1 = 41;
+ public static final int Callout2 = 42;
+ public static final int Callout3 = 43;
+ public static final int AccentCallout1 = 44;
+ public static final int AccentCallout2 = 45;
+ public static final int AccentCallout3 = 46;
+ public static final int BorderCallout1 = 47;
+ public static final int BorderCallout2 = 48;
+ public static final int BorderCallout3 = 49;
+ public static final int AccentBorderCallout1 = 50;
+ public static final int AccentBorderCallout2 = 51;
+ public static final int AccentBorderCallout3 = 52;
+ public static final int Ribbon = 53;
+ public static final int Ribbon2 = 54;
+ public static final int Chevron = 55;
+ public static final int Pentagon = 56;
+ public static final int NoSmoking = 57;
+ public static final int Star8 = 58;
+ public static final int Star16 = 59;
+ public static final int Star32 = 60;
+ public static final int WedgeRectCallout = 61;
+ public static final int WedgeRRectCallout = 62;
+ public static final int WedgeEllipseCallout = 63;
+ public static final int Wave = 64;
+ public static final int FoldedCorner = 65;
+ public static final int LeftArrow = 66;
+ public static final int DownArrow = 67;
+ public static final int UpArrow = 68;
+ public static final int LeftRightArrow = 69;
+ public static final int UpDownArrow = 70;
+ public static final int IrregularSeal1 = 71;
+ public static final int IrregularSeal2 = 72;
+ public static final int LightningBolt = 73;
+ public static final int Heart = 74;
+ public static final int PictureFrame = 75;
+ public static final int QuadArrow = 76;
+ public static final int LeftArrowCallout = 77;
+ public static final int RightArrowCallout = 78;
+ public static final int UpArrowCallout = 79;
+ public static final int DownArrowCallout = 80;
+ public static final int LeftRightArrowCallout = 81;
+ public static final int UpDownArrowCallout = 82;
+ public static final int QuadArrowCallout = 83;
+ public static final int Bevel = 84;
+ public static final int LeftBracket = 85;
+ public static final int RightBracket = 86;
+ public static final int LeftBrace = 87;
+ public static final int RightBrace = 88;
+ public static final int LeftUpArrow = 89;
+ public static final int BentUpArrow = 90;
+ public static final int BentArrow = 91;
+ public static final int Star24 = 92;
+ public static final int StripedRightArrow = 93;
+ public static final int NotchedRightArrow = 94;
+ public static final int BlockArc = 95;
+ public static final int SmileyFace = 96;
+ public static final int VerticalScroll = 97;
+ public static final int HorizontalScroll = 98;
+ public static final int CircularArrow = 99;
+ public static final int NotchedCircularArrow = 100;
+ public static final int UturnArrow = 101;
+ public static final int CurvedRightArrow = 102;
+ public static final int CurvedLeftArrow = 103;
+ public static final int CurvedUpArrow = 104;
+ public static final int CurvedDownArrow = 105;
+ public static final int CloudCallout = 106;
+ public static final int EllipseRibbon = 107;
+ public static final int EllipseRibbon2 = 108;
+ public static final int FlowChartProcess = 109;
+ public static final int FlowChartDecision = 110;
+ public static final int FlowChartInputOutput = 111;
+ public static final int FlowChartPredefinedProcess = 112;
+ public static final int FlowChartInternalStorage = 113;
+ public static final int FlowChartDocument = 114;
+ public static final int FlowChartMultidocument = 115;
+ public static final int FlowChartTerminator = 116;
+ public static final int FlowChartPreparation = 117;
+ public static final int FlowChartManualInput = 118;
+ public static final int FlowChartManualOperation = 119;
+ public static final int FlowChartConnector = 120;
+ public static final int FlowChartPunchedCard = 121;
+ public static final int FlowChartPunchedTape = 122;
+ public static final int FlowChartSummingJunction = 123;
+ public static final int FlowChartOr = 124;
+ public static final int FlowChartCollate = 125;
+ public static final int FlowChartSort = 126;
+ public static final int FlowChartExtract = 127;
+ public static final int FlowChartMerge = 128;
+ public static final int FlowChartOfflineStorage = 129;
+ public static final int FlowChartOnlineStorage = 130;
+ public static final int FlowChartMagneticTape = 131;
+ public static final int FlowChartMagneticDisk = 132;
+ public static final int FlowChartMagneticDrum = 133;
+ public static final int FlowChartDisplay = 134;
+ public static final int FlowChartDelay = 135;
+ public static final int TextPlainText = 136;
+ public static final int TextStop = 137;
+ public static final int TextTriangle = 138;
+ public static final int TextTriangleInverted = 139;
+ public static final int TextChevron = 140;
+ public static final int TextChevronInverted = 141;
+ public static final int TextRingInside = 142;
+ public static final int TextRingOutside = 143;
+ public static final int TextArchUpCurve = 144;
+ public static final int TextArchDownCurve = 145;
+ public static final int TextCircleCurve = 146;
+ public static final int TextButtonCurve = 147;
+ public static final int TextArchUpPour = 148;
+ public static final int TextArchDownPour = 149;
+ public static final int TextCirclePour = 150;
+ public static final int TextButtonPour = 151;
+ public static final int TextCurveUp = 152;
+ public static final int TextCurveDown = 153;
+ public static final int TextCascadeUp = 154;
+ public static final int TextCascadeDown = 155;
+ public static final int TextWave1 = 156;
+ public static final int TextWave2 = 157;
+ public static final int TextWave3 = 158;
+ public static final int TextWave4 = 159;
+ public static final int TextInflate = 160;
+ public static final int TextDeflate = 161;
+ public static final int TextInflateBottom = 162;
+ public static final int TextDeflateBottom = 163;
+ public static final int TextInflateTop = 164;
+ public static final int TextDeflateTop = 165;
+ public static final int TextDeflateInflate = 166;
+ public static final int TextDeflateInflateDeflate = 167;
+ public static final int TextFadeRight = 168;
+ public static final int TextFadeLeft = 169;
+ public static final int TextFadeUp = 170;
+ public static final int TextFadeDown = 171;
+ public static final int TextSlantUp = 172;
+ public static final int TextSlantDown = 173;
+ public static final int TextCanUp = 174;
+ public static final int TextCanDown = 175;
+ public static final int FlowChartAlternateProcess = 176;
+ public static final int FlowChartOffpageConnector = 177;
+ public static final int Callout90 = 178;
+ public static final int AccentCallout90 = 179;
+ public static final int BorderCallout90 = 180;
+ public static final int AccentBorderCallout90 = 181;
+ public static final int LeftRightUpArrow = 182;
+ public static final int Sun = 183;
+ public static final int Moon = 184;
+ public static final int BracketPair = 185;
+ public static final int BracePair = 186;
+ public static final int Star4 = 187;
+ public static final int DoubleWave = 188;
+ public static final int ActionButtonBlank = 189;
+ public static final int ActionButtonHome = 190;
+ public static final int ActionButtonHelp = 191;
+ public static final int ActionButtonInformation = 192;
+ public static final int ActionButtonForwardNext = 193;
+ public static final int ActionButtonBackPrevious = 194;
+ public static final int ActionButtonEnd = 195;
+ public static final int ActionButtonBeginning = 196;
+ public static final int ActionButtonReturn = 197;
+ public static final int ActionButtonDocument = 198;
+ public static final int ActionButtonSound = 199;
+ public static final int ActionButtonMovie = 200;
+ public static final int HostControl = 201;
+ public static final int TextBox = 202;
+
+ /**
+ * Return name of the shape by id
+ * @param type - the id of the shape, one of the static constants defined in this class
+ * @return the name of the shape
+ */
+ public static String typeName(int type) {
+ String name = (String)types.get(new Integer(type));
+ return name;
+ }
+
+ public static HashMap types;
+ static {
+ types = new HashMap();
+ try {
+ Field[] f = ShapeTypes.class.getFields();
+ for (int i = 0; i < f.length; i++){
+ Object val = f[i].get(null);
+ if (val instanceof Integer) {
+ types.put(val, f[i].getName());
+ }
+ }
+ } catch (IllegalAccessException e){
+ throw new RuntimeException("Failed to initialize shape types");
+ }
+ }
+
+}
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java?view=diff&rev=489760&r1=489759&r2=489760
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java (original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java Fri Dec 22 12:56:04 2006
@@ -1,217 +1,217 @@
-/* ====================================================================
- Copyright 2002-2004 Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.model;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.hslf.record.ColorSchemeAtom;
-
-import java.awt.*;
-
-/**
- * An abstract simple (non-group) shape.
- * This is the parent class for all primitive shapes like Line, Rectangle, etc.
- *
- * @author Yegor Kozlov
- */
-public class SimpleShape extends Shape {
-
- /**
- * Create a SimpleShape object and initialize it from the supplied Record container.
- *
- * @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
- * @param parent the parent of the shape
- */
- protected SimpleShape(EscherContainerRecord escherRecord, Shape parent){
- super(escherRecord, parent);
- }
-
- /**
- * Create a new Shape
- *
- * @param isChild <code>true</code> if the Line is inside a group, <code>false</code> otherwise
- * @return the record container which holds this shape
- */
- protected EscherContainerRecord createSpContainer(boolean isChild) {
- EscherContainerRecord spContainer = new EscherContainerRecord();
- spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
- spContainer.setOptions((short)15);
-
- EscherSpRecord sp = new EscherSpRecord();
- int flags = EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE;
- if (isChild) flags |= EscherSpRecord.FLAG_CHILD;
- sp.setFlags(flags);
- spContainer.addChildRecord(sp);
-
- EscherOptRecord opt = new EscherOptRecord();
- opt.setRecordId(EscherOptRecord.RECORD_ID);
- spContainer.addChildRecord(opt);
-
- EscherRecord anchor;
- if(isChild) anchor = new EscherChildAnchorRecord();
- else {
- anchor = new EscherClientAnchorRecord();
-
- //hack. internal variable EscherClientAnchorRecord.shortRecord can be
- //initialized only in fillFields(). We need to set shortRecord=false;
- byte[] header = new byte[16];
- LittleEndian.putUShort(header, 0, 0);
- LittleEndian.putUShort(header, 2, 0);
- LittleEndian.putInt(header, 4, 8);
- anchor.fillFields(header, 0, null);
- }
- spContainer.addChildRecord(anchor);
-
- return spContainer;
- }
-
- /**
- * Returns width of the line in in points
- */
- public double getLineWidth(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
- EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
- return prop == null ? 0 : (double)prop.getPropertyValue()/EMU_PER_POINT;
- }
-
- /**
- * Sets the width of line in in points
- * @param width the width of line in in points
- */
- public void setLineWidth(double width){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
- setEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH, (int)(width*EMU_PER_POINT));
- }
-
- /**
- * Sets the color of line
- *
- * @param color new color of the line
- */
- public void setLineColor(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.LINESTYLE__COLOR, rgb);
- setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, color == null ? 0x180010 : 0x180018);
- }
-
- /**
- * @return color of the line. If color is not set returns <code>java.awt.Color.black</code>
- */
- public Color getLineColor(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
-
- EscherSimpleProperty p1 = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__COLOR);
- EscherSimpleProperty p2 = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH);
- int p2val = p2 == null ? 0 : p2.getPropertyValue();
- Color clr = null;
- if (p1 != null && (p2val & 0x8) != 0){
- int rgb = p1.getPropertyValue();
- if (rgb >= 0x8000000) {
- int idx = rgb % 0x8000000;
- ColorSchemeAtom ca = getSheet().getColorScheme();
- if(idx >= 0 && idx <= 7) rgb = ca.getColor(idx);
- }
- Color tmp = new Color(rgb, true);
- clr = new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed());
- }
- return clr;
- }
-
- /**
- * Gets line dashing. One of the PEN_* constants defined in this class.
- *
- * @return dashing of the line.
- */
- public int getLineDashing(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
-
- EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING);
- return prop == null ? Line.PEN_SOLID : prop.getPropertyValue();
- }
-
- /**
- * Sets line dashing. One of the PEN_* constants defined in this class.
- *
- * @param pen new style of the line.
- */
- public void setLineDashing(int pen){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
-
- setEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING, pen == Line.PEN_SOLID ? -1 : pen);
- }
-
- /**
- * Sets line style. One of the constants defined in this class.
- *
- * @param style new style of the line.
- */
- public void setLineStyle(int style){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
- setEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE, style == Line.LINE_SIMPLE ? -1 : style);
- }
-
- /**
- * Returns line style. One of the constants defined in this class.
- *
- * @return style of the line.
- */
- public int getLineStyle(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
- EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE);
- return prop == null ? Line.LINE_SIMPLE : prop.getPropertyValue();
- }
-
- /**
- * The color used to fill this shape.
- *
- * @param color the background color
- */
- public Color getFillColor(Color color){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
- EscherSimpleProperty p1 = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.FILL__FILLCOLOR);
- EscherSimpleProperty p2= (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
-
- int p2val = p2 == null ? 0 : p2.getPropertyValue();
-
- Color clr = null;
- if (p1 != null && (p2val & 0x10) != 0){
- int rgb = p1.getPropertyValue();
- if (rgb >= 0x8000000) {
- int idx = rgb % 0x8000000;
- ColorSchemeAtom ca = getSheet().getColorScheme();
- rgb = ca.getColor(idx);
- }
- Color tmp = new Color(rgb, true);
- clr = new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed());
- }
- return clr;
- }
-
- /**
- * The color used to fill this shape.
- *
- * @param color the background color
- */
- public void setFillColor(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__FILLCOLOR, rgb);
- setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, color == null ? 0x150010 : 0x150011);
- }
-
-}
+/* ====================================================================
+ Copyright 2002-2004 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.model;
+
+import org.apache.poi.ddf.*;
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.hslf.record.ColorSchemeAtom;
+
+import java.awt.*;
+
+/**
+ * An abstract simple (non-group) shape.
+ * This is the parent class for all primitive shapes like Line, Rectangle, etc.
+ *
+ * @author Yegor Kozlov
+ */
+public class SimpleShape extends Shape {
+
+ /**
+ * Create a SimpleShape object and initialize it from the supplied Record container.
+ *
+ * @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
+ * @param parent the parent of the shape
+ */
+ protected SimpleShape(EscherContainerRecord escherRecord, Shape parent){
+ super(escherRecord, parent);
+ }
+
+ /**
+ * Create a new Shape
+ *
+ * @param isChild <code>true</code> if the Line is inside a group, <code>false</code> otherwise
+ * @return the record container which holds this shape
+ */
+ protected EscherContainerRecord createSpContainer(boolean isChild) {
+ EscherContainerRecord spContainer = new EscherContainerRecord();
+ spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
+ spContainer.setOptions((short)15);
+
+ EscherSpRecord sp = new EscherSpRecord();
+ int flags = EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE;
+ if (isChild) flags |= EscherSpRecord.FLAG_CHILD;
+ sp.setFlags(flags);
+ spContainer.addChildRecord(sp);
+
+ EscherOptRecord opt = new EscherOptRecord();
+ opt.setRecordId(EscherOptRecord.RECORD_ID);
+ spContainer.addChildRecord(opt);
+
+ EscherRecord anchor;
+ if(isChild) anchor = new EscherChildAnchorRecord();
+ else {
+ anchor = new EscherClientAnchorRecord();
+
+ //hack. internal variable EscherClientAnchorRecord.shortRecord can be
+ //initialized only in fillFields(). We need to set shortRecord=false;
+ byte[] header = new byte[16];
+ LittleEndian.putUShort(header, 0, 0);
+ LittleEndian.putUShort(header, 2, 0);
+ LittleEndian.putInt(header, 4, 8);
+ anchor.fillFields(header, 0, null);
+ }
+ spContainer.addChildRecord(anchor);
+
+ return spContainer;
+ }
+
+ /**
+ * Returns width of the line in in points
+ */
+ public double getLineWidth(){
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
+ return prop == null ? 0 : (double)prop.getPropertyValue()/EMU_PER_POINT;
+ }
+
+ /**
+ * Sets the width of line in in points
+ * @param width the width of line in in points
+ */
+ public void setLineWidth(double width){
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ setEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH, (int)(width*EMU_PER_POINT));
+ }
+
+ /**
+ * Sets the color of line
+ *
+ * @param color new color of the line
+ */
+ public void setLineColor(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.LINESTYLE__COLOR, rgb);
+ setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, color == null ? 0x180010 : 0x180018);
+ }
+
+ /**
+ * @return color of the line. If color is not set returns <code>java.awt.Color.black</code>
+ */
+ public Color getLineColor(){
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+
+ EscherSimpleProperty p1 = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__COLOR);
+ EscherSimpleProperty p2 = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH);
+ int p2val = p2 == null ? 0 : p2.getPropertyValue();
+ Color clr = null;
+ if (p1 != null && (p2val & 0x8) != 0){
+ int rgb = p1.getPropertyValue();
+ if (rgb >= 0x8000000) {
+ int idx = rgb % 0x8000000;
+ ColorSchemeAtom ca = getSheet().getColorScheme();
+ if(idx >= 0 && idx <= 7) rgb = ca.getColor(idx);
+ }
+ Color tmp = new Color(rgb, true);
+ clr = new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed());
+ }
+ return clr;
+ }
+
+ /**
+ * Gets line dashing. One of the PEN_* constants defined in this class.
+ *
+ * @return dashing of the line.
+ */
+ public int getLineDashing(){
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+
+ EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING);
+ return prop == null ? Line.PEN_SOLID : prop.getPropertyValue();
+ }
+
+ /**
+ * Sets line dashing. One of the PEN_* constants defined in this class.
+ *
+ * @param pen new style of the line.
+ */
+ public void setLineDashing(int pen){
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+
+ setEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING, pen == Line.PEN_SOLID ? -1 : pen);
+ }
+
+ /**
+ * Sets line style. One of the constants defined in this class.
+ *
+ * @param style new style of the line.
+ */
+ public void setLineStyle(int style){
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ setEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE, style == Line.LINE_SIMPLE ? -1 : style);
+ }
+
+ /**
+ * Returns line style. One of the constants defined in this class.
+ *
+ * @return style of the line.
+ */
+ public int getLineStyle(){
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE);
+ return prop == null ? Line.LINE_SIMPLE : prop.getPropertyValue();
+ }
+
+ /**
+ * The color used to fill this shape.
+ *
+ * @param color the background color
+ */
+ public Color getFillColor(Color color){
+ EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherSimpleProperty p1 = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.FILL__FILLCOLOR);
+ EscherSimpleProperty p2= (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST);
+
+ int p2val = p2 == null ? 0 : p2.getPropertyValue();
+
+ Color clr = null;
+ if (p1 != null && (p2val & 0x10) != 0){
+ int rgb = p1.getPropertyValue();
+ if (rgb >= 0x8000000) {
+ int idx = rgb % 0x8000000;
+ ColorSchemeAtom ca = getSheet().getColorScheme();
+ rgb = ca.getColor(idx);
+ }
+ Color tmp = new Color(rgb, true);
+ clr = new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed());
+ }
+ return clr;
+ }
+
+ /**
+ * The color used to fill this shape.
+ *
+ * @param color the background color
+ */
+ public void setFillColor(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__FILLCOLOR, rgb);
+ setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, color == null ? 0x150010 : 0x150011);
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/