/** * 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"); } }
/** * Creates a deep copy clone. * * @return The deep copy clone. * @throws RuntimeException DOCUMENT ME! */ public Object clone() { LineSymbolizerImpl clone; try { clone = (LineSymbolizerImpl) super.clone(); if (stroke != null && stroke instanceof Cloneable) { clone.stroke = (StrokeImpl) ((Cloneable) stroke).clone(); } } catch (CloneNotSupportedException e) { throw new RuntimeException(e); // this should never happen. } return clone; }
/** * Creates a deep copy clone. TODO: Need to complete the deep copy, currently only shallow copy. * * @return The deep copy clone. * @throws RuntimeException DOCUMENT ME! */ public Object clone() { PolygonSymbolizerImpl clone; try { clone = (PolygonSymbolizerImpl) super.clone(); if (fill != null) { clone.fill = (Fill) ((Cloneable) fill).clone(); } if (stroke != null) { clone.stroke = (StrokeImpl) ((Cloneable) stroke).clone(); } } catch (CloneNotSupportedException e) { throw new RuntimeException(e); // this should never happen. } return clone; }
/** * Returns a clone of the FillImpl. * * @see org.geotools.styling.Fill#clone() */ public Object clone() { try { FillImpl clone = (FillImpl) super.clone(); if (graphicFill != null) { clone.graphicFill = (Graphic) ((Cloneable) graphicFill).clone(); } return clone; } catch (CloneNotSupportedException e) { // This will never happen throw new RuntimeException("Failed to clone FillImpl"); } }
/** * Creates a deep copy clone. * * @return The deep copy clone. * @throws RuntimeException DOCUMENT ME! */ public Object clone() { PointSymbolizerImpl clone; try { clone = (PointSymbolizerImpl) super.clone(); if (graphic != null) clone.graphic = (GraphicImpl) ((Cloneable) graphic).clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); // this should never happen. } return clone; }
/** * Creates a deep copy of the Mark. * * <p>Only the fill and stroke are cloned since Expressions should be immutable. * * @see org.geotools.styling.Mark#clone() */ public Object clone() { try { MarkImpl clone = (MarkImpl) super.clone(); if (fill != null) { clone.fill = (FillImpl) ((Cloneable) fill).clone(); } if (stroke != null && stroke instanceof Cloneable) { clone.stroke = (StrokeImpl) ((Cloneable) stroke).clone(); } return clone; } catch (CloneNotSupportedException e) { // this will never happen throw new RuntimeException("Failed to clone MarkImpl"); } }
/** * Clone the StrokeImpl object. * * <p>The clone is a deep copy of the original, except for the expression values which are * immutable. * * @see org.geotools.styling.Stroke#clone() */ public Object clone() { try { StrokeImpl clone = (StrokeImpl) super.clone(); if (dashArray != null) { clone.setDashArray((new ArrayList<Expression>(dashArray))); } if (fillGraphic != null && fillGraphic instanceof Cloneable) { clone.fillGraphic = (GraphicImpl) ((Cloneable) fillGraphic).clone(); } if (strokeGraphic != null && fillGraphic instanceof Cloneable) { clone.strokeGraphic = (GraphicImpl) ((Cloneable) strokeGraphic).clone(); } return clone; } catch (CloneNotSupportedException e) { // This will never happen throw new RuntimeException("Failed to clone StrokeImpl"); } }
/** * Clones the Style. Creates deep copy clone of the style. * * @return the Clone of the style. * @throws RuntimeException DOCUMENT ME! * @see org.geotools.styling.Style#clone() */ public Object clone() { Style clone; try { clone = (Style) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException(e); // this should never happen since we implement Cloneable } FeatureTypeStyle[] ftsArray = new FeatureTypeStyle[featureTypeStyles.size()]; for (int i = 0; i < ftsArray.length; i++) { FeatureTypeStyle fts = (FeatureTypeStyle) featureTypeStyles.get(i); ftsArray[i] = (FeatureTypeStyle) ((Cloneable) fts).clone(); } clone.setFeatureTypeStyles(ftsArray); return clone; }
/** * Creates a deep copy clone of the FeatureTypeStyle. * * @see org.geotools.styling.FeatureTypeStyle#clone() */ public Object clone() { FeatureTypeStyleImpl clone; try { clone = (FeatureTypeStyleImpl) super.clone(); } catch (final CloneNotSupportedException e) { throw new AssertionError(e); // this should never happen. } final List<Rule> rulesCopy = new ArrayList<Rule>(); for (final Rule rl : rules) { rulesCopy.add((Rule) ((Cloneable) rl).clone()); } clone.rules = new ArrayList<Rule>(); clone.featureTypeNames = new LinkedHashSet<Name>(); clone.semantics = new LinkedHashSet<SemanticType>(); final List<Rule> cloneRules = (List<Rule>) clone.rules(); cloneRules.addAll(rulesCopy); clone.featureTypeNames().addAll(featureTypeNames); clone.semanticTypeIdentifiers().addAll(semantics); return clone; }
return ((org.opengis.util.Cloneable) object).clone();
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); }
/** * 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 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); }