Home | History | Annotate | Download | only in graphviz
      1 /**
      2  * Copyright (C) 2008 Google Inc.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.google.inject.grapher.graphviz;
     18 
     19 import com.google.common.collect.ImmutableList;
     20 import com.google.common.collect.ImmutableMap;
     21 import com.google.common.collect.Maps;
     22 import com.google.inject.grapher.NodeId;
     23 
     24 import java.util.List;
     25 import java.util.Map;
     26 
     27 /**
     28  * Data object to encapsulate the attributes of Graphviz nodes that we're
     29  * interested in drawing.
     30  *
     31  * @author phopkins (at) gmail.com (Pete Hopkins)
     32  */
     33 public class GraphvizNode {
     34   private final NodeId nodeId;
     35 
     36   private NodeStyle style = NodeStyle.SOLID;
     37   private NodeShape shape = NodeShape.BOX;
     38 
     39   private String title = "";
     40   private Map<Integer, String> subtitles = Maps.newTreeMap();
     41 
     42   private String headerTextColor = "#000000";
     43   private String headerBackgroundColor = "#ffffff";
     44 
     45   private String identifier;
     46 
     47   /** {@link Map} from port ID to field title */
     48   private Map<String, String> fields = Maps.newLinkedHashMap();
     49 
     50   /** @since 4.0 */
     51   public GraphvizNode(NodeId nodeId) {
     52     this.nodeId = nodeId;
     53   }
     54 
     55   /** @since 4.0 */
     56   public NodeId getNodeId() {
     57     return nodeId;
     58   }
     59 
     60   public NodeShape getShape() {
     61     return shape;
     62   }
     63 
     64   public void setShape(NodeShape shape) {
     65     this.shape = shape;
     66   }
     67 
     68   public NodeStyle getStyle() {
     69     return style;
     70   }
     71 
     72   public void setStyle(NodeStyle style) {
     73     this.style = style;
     74   }
     75 
     76   public String getTitle() {
     77     return title;
     78   }
     79 
     80   public void setTitle(String title) {
     81     this.title = title;
     82   }
     83 
     84   public List<String> getSubtitles() {
     85     return ImmutableList.copyOf(subtitles.values());
     86   }
     87 
     88   public void addSubtitle(int position, String subtitle) {
     89     this.subtitles.put(position, subtitle);
     90   }
     91 
     92   public String getHeaderTextColor() {
     93     return headerTextColor;
     94   }
     95 
     96   public void setHeaderTextColor(String headerTextColor) {
     97     this.headerTextColor = headerTextColor;
     98   }
     99 
    100   public String getHeaderBackgroundColor() {
    101     return headerBackgroundColor;
    102   }
    103 
    104   public void setHeaderBackgroundColor(String headerBackgroundColor) {
    105     this.headerBackgroundColor = headerBackgroundColor;
    106   }
    107 
    108   public void addField(String portId, String title) {
    109     fields.put(portId, title);
    110   }
    111 
    112   public Map<String, String> getFields() {
    113     return ImmutableMap.copyOf(fields);
    114   }
    115 
    116   /** @since 4.0 */
    117   public String getIdentifier() {
    118     return identifier;
    119   }
    120 
    121   /** @since 4.0 */
    122   public void setIdentifier(String identifier) {
    123     this.identifier = identifier;
    124   }
    125 }
    126