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 import java.util.List; 24 import java.util.Map; 25 26 /** 27 * Data object to encapsulate the attributes of Graphviz nodes that we're interested in drawing. 28 * 29 * @author phopkins@gmail.com (Pete Hopkins) 30 */ 31 public class GraphvizNode { 32 private final NodeId nodeId; 33 34 private NodeStyle style = NodeStyle.SOLID; 35 private NodeShape shape = NodeShape.BOX; 36 37 private String title = ""; 38 private Map<Integer, String> subtitles = Maps.newTreeMap(); 39 40 private String headerTextColor = "#000000"; 41 private String headerBackgroundColor = "#ffffff"; 42 43 private String identifier; 44 45 /** {@link Map} from port ID to field title */ 46 private Map<String, String> fields = Maps.newLinkedHashMap(); 47 48 /** @since 4.0 */ GraphvizNode(NodeId nodeId)49 public GraphvizNode(NodeId nodeId) { 50 this.nodeId = nodeId; 51 } 52 53 /** @since 4.0 */ getNodeId()54 public NodeId getNodeId() { 55 return nodeId; 56 } 57 getShape()58 public NodeShape getShape() { 59 return shape; 60 } 61 setShape(NodeShape shape)62 public void setShape(NodeShape shape) { 63 this.shape = shape; 64 } 65 getStyle()66 public NodeStyle getStyle() { 67 return style; 68 } 69 setStyle(NodeStyle style)70 public void setStyle(NodeStyle style) { 71 this.style = style; 72 } 73 getTitle()74 public String getTitle() { 75 return title; 76 } 77 setTitle(String title)78 public void setTitle(String title) { 79 this.title = title; 80 } 81 getSubtitles()82 public List<String> getSubtitles() { 83 return ImmutableList.copyOf(subtitles.values()); 84 } 85 addSubtitle(int position, String subtitle)86 public void addSubtitle(int position, String subtitle) { 87 this.subtitles.put(position, subtitle); 88 } 89 getHeaderTextColor()90 public String getHeaderTextColor() { 91 return headerTextColor; 92 } 93 setHeaderTextColor(String headerTextColor)94 public void setHeaderTextColor(String headerTextColor) { 95 this.headerTextColor = headerTextColor; 96 } 97 getHeaderBackgroundColor()98 public String getHeaderBackgroundColor() { 99 return headerBackgroundColor; 100 } 101 setHeaderBackgroundColor(String headerBackgroundColor)102 public void setHeaderBackgroundColor(String headerBackgroundColor) { 103 this.headerBackgroundColor = headerBackgroundColor; 104 } 105 addField(String portId, String title)106 public void addField(String portId, String title) { 107 fields.put(portId, title); 108 } 109 getFields()110 public Map<String, String> getFields() { 111 return ImmutableMap.copyOf(fields); 112 } 113 114 /** @since 4.0 */ getIdentifier()115 public String getIdentifier() { 116 return identifier; 117 } 118 119 /** @since 4.0 */ setIdentifier(String identifier)120 public void setIdentifier(String identifier) { 121 this.identifier = identifier; 122 } 123 } 124