aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/sl
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2015-08-24 23:15:14 +0000
committerAndreas Beeker <kiwiwings@apache.org>2015-08-24 23:15:14 +0000
commitbc61534b9224db6b439307b199753405634b9793 (patch)
treeeca8a9e6e1fbbabc85cf071679f167e01fca2947 /src/java/org/apache/poi/sl
parent5204aacf5489be00c2fd5cced71414bfeec86aa2 (diff)
downloadpoi-bc61534b9224db6b439307b199753405634b9793.tar.gz
poi-bc61534b9224db6b439307b199753405634b9793.zip
common sl: reworked and unified generics definitions
made various methods available through common sl added createTextBox,AutoShape,... methods to ShapeContainers hslf tables created by poi, will be identified as such when the file is read again git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1697515 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/sl')
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawAutoShape.java4
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawBackground.java24
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawConnectorShape.java6
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawFactory.java82
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawFreeformShape.java17
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawGroupShape.java15
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawMasterSheet.java9
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawNothing.java6
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawPaint.java4
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawPictureShape.java15
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawShape.java42
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawSheet.java12
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawSimpleShape.java73
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawSlide.java6
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawTableShape.java40
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawTextBox.java4
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawTextParagraph.java20
-rw-r--r--src/java/org/apache/poi/sl/draw/DrawTextShape.java27
-rw-r--r--src/java/org/apache/poi/sl/usermodel/AutoShape.java5
-rw-r--r--src/java/org/apache/poi/sl/usermodel/Background.java5
-rw-r--r--src/java/org/apache/poi/sl/usermodel/ConnectorShape.java5
-rw-r--r--src/java/org/apache/poi/sl/usermodel/FreeformShape.java5
-rw-r--r--src/java/org/apache/poi/sl/usermodel/GroupShape.java5
-rw-r--r--src/java/org/apache/poi/sl/usermodel/Line.java5
-rw-r--r--src/java/org/apache/poi/sl/usermodel/MasterSheet.java5
-rw-r--r--src/java/org/apache/poi/sl/usermodel/Notes.java7
-rw-r--r--src/java/org/apache/poi/sl/usermodel/PictureShape.java5
-rw-r--r--src/java/org/apache/poi/sl/usermodel/PlaceableShape.java7
-rw-r--r--src/java/org/apache/poi/sl/usermodel/Shape.java9
-rw-r--r--src/java/org/apache/poi/sl/usermodel/ShapeContainer.java49
-rw-r--r--src/java/org/apache/poi/sl/usermodel/Sheet.java11
-rw-r--r--src/java/org/apache/poi/sl/usermodel/SimpleShape.java5
-rw-r--r--src/java/org/apache/poi/sl/usermodel/Slide.java9
-rw-r--r--src/java/org/apache/poi/sl/usermodel/SlideShow.java13
-rw-r--r--src/java/org/apache/poi/sl/usermodel/TableCell.java25
-rw-r--r--src/java/org/apache/poi/sl/usermodel/TableShape.java5
-rw-r--r--src/java/org/apache/poi/sl/usermodel/TextBox.java5
-rw-r--r--src/java/org/apache/poi/sl/usermodel/TextParagraph.java8
-rw-r--r--src/java/org/apache/poi/sl/usermodel/TextShape.java28
39 files changed, 419 insertions, 208 deletions
diff --git a/src/java/org/apache/poi/sl/draw/DrawAutoShape.java b/src/java/org/apache/poi/sl/draw/DrawAutoShape.java
index 6af2b4b9c1..9cda7a32a6 100644
--- a/src/java/org/apache/poi/sl/draw/DrawAutoShape.java
+++ b/src/java/org/apache/poi/sl/draw/DrawAutoShape.java
@@ -20,8 +20,8 @@ package org.apache.poi.sl.draw;
import org.apache.poi.sl.usermodel.*;
-public class DrawAutoShape<T extends AutoShape<? extends TextParagraph<? extends TextRun>>> extends DrawTextShape<T> {
- public DrawAutoShape(T shape) {
+public class DrawAutoShape extends DrawTextShape {
+ public DrawAutoShape(AutoShape<?,?> shape) {
super(shape);
}
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawBackground.java b/src/java/org/apache/poi/sl/draw/DrawBackground.java
index 35c844d8d0..4072fe4bcd 100644
--- a/src/java/org/apache/poi/sl/draw/DrawBackground.java
+++ b/src/java/org/apache/poi/sl/draw/DrawBackground.java
@@ -17,24 +17,28 @@
package org.apache.poi.sl.draw;
-import java.awt.*;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.Paint;
import java.awt.geom.Rectangle2D;
-import org.apache.poi.sl.usermodel.*;
-import org.apache.poi.sl.usermodel.Shape;
+import org.apache.poi.sl.usermodel.Background;
+import org.apache.poi.sl.usermodel.PlaceableShape;
+import org.apache.poi.sl.usermodel.ShapeContainer;
-public class DrawBackground<T extends Background> extends DrawShape<T> {
- public DrawBackground(T shape) {
+public class DrawBackground extends DrawShape {
+ public DrawBackground(Background<?,?> shape) {
super(shape);
}
+ @SuppressWarnings("rawtypes")
public void draw(Graphics2D graphics) {
Dimension pg = shape.getSheet().getSlideShow().getPageSize();
final Rectangle2D anchor = new Rectangle2D.Double(0, 0, pg.getWidth(), pg.getHeight());
- PlaceableShape ps = new PlaceableShape(){
- public ShapeContainer<? extends Shape> getParent() { return null; }
+ PlaceableShape<?,?> ps = new PlaceableShape(){
+ public ShapeContainer<?,?> getParent() { return null; }
public Rectangle2D getAnchor() { return anchor; }
public void setAnchor(Rectangle2D anchor) {}
public double getRotation() { return 0; }
@@ -47,7 +51,7 @@ public class DrawBackground<T extends Background> extends DrawShape<T> {
DrawFactory drawFact = DrawFactory.getInstance(graphics);
DrawPaint dp = drawFact.getPaint(ps);
- Paint fill = dp.getPaint(graphics, shape.getFillStyle().getPaint());
+ Paint fill = dp.getPaint(graphics, getShape().getFillStyle().getPaint());
Rectangle2D anchor2 = getAnchor(graphics, anchor);
if(fill != null) {
@@ -56,5 +60,7 @@ public class DrawBackground<T extends Background> extends DrawShape<T> {
}
}
-
+ protected Background<?,?> getShape() {
+ return (Background<?,?>)shape;
+ }
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawConnectorShape.java b/src/java/org/apache/poi/sl/draw/DrawConnectorShape.java
index 0fee07cf6d..00bcd1b58e 100644
--- a/src/java/org/apache/poi/sl/draw/DrawConnectorShape.java
+++ b/src/java/org/apache/poi/sl/draw/DrawConnectorShape.java
@@ -17,10 +17,10 @@
package org.apache.poi.sl.draw;
-import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.usermodel.ConnectorShape;
-public class DrawConnectorShape<T extends ConnectorShape> extends DrawSimpleShape<T> {
- public DrawConnectorShape(T shape) {
+public class DrawConnectorShape extends DrawSimpleShape {
+ public DrawConnectorShape(ConnectorShape<?,?> shape) {
super(shape);
}
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawFactory.java b/src/java/org/apache/poi/sl/draw/DrawFactory.java
index 8e75514e4d..19d3476470 100644
--- a/src/java/org/apache/poi/sl/draw/DrawFactory.java
+++ b/src/java/org/apache/poi/sl/draw/DrawFactory.java
@@ -28,17 +28,14 @@ import org.apache.poi.sl.usermodel.ConnectorShape;
import org.apache.poi.sl.usermodel.FreeformShape;
import org.apache.poi.sl.usermodel.GroupShape;
import org.apache.poi.sl.usermodel.MasterSheet;
-import org.apache.poi.sl.usermodel.Notes;
import org.apache.poi.sl.usermodel.PictureShape;
import org.apache.poi.sl.usermodel.PlaceableShape;
import org.apache.poi.sl.usermodel.Shape;
import org.apache.poi.sl.usermodel.Sheet;
import org.apache.poi.sl.usermodel.Slide;
-import org.apache.poi.sl.usermodel.SlideShow;
import org.apache.poi.sl.usermodel.TableShape;
import org.apache.poi.sl.usermodel.TextBox;
import org.apache.poi.sl.usermodel.TextParagraph;
-import org.apache.poi.sl.usermodel.TextRun;
import org.apache.poi.sl.usermodel.TextShape;
public class DrawFactory {
@@ -77,90 +74,89 @@ public class DrawFactory {
return factory;
}
- @SuppressWarnings("unchecked")
- public Drawable getDrawable(Shape shape) {
+ public Drawable getDrawable(Shape<?,?> shape) {
if (shape instanceof TextBox) {
- return getDrawable((TextBox<? extends TextParagraph<? extends TextRun>>)shape);
+ return getDrawable((TextBox<?,?>)shape);
} else if (shape instanceof FreeformShape) {
- return getDrawable((FreeformShape<? extends TextParagraph<? extends TextRun>>)shape);
+ return getDrawable((FreeformShape<?,?>)shape);
} else if (shape instanceof TextShape) {
- return getDrawable((TextShape<? extends TextParagraph<? extends TextRun>>)shape);
+ return getDrawable((TextShape<?,?>)shape);
+ } else if (shape instanceof TableShape) {
+ return getDrawable((TableShape<?,?>)shape);
} else if (shape instanceof GroupShape) {
- return getDrawable((GroupShape<? extends Shape>)shape);
+ return getDrawable((GroupShape<?,?>)shape);
} else if (shape instanceof PictureShape) {
- return getDrawable((PictureShape)shape);
+ return getDrawable((PictureShape<?,?>)shape);
} else if (shape instanceof Background) {
- return getDrawable((Background)shape);
+ return getDrawable((Background<?,?>)shape);
} else if (shape instanceof ConnectorShape) {
- return getDrawable((ConnectorShape)shape);
- } else if (shape instanceof TableShape) {
- return getDrawable((TableShape)shape);
+ return getDrawable((ConnectorShape<?,?>)shape);
} else if (shape instanceof Slide) {
- return getDrawable((Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>)shape);
+ return getDrawable((Slide<?,?>)shape);
} else if (shape instanceof MasterSheet) {
- return getDrawable((MasterSheet<? extends Shape, ? extends SlideShow>)shape);
+ return getDrawable((MasterSheet<?,?>)shape);
} else if (shape instanceof Sheet) {
- return getDrawable((Sheet<? extends Shape, ? extends SlideShow>)shape);
+ return getDrawable((Sheet<?,?>)shape);
} else if (shape.getClass().isAnnotationPresent(DrawNotImplemented.class)) {
- return new DrawNothing<Shape>(shape);
+ return new DrawNothing(shape);
}
throw new IllegalArgumentException("Unsupported shape type: "+shape.getClass());
}
- public <T extends Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>> DrawSlide<T> getDrawable(T sheet) {
- return new DrawSlide<T>(sheet);
+ public DrawSlide getDrawable(Slide<?,?> sheet) {
+ return new DrawSlide(sheet);
}
- public <T extends Sheet<? extends Shape, ? extends SlideShow>> DrawSheet<T> getDrawable(T sheet) {
- return new DrawSheet<T>(sheet);
+ public DrawSheet getDrawable(Sheet<?,?> sheet) {
+ return new DrawSheet(sheet);
}
- public <T extends MasterSheet<? extends Shape, ? extends SlideShow>> DrawMasterSheet<T> getDrawable(T sheet) {
- return new DrawMasterSheet<T>(sheet);
+ public DrawMasterSheet getDrawable(MasterSheet<?,?> sheet) {
+ return new DrawMasterSheet(sheet);
}
- public <T extends TextBox<? extends TextParagraph<?>>> DrawTextBox<T> getDrawable(T shape) {
- return new DrawTextBox<T>(shape);
+ public DrawTextBox getDrawable(TextBox<?,?> shape) {
+ return new DrawTextBox(shape);
}
- public <T extends FreeformShape<? extends TextParagraph<? extends TextRun>>> DrawFreeformShape<T> getDrawable(T shape) {
- return new DrawFreeformShape<T>(shape);
+ public DrawFreeformShape getDrawable(FreeformShape<?,?> shape) {
+ return new DrawFreeformShape(shape);
}
- public <T extends ConnectorShape> DrawConnectorShape<T> getDrawable(T shape) {
- return new DrawConnectorShape<T>(shape);
+ public DrawConnectorShape getDrawable(ConnectorShape<?,?> shape) {
+ return new DrawConnectorShape(shape);
}
- public <T extends TableShape> DrawTableShape<T> getDrawable(T shape) {
- return new DrawTableShape<T>(shape);
+ public DrawTableShape getDrawable(TableShape<?,?> shape) {
+ return new DrawTableShape(shape);
}
- public <T extends TextShape<? extends TextParagraph<? extends TextRun>>> DrawTextShape<T> getDrawable(T shape) {
- return new DrawTextShape<T>(shape);
+ public DrawTextShape getDrawable(TextShape<?,?> shape) {
+ return new DrawTextShape(shape);
}
- public <T extends GroupShape<? extends Shape>> DrawGroupShape<T> getDrawable(T shape) {
- return new DrawGroupShape<T>(shape);
+ public DrawGroupShape getDrawable(GroupShape<?,?> shape) {
+ return new DrawGroupShape(shape);
}
- public <T extends PictureShape> DrawPictureShape<T> getDrawable(T shape) {
- return new DrawPictureShape<T>(shape);
+ public DrawPictureShape getDrawable(PictureShape<?,?> shape) {
+ return new DrawPictureShape(shape);
}
- public <T extends TextRun> DrawTextParagraph<T> getDrawable(TextParagraph<T> paragraph) {
- return new DrawTextParagraph<T>(paragraph);
+ public DrawTextParagraph getDrawable(TextParagraph<?,?,?> paragraph) {
+ return new DrawTextParagraph(paragraph);
}
- public <T extends Background> DrawBackground<T> getDrawable(T shape) {
- return new DrawBackground<T>(shape);
+ public DrawBackground getDrawable(Background<?,?> shape) {
+ return new DrawBackground(shape);
}
public DrawTextFragment getTextFragment(TextLayout layout, AttributedString str) {
return new DrawTextFragment(layout, str);
}
- public DrawPaint getPaint(PlaceableShape shape) {
+ public DrawPaint getPaint(PlaceableShape<?,?> shape) {
return new DrawPaint(shape);
}
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawFreeformShape.java b/src/java/org/apache/poi/sl/draw/DrawFreeformShape.java
index 1c3d6c07b4..ee3bebb1c2 100644
--- a/src/java/org/apache/poi/sl/draw/DrawFreeformShape.java
+++ b/src/java/org/apache/poi/sl/draw/DrawFreeformShape.java
@@ -27,21 +27,24 @@ import org.apache.poi.sl.draw.geom.Path;
import org.apache.poi.sl.usermodel.FillStyle;
import org.apache.poi.sl.usermodel.FreeformShape;
import org.apache.poi.sl.usermodel.StrokeStyle;
-import org.apache.poi.sl.usermodel.TextParagraph;
-import org.apache.poi.sl.usermodel.TextRun;
-public class DrawFreeformShape<T extends FreeformShape<? extends TextParagraph<? extends TextRun>>> extends DrawAutoShape<T> {
- public DrawFreeformShape(T shape) {
+public class DrawFreeformShape extends DrawAutoShape {
+ public DrawFreeformShape(FreeformShape<?,?> shape) {
super(shape);
}
protected Collection<Outline> computeOutlines(Graphics2D graphics) {
List<Outline> lst = new ArrayList<Outline>();
- java.awt.Shape sh = shape.getPath();
- FillStyle fs = shape.getFillStyle();
- StrokeStyle ss = shape.getStrokeStyle();
+ java.awt.Shape sh = getShape().getPath();
+ FillStyle fs = getShape().getFillStyle();
+ StrokeStyle ss = getShape().getStrokeStyle();
Path path = new Path(fs != null, ss != null);
lst.add(new Outline(sh, path));
return lst;
}
+
+ @Override
+ protected FreeformShape<?,?> getShape() {
+ return (FreeformShape<?,?>)shape;
+ }
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawGroupShape.java b/src/java/org/apache/poi/sl/draw/DrawGroupShape.java
index 60af5f710e..999e34c546 100644
--- a/src/java/org/apache/poi/sl/draw/DrawGroupShape.java
+++ b/src/java/org/apache/poi/sl/draw/DrawGroupShape.java
@@ -24,18 +24,18 @@ import java.awt.geom.Rectangle2D;
import org.apache.poi.sl.usermodel.*;
-public class DrawGroupShape<T extends GroupShape<? extends Shape>> extends DrawShape<T> implements Drawable {
+public class DrawGroupShape extends DrawShape {
- public DrawGroupShape(T shape) {
+ public DrawGroupShape(GroupShape<?,?> shape) {
super(shape);
}
public void draw(Graphics2D graphics) {
// the coordinate system of this group of shape
- Rectangle2D interior = shape.getInteriorAnchor();
+ Rectangle2D interior = getShape().getInteriorAnchor();
// anchor of this group relative to the parent shape
- Rectangle2D exterior = shape.getAnchor();
+ Rectangle2D exterior = getShape().getAnchor();
AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
AffineTransform tx0 = new AffineTransform(tx);
@@ -50,7 +50,7 @@ public class DrawGroupShape<T extends GroupShape<? extends Shape>> extends DrawS
DrawFactory drawFact = DrawFactory.getInstance(graphics);
AffineTransform at2 = graphics.getTransform();
- for (Shape child : shape) {
+ for (Shape<?,?> child : getShape()) {
// remember the initial transform and restore it after we are done with the drawing
AffineTransform at = graphics.getTransform();
graphics.setRenderingHint(Drawable.GSAVE, true);
@@ -67,4 +67,9 @@ public class DrawGroupShape<T extends GroupShape<? extends Shape>> extends DrawS
graphics.setTransform(at2);
graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, tx0);
}
+
+ @Override
+ protected GroupShape<?,?> getShape() {
+ return (GroupShape<?,?>)shape;
+ }
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java b/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java
index 6b5d0781df..76ae92de70 100644
--- a/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java
+++ b/src/java/org/apache/poi/sl/draw/DrawMasterSheet.java
@@ -20,9 +20,9 @@ package org.apache.poi.sl.draw;
import org.apache.poi.sl.usermodel.*;
-public class DrawMasterSheet<T extends MasterSheet<? extends Shape, ? extends SlideShow>> extends DrawSheet<T> {
+public class DrawMasterSheet extends DrawSheet {
- public DrawMasterSheet(T sheet) {
+ public DrawMasterSheet(MasterSheet<?,?> sheet) {
super(sheet);
}
@@ -32,7 +32,8 @@ public class DrawMasterSheet<T extends MasterSheet<? extends Shape, ? extends Sl
* Subclasses can override it and skip certain shapes from drawings,
* for instance, slide masters and layouts don't display placeholders
*/
- protected boolean canDraw(Shape shape){
- return !(shape instanceof SimpleShape) || !((SimpleShape)shape).isPlaceholder();
+ @Override
+ protected boolean canDraw(Shape<?,?> shape){
+ return !(shape instanceof SimpleShape) || !((SimpleShape<?,?>)shape).isPlaceholder();
}
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawNothing.java b/src/java/org/apache/poi/sl/draw/DrawNothing.java
index eb32888809..d1710b2352 100644
--- a/src/java/org/apache/poi/sl/draw/DrawNothing.java
+++ b/src/java/org/apache/poi/sl/draw/DrawNothing.java
@@ -22,11 +22,11 @@ import java.awt.Graphics2D;
import org.apache.poi.sl.usermodel.Shape;
-public class DrawNothing<T extends Shape> implements Drawable {
+public class DrawNothing implements Drawable {
- protected final T shape;
+ protected final Shape<?,?> shape;
- public DrawNothing(T shape) {
+ public DrawNothing(Shape<?,?> shape) {
this.shape = shape;
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawPaint.java b/src/java/org/apache/poi/sl/draw/DrawPaint.java
index 4309d4ec5d..7aed90811f 100644
--- a/src/java/org/apache/poi/sl/draw/DrawPaint.java
+++ b/src/java/org/apache/poi/sl/draw/DrawPaint.java
@@ -50,9 +50,9 @@ public class DrawPaint {
private final static POILogger LOG = POILogFactory.getLogger(DrawPaint.class);
- protected PlaceableShape shape;
+ protected PlaceableShape<?,?> shape;
- public DrawPaint(PlaceableShape shape) {
+ public DrawPaint(PlaceableShape<?,?> shape) {
this.shape = shape;
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawPictureShape.java b/src/java/org/apache/poi/sl/draw/DrawPictureShape.java
index 3d00b4ec6b..43586f111f 100644
--- a/src/java/org/apache/poi/sl/draw/DrawPictureShape.java
+++ b/src/java/org/apache/poi/sl/draw/DrawPictureShape.java
@@ -26,22 +26,22 @@ import org.apache.poi.sl.usermodel.PictureData;
import org.apache.poi.sl.usermodel.PictureShape;
-public class DrawPictureShape<T extends PictureShape> extends DrawSimpleShape<T> {
- public DrawPictureShape(T shape) {
+public class DrawPictureShape extends DrawSimpleShape {
+ public DrawPictureShape(PictureShape<?,?> shape) {
super(shape);
}
@Override
public void drawContent(Graphics2D graphics) {
- PictureData data = shape.getPictureData();
+ PictureData data = getShape().getPictureData();
if(data == null) return;
ImageRenderer renderer = (ImageRenderer)graphics.getRenderingHint(Drawable.IMAGE_RENDERER);
if (renderer == null) renderer = new ImageRenderer();
- Rectangle2D anchor = getAnchor(graphics, shape);
+ Rectangle2D anchor = getAnchor(graphics, getShape());
- Insets insets = shape.getClipping();
+ Insets insets = getShape().getClipping();
try {
renderer.loadImage(data.getData(), data.getContentType());
@@ -51,4 +51,9 @@ public class DrawPictureShape<T extends PictureShape> extends DrawSimpleShape<T>
throw new RuntimeException(e);
}
}
+
+ @Override
+ protected PictureShape<?,?> getShape() {
+ return (PictureShape<?,?>)shape;
+ }
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawShape.java b/src/java/org/apache/poi/sl/draw/DrawShape.java
index 13ef4292a3..deca5d7a32 100644
--- a/src/java/org/apache/poi/sl/draw/DrawShape.java
+++ b/src/java/org/apache/poi/sl/draw/DrawShape.java
@@ -25,14 +25,14 @@ import org.apache.poi.sl.usermodel.PlaceableShape;
import org.apache.poi.sl.usermodel.Shape;
-public class DrawShape<T extends Shape> implements Drawable {
+public class DrawShape implements Drawable {
- protected final T shape;
-
- public DrawShape(T shape) {
+ protected final Shape<?,?> shape;
+
+ public DrawShape(Shape<?,?> shape) {
this.shape = shape;
}
-
+
/**
* Apply 2-D transforms before drawing this shape. This includes rotation and flipping.
*
@@ -40,8 +40,8 @@ public class DrawShape<T extends Shape> implements Drawable {
*/
public void applyTransform(Graphics2D graphics) {
if (!(shape instanceof PlaceableShape)) return;
-
- PlaceableShape ps = (PlaceableShape)shape;
+
+ PlaceableShape<?,?> ps = (PlaceableShape<?,?>)shape;
AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
if (tx == null) tx = new AffineTransform();
final Rectangle2D anchor = tx.createTransformedShape(ps.getAnchor()).getBounds2D();
@@ -59,12 +59,12 @@ public class DrawShape<T extends Shape> implements Drawable {
int quadrant = (((int)rotation+45)/90)%4;
double scaleX = 1.0, scaleY = 1.0;
-
+
// scale to bounding box (bug #53176)
if (quadrant == 1 || quadrant == 3) {
- // In quadrant 1 and 3, which is basically a shape in a more or less portrait orientation
- // (45-135 degrees and 225-315 degrees), we need to first rotate the shape by a multiple
- // of 90 degrees and then resize the bounding box to its original bbox. After that we can
+ // In quadrant 1 and 3, which is basically a shape in a more or less portrait orientation
+ // (45-135 degrees and 225-315 degrees), we need to first rotate the shape by a multiple
+ // of 90 degrees and then resize the bounding box to its original bbox. After that we can
// rotate the shape to the exact rotation amount.
// It's strange that you'll need to rotate the shape back and forth again, but you can
// think of it, as if you paint the shape on a canvas. First you rotate the canvas, which might
@@ -82,19 +82,19 @@ public class DrawShape<T extends Shape> implements Drawable {
txs.translate(-centerX, -centerY);
txs.concatenate(tx);
}
-
+
txs.translate(centerX, centerY);
txs.rotate(Math.PI/2.);
txs.translate(-centerX, -centerY);
-
+
Rectangle2D anchor2 = txs.createTransformedShape(ps.getAnchor()).getBounds2D();
-
+
scaleX = anchor.getWidth() == 0. ? 1.0 : anchor.getWidth() / anchor2.getWidth();
scaleY = anchor.getHeight() == 0. ? 1.0 : anchor.getHeight() / anchor2.getHeight();
} else {
quadrant = 0;
}
-
+
// transformation is applied reversed ...
graphics.translate(centerX, centerY);
graphics.rotate(Math.toRadians(rotation-quadrant*90.));
@@ -122,13 +122,13 @@ public class DrawShape<T extends Shape> implements Drawable {
public void draw(Graphics2D graphics) {
}
- public void drawContent(Graphics2D context) {
+ public void drawContent(Graphics2D graphics) {
}
- public static Rectangle2D getAnchor(Graphics2D graphics, PlaceableShape shape) {
+ public static Rectangle2D getAnchor(Graphics2D graphics, PlaceableShape<?,?> shape) {
return getAnchor(graphics, shape.getAnchor());
}
-
+
public static Rectangle2D getAnchor(Graphics2D graphics, Rectangle2D anchor) {
if(graphics == null) {
return anchor;
@@ -139,5 +139,9 @@ public class DrawShape<T extends Shape> implements Drawable {
anchor = tx.createTransformedShape(anchor).getBounds2D();
}
return anchor;
- }
+ }
+
+ protected Shape<?,?> getShape() {
+ return shape;
+ }
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawSheet.java b/src/java/org/apache/poi/sl/draw/DrawSheet.java
index e4c7e185e8..dbe82ea6c8 100644
--- a/src/java/org/apache/poi/sl/draw/DrawSheet.java
+++ b/src/java/org/apache/poi/sl/draw/DrawSheet.java
@@ -26,11 +26,11 @@ import java.awt.geom.AffineTransform;
import org.apache.poi.sl.usermodel.*;
-public class DrawSheet<T extends Sheet<? extends Shape, ? extends SlideShow>> implements Drawable {
+public class DrawSheet implements Drawable {
- protected final T sheet;
+ protected final Sheet<?,?> sheet;
- public DrawSheet(T sheet) {
+ public DrawSheet(Sheet<?,?> sheet) {
this.sheet = sheet;
}
@@ -41,7 +41,7 @@ public class DrawSheet<T extends Sheet<? extends Shape, ? extends SlideShow>> im
graphics.fillRect(0, 0, (int)dim.getWidth(), (int)dim.getHeight());
DrawFactory drawFact = DrawFactory.getInstance(graphics);
- MasterSheet<? extends Shape, ? extends SlideShow> master = sheet.getMasterSheet();
+ MasterSheet<?,?> master = sheet.getMasterSheet();
if(sheet.getFollowMasterGraphics() && master != null) {
Drawable drawer = drawFact.getDrawable(master);
@@ -50,7 +50,7 @@ public class DrawSheet<T extends Sheet<? extends Shape, ? extends SlideShow>> im
graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, new AffineTransform());
- for (Shape shape : sheet.getShapes()) {
+ for (Shape<?,?> shape : sheet.getShapes()) {
if(!canDraw(shape)) continue;
// remember the initial transform and restore it after we are done with drawing
@@ -85,7 +85,7 @@ public class DrawSheet<T extends Sheet<? extends Shape, ? extends SlideShow>> im
* Subclasses can override it and skip certain shapes from drawings,
* for instance, slide masters and layouts don't display placeholders
*/
- protected boolean canDraw(Shape shape){
+ protected boolean canDraw(Shape<?,?> shape){
return true;
}
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java b/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java
index 8ffc57e606..37cd6d8b88 100644
--- a/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java
+++ b/src/java/org/apache/poi/sl/draw/DrawSimpleShape.java
@@ -17,39 +17,60 @@
package org.apache.poi.sl.draw;
-import java.awt.*;
-import java.awt.geom.*;
-import java.io.*;
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Rectangle2D;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
import java.nio.charset.Charset;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
-import javax.xml.bind.*;
-import javax.xml.stream.*;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
import javax.xml.stream.EventFilter;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import org.apache.poi.sl.draw.binding.CTCustomGeometry2D;
-import org.apache.poi.sl.draw.geom.*;
-import org.apache.poi.sl.usermodel.*;
+import org.apache.poi.sl.draw.geom.Context;
+import org.apache.poi.sl.draw.geom.CustomGeometry;
+import org.apache.poi.sl.draw.geom.Outline;
+import org.apache.poi.sl.draw.geom.Path;
+import org.apache.poi.sl.usermodel.LineDecoration;
import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;
import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
-import org.apache.poi.sl.usermodel.StrokeStyle.*;
+import org.apache.poi.sl.usermodel.Shadow;
+import org.apache.poi.sl.usermodel.SimpleShape;
+import org.apache.poi.sl.usermodel.StrokeStyle;
+import org.apache.poi.sl.usermodel.StrokeStyle.LineCap;
+import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
import org.apache.poi.util.Units;
-public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
+public class DrawSimpleShape extends DrawShape {
- public DrawSimpleShape(T shape) {
+ public DrawSimpleShape(SimpleShape<?,?> shape) {
super(shape);
}
@Override
public void draw(Graphics2D graphics) {
- DrawPaint drawPaint = DrawFactory.getInstance(graphics).getPaint(shape);
- Paint fill = drawPaint.getPaint(graphics, shape.getFillStyle().getPaint());
- Paint line = drawPaint.getPaint(graphics, shape.getStrokeStyle().getPaint());
+ DrawPaint drawPaint = DrawFactory.getInstance(graphics).getPaint(getShape());
+ Paint fill = drawPaint.getPaint(graphics, getShape().getFillStyle().getPaint());
+ Paint line = drawPaint.getPaint(graphics, getShape().getStrokeStyle().getPaint());
BasicStroke stroke = getStroke(); // the stroke applies both to the shadow and the shape
graphics.setStroke(stroke);
@@ -94,7 +115,7 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
graphics.setPaint(line);
List<Outline> lst = new ArrayList<Outline>();
- LineDecoration deco = shape.getLineDecoration();
+ LineDecoration deco = getShape().getLineDecoration();
Outline head = getHeadDecoration(graphics, deco, stroke);
if (head != null) lst.add(head);
Outline tail = getTailDecoration(graphics, deco, stroke);
@@ -117,7 +138,7 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
double lineWidth = Math.max(2.5, stroke.getLineWidth());
- Rectangle2D anchor = getAnchor(graphics, shape);
+ Rectangle2D anchor = getAnchor(graphics, getShape());
double x2 = anchor.getX() + anchor.getWidth(),
y2 = anchor.getY() + anchor.getHeight();
@@ -175,7 +196,7 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
double lineWidth = Math.max(2.5, stroke.getLineWidth());
- Rectangle2D anchor = getAnchor(graphics, shape);
+ Rectangle2D anchor = getAnchor(graphics, getShape());
double x1 = anchor.getX(),
y1 = anchor.getY();
@@ -228,7 +249,7 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
}
public BasicStroke getStroke() {
- StrokeStyle strokeStyle = shape.getStrokeStyle();
+ StrokeStyle strokeStyle = getShape().getStrokeStyle();
float lineWidth = (float) strokeStyle.getLineWidth();
if (lineWidth == 0.0f) lineWidth = 0.25f; // Both PowerPoint and OOo draw zero-length lines as 0.25pt
@@ -275,14 +296,14 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
, Paint fill
, Paint line
) {
- Shadow shadow = shape.getShadow();
+ Shadow shadow = getShape().getShadow();
if (shadow == null || (fill == null && line == null)) return;
SolidPaint shadowPaint = shadow.getFillStyle();
Color shadowColor = DrawPaint.applyColorTransform(shadowPaint.getSolidColor());
- double shapeRotation = shape.getRotation();
- if(shape.getFlipVertical()) {
+ double shapeRotation = getShape().getRotation();
+ if(getShape().getFlipVertical()) {
shapeRotation += 180;
}
double angle = shadow.getAngle() - shapeRotation;
@@ -366,12 +387,12 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
protected Collection<Outline> computeOutlines(Graphics2D graphics) {
List<Outline> lst = new ArrayList<Outline>();
- CustomGeometry geom = shape.getGeometry();
+ CustomGeometry geom = getShape().getGeometry();
if(geom == null) {
return lst;
}
- Rectangle2D anchor = getAnchor(graphics, shape);
+ Rectangle2D anchor = getAnchor(graphics, getShape());
for (Path p : geom) {
double w = p.getW() == -1 ? anchor.getWidth() * Units.EMU_PER_POINT : p.getW();
@@ -381,7 +402,7 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
// so we build the path starting from (0,0).
final Rectangle2D pathAnchor = new Rectangle2D.Double(0,0,w,h);
- Context ctx = new Context(geom, pathAnchor, shape);
+ Context ctx = new Context(geom, pathAnchor, getShape());
java.awt.Shape gp = p.getPath(ctx);
@@ -411,4 +432,8 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
return lst;
}
+ @Override
+ protected SimpleShape<?,?> getShape() {
+ return (SimpleShape<?,?>)shape;
+ }
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawSlide.java b/src/java/org/apache/poi/sl/draw/DrawSlide.java
index cfa316738e..ae4baa27fb 100644
--- a/src/java/org/apache/poi/sl/draw/DrawSlide.java
+++ b/src/java/org/apache/poi/sl/draw/DrawSlide.java
@@ -22,14 +22,14 @@ import java.awt.Graphics2D;
import org.apache.poi.sl.usermodel.*;
-public class DrawSlide<T extends Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>> extends DrawSheet<T> {
+public class DrawSlide extends DrawSheet {
- public DrawSlide(T slide) {
+ public DrawSlide(Slide<?,?> slide) {
super(slide);
}
public void draw(Graphics2D graphics) {
- Background bg = sheet.getBackground();
+ Background<?,?> bg = sheet.getBackground();
if(bg != null) {
DrawFactory drawFact = DrawFactory.getInstance(graphics);
Drawable db = drawFact.getDrawable(bg);
diff --git a/src/java/org/apache/poi/sl/draw/DrawTableShape.java b/src/java/org/apache/poi/sl/draw/DrawTableShape.java
index ceb6450d0b..b252ddfda9 100644
--- a/src/java/org/apache/poi/sl/draw/DrawTableShape.java
+++ b/src/java/org/apache/poi/sl/draw/DrawTableShape.java
@@ -17,11 +17,45 @@
package org.apache.poi.sl.draw;
-import org.apache.poi.sl.usermodel.*;
+import java.awt.Graphics2D;
-public class DrawTableShape<T extends TableShape> extends DrawShape<T> {
+import org.apache.poi.sl.usermodel.GroupShape;
+import org.apache.poi.sl.usermodel.TableShape;
+
+public class DrawTableShape extends DrawShape {
// to be implemented ...
- public DrawTableShape(T shape) {
+ public DrawTableShape(TableShape<?,?> shape) {
super(shape);
}
+
+ protected Drawable getDrawable(Graphics2D graphics) {
+ if (shape instanceof GroupShape) {
+ DrawFactory df = DrawFactory.getInstance(graphics);
+ return df.getDrawable((GroupShape<?,?>)shape);
+ }
+ return null;
+ }
+
+ public void applyTransform(Graphics2D graphics) {
+ Drawable d = getDrawable(graphics);
+ if (d != null) {
+ d.applyTransform(graphics);
+ }
+ }
+
+ public void draw(Graphics2D graphics) {
+ Drawable d = getDrawable(graphics);
+ if (d != null) {
+ d.draw(graphics);
+ }
+ }
+
+ public void drawContent(Graphics2D graphics) {
+ Drawable d = getDrawable(graphics);
+ if (d != null) {
+ d.drawContent(graphics);
+ }
+ }
+
+
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawTextBox.java b/src/java/org/apache/poi/sl/draw/DrawTextBox.java
index 89d69223ff..d44d10807e 100644
--- a/src/java/org/apache/poi/sl/draw/DrawTextBox.java
+++ b/src/java/org/apache/poi/sl/draw/DrawTextBox.java
@@ -19,8 +19,8 @@ package org.apache.poi.sl.draw;
import org.apache.poi.sl.usermodel.*;
-public class DrawTextBox<T extends TextBox<? extends TextParagraph<? extends TextRun>>> extends DrawAutoShape<T> {
- public DrawTextBox(T shape) {
+public class DrawTextBox extends DrawAutoShape {
+ public DrawTextBox(TextBox<?,?> shape) {
super(shape);
}
}
diff --git a/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java b/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java
index 1bdd1e829f..8cfa481626 100644
--- a/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java
+++ b/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java
@@ -35,7 +35,6 @@ import org.apache.poi.sl.usermodel.AutoNumberingScheme;
import org.apache.poi.sl.usermodel.Insets2D;
import org.apache.poi.sl.usermodel.PaintStyle;
import org.apache.poi.sl.usermodel.PlaceableShape;
-import org.apache.poi.sl.usermodel.Shape;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.TextParagraph;
import org.apache.poi.sl.usermodel.TextParagraph.BulletStyle;
@@ -45,8 +44,8 @@ import org.apache.poi.sl.usermodel.TextRun.TextCap;
import org.apache.poi.sl.usermodel.TextShape;
import org.apache.poi.util.Units;
-public class DrawTextParagraph<T extends TextRun> implements Drawable {
- protected TextParagraph<T> paragraph;
+public class DrawTextParagraph implements Drawable {
+ protected TextParagraph<?,?,?> paragraph;
double x, y;
protected List<DrawTextFragment> lines = new ArrayList<DrawTextFragment>();
protected String rawText;
@@ -58,7 +57,7 @@ public class DrawTextParagraph<T extends TextRun> implements Drawable {
*/
protected double maxLineHeight;
- public DrawTextParagraph(TextParagraph<T> paragraph) {
+ public DrawTextParagraph(TextParagraph<?,?,?> paragraph) {
this.paragraph = paragraph;
}
@@ -266,7 +265,7 @@ public class DrawTextParagraph<T extends TextRun> implements Drawable {
if (buFont == null) buFont = paragraph.getDefaultFontFamily();
assert(buFont != null);
- PlaceableShape ps = getParagraphShape();
+ PlaceableShape<?,?> ps = getParagraphShape();
PaintStyle fgPaintStyle = bulletStyle.getBulletFontColor();
Paint fgPaint;
if (fgPaintStyle == null) {
@@ -377,7 +376,7 @@ public class DrawTextParagraph<T extends TextRun> implements Drawable {
}
double width;
- TextShape<? extends TextParagraph<T>> ts = paragraph.getParentShape();
+ TextShape<?,?> ts = paragraph.getParentShape();
if (!ts.getWordWrap()) {
// if wordWrap == false then we return the advance to the right border of the sheet
width = ts.getSheet().getSlideShow().getPageSize().getWidth() - anchor.getX();
@@ -413,9 +412,10 @@ public class DrawTextParagraph<T extends TextRun> implements Drawable {
/**
* Helper method for paint style relative to bounds, e.g. gradient paint
*/
- private PlaceableShape getParagraphShape() {
- PlaceableShape ps = new PlaceableShape(){
- public ShapeContainer<? extends Shape> getParent() { return null; }
+ @SuppressWarnings("rawtypes")
+ private PlaceableShape<?,?> getParagraphShape() {
+ PlaceableShape<?,?> ps = new PlaceableShape(){
+ public ShapeContainer<?,?> getParent() { return null; }
public Rectangle2D getAnchor() { return paragraph.getParentShape().getAnchor(); }
public void setAnchor(Rectangle2D anchor) {}
public double getRotation() { return 0; }
@@ -432,7 +432,7 @@ public class DrawTextParagraph<T extends TextRun> implements Drawable {
List<AttributedStringData> attList = new ArrayList<AttributedStringData>();
if (text == null) text = new StringBuilder();
- PlaceableShape ps = getParagraphShape();
+ PlaceableShape<?,?> ps = getParagraphShape();
DrawFontManager fontHandler = (DrawFontManager)graphics.getRenderingHint(Drawable.FONT_HANDLER);
diff --git a/src/java/org/apache/poi/sl/draw/DrawTextShape.java b/src/java/org/apache/poi/sl/draw/DrawTextShape.java
index 36896ba688..b1ec2d9436 100644
--- a/src/java/org/apache/poi/sl/draw/DrawTextShape.java
+++ b/src/java/org/apache/poi/sl/draw/DrawTextShape.java
@@ -27,9 +27,9 @@ import org.apache.poi.sl.usermodel.*;
import org.apache.poi.sl.usermodel.TextParagraph.BulletStyle;
import org.apache.poi.util.JvmBugs;
-public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends TextRun>>> extends DrawSimpleShape<T> {
+public class DrawTextShape extends DrawSimpleShape {
- public DrawTextShape(T shape) {
+ public DrawTextShape(TextShape<?,?> shape) {
super(shape);
}
@@ -37,8 +37,8 @@ public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends
public void drawContent(Graphics2D graphics) {
fixFonts(graphics);
- Rectangle2D anchor = DrawShape.getAnchor(graphics, shape);
- Insets2D insets = shape.getInsets();
+ Rectangle2D anchor = DrawShape.getAnchor(graphics, getShape());
+ Insets2D insets = getShape().getInsets();
double x = anchor.getX() + insets.left;
double y = anchor.getY();
@@ -50,7 +50,7 @@ public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends
// (see DrawShape#applyTransform ), but we need to restore it to avoid painting "upside down".
// See Bugzilla 54210.
- if(shape.getFlipVertical()){
+ if(getShape().getFlipVertical()){
graphics.translate(anchor.getX(), anchor.getY() + anchor.getHeight());
graphics.scale(1, -1);
graphics.translate(-anchor.getX(), -anchor.getY());
@@ -65,7 +65,7 @@ public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends
// Horizontal flipping applies only to shape outline and not to the text in the shape.
// Applying flip second time restores the original not-flipped transform
- if(shape.getFlipHorizontal()){
+ if(getShape().getFlipHorizontal()){
graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
graphics.scale(-1, 1);
graphics.translate(-anchor.getX() , -anchor.getY());
@@ -73,9 +73,9 @@ public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends
// first dry-run to calculate the total height of the text
- double textHeight = shape.getTextHeight();
+ double textHeight = getShape().getTextHeight();
- switch (shape.getVerticalAlignment()){
+ switch (getShape().getVerticalAlignment()){
case TOP:
y += insets.top;
break;
@@ -104,12 +104,12 @@ public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends
DrawFactory fact = DrawFactory.getInstance(graphics);
double y0 = y;
- Iterator<? extends TextParagraph<? extends TextRun>> paragraphs = shape.iterator();
+ Iterator<? extends TextParagraph<?,?,? extends TextRun>> paragraphs = getShape().iterator();
boolean isFirstLine = true;
for (int autoNbrIdx=0; paragraphs.hasNext(); autoNbrIdx++){
- TextParagraph<? extends TextRun> p = paragraphs.next();
- DrawTextParagraph<? extends TextRun> dp = fact.getDrawable(p);
+ TextParagraph<?,?,? extends TextRun> p = paragraphs.next();
+ DrawTextParagraph dp = fact.getDrawable(p);
BulletStyle bs = p.getBulletStyle();
if (bs == null || bs.getAutoNumberingScheme() == null) {
autoNbrIdx = -1;
@@ -180,4 +180,9 @@ public class DrawTextShape<T extends TextShape<? extends TextParagraph<? extends
if (!fontMap.containsKey("Calibri")) fontMap.put("Calibri", "Lucida Sans");
if (!fontMap.containsKey("Cambria")) fontMap.put("Cambria", "Lucida Bright");
}
+
+ @Override
+ protected TextShape<?,?> getShape() {
+ return (TextShape<?,?>)shape;
+ }
}
diff --git a/src/java/org/apache/poi/sl/usermodel/AutoShape.java b/src/java/org/apache/poi/sl/usermodel/AutoShape.java
index 1bf073dfbb..bea0502135 100644
--- a/src/java/org/apache/poi/sl/usermodel/AutoShape.java
+++ b/src/java/org/apache/poi/sl/usermodel/AutoShape.java
@@ -17,5 +17,8 @@
package org.apache.poi.sl.usermodel;
-public interface AutoShape<T extends TextParagraph<? extends TextRun>> extends TextShape<T> {
+public interface AutoShape<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends TextShape<S,P> {
}
diff --git a/src/java/org/apache/poi/sl/usermodel/Background.java b/src/java/org/apache/poi/sl/usermodel/Background.java
index 8d868b8600..879879a209 100644
--- a/src/java/org/apache/poi/sl/usermodel/Background.java
+++ b/src/java/org/apache/poi/sl/usermodel/Background.java
@@ -17,6 +17,9 @@
package org.apache.poi.sl.usermodel;
-public interface Background extends Shape {
+public interface Background<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends Shape<S,P> {
FillStyle getFillStyle();
}
diff --git a/src/java/org/apache/poi/sl/usermodel/ConnectorShape.java b/src/java/org/apache/poi/sl/usermodel/ConnectorShape.java
index 7e2bbf065c..8d356b655a 100644
--- a/src/java/org/apache/poi/sl/usermodel/ConnectorShape.java
+++ b/src/java/org/apache/poi/sl/usermodel/ConnectorShape.java
@@ -17,6 +17,9 @@
package org.apache.poi.sl.usermodel;
-public interface ConnectorShape extends SimpleShape {
+public interface ConnectorShape<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends SimpleShape<S,P> {
}
diff --git a/src/java/org/apache/poi/sl/usermodel/FreeformShape.java b/src/java/org/apache/poi/sl/usermodel/FreeformShape.java
index ec288854a2..19b5d313fc 100644
--- a/src/java/org/apache/poi/sl/usermodel/FreeformShape.java
+++ b/src/java/org/apache/poi/sl/usermodel/FreeformShape.java
@@ -19,7 +19,10 @@ package org.apache.poi.sl.usermodel;
import java.awt.geom.GeneralPath;
-public interface FreeformShape<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> {
+public interface FreeformShape<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends AutoShape<S,P> {
/**
* Gets the shape path.
* <p>
diff --git a/src/java/org/apache/poi/sl/usermodel/GroupShape.java b/src/java/org/apache/poi/sl/usermodel/GroupShape.java
index 8133ac048e..31f5be5345 100644
--- a/src/java/org/apache/poi/sl/usermodel/GroupShape.java
+++ b/src/java/org/apache/poi/sl/usermodel/GroupShape.java
@@ -19,7 +19,10 @@ package org.apache.poi.sl.usermodel;
import java.awt.geom.Rectangle2D;
-public interface GroupShape<T extends Shape> extends Shape, ShapeContainer<T>, PlaceableShape {
+public interface GroupShape<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends Shape<S,P>, ShapeContainer<S,P>, PlaceableShape<S,P> {
/**
* Gets the coordinate space of this group. All children are constrained
diff --git a/src/java/org/apache/poi/sl/usermodel/Line.java b/src/java/org/apache/poi/sl/usermodel/Line.java
index aa42eeab63..d2c2134e52 100644
--- a/src/java/org/apache/poi/sl/usermodel/Line.java
+++ b/src/java/org/apache/poi/sl/usermodel/Line.java
@@ -25,6 +25,9 @@ import org.apache.poi.util.Internal;
*/
@Internal
-public interface Line<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> {
+public interface Line<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends AutoShape<S,P> {
}
diff --git a/src/java/org/apache/poi/sl/usermodel/MasterSheet.java b/src/java/org/apache/poi/sl/usermodel/MasterSheet.java
index 727217d3fa..ac23bc3bba 100644
--- a/src/java/org/apache/poi/sl/usermodel/MasterSheet.java
+++ b/src/java/org/apache/poi/sl/usermodel/MasterSheet.java
@@ -17,6 +17,9 @@
package org.apache.poi.sl.usermodel;
-public interface MasterSheet<T extends Shape, SS extends SlideShow> extends Sheet<T,SS> {
+public interface MasterSheet<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends Sheet<S,P> {
}
diff --git a/src/java/org/apache/poi/sl/usermodel/Notes.java b/src/java/org/apache/poi/sl/usermodel/Notes.java
index 3e4b924721..377ad24c40 100644
--- a/src/java/org/apache/poi/sl/usermodel/Notes.java
+++ b/src/java/org/apache/poi/sl/usermodel/Notes.java
@@ -19,6 +19,9 @@ package org.apache.poi.sl.usermodel;
import java.util.List;
-public interface Notes<T extends Shape, SS extends SlideShow> extends Sheet<T,SS> {
- List<? extends List<? extends TextParagraph<? extends TextRun>>> getTextParagraphs();
+public interface Notes<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends Sheet<S,P> {
+ List<? extends List<P>> getTextParagraphs();
}
diff --git a/src/java/org/apache/poi/sl/usermodel/PictureShape.java b/src/java/org/apache/poi/sl/usermodel/PictureShape.java
index a2c0824e0c..c7fb629410 100644
--- a/src/java/org/apache/poi/sl/usermodel/PictureShape.java
+++ b/src/java/org/apache/poi/sl/usermodel/PictureShape.java
@@ -19,7 +19,10 @@ package org.apache.poi.sl.usermodel;
import java.awt.Insets;
-public interface PictureShape extends SimpleShape {
+public interface PictureShape<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends SimpleShape<S,P> {
/**
* Returns the picture data for this picture.
*
diff --git a/src/java/org/apache/poi/sl/usermodel/PlaceableShape.java b/src/java/org/apache/poi/sl/usermodel/PlaceableShape.java
index f81a344b17..f434b3cc6d 100644
--- a/src/java/org/apache/poi/sl/usermodel/PlaceableShape.java
+++ b/src/java/org/apache/poi/sl/usermodel/PlaceableShape.java
@@ -19,8 +19,11 @@ package org.apache.poi.sl.usermodel;
import java.awt.geom.Rectangle2D;
-public interface PlaceableShape {
- ShapeContainer<? extends Shape> getParent();
+public interface PlaceableShape<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> {
+ ShapeContainer<S,P> getParent();
/**
* @return the position of this shape within the drawing canvas.
diff --git a/src/java/org/apache/poi/sl/usermodel/Shape.java b/src/java/org/apache/poi/sl/usermodel/Shape.java
index 4de645d41f..164c406438 100644
--- a/src/java/org/apache/poi/sl/usermodel/Shape.java
+++ b/src/java/org/apache/poi/sl/usermodel/Shape.java
@@ -18,12 +18,15 @@
package org.apache.poi.sl.usermodel;
-public interface Shape {
- ShapeContainer<? extends Shape> getParent();
+public interface Shape<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> {
+ ShapeContainer<S,P> getParent();
/**
*
* @return the sheet this shape belongs to
*/
- Sheet<? extends Shape, ? extends SlideShow> getSheet();
+ Sheet<S,P> getSheet();
}
diff --git a/src/java/org/apache/poi/sl/usermodel/ShapeContainer.java b/src/java/org/apache/poi/sl/usermodel/ShapeContainer.java
index 0172fa7701..b5c2960986 100644
--- a/src/java/org/apache/poi/sl/usermodel/ShapeContainer.java
+++ b/src/java/org/apache/poi/sl/usermodel/ShapeContainer.java
@@ -20,7 +20,10 @@ package org.apache.poi.sl.usermodel;
import java.util.List;
-public interface ShapeContainer<T extends Shape> extends Iterable<T> {
+public interface ShapeContainer<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends Iterable<S> {
/**
* Returns an list containing all of the elements in this container in proper
* sequence (from first to last element).
@@ -28,9 +31,9 @@ public interface ShapeContainer<T extends Shape> extends Iterable<T> {
* @return an list containing all of the elements in this container in proper
* sequence
*/
- List<T> getShapes();
+ List<S> getShapes();
- void addShape(T shape);
+ void addShape(S shape);
/**
* Removes the specified shape from this sheet, if it is present
@@ -42,5 +45,43 @@ public interface ShapeContainer<T extends Shape> extends Iterable<T> {
* @throws IllegalArgumentException if the type of the specified shape
* is incompatible with this sheet (optional)
*/
- boolean removeShape(T shape);
+ boolean removeShape(S shape);
+
+ /**
+ * create a new shape with a predefined geometry and add it to this shape container
+ */
+ AutoShape<S,P> createAutoShape();
+
+ /**
+ * create a new shape with a custom geometry
+ */
+ FreeformShape<S,P> createFreeform();
+
+ /**
+ * create a text box
+ */
+ TextBox<S,P> createTextBox();
+
+ /**
+ * create a connector
+ */
+ ConnectorShape<S,P> createConnector();
+
+ /**
+ * create a group of shapes belonging to this container
+ */
+ GroupShape<S,P> createGroup();
+
+ /**
+ * create a picture belonging to this container
+ */
+ PictureShape<S,P> createPicture(PictureData pictureData);
+
+ /**
+ * Create a new Table of the given number of rows and columns
+ *
+ * @param numrows the number of rows
+ * @param numcols the number of columns
+ */
+ TableShape<S,P> createTable(int numRows, int numCols);
}
diff --git a/src/java/org/apache/poi/sl/usermodel/Sheet.java b/src/java/org/apache/poi/sl/usermodel/Sheet.java
index f94b7727a7..923dac3781 100644
--- a/src/java/org/apache/poi/sl/usermodel/Sheet.java
+++ b/src/java/org/apache/poi/sl/usermodel/Sheet.java
@@ -23,8 +23,11 @@ import java.awt.Graphics2D;
/**
* Common parent of Slides, Notes and Masters
*/
-public interface Sheet<T extends Shape, SS extends SlideShow> extends ShapeContainer<T> {
- SS getSlideShow();
+public interface Sheet<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends ShapeContainer<S,P> {
+ SlideShow<S,P> getSlideShow();
/**
* @return whether shapes on the master sheet should be shown. By default master graphics is turned off.
@@ -33,9 +36,9 @@ public interface Sheet<T extends Shape, SS extends SlideShow> extends ShapeConta
*/
boolean getFollowMasterGraphics();
- MasterSheet<T,SS> getMasterSheet();
+ MasterSheet<S,P> getMasterSheet();
- Background getBackground();
+ Background<S,P> getBackground();
/**
* Convenience method to draw a sheet to a graphics context
diff --git a/src/java/org/apache/poi/sl/usermodel/SimpleShape.java b/src/java/org/apache/poi/sl/usermodel/SimpleShape.java
index e4e8efe3a1..92612cf956 100644
--- a/src/java/org/apache/poi/sl/usermodel/SimpleShape.java
+++ b/src/java/org/apache/poi/sl/usermodel/SimpleShape.java
@@ -21,7 +21,10 @@ import org.apache.poi.sl.draw.geom.CustomGeometry;
import org.apache.poi.sl.draw.geom.IAdjustableShape;
-public interface SimpleShape extends Shape, IAdjustableShape, PlaceableShape {
+public interface SimpleShape<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends Shape<S,P>, IAdjustableShape, PlaceableShape<S,P> {
FillStyle getFillStyle();
LineDecoration getLineDecoration();
StrokeStyle getStrokeStyle();
diff --git a/src/java/org/apache/poi/sl/usermodel/Slide.java b/src/java/org/apache/poi/sl/usermodel/Slide.java
index b992a5e3c6..237e0229bb 100644
--- a/src/java/org/apache/poi/sl/usermodel/Slide.java
+++ b/src/java/org/apache/poi/sl/usermodel/Slide.java
@@ -17,9 +17,12 @@
package org.apache.poi.sl.usermodel;
-public interface Slide<T extends Shape, SS extends SlideShow, N extends Notes<T,SS>> extends Sheet<T, SS> {
- N getNotes();
- void setNotes(N notes);
+public interface Slide<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends Sheet<S,P> {
+ Notes<S,P> getNotes();
+ void setNotes(Notes<S,P> notes);
boolean getFollowMasterBackground();
void setFollowMasterBackground(boolean follow);
diff --git a/src/java/org/apache/poi/sl/usermodel/SlideShow.java b/src/java/org/apache/poi/sl/usermodel/SlideShow.java
index ac2a7a7d90..2b04327e46 100644
--- a/src/java/org/apache/poi/sl/usermodel/SlideShow.java
+++ b/src/java/org/apache/poi/sl/usermodel/SlideShow.java
@@ -24,18 +24,21 @@ import java.util.List;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
-public interface SlideShow {
- Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>> createSlide() throws IOException;
+public interface SlideShow<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> {
+ Slide<S,P> createSlide() throws IOException;
- List<? extends Slide<? extends Shape, ? extends SlideShow, ? extends Notes<?,?>>> getSlides();
+ List<? extends Slide<S,P>> getSlides();
- MasterSheet<? extends Shape, ? extends SlideShow> createMasterSheet() throws IOException;
+ MasterSheet<S,P> createMasterSheet() throws IOException;
/**
* Returns all slide masters.
* This doesn't include notes master and other arbitrary masters.
*/
- List<? extends MasterSheet<? extends Shape, ? extends SlideShow>> getSlideMasters();
+ List<? extends MasterSheet<S,P>> getSlideMasters();
Resources getResources();
diff --git a/src/java/org/apache/poi/sl/usermodel/TableCell.java b/src/java/org/apache/poi/sl/usermodel/TableCell.java
new file mode 100644
index 0000000000..30cb2da37d
--- /dev/null
+++ b/src/java/org/apache/poi/sl/usermodel/TableCell.java
@@ -0,0 +1,25 @@
+/* ====================================================================
+ 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.sl.usermodel;
+
+public interface TableCell<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends TextShape<S,P> {
+
+}
diff --git a/src/java/org/apache/poi/sl/usermodel/TableShape.java b/src/java/org/apache/poi/sl/usermodel/TableShape.java
index 4fda40f2df..2ac2881d6d 100644
--- a/src/java/org/apache/poi/sl/usermodel/TableShape.java
+++ b/src/java/org/apache/poi/sl/usermodel/TableShape.java
@@ -17,6 +17,9 @@
package org.apache.poi.sl.usermodel;
-public interface TableShape extends Shape, PlaceableShape {
+public interface TableShape<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends Shape<S,P>, PlaceableShape<S,P> {
// to be defined ...
}
diff --git a/src/java/org/apache/poi/sl/usermodel/TextBox.java b/src/java/org/apache/poi/sl/usermodel/TextBox.java
index 3fa3bbe20d..94fd4de40d 100644
--- a/src/java/org/apache/poi/sl/usermodel/TextBox.java
+++ b/src/java/org/apache/poi/sl/usermodel/TextBox.java
@@ -17,5 +17,8 @@
package org.apache.poi.sl.usermodel;
-public interface TextBox<T extends TextParagraph<? extends TextRun>> extends AutoShape<T> {
+public interface TextBox<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends AutoShape<S,P> {
}
diff --git a/src/java/org/apache/poi/sl/usermodel/TextParagraph.java b/src/java/org/apache/poi/sl/usermodel/TextParagraph.java
index 97296bb0bc..00a016058d 100644
--- a/src/java/org/apache/poi/sl/usermodel/TextParagraph.java
+++ b/src/java/org/apache/poi/sl/usermodel/TextParagraph.java
@@ -21,7 +21,11 @@ import java.awt.Color;
-public interface TextParagraph<T extends TextRun> extends Iterable<T> {
+public interface TextParagraph<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,T>,
+ T extends TextRun
+> extends Iterable<T> {
/**
* Specifies a list of text alignment types
@@ -334,5 +338,5 @@ public interface TextParagraph<T extends TextRun> extends Iterable<T> {
Double getDefaultTabSize();
- TextShape<? extends TextParagraph<T>> getParentShape();
+ TextShape<S,P> getParentShape();
}
diff --git a/src/java/org/apache/poi/sl/usermodel/TextShape.java b/src/java/org/apache/poi/sl/usermodel/TextShape.java
index 927fdf1f9d..5f55a1dc40 100644
--- a/src/java/org/apache/poi/sl/usermodel/TextShape.java
+++ b/src/java/org/apache/poi/sl/usermodel/TextShape.java
@@ -17,11 +17,12 @@
package org.apache.poi.sl.usermodel;
-import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import java.util.List;
-
-
-public interface TextShape<T extends TextParagraph<? extends TextRun>> extends SimpleShape, Iterable<T> {
+public interface TextShape<
+ S extends Shape<S,P>,
+ P extends TextParagraph<S,P,? extends TextRun>
+> extends SimpleShape<S,P>, Iterable<P> {
/**
* Vertical Text Types
*/
@@ -87,40 +88,45 @@ public interface TextShape<T extends TextParagraph<? extends TextRun>> extends S
* </p>
*/
SHAPE
- }
+ }
/**
+ * @return the TextParagraphs for this text box
+ */
+ List<? extends TextParagraph<S,P,? extends TextRun>> getTextParagraphs();
+
+ /**
* @return text shape margin
*/
Insets2D getInsets();
-
+
/**
* Compute the cumulative height occupied by the text
*/
double getTextHeight();
-
+
/**
* Returns the type of vertical alignment for the text.
*
* @return the type of vertical alignment
*/
VerticalAlignment getVerticalAlignment();
-
+
/**
* Returns if the text is centered.
* If true and if the individual paragraph settings allow it,
* the whole text block will be displayed centered, i.e. its left and right
* margin will be maximized while still keeping the alignment of the paragraphs
*
- * @return true, if the text anchor is horizontal centered
+ * @return true, if the text anchor is horizontal centered
*/
boolean isHorizontalCentered();
-
+
/**
* @return whether to wrap words within the bounding rectangle
*/
boolean getWordWrap();
-
+
/**
* @return vertical orientation of the text
*/