| Line | Hits | Source |
|---|---|---|
| 1 | /******************************************************************************* | |
| 2 | * Demetrix process modelling system | |
| 3 | * | |
| 4 | * Copyright (c) 2003, 2004 Dimitri A. Pissarenko | |
| 5 | * | |
| 6 | * This file is part of Demetrix. | |
| 7 | * | |
| 8 | * Demetrix is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2.1 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * Demetrix is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with Demetrix; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | * | |
| 22 | * For further information you may | |
| 23 | * | |
| 24 | * - send an e-mail in Russian, German or English to dimitri.pissarenko@gmx.net | |
| 25 | * - look at http://sourceforge.net/projects/demetrix/ | |
| 26 | * - look at http://demetrix.sourceforge.net/ | |
| 27 | * - look at http://members.inode.at/d.pissarenko/ | |
| 28 | * | |
| 29 | *****************************************************************************/ | |
| 30 | ||
| 31 | package net.sourceforge.demetrix.model; | |
| 32 | ||
| 33 | import java.util.Enumeration; | |
| 34 | ||
| 35 | import java.util.Iterator; | |
| 36 | ||
| 37 | import net.sourceforge.demetrix.properties.BooleanProperty; | |
| 38 | ||
| 39 | import net.sourceforge.demetrix.properties.DemetrixPropertiesHolder; | |
| 40 | ||
| 41 | import net.sourceforge.demetrix.properties.DemetrixPropertiesStorage; | |
| 42 | ||
| 43 | import net.sourceforge.demetrix.properties.DemetrixProperty; | |
| 44 | ||
| 45 | import net.sourceforge.demetrix.properties.StringProperty; | |
| 46 | ||
| 47 | import org._3pq.jgrapht.edge.DirectedEdge; | |
| 48 | import org.apache.log4j.Logger; | |
| 49 | ||
| 50 | /** | |
| 51 | * @author Dimitri Pissarenko | |
| 52 | * | |
| 53 | */ | |
| 54 | ||
| 55 | public class Link extends DirectedEdge implements DemetrixPropertiesHolder { | |
| 56 | private Logger logger=Logger.getLogger(getClass()); | |
| 57 | private DemetrixPropertiesStorage properties; | |
| 58 | ||
| 59 | public Link( | |
| 60 | DemetrixPropertiesHolder sourceVertex, | |
| 61 | DemetrixPropertiesHolder targetVertex) { | |
| 62 | ||
| 63 | 14 | super(sourceVertex, targetVertex); |
| 64 | ||
| 65 | 14 | BooleanProperty showLabelProperty = null; |
| 66 | ||
| 67 | 14 | StringProperty sourceProperty = null; |
| 68 | ||
| 69 | 14 | StringProperty destProperty = null; |
| 70 | ||
| 71 | 14 | StringProperty nameProperty = null; |
| 72 | ||
| 73 | 14 | if (sourceVertex == null) { |
| 74 | 2 | throw new RuntimeException("can not create a link with a null source vertex"); |
| 75 | } | |
| 76 | 12 | if (targetVertex == null) { |
| 77 | 1 | throw new RuntimeException("can not create a link with a null target vertex"); |
| 78 | } | |
| 79 | ||
| 80 | ||
| 81 | ||
| 82 | 11 | this.properties = new DemetrixPropertiesStorage(); |
| 83 | ||
| 84 | /** | |
| 85 | * add SHOW_LABEL_PROPERTY | |
| 86 | */ | |
| 87 | ||
| 88 | 11 | showLabelProperty = new BooleanProperty(); |
| 89 | ||
| 90 | 11 | showLabelProperty.setName(Link.SHOW_LABEL_PROPERTY); |
| 91 | ||
| 92 | 11 | showLabelProperty.setValue(Boolean.FALSE); |
| 93 | ||
| 94 | 11 | this.properties.addProperty(showLabelProperty); |
| 95 | ||
| 96 | /** | |
| 97 | * add SOURCE_PROPERTY | |
| 98 | */ | |
| 99 | ||
| 100 | 11 | sourceProperty = new StringProperty(); |
| 101 | ||
| 102 | 11 | sourceProperty.setName(Link.SOURCE_PROPERTY); |
| 103 | ||
| 104 | 11 | sourceProperty.setReadOnly(true); |
| 105 | ||
| 106 | 11 | nameProperty = (StringProperty) sourceVertex.getProperty("name"); |
| 107 | ||
| 108 | ||
| 109 | 11 | if (nameProperty.getValue() == null) { |
| 110 | ||
| 111 | 2 | throw new RuntimeException("can not create a link with a source, whose \"name\" property is null"); |
| 112 | ||
| 113 | } | |
| 114 | ||
| 115 | 9 | sourceProperty.setValue(nameProperty.getValue()); |
| 116 | ||
| 117 | 9 | this.properties.addProperty(sourceProperty); |
| 118 | ||
| 119 | /** | |
| 120 | * add DESTINATION_PROPERTY | |
| 121 | */ | |
| 122 | ||
| 123 | 9 | destProperty = new StringProperty(); |
| 124 | ||
| 125 | 9 | destProperty.setName(Link.DESTINATION_PROPERTY); |
| 126 | ||
| 127 | 9 | destProperty.setReadOnly(true); |
| 128 | ||
| 129 | 9 | nameProperty = (StringProperty) targetVertex.getProperty("name"); |
| 130 | ||
| 131 | 9 | if (nameProperty.getValue() == null) { |
| 132 | ||
| 133 | 0 | throw new RuntimeException("can not create a link with a target, whose \"name\" property is null"); |
| 134 | ||
| 135 | } | |
| 136 | ||
| 137 | 9 | destProperty.setValue(nameProperty.getValue()); |
| 138 | ||
| 139 | 9 | this.properties.addProperty(destProperty); |
| 140 | ||
| 141 | 9 | } |
| 142 | ||
| 143 | /* (non-Javadoc) | |
| 144 | * @see java.lang.Object#toString() | |
| 145 | */ | |
| 146 | ||
| 147 | public String toString() { | |
| 148 | ||
| 149 | 0 | BooleanProperty showLabelProperty = null; |
| 150 | ||
| 151 | 0 | Boolean value = null; |
| 152 | ||
| 153 | 0 | showLabelProperty = |
| 154 | (BooleanProperty) this.getProperty(Link.SHOW_LABEL_PROPERTY); | |
| 155 | ||
| 156 | 0 | if (showLabelProperty != null) { |
| 157 | ||
| 158 | 0 | value = (Boolean) showLabelProperty.getValue(); |
| 159 | ||
| 160 | 0 | if (value.booleanValue()) { |
| 161 | ||
| 162 | 0 | return super.toString(); |
| 163 | ||
| 164 | } else { | |
| 165 | ||
| 166 | 0 | return ""; |
| 167 | ||
| 168 | } | |
| 169 | ||
| 170 | } else { | |
| 171 | ||
| 172 | 0 | return ""; |
| 173 | ||
| 174 | } | |
| 175 | ||
| 176 | } | |
| 177 | ||
| 178 | public final static String SHOW_LABEL_PROPERTY = "Show label?"; | |
| 179 | ||
| 180 | public final static String SOURCE_PROPERTY = "source"; | |
| 181 | ||
| 182 | public final static String DESTINATION_PROPERTY = "destination"; | |
| 183 | ||
| 184 | /* (non-Javadoc) | |
| 185 | * @see net.sourceforge.demetrix.properties.DemetrixPropertiesHolder#addProperty(net.sourceforge.demetrix.properties.DemetrixProperty) | |
| 186 | */ | |
| 187 | ||
| 188 | public void addProperty(DemetrixProperty property) { | |
| 189 | ||
| 190 | 0 | this.properties.addProperty(property); |
| 191 | ||
| 192 | 0 | } |
| 193 | ||
| 194 | /* (non-Javadoc) | |
| 195 | * @see net.sourceforge.demetrix.properties.DemetrixPropertiesHolder#getAllProperties() | |
| 196 | */ | |
| 197 | ||
| 198 | public Iterator getAllProperties() { | |
| 199 | ||
| 200 | 0 | return this.properties.getAllProperties(); |
| 201 | ||
| 202 | } | |
| 203 | ||
| 204 | /* (non-Javadoc) | |
| 205 | * @see net.sourceforge.demetrix.properties.DemetrixPropertiesHolder#getProperty(java.lang.String) | |
| 206 | */ | |
| 207 | ||
| 208 | public DemetrixProperty getProperty(String name) { | |
| 209 | ||
| 210 | 24 | return this.properties.getProperty(name); |
| 211 | ||
| 212 | } | |
| 213 | ||
| 214 | /* (non-Javadoc) | |
| 215 | * @see net.sourceforge.demetrix.properties.DemetrixPropertiesHolder#getAllPropertyNames() | |
| 216 | */ | |
| 217 | ||
| 218 | public Enumeration getAllPropertyNames() { | |
| 219 | ||
| 220 | 0 | return this.properties.getAllPropertyNames(); |
| 221 | ||
| 222 | } | |
| 223 | ||
| 224 | /* (non-Javadoc) | |
| 225 | * @see net.sourceforge.demetrix.properties.DemetrixPropertiesHolder#getPropertiesStorage() | |
| 226 | */ | |
| 227 | public DemetrixPropertiesHolder getPropertiesStorage() { | |
| 228 | 0 | return this.properties; |
| 229 | } | |
| 230 | ||
| 231 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |