@Override public void fullRedraw() { setupCanvas(); final StyleLibrary style = context.getStyleLibrary(); CSSClass css = new CSSClass(svgp, POLYS); // TODO: separate fill and line colors? css.setStatement( SVGConstants.CSS_STROKE_WIDTH_PROPERTY, style.getLineWidth(StyleLibrary.POLYGONS)); css.setStatement(SVGConstants.CSS_STROKE_PROPERTY, style.getColor(StyleLibrary.POLYGONS)); css.setStatement(SVGConstants.CSS_FILL_PROPERTY, SVGConstants.CSS_NONE_VALUE); svgp.addCSSClassOrLogError(css); svgp.updateStyleElement(); // draw data for (DBIDIter iditer = rep.iterDBIDs(); iditer.valid(); iditer.advance()) { try { PolygonsObject poly = rep.get(iditer); if (poly == null) { continue; } SVGPath path = new SVGPath(); for (Polygon ppoly : poly.getPolygons()) { Vector first = ppoly.get(0); double[] f = proj.fastProjectDataToRenderSpace(first.getArrayRef()); path.moveTo(f[0], f[1]); for (ArrayListIter<Vector> it = ppoly.iter(); it.valid(); it.advance()) { if (it.getOffset() == 0) { continue; } double[] p = proj.fastProjectDataToRenderSpace(it.get().getArrayRef()); path.drawTo(p[0], p[1]); } // close path. path.drawTo(f[0], f[1]); } Element e = path.makeElement(svgp); SVGUtil.addCSSClass(e, POLYS); layer.appendChild(e); } catch (ObjectNotFoundException e) { // ignore. } } }
/** Adds the required CSS-Classes */ private void addCSSClasses() { // Class for the epsilon-value final StyleLibrary style = context.getStyleLibrary(); if (!svgp.getCSSClassManager().contains(CSS_EPSILON)) { final CSSClass label = new CSSClass(svgp, CSS_EPSILON); label.setStatement( SVGConstants.CSS_FILL_PROPERTY, style.getTextColor(StyleLibrary.AXIS_LABEL)); label.setStatement( SVGConstants.CSS_FONT_FAMILY_PROPERTY, style.getFontFamily(StyleLibrary.AXIS_LABEL)); label.setStatement( SVGConstants.CSS_FONT_SIZE_PROPERTY, style.getTextSize(StyleLibrary.AXIS_LABEL)); svgp.addCSSClassOrLogError(label); } // Class for the epsilon cut line if (!svgp.getCSSClassManager().contains(CSS_LINE)) { final CSSClass lcls = new CSSClass(svgp, CSS_LINE); lcls.setStatement(SVGConstants.CSS_STROKE_PROPERTY, style.getColor(StyleLibrary.PLOT)); lcls.setStatement( SVGConstants.CSS_STROKE_WIDTH_PROPERTY, 0.5 * style.getLineWidth(StyleLibrary.PLOT)); svgp.addCSSClassOrLogError(lcls); } }