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