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);
}
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);
}
}
}
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);
}
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();
}
Aggregations