import java.io.IOException;
import java.util.List;
-import org.apache.poi.hslf.model.Line;
import org.apache.poi.hslf.model.PPGraphics2D;
import org.apache.poi.hslf.record.TextHeaderAtom;
import org.apache.poi.hslf.usermodel.HSLFAutoShape;
import org.apache.poi.hslf.usermodel.HSLFTextBox;
import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
import org.apache.poi.hslf.usermodel.HSLFTextRun;
+import org.apache.poi.hslf.usermodel.HSLFLine;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.sl.usermodel.VerticalAlignment;
}
}
- Line border1 = table1.createBorder();
+ HSLFLine border1 = table1.createBorder();
border1.setLineColor(Color.black);
border1.setLineWidth(1.0);
table1.setAllBorders(border1);
- Line border2 = table1.createBorder();
+ HSLFLine border2 = table1.createBorder();
border2.setLineColor(Color.black);
border2.setLineWidth(2.0);
table1.setOutsideBorders(border2);
import java.awt.Color;
import java.io.FileOutputStream;
-import org.apache.poi.hslf.model.Line;
import org.apache.poi.hslf.usermodel.HSLFSlide;
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.hslf.usermodel.HSLFTable;
import org.apache.poi.hslf.usermodel.HSLFTableCell;
import org.apache.poi.hslf.usermodel.HSLFTextRun;
+import org.apache.poi.hslf.usermodel.HSLFLine;
import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
import org.apache.poi.sl.usermodel.VerticalAlignment;
}
}
- Line border1 = table1.createBorder();
+ HSLFLine border1 = table1.createBorder();
border1.setLineColor(Color.black);
border1.setLineWidth(1.0);
table1.setAllBorders(border1);
table2.setRowHeight(0, 30);
table2.setRowHeight(1, 70);
- Line border2 = table2.createBorder();
+ HSLFLine border2 = table2.createBorder();
table2.setOutsideBorders(border2);
slide.addShape(table2);
package org.apache.poi.sl.usermodel;
+import org.apache.poi.util.Internal;
+
+/**
+ * Interface for Lines ... this will be eventually removed,
+ * so don't depend on it in user classes, but use AutoShape instead!
+ */
+
+@Internal
public interface Line<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> {
}
+++ /dev/null
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.EscherContainerRecord;
-import org.apache.poi.ddf.EscherOptRecord;
-import org.apache.poi.ddf.EscherProperties;
-import org.apache.poi.ddf.EscherSpRecord;
-import org.apache.poi.hslf.usermodel.HSLFGroupShape;
-import org.apache.poi.hslf.usermodel.HSLFShape;
-import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
-import org.apache.poi.hslf.usermodel.HSLFTextShape;
-import org.apache.poi.sl.usermodel.ShapeContainer;
-import org.apache.poi.sl.usermodel.ShapeType;
-
-/**
- * Represents a line in a PowerPoint drawing
- *
- * @author Yegor Kozlov
- */
-public final class Line extends HSLFTextShape implements org.apache.poi.sl.usermodel.Line<HSLFTextParagraph> {
- public Line(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
- super(escherRecord, parent);
- }
-
- public Line(ShapeContainer<HSLFShape> parent){
- super(null, parent);
- _escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
- }
-
- public Line(){
- this(null);
- }
-
- protected EscherContainerRecord createSpContainer(boolean isChild){
- _escherContainer = super.createSpContainer(isChild);
-
- setShapeType(ShapeType.LINE);
-
- EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
- short type = (short)((ShapeType.LINE.nativeId << 4) | 0x2);
- spRecord.setOptions(type);
-
- //set default properties for a line
- EscherOptRecord opt = getEscherOptRecord();
-
- //default line properties
- setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, 4);
- setEscherProperty(opt, EscherProperties.GEOMETRY__FILLOK, 0x10000);
- setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x100000);
- setEscherProperty(opt, EscherProperties.LINESTYLE__COLOR, 0x8000001);
- setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0xA0008);
- setEscherProperty(opt, EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
-
- return _escherContainer;
- }
-
-// /**
-// * Sets the orientation of the line, if inverse is false, then line goes
-// * from top-left to bottom-right, otherwise use inverse equals true
-// *
-// * @param inverse the orientation of the line
-// */
-// public void setInverse(boolean inverse) {
-// setShapeType(inverse ? ShapeType.LINE_INV : ShapeType.LINE);
-// }
-//
-// /**
-// * Gets the orientation of the line, if inverse is false, then line goes
-// * from top-left to bottom-right, otherwise inverse equals true
-// *
-// * @return inverse the orientation of the line
-// */
-// public boolean isInverse() {
-// return (getShapeType() == ShapeType.LINE_INV);
-// }
-}
--- /dev/null
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.usermodel;
+
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherOptRecord;
+import org.apache.poi.ddf.EscherProperties;
+import org.apache.poi.ddf.EscherSpRecord;
+import org.apache.poi.sl.usermodel.Line;
+import org.apache.poi.sl.usermodel.ShapeContainer;
+import org.apache.poi.sl.usermodel.ShapeType;
+
+/**
+ * Represents a line in a PowerPoint drawing
+ *
+ * @author Yegor Kozlov
+ */
+public final class HSLFLine extends HSLFTextShape implements Line<HSLFTextParagraph> {
+ public HSLFLine(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
+ super(escherRecord, parent);
+ }
+
+ public HSLFLine(ShapeContainer<HSLFShape> parent){
+ super(null, parent);
+ _escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
+ }
+
+ public HSLFLine(){
+ this(null);
+ }
+
+ protected EscherContainerRecord createSpContainer(boolean isChild){
+ _escherContainer = super.createSpContainer(isChild);
+
+ setShapeType(ShapeType.LINE);
+
+ EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
+ short type = (short)((ShapeType.LINE.nativeId << 4) | 0x2);
+ spRecord.setOptions(type);
+
+ //set default properties for a line
+ EscherOptRecord opt = getEscherOptRecord();
+
+ //default line properties
+ setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, 4);
+ setEscherProperty(opt, EscherProperties.GEOMETRY__FILLOK, 0x10000);
+ setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x100000);
+ setEscherProperty(opt, EscherProperties.LINESTYLE__COLOR, 0x8000001);
+ setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0xA0008);
+ setEscherProperty(opt, EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
+
+ return _escherContainer;
+ }
+
+// /**
+// * Sets the orientation of the line, if inverse is false, then line goes
+// * from top-left to bottom-right, otherwise use inverse equals true
+// *
+// * @param inverse the orientation of the line
+// */
+// public void setInverse(boolean inverse) {
+// setShapeType(inverse ? ShapeType.LINE_INV : ShapeType.LINE);
+// }
+//
+// /**
+// * Gets the orientation of the line, if inverse is false, then line goes
+// * from top-left to bottom-right, otherwise inverse equals true
+// *
+// * @return inverse the orientation of the line
+// */
+// public boolean isInverse() {
+// return (getShapeType() == ShapeType.LINE_INV);
+// }
+}
break;
}
case LINE:
- shape = new Line(spContainer, parent);
+ shape = new HSLFLine(spContainer, parent);
break;
case NOT_PRIMITIVE: {
EscherOptRecord opt = HSLFShape.getEscherChild(spContainer, EscherOptRecord.RECORD_ID);
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherSimpleProperty;
import org.apache.poi.ddf.EscherTextboxRecord;
-import org.apache.poi.hslf.model.Line;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.TableShape;
import org.apache.poi.util.LittleEndian;
HSLFTableCell c = cells[i][j];
addShape(c);
- Line bt = c.getBorderTop();
+ HSLFLine bt = c.getBorderTop();
if(bt != null) addShape(bt);
- Line br = c.getBorderRight();
+ HSLFLine br = c.getBorderRight();
if(br != null) addShape(br);
- Line bb = c.getBorderBottom();
+ HSLFLine bb = c.getBorderBottom();
if(bb != null) addShape(bb);
- Line bl = c.getBorderLeft();
+ HSLFLine bl = c.getBorderLeft();
if(bl != null) addShape(bl);
}
*
* @param line the border line
*/
- public void setAllBorders(Line line){
+ public void setAllBorders(HSLFLine line){
for (int i = 0; i < cells.length; i++) {
for (int j = 0; j < cells[i].length; j++) {
HSLFTableCell cell = cells[i][j];
*
* @param line the border line
*/
- public void setOutsideBorders(Line line){
+ public void setOutsideBorders(HSLFLine line){
for (int i = 0; i < cells.length; i++) {
for (int j = 0; j < cells[i].length; j++) {
HSLFTableCell cell = cells[i][j];
*
* @param line the border line
*/
- public void setInsideBorders(Line line){
+ public void setInsideBorders(HSLFLine line){
for (int i = 0; i < cells.length; i++) {
for (int j = 0; j < cells[i].length; j++) {
HSLFTableCell cell = cells[i][j];
}
}
- private Line cloneBorder(Line line){
- Line border = createBorder();
+ private HSLFLine cloneBorder(HSLFLine line){
+ HSLFLine border = createBorder();
border.setLineWidth(line.getLineWidth());
border.setLineDashing(line.getLineDashing());
border.setLineColor(line.getLineColor());
*
* @return the created border
*/
- public Line createBorder(){
- Line line = new Line(this);
+ public HSLFLine createBorder(){
+ HSLFLine line = new HSLFLine(this);
EscherOptRecord opt = getEscherOptRecord();
setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, -1);
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherOptRecord;
import org.apache.poi.ddf.EscherProperties;
-import org.apache.poi.hslf.model.Line;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
protected static final int DEFAULT_WIDTH = 100;
protected static final int DEFAULT_HEIGHT = 40;
- private Line borderLeft;
- private Line borderRight;
- private Line borderTop;
- private Line borderBottom;
+ private HSLFLine borderLeft;
+ private HSLFLine borderRight;
+ private HSLFLine borderTop;
+ private HSLFLine borderBottom;
/**
* Create a TableCell object and initialize it from the supplied Record container.
return _escherContainer;
}
- protected void anchorBorder(int type, Line line){
+ protected void anchorBorder(int type, HSLFLine line){
Rectangle cellAnchor = getAnchor();
Rectangle lineAnchor = new Rectangle();
switch(type){
line.setAnchor(lineAnchor);
}
- public Line getBorderLeft() {
+ public HSLFLine getBorderLeft() {
return borderLeft;
}
- public void setBorderLeft(Line line) {
+ public void setBorderLeft(HSLFLine line) {
if(line != null) anchorBorder(HSLFTable.BORDER_LEFT, line);
this.borderLeft = line;
}
- public Line getBorderRight() {
+ public HSLFLine getBorderRight() {
return borderRight;
}
- public void setBorderRight(Line line) {
+ public void setBorderRight(HSLFLine line) {
if(line != null) anchorBorder(HSLFTable.BORDER_RIGHT, line);
this.borderRight = line;
}
- public Line getBorderTop() {
+ public HSLFLine getBorderTop() {
return borderTop;
}
- public void setBorderTop(Line line) {
+ public void setBorderTop(HSLFLine line) {
if(line != null) anchorBorder(HSLFTable.BORDER_TOP, line);
this.borderTop = line;
}
- public Line getBorderBottom() {
+ public HSLFLine getBorderBottom() {
return borderBottom;
}
- public void setBorderBottom(Line line) {
+ public void setBorderBottom(HSLFLine line) {
if(line != null) anchorBorder(HSLFTable.BORDER_BOTTOM, line);
this.borderBottom = line;
}
import org.apache.poi.hslf.usermodel.HSLFSlide;
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
+import org.apache.poi.hslf.usermodel.HSLFLine;
import org.apache.poi.sl.usermodel.StrokeStyle.LineCompound;
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
import org.junit.Test;
slide.addTitle().setText("Lines tester");
- Line line;
+ HSLFLine line;
/**
* line styles
*/
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 200, 300, 0));
line.setLineCompound(LineCompound.SINGLE);
line.setLineColor(Color.blue);
slide.addShape(line);
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 230, 300, 0));
line.setLineCompound(LineCompound.DOUBLE);
line.setLineWidth(3.5);
slide.addShape(line);
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 260, 300, 0));
line.setLineCompound(LineCompound.TRIPLE);
line.setLineWidth(6);
slide.addShape(line);
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 290, 300, 0));
line.setLineCompound(LineCompound.THICK_THIN);
line.setLineWidth(4.5);
slide.addShape(line);
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 320, 300, 0));
line.setLineCompound(LineCompound.THIN_THICK);
line.setLineWidth(5.5);
/**
* line dashing
*/
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(450, 200, 300, 0));
line.setLineDashing(LineDash.SOLID);
slide.addShape(line);
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(450, 230, 300, 0));
line.setLineDashing(LineDash.DASH);
slide.addShape(line);
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(450, 260, 300, 0));
line.setLineDashing(LineDash.DOT);
slide.addShape(line);
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(450, 290, 300, 0));
line.setLineDashing(LineDash.DASH_DOT);
slide.addShape(line);
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(450, 320, 300, 0));
line.setLineDashing(LineDash.LG_DASH_DOT_DOT);
slide.addShape(line);
/**
* Combinations
*/
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 400, 300, 0));
line.setLineDashing(LineDash.DASH_DOT);
line.setLineCompound(LineCompound.TRIPLE);
line.setLineWidth(5.0);
slide.addShape(line);
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 430, 300, 0));
line.setLineDashing(LineDash.DASH);
line.setLineCompound(LineCompound.THICK_THIN);
line.setLineWidth(4.0);
slide.addShape(line);
- line = new Line();
+ line = new HSLFLine();
line.setAnchor(new java.awt.Rectangle(75, 460, 300, 0));
line.setLineDashing(LineDash.DOT);
line.setLineCompound(LineCompound.DOUBLE);
import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
import org.apache.poi.hslf.usermodel.HSLFTextRun;
import org.apache.poi.hslf.usermodel.HSLFTextShape;
+import org.apache.poi.hslf.usermodel.HSLFLine;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
public void graphics() throws Exception {
HSLFSlide slide = ppt.createSlide();
- Line line = new Line();
+ HSLFLine line = new HSLFLine();
java.awt.Rectangle lineAnchor = new java.awt.Rectangle(100, 200, 50, 60);
line.setAnchor(lineAnchor);
line.setLineWidth(3);
List<HSLFShape> shape = slide.getShapes();
assertEquals(2, shape.size());
- assertTrue(shape.get(0) instanceof Line); //group shape
+ assertTrue(shape.get(0) instanceof HSLFLine); //group shape
assertEquals(lineAnchor, shape.get(0).getAnchor()); //group shape
assertTrue(shape.get(1) instanceof HSLFAutoShape); //group shape
pict.setAnchor(new Rectangle(0, 0, 200, 200));
group.addShape(pict);
- Line line = new Line(group);
+ HSLFLine line = new HSLFLine(group);
line.setAnchor(new Rectangle(300, 300, 500, 0));
group.addShape(line);
List<HSLFShape> grshape = group.getShapes();
assertEquals(2, grshape.size());
assertTrue(grshape.get(0) instanceof HSLFPictureShape);
- assertTrue(grshape.get(1) instanceof Line);
+ assertTrue(grshape.get(1) instanceof HSLFLine);
pict = (HSLFPictureShape)grshape.get(0);
assertEquals(new Rectangle(0, 0, 200, 200), pict.getAnchor());
- line = (Line)grshape.get(1);
+ line = (HSLFLine)grshape.get(1);
assertEquals(new Rectangle(300, 300, 500, 0), line.getAnchor());
}
int dgShapesUsed = dg.getNumShapes(); // number of shapes in the slide
//insert 3 shapes and make sure the Ids are properly incremented
for (int i = 0; i < 3; i++) {
- shape = new Line();
+ shape = new HSLFLine();
assertEquals(0, shape.getShapeId());
slide.addShape(shape);
assertTrue(shape.getShapeId() > 0);
//make sure it is so
int numClusters = dgg.getNumIdClusters();
for (int i = 0; i < 1025; i++) {
- shape = new Line();
+ shape = new HSLFLine();
slide.addShape(shape);
}
assertEquals(numClusters + 1, dgg.getNumIdClusters());