use of com.google.code.appengine.awt.Rectangle in project activityinfo by bedatadriven.
the class PPTMapRenderer method addBubble.
private void addBubble(Slide slide, int offsetX, int offsetY, BubbleMapMarker marker) {
AutoShape shape = new AutoShape(ShapeTypes.Ellipse);
shape.setAnchor(new Rectangle(offsetX + marker.getX() - marker.getRadius(), offsetY + marker.getY() - marker.getRadius(), marker.getRadius() * 2, marker.getRadius() * 2));
shape.setFillColor(ColorUtil.colorFromString(marker.getColor()));
shape.setEscherProperty(EscherProperties.FILL__FILLOPACITY, 49087);
shape.setLineColor(bubbleStrokeColor(ColorUtil.toInteger(marker.getColor())));
slide.addShape(shape);
}
use of com.google.code.appengine.awt.Rectangle in project activityinfo by bedatadriven.
the class PPTChartRenderer method render.
public void render(PivotChartReportElement element, SlideShow ppt) throws IOException {
// add first slide
Slide slide = ppt.createSlide();
// define position of the drawing in the slide
Dimension pageSize = ppt.getPageSize();
Dimension chartSize = new Dimension((int) (pageSize.getWidth() - 72), (int) (pageSize.getHeight() - 183));
Rectangle bounds = new com.google.code.appengine.awt.Rectangle(new Point(36, 126), chartSize);
ShapeGroup group = new ShapeGroup();
group.setAnchor(bounds);
slide.addShape(group);
Graphics2D graphics = new PPGraphics2D(group);
ChartRendererJC jc = new ChartRendererJC();
jc.render(element, false, graphics, (int) chartSize.getWidth(), (int) chartSize.getHeight(), 72);
}
use of com.google.code.appengine.awt.Rectangle in project activityinfo by bedatadriven.
the class ImageMapRenderer method drawPieMarker.
public static void drawPieMarker(Graphics2D g2d, PieMapMarker marker) {
// Determine the total area
Rectangle area = new Rectangle();
area.setRect(marker.getX() - marker.getRadius(), marker.getY() - marker.getRadius(), marker.getRadius() * 2, marker.getRadius() * 2);
// Get total value of all slices
double total = 0.0D;
for (PieMapMarker.SliceValue slice : marker.getSlices()) {
total += slice.getValue();
}
// Draw each pie slice
double curValue = 0.0D;
int startAngle = 0;
int i = 0;
for (PieMapMarker.SliceValue slice : marker.getSlices()) {
// Compute the start and stop angles
startAngle = (int) (curValue * 360 / total);
int arcAngle = (int) (slice.getValue() * 360 / total);
// and last slice
if (i++ == marker.getSlices().size() - 1) {
arcAngle = 360 - startAngle;
}
// Set the color and draw a filled arc
g2d.setColor(bubbleFillColor(ColorUtil.colorFromString(slice.getColor())));
g2d.fillArc(area.x, area.y, area.width, area.height, startAngle, arcAngle);
curValue += slice.getValue();
}
if (marker.getLabel() != null) {
drawLabel(g2d, marker);
}
}
use of com.google.code.appengine.awt.Rectangle in project activityinfo by bedatadriven.
the class PPTMapRenderer method addIconMarker.
private void addIconMarker(SlideShow ppt, Slide slide, int offsetX, int offsetY, Map<String, Integer> iconPictureIndex, IconMapMarker marker) {
Integer iconIndex = iconPictureIndex.get(marker.getIcon().getName());
if (iconIndex == null) {
try {
iconIndex = ppt.addPicture(new File(getMapIconRoot() + "/" + marker.getIcon().getName() + ".png"), Picture.PNG);
} catch (IOException e) {
iconIndex = -1;
}
iconPictureIndex.put(marker.getIcon().getName(), iconIndex);
}
if (iconIndex != -1) {
IconRectCalculator rectCtor = new IconRectCalculator(marker.getIcon());
Picture icon = new Picture(iconIndex);
org.activityinfo.shared.geom.Rectangle iconRect = rectCtor.iconRect(offsetX + marker.getX(), offsetY + marker.getY());
icon.setAnchor(new Rectangle(iconRect.getX(), iconRect.getY(), iconRect.getWidth(), iconRect.getHeight()));
slide.addShape(icon);
}
}
use of com.google.code.appengine.awt.Rectangle in project activityinfo by bedatadriven.
the class PPTTileHandler method addTile.
@Override
public void addTile(String tileUrl, int x, int y, int width, int height) {
try {
byte[] imageBytes = Resources.toByteArray(new URL(tileUrl));
int pictureIndex = ppt.addPicture(imageBytes, Picture.PNG);
Picture basemap = new Picture(pictureIndex);
basemap.setAnchor(new Rectangle(x, y, width, height));
basemap.setLineWidth(0);
shapeGroup.addShape(basemap);
} catch (MalformedURLException e) {
throw new RuntimeException("Bad tile URL", e);
} catch (IOException e) {
// ignore missing tiles
}
}
Aggregations