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

com.google.inject.grapher.graphviz.GraphvizNode Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2008 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.inject.grapher.graphviz;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.inject.grapher.NodeId;
import java.util.List;
import java.util.Map;

/**
 * Data object to encapsulate the attributes of Graphviz nodes that we're interested in drawing.
 *
 * @author [email protected] (Pete Hopkins)
 */
public class GraphvizNode {
  private final NodeId nodeId;

  private NodeStyle style = NodeStyle.SOLID;
  private NodeShape shape = NodeShape.BOX;

  private String title = "";
  private Map subtitles = Maps.newTreeMap();

  private String headerTextColor = "#000000";
  private String headerBackgroundColor = "#ffffff";

  private String identifier;

  /** {@link Map} from port ID to field title */
  private Map fields = Maps.newLinkedHashMap();

  /** @since 4.0 */
  public GraphvizNode(NodeId nodeId) {
    this.nodeId = nodeId;
  }

  /** @since 4.0 */
  public NodeId getNodeId() {
    return nodeId;
  }

  public NodeShape getShape() {
    return shape;
  }

  public void setShape(NodeShape shape) {
    this.shape = shape;
  }

  public NodeStyle getStyle() {
    return style;
  }

  public void setStyle(NodeStyle style) {
    this.style = style;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public List getSubtitles() {
    return ImmutableList.copyOf(subtitles.values());
  }

  public void addSubtitle(int position, String subtitle) {
    this.subtitles.put(position, subtitle);
  }

  public String getHeaderTextColor() {
    return headerTextColor;
  }

  public void setHeaderTextColor(String headerTextColor) {
    this.headerTextColor = headerTextColor;
  }

  public String getHeaderBackgroundColor() {
    return headerBackgroundColor;
  }

  public void setHeaderBackgroundColor(String headerBackgroundColor) {
    this.headerBackgroundColor = headerBackgroundColor;
  }

  public void addField(String portId, String title) {
    fields.put(portId, title);
  }

  public Map getFields() {
    return ImmutableMap.copyOf(fields);
  }

  /** @since 4.0 */
  public String getIdentifier() {
    return identifier;
  }

  /** @since 4.0 */
  public void setIdentifier(String identifier) {
    this.identifier = identifier;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy