1 19 package jcckit.plot; 20 21 import jcckit.graphic.GraphPoint; 22 import jcckit.graphic.GraphicAttributes; 23 import jcckit.graphic.GraphicalElement; 24 import jcckit.util.ConfigParameters; 25 import jcckit.util.Factory; 26 27 33 public abstract class AbstractSymbolFactory implements SymbolFactory { 34 35 protected final double _size; 36 37 38 protected final GraphicAttributes _attributes; 39 40 55 public AbstractSymbolFactory(ConfigParameters config) { 56 _size = config.getDouble(SIZE_KEY, DEFAULT_SIZE); 57 _attributes = (GraphicAttributes) Factory.createOrGet( 58 config.getNode(ATTRIBUTES_KEY), null); 59 } 60 61 69 public Symbol createSymbol(GraphPoint point, Hint hintFromPreviousPoint, 70 Hint hintFromPreviousCurve) { 71 GraphicAttributes attributes = _attributes; 72 Hint hintForNextPoint = hintFromPreviousPoint; 73 if (hintFromPreviousPoint instanceof AttributesHint) { 74 attributes = ((AttributesHint) hintFromPreviousPoint).getAttributes(); 75 hintForNextPoint 76 = ((AttributesHint) hintFromPreviousPoint).getNextHint(); 77 } 78 return createSymbol(point, attributes, hintForNextPoint, 79 hintFromPreviousCurve); 80 } 81 82 93 protected Symbol createSymbol(GraphPoint point, GraphicAttributes attributes, 94 Hint hintForNextPoint, 95 Hint hintFromPreviousCurve) { 96 return new Symbol(createPlainSymbol(point, _size, attributes), 97 hintForNextPoint, hintFromPreviousCurve); 98 } 99 100 107 public GraphicalElement createLegendSymbol(GraphPoint centerPosition, 108 double size) { 109 return createPlainSymbol(centerPosition, _size, _attributes); 110 } 111 112 118 protected abstract GraphicalElement createPlainSymbol( 119 GraphPoint centerPosition, double size, GraphicAttributes attributes); 120 } 121 | Popular Tags |