NamedSymbol implements Symbol { public static NamedSymbol getSymbol(String name) { return symbols.get(name.toLowerCase()); } NamedSymbol(String name, Symbol symbol); static NamedSymbol getSymbol(String name); String getName(); Symbol getSymbol(); @Override boolean isHitBy(double x, double y); @Override Rectangle2D getBounds(); @Override void draw(Rendering rendering, FigureStyle style); @Override String toString(); final static NamedSymbol PLUS; final static NamedSymbol CROSS; final static NamedSymbol STAR; final static NamedSymbol SQUARE; final static NamedSymbol CIRCLE; final static NamedSymbol PIN; }
@Test public void testNames() throws Exception { assertSame(NamedSymbol.CROSS, NamedSymbol.getSymbol("cross")); assertSame(NamedSymbol.CROSS, NamedSymbol.getSymbol("Cross")); assertSame(NamedSymbol.PLUS, NamedSymbol.getSymbol("plus")); assertSame(NamedSymbol.PLUS, NamedSymbol.getSymbol("PLUS")); assertSame(NamedSymbol.STAR, NamedSymbol.getSymbol("STAR")); assertSame(NamedSymbol.STAR, NamedSymbol.getSymbol("star")); assertSame(NamedSymbol.PIN, NamedSymbol.getSymbol("PIN")); assertSame(NamedSymbol.PIN, NamedSymbol.getSymbol("Pin")); assertSame(NamedSymbol.SQUARE, NamedSymbol.getSymbol("square")); assertSame(NamedSymbol.SQUARE, NamedSymbol.getSymbol("Square")); assertSame(NamedSymbol.CIRCLE, NamedSymbol.getSymbol("circle")); assertSame(NamedSymbol.CIRCLE, NamedSymbol.getSymbol("CIRCLE")); assertSame(null, NamedSymbol.getSymbol("Unknown")); }