Search in sources :

Example 1 with BasicStroke

use of com.google.code.appengine.awt.BasicStroke in project activityinfo by bedatadriven.

the class ChartRendererJC method computeLineChartProperties.

private AxisChartTypeProperties computeLineChartProperties(PivotChartReportElement element, int dpi) {
    List<PivotTableData.Axis> series = element.getContent().getData().getRootSeries().getLeaves();
    Stroke[] stroke = new Stroke[series.size()];
    Shape[] shape = new Shape[series.size()];
    int si = 0;
    for (PivotTableData.Axis s : series) {
        stroke[si] = new BasicStroke(2f / 72f * dpi);
        shape[si] = new Rectangle2D.Double(0, 0, 4f / 72f * dpi, 4f / 72f * dpi);
        si++;
    }
    return new LineChartProperties(stroke, shape);
}
Also used : BasicStroke(com.google.code.appengine.awt.BasicStroke) LineChartProperties(org.krysalis.jcharts.properties.LineChartProperties) BasicStroke(com.google.code.appengine.awt.BasicStroke) Stroke(com.google.code.appengine.awt.Stroke) ChartStroke(org.krysalis.jcharts.properties.util.ChartStroke) Shape(com.google.code.appengine.awt.Shape) Rectangle2D(com.google.code.appengine.awt.geom.Rectangle2D) Paint(com.google.code.appengine.awt.Paint) PivotTableData(org.activityinfo.shared.report.content.PivotTableData)

Example 2 with BasicStroke

use of com.google.code.appengine.awt.BasicStroke in project activityinfo by bedatadriven.

the class ImageMapRenderer method drawAdminOverlay.

@LogSlow(threshold = 50)
protected void drawAdminOverlay(TiledMap map, Graphics2D g2d, AdminOverlay overlay) {
    List<AdminGeo> geometry = geometryProvider.getGeometries(overlay.getAdminLevelId());
    Color strokeColor = ColorUtil.colorFromString(overlay.getOutlineColor());
    g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    for (AdminGeo adminGeo : geometry) {
        AdminMarker polygon = overlay.getPolygon(adminGeo.getId());
        if (polygon != null) {
            GeneralPath path = PathUtils.toPath(map, adminGeo.getGeometry());
            g2d.setColor(bubbleFillColor(ColorUtil.colorFromString(polygon.getColor())));
            g2d.fill(path);
            g2d.setColor(strokeColor);
            g2d.draw(path);
        }
    }
}
Also used : BasicStroke(com.google.code.appengine.awt.BasicStroke) AdminGeo(org.activityinfo.server.geo.AdminGeo) GeneralPath(com.google.code.appengine.awt.geom.GeneralPath) AdminMarker(org.activityinfo.shared.report.content.AdminMarker) Color(com.google.code.appengine.awt.Color) LogSlow(org.activityinfo.server.util.logging.LogSlow)

Example 3 with BasicStroke

use of com.google.code.appengine.awt.BasicStroke in project activityinfo by bedatadriven.

the class ImageMapRenderer method drawBubble.

public static void drawBubble(Graphics2D g2d, Color colorRgb, int x, int y, int radius) {
    Ellipse2D.Double ellipse = new Ellipse2D.Double(x - radius, y - radius, radius * 2, radius * 2);
    g2d.setPaint(bubbleFillColor(colorRgb));
    g2d.fill(ellipse);
    g2d.setPaint(bubbleFillColor(colorRgb));
    g2d.setStroke(new BasicStroke(1.5f));
    g2d.draw(ellipse);
}
Also used : BasicStroke(com.google.code.appengine.awt.BasicStroke) Ellipse2D(com.google.code.appengine.awt.geom.Ellipse2D)

Example 4 with BasicStroke

use of com.google.code.appengine.awt.BasicStroke in project activityinfo by bedatadriven.

the class AdminTileRenderer method render.

public byte[] render(int zoom, int x, int y) throws IOException {
    Extents extents = TileMath.tileBounds(zoom, x, y);
    mapPixelBounds = new Envelope(0, TileMath.TILE_SIZE, 0, TileMath.TILE_SIZE);
    Envelope envelope = new Envelope(extents.getMinLon(), extents.getMaxLon(), extents.getMinLat(), extents.getMaxLat());
    Geometry filter = gf.toGeometry(envelope);
    LOGGER.info("Creating Buffered Image...");
    BufferedImage image = new BufferedImage(TileMath.TILE_SIZE, TileMath.TILE_SIZE, ColorSpace.TYPE_RGB);
    Graphics2D g2d = image.createGraphics();
    g2d.setPaint(Color.WHITE);
    g2d.fillRect(0, 0, TileMath.TILE_SIZE, TileMath.TILE_SIZE);
    LOGGER.info("Querying geometry...");
    Criteria criteria = session.createCriteria(AdminEntity.class);
    criteria.add(SpatialRestrictions.filter("geometry", filter));
    criteria.add(Restrictions.eq("level", level));
    TiledMap map = new TiledMap(zoom, new Tile(x, y));
    g2d.setColor(Color.BLACK);
    g2d.setStroke(new BasicStroke(1));
    g2d.setFont(new Font("Arial", 0, 10));
    List<AdminEntity> entities = criteria.list();
    /*
         * Project Geometry onto this tile
         */
    LOGGER.info("Projecting geometry...");
    GeometryProjecter projector = new GeometryProjecter(map);
    Map<Integer, Geometry> projected = Maps.newHashMap();
    for (AdminEntity entity : entities) {
        LOGGER.info(entity.getName());
        Geometry transformed = projector.transform(entity.getGeometry());
        Geometry simplified = DouglasPeuckerSimplifier.simplify(transformed, 1.25);
        projected.put(entity.getId(), simplified);
    }
    /*
         * Draw outlines
         */
    LOGGER.info("Drawing geometry...");
    for (AdminEntity entity : entities) {
        Geometry geom = projected.get(entity.getId());
        g2d.draw(toPath(geom));
    }
    /*
         * Draw labels
         */
    LOGGER.info("Drawing geometry...");
    for (AdminEntity entity : entities) {
        Geometry geom = projected.get(entity.getId());
    // Polygon polygon = largestPolygon(geom);
    // 
    // if (polygon != null) {
    // labelPolygon(g2d, polygon, entity.getName());
    // }
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write(image, "png", baos);
    return baos.toByteArray();
}
Also used : BasicStroke(com.google.code.appengine.awt.BasicStroke) AdminEntity(org.activityinfo.server.database.hibernate.entity.AdminEntity) Tile(org.activityinfo.shared.util.mapping.Tile) Criteria(org.hibernate.Criteria) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Extents(org.activityinfo.shared.util.mapping.Extents) Envelope(com.vividsolutions.jts.geom.Envelope) BufferedImage(com.google.code.appengine.awt.image.BufferedImage) Font(com.google.code.appengine.awt.Font) Graphics2D(com.google.code.appengine.awt.Graphics2D) Geometry(com.vividsolutions.jts.geom.Geometry) TiledMap(org.activityinfo.server.report.generator.map.TiledMap)

Aggregations

BasicStroke (com.google.code.appengine.awt.BasicStroke)4 Color (com.google.code.appengine.awt.Color)1 Font (com.google.code.appengine.awt.Font)1 Graphics2D (com.google.code.appengine.awt.Graphics2D)1 Paint (com.google.code.appengine.awt.Paint)1 Shape (com.google.code.appengine.awt.Shape)1 Stroke (com.google.code.appengine.awt.Stroke)1 Ellipse2D (com.google.code.appengine.awt.geom.Ellipse2D)1 GeneralPath (com.google.code.appengine.awt.geom.GeneralPath)1 Rectangle2D (com.google.code.appengine.awt.geom.Rectangle2D)1 BufferedImage (com.google.code.appengine.awt.image.BufferedImage)1 Envelope (com.vividsolutions.jts.geom.Envelope)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 AdminEntity (org.activityinfo.server.database.hibernate.entity.AdminEntity)1 AdminGeo (org.activityinfo.server.geo.AdminGeo)1 TiledMap (org.activityinfo.server.report.generator.map.TiledMap)1 LogSlow (org.activityinfo.server.util.logging.LogSlow)1 AdminMarker (org.activityinfo.shared.report.content.AdminMarker)1 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)1