/** Rescale a list of expressions, can handle null. */ protected List<Expression> rescale(List<Expression> expressions) { if (expressions == null || expressions.isEmpty()) { return expressions; } List<Expression> rescaled = new ArrayList<>(expressions.size()); for (Expression expression : expressions) { rescaled.add(rescale(expression)); } return rescaled; }
font.setSize(rescale(font.getSize())); Displacement disp = pointPlacement.getDisplacement(); if (disp != null) { disp.setDisplacementX(rescale(disp.getDisplacementX())); disp.setDisplacementY(rescale(disp.getDisplacementY())); pointPlacement.setDisplacement(disp); linePlacement.setGap(rescale(linePlacement.getGap())); linePlacement.setInitialGap(rescale(linePlacement.getInitialGap())); linePlacement.setPerpendicularOffset( rescale(linePlacement.getPerpendicularOffset())); copy.getHalo().setRadius(rescale(copy.getHalo().getRadius()));
/** * Increase stroke width. * * <p>Based on feedback we may need to change the dash array as well. * * <p> */ public void visit(org.geotools.styling.Stroke stroke) { Stroke copy = sf.getDefaultStroke(); copy.setColor(copy(stroke.getColor())); copy.setDashArray(rescaleDashArray(stroke.dashArray())); copy.setDashOffset(rescale(stroke.getDashOffset())); copy.setGraphicFill(copy(stroke.getGraphicFill())); copy.setGraphicStroke(copy(stroke.getGraphicStroke())); copy.setLineCap(copy(stroke.getLineCap())); copy.setLineJoin(copy(stroke.getLineJoin())); copy.setOpacity(copy(stroke.getOpacity())); copy.setWidth(rescale(stroke.getWidth())); pages.push(copy); }
font.setSize(rescale(font.getSize())); Displacement disp = pointPlacement.getDisplacement(); if (disp != null) { disp.setDisplacementX(rescale(disp.getDisplacementX())); disp.setDisplacementY(rescale(disp.getDisplacementY())); pointPlacement.setDisplacement(disp); linePlacement.setGap(rescale(linePlacement.getGap())); linePlacement.setInitialGap(rescale(linePlacement.getInitialGap())); linePlacement.setPerpendicularOffset(rescale(linePlacement.getPerpendicularOffset())); copy.getHalo().setRadius(rescale(copy.getHalo().getRadius()));
protected Expression rescaleGraphicSize(Graphic gr) { return rescale(gr.getSize()); }
/** * Rescale using listMultiply, if there is only one entry. * * @param expressions * @return */ protected List<Expression> rescaleDashArray(List<Expression> expressions) { if (expressions == null || expressions.isEmpty()) { return expressions; } Expression rescaleToExpression = rescale(ff.literal(1)); // How to test, if it is a measure with a unit or not? String data = ((Literal) rescaleToExpression).getValue().toString(); boolean evaluate = rescaleToExpression instanceof Literal && Character.isDigit(data.charAt(data.length() - 1)); List<Expression> rescaled = new ArrayList<>(expressions.size()); for (Expression expression : expressions) { Expression rescale = ff.function("listMultiply", rescaleToExpression, expression); if (expression instanceof Literal && evaluate) { rescaled.add(ff.literal(rescale.evaluate(null))); } else { rescaled.add(rescale); } } return rescaled; }
@Override public void visit(LineSymbolizer sym) { this.defaultUnit = sym.getUnitOfMeasure(); try { super.visit(sym); LineSymbolizer copy = (LineSymbolizer) pages.peek(); copy.setPerpendicularOffset(rescale(copy.getPerpendicularOffset())); } finally { this.defaultUnit = null; } }
@Override float[] rescale(float[] values) { if (rescaling) { return super.rescale(values); } else { return values; } }
@Override protected Expression rescale(Expression expr) { if (rescaling) { return super.rescale(expr); } else { return expr; } }
/** * Increase stroke width. * <p> * Based on feedback we may need to change the dash array as well. * <p> */ public void visit(org.geotools.styling.Stroke stroke) { Stroke copy = sf.getDefaultStroke(); copy.setColor( copy(stroke.getColor())); copy.setDashArray( rescale(stroke.getDashArray())); copy.setDashOffset( rescale(stroke.getDashOffset())); copy.setGraphicFill( copy(stroke.getGraphicFill())); copy.setGraphicStroke( copy( stroke.getGraphicStroke())); copy.setLineCap(copy(stroke.getLineCap())); copy.setLineJoin( copy(stroke.getLineJoin())); copy.setOpacity( copy(stroke.getOpacity())); copy.setWidth( rescale(stroke.getWidth())); pages.push(copy); }
Expression sizeCopy = rescale( gr.getSize() );