/** * Clones the given grid range if necessary. This is mostly a protection for {@link GridRange2D} * which is mutable, at the opposite of {@link GeneralGridRange} which is immutable. We test for * the {@link GridRange2D} super-class which defines a {@code clone()} method, instead of {@link * GridRange2D} itself, for gaining some generality. */ private static GridEnvelope clone(GridEnvelope gridRange) { if (gridRange instanceof Cloneable) { gridRange = (GridEnvelope) ((Cloneable) gridRange).clone(); } return gridRange; }
public Object clone() { try { PointPlacementImpl clone = (PointPlacementImpl) super.clone(); clone.anchorPoint = (AnchorPointImpl) ((Cloneable) anchorPoint).clone(); clone.displacement = (DisplacementImpl) ((Cloneable) displacement).clone(); return clone; } catch (CloneNotSupportedException e) { throw new RuntimeException("Won't happen"); } }
/** * Creates a deep copy clone of the Halo. * * @return The clone. * @throws RuntimeException DOCUMENT ME! */ public Object clone() { try { HaloImpl clone = (HaloImpl) super.clone(); clone.fill = (FillImpl) ((Cloneable) fill).clone(); return clone; } catch (CloneNotSupportedException e) { throw new RuntimeException("This will never happen"); } }
public void testPointPlacement() { PointPlacement pointPl = styleFactory.getDefaultPointPlacement(); PointPlacement clone = (PointPlacement) ((Cloneable) pointPl).clone(); assertClone(pointPl, clone); PointPlacement other = (PointPlacement) ((Cloneable) pointPl).clone(); other.setRotation(filterFactory.literal(274.0)); assertEqualsContract(clone, other, pointPl); }
public void testExternalGraphic() { ExternalGraphic exGraphic = styleFactory.createExternalGraphic("http://somewhere", "image/png"); ExternalGraphic clone = (ExternalGraphic) ((Cloneable) exGraphic).clone(); assertClone(exGraphic, clone); ExternalGraphic notEq = styleFactory.createExternalGraphic("http://somewhereelse", "image/jpeg"); assertEqualsContract(clone, notEq, exGraphic); // make sure it works for different format, same url ExternalGraphic notEq2 = (ExternalGraphic) ((Cloneable) clone).clone(); notEq2.setFormat("image/jpeg"); assertEqualsContract(clone, notEq2, exGraphic); }
public void testMark() { Mark mark = styleFactory.getCircleMark(); Mark clone = (Mark) ((Cloneable) mark).clone(); assertClone(mark, clone); Mark notEq = styleFactory.getStarMark(); assertEqualsContract(clone, notEq, mark); }
public void testFill() { Fill fill = styleFactory.getDefaultFill(); Fill clone = (Fill) ((Cloneable) fill).clone(); assertClone(fill, clone); Fill notEq = styleFactory.createFill(filterFactory.literal("#FF0000")); assertEqualsContract(clone, notEq, fill); }
public void testPointSymbolizer() throws Exception { PointSymbolizer pointSymb = styleFactory.createPointSymbolizer(); PointSymbolizer clone = (PointSymbolizer) ((Cloneable) pointSymb).clone(); assertClone(pointSymb, clone); PointSymbolizer notEq = styleFactory.getDefaultPointSymbolizer(); notEq.setGeometryPropertyName("something_else"); assertEqualsContract(clone, notEq, pointSymb); }
public void testPolygonSymbolizer() { PolygonSymbolizer polygonSymb = styleFactory.createPolygonSymbolizer(); PolygonSymbolizer clone = (PolygonSymbolizer) ((Cloneable) polygonSymb).clone(); assertClone(polygonSymb, clone); PolygonSymbolizer notEq = styleFactory.getDefaultPolygonSymbolizer(); notEq.setGeometryPropertyName("something_else"); assertEqualsContract(clone, notEq, polygonSymb); }
public void testLineSymbolizer() { LineSymbolizer lineSymb = styleFactory.createLineSymbolizer(); LineSymbolizer clone = (LineSymbolizer) ((Cloneable) lineSymb).clone(); assertClone(lineSymb, clone); LineSymbolizer notEq = styleFactory.getDefaultLineSymbolizer(); notEq.setGeometryPropertyName("something_else"); assertEqualsContract(clone, notEq, lineSymb); }
public void testPointPlacement() { PointPlacement pointPl = sf.getDefaultPointPlacement(); PointPlacement clone = (PointPlacement) visitor.copy(pointPl); assertCopy(pointPl, clone); PointPlacement other = (PointPlacement) ((Cloneable) pointPl).clone(); other.setRotation(ff.literal(274.0)); assertEqualsContract(clone, other, pointPl); }
public void testLinePlacement() throws Exception { LinePlacement linePlacement = styleFactory.createLinePlacement(filterFactory.literal(12)); LinePlacement clone = (LinePlacement) ((Cloneable) linePlacement).clone(); assertClone(linePlacement, clone); LinePlacement other = styleFactory.createLinePlacement(filterFactory.property("NAME")); assertEqualsContract(clone, other, linePlacement); }
public void testFont() { Font font = styleFactory.getDefaultFont(); Font clone = (Font) ((Cloneable) font).clone(); assertClone(font, clone); Font other = styleFactory.createFont( filterFactory.literal("other"), filterFactory.literal("normal"), filterFactory.literal("BOLD"), filterFactory.literal(12)); assertEqualsContract(clone, other, font); }
public void testHalo() { Halo halo = styleFactory.createHalo(styleFactory.getDefaultFill(), filterFactory.literal(10)); Halo clone = (Halo) ((Cloneable) halo).clone(); assertClone(halo, clone); Halo other = styleFactory.createHalo(styleFactory.getDefaultFill(), filterFactory.literal(12)); assertEqualsContract(clone, other, halo); }
public void testDisplacement() { Displacement displacement = styleFactory.createDisplacement(filterFactory.literal(1), filterFactory.literal(2)); Displacement clone = (Displacement) ((Cloneable) displacement).clone(); assertClone(displacement, clone); Displacement other = styleFactory.createDisplacement(filterFactory.literal(3), filterFactory.literal(4)); assertEqualsContract(clone, other, displacement); }
public void testAnchorPoint() { AnchorPoint anchorPoint = styleFactory.createAnchorPoint(filterFactory.literal(1), filterFactory.literal(2)); AnchorPoint clone = (AnchorPoint) ((Cloneable) anchorPoint).clone(); assertClone(anchorPoint, clone); AnchorPoint other = styleFactory.createAnchorPoint(filterFactory.literal(3), filterFactory.literal(4)); assertEqualsContract(clone, other, anchorPoint); }
public void testGraphic() { Graphic graphic = styleFactory.getDefaultGraphic(); graphic.addMark(styleFactory.getDefaultMark()); Graphic clone = (Graphic) ((Cloneable) graphic).clone(); assertClone(graphic, clone); assertEqualsContract(clone, graphic); assertEquals(clone.getSymbols().length, graphic.getSymbols().length); Graphic notEq = styleFactory.getDefaultGraphic(); assertEqualsContract(clone, notEq, graphic); }
public void testStroke() { Stroke stroke = sf.getDefaultStroke(); Stroke clone = visitor.copy(stroke); assertCopy(stroke, clone); Stroke notEq = sf.createStroke(ff.literal("#FF0000"), ff.literal(10)); assertEqualsContract(clone, notEq, stroke); // a stroke is a complex object with lots of properties, // need more extensive tests here. Stroke dashArray = sf.getDefaultStroke(); dashArray.setDashArray(new float[] {1.0f, 2.0f, 3.0f}); Stroke dashArray2 = (Stroke) ((Cloneable) dashArray).clone(); assertEqualsContract(dashArray, dashArray2); }
public void testStyle() throws Exception { FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(); fts.setFeatureTypeName("feature-type-1"); FeatureTypeStyle fts2 = fts2(); Style style = styleFactory.getDefaultStyle(); style.addFeatureTypeStyle(fts); style.addFeatureTypeStyle(fts2); Style clone = (Style) ((Cloneable) style).clone(); assertClone(style, clone); Style notEq = styleFactory.getDefaultStyle(); fts2 = fts2(); notEq.addFeatureTypeStyle(fts2); assertEqualsContract(clone, notEq, style); }
public void testTextSymbolizer() { TextSymbolizer textSymb = styleFactory.createTextSymbolizer(); Expression offset = filterFactory.literal(10); textSymb.setLabelPlacement(styleFactory.createLinePlacement(offset)); TextSymbolizer clone = (TextSymbolizer) ((Cloneable) textSymb).clone(); assertClone(textSymb, clone); TextSymbolizer notEq = styleFactory.getDefaultTextSymbolizer(); Expression ancX = filterFactory.literal(10); Expression ancY = filterFactory.literal(10); AnchorPoint ancPoint = styleFactory.createAnchorPoint(ancX, ancY); LabelPlacement placement = styleFactory.createPointPlacement(ancPoint, null, null); notEq.setLabelPlacement(placement); assertEqualsContract(clone, notEq, textSymb); }