Search in sources :

Example 1 with Rectangle

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);
}
Also used : Rectangle(com.google.code.appengine.awt.Rectangle) AutoShape(org.apache.poi.hslf.model.AutoShape)

Example 2 with Rectangle

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);
}
Also used : PPGraphics2D(org.apache.poi.hslf.model.PPGraphics2D) ChartRendererJC(org.activityinfo.server.report.renderer.ChartRendererJC) Slide(org.apache.poi.hslf.model.Slide) Rectangle(com.google.code.appengine.awt.Rectangle) Dimension(com.google.code.appengine.awt.Dimension) Point(com.google.code.appengine.awt.Point) ShapeGroup(org.apache.poi.hslf.model.ShapeGroup) PPGraphics2D(org.apache.poi.hslf.model.PPGraphics2D) Graphics2D(com.google.code.appengine.awt.Graphics2D)

Example 3 with Rectangle

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);
    }
}
Also used : PieMapMarker(org.activityinfo.shared.report.content.PieMapMarker) Rectangle(com.google.code.appengine.awt.Rectangle)

Example 4 with Rectangle

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);
    }
}
Also used : Picture(org.apache.poi.hslf.model.Picture) Rectangle(com.google.code.appengine.awt.Rectangle) IconRectCalculator(org.activityinfo.server.report.generator.map.IconRectCalculator) IOException(java.io.IOException) File(java.io.File)

Example 5 with Rectangle

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
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) Picture(org.apache.poi.hslf.model.Picture) Rectangle(com.google.code.appengine.awt.Rectangle) IOException(java.io.IOException) URL(java.net.URL)

Aggregations

Rectangle (com.google.code.appengine.awt.Rectangle)5 IOException (java.io.IOException)2 Picture (org.apache.poi.hslf.model.Picture)2 Dimension (com.google.code.appengine.awt.Dimension)1 Graphics2D (com.google.code.appengine.awt.Graphics2D)1 Point (com.google.code.appengine.awt.Point)1 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 IconRectCalculator (org.activityinfo.server.report.generator.map.IconRectCalculator)1 ChartRendererJC (org.activityinfo.server.report.renderer.ChartRendererJC)1 PieMapMarker (org.activityinfo.shared.report.content.PieMapMarker)1 AutoShape (org.apache.poi.hslf.model.AutoShape)1 PPGraphics2D (org.apache.poi.hslf.model.PPGraphics2D)1 ShapeGroup (org.apache.poi.hslf.model.ShapeGroup)1 Slide (org.apache.poi.hslf.model.Slide)1