All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jcckit.plot.AbstractSymbolFactory Maven / Gradle / Ivy

Go to download

PlantUML is a component that allows to quickly write : * sequence diagram, * use case diagram, * class diagram, * activity diagram, * component diagram, * state diagram * object diagram

The newest version!
/*
 * Copyright 2003-2004, Franz-Josef Elmer, All rights reserved
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details
 * (http://www.gnu.org/copyleft/lesser.html).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package jcckit.plot;

import jcckit.graphic.GraphPoint;
import jcckit.graphic.GraphicAttributes;
import jcckit.graphic.GraphicalElement;
import jcckit.util.ConfigParameters;
import jcckit.util.Factory;

/**
 * Abstract superclass of all {@link SymbolFactory SymbolFactories}.
 * Subclasses have to implement {@link #createPlainSymbol createPlainSymbol()}.
 *
 * @author Franz-Josef Elmer
 */
public abstract class AbstractSymbolFactory implements SymbolFactory {
  /** Size of all symbols. */
  protected final double _size;
  
  /** Attributes of all symbols. */
  protected final GraphicAttributes _attributes;

  /**
   * Creates an instance from the specified configuration parameters.
   * 
   * 
   *     
   * 
   *     
   *     
   * 
   *     
   *     
   * 
Key & Default ValueTypeMandatoryDescription
size = 0.01doublenoSize of the symbol in device-independent units.
attributesConfigParametersnoConfiguration parameters for the attributes of the symbol. * className has to be a class which is an instance of * {@link GraphicAttributes}.
*/ public AbstractSymbolFactory(ConfigParameters config) { _size = config.getDouble(SIZE_KEY, DEFAULT_SIZE); _attributes = (GraphicAttributes) Factory.createOrGet( config.getNode(ATTRIBUTES_KEY), null); } /** * Creates a symbol. * Evaluate hintFromPreviousPoint if it is a {@link AttributesHint}. * Calls {@link #createSymbol(GraphPoint, GraphicAttributes, Hint, Hint)}. * @param point Symbol position. * @param hintFromPreviousPoint Hint from the previous point. * @param hintFromPreviousCurve Hint from the previous curve. */ public Symbol createSymbol(GraphPoint point, Hint hintFromPreviousPoint, Hint hintFromPreviousCurve) { GraphicAttributes attributes = _attributes; Hint hintForNextPoint = hintFromPreviousPoint; if (hintFromPreviousPoint instanceof AttributesHint) { attributes = ((AttributesHint) hintFromPreviousPoint).getAttributes(); hintForNextPoint = ((AttributesHint) hintFromPreviousPoint).getNextHint(); } return createSymbol(point, attributes, hintForNextPoint, hintFromPreviousCurve); } /** * Creates a symbol. * Uses {@link #createPlainSymbol createPlainSymbol()}. * @param point Symbol position. * @param attributes Symbol attributes. * @param hintForNextPoint Hint for the next point. Will be delivered * unchanged in the return Symbol object. * @param hintFromPreviousCurve Hint from the previous curve. * Will be delivered unchanged in the return Symbol object. * Subclasses may override this behavior. */ protected Symbol createSymbol(GraphPoint point, GraphicAttributes attributes, Hint hintForNextPoint, Hint hintFromPreviousCurve) { return new Symbol(createPlainSymbol(point, _size, attributes), hintForNextPoint, hintFromPreviousCurve); } /** * Creates a symbol for the legend at the specified position. * Uses {@link #createPlainSymbol createPlainSymbol()} * @param centerPosition Center position of the symbol. * @param size The size of the symbol. Will be ignored because the value * given in the constructor will be used. */ public GraphicalElement createLegendSymbol(GraphPoint centerPosition, double size) { return createPlainSymbol(centerPosition, _size, _attributes); } /** * Creates the graphical element of the plain symbol. * @param centerPosition Center position of the symbol. * @param size The size of the symbol. * @param attributes The attributes of the symbol. */ protected abstract GraphicalElement createPlainSymbol( GraphPoint centerPosition, double size, GraphicAttributes attributes); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy