001 /* 002 Copyright (C) 2002-2003 Renaud Pawlak <renaud@aopsys.com> 003 004 This program is free software; you can redistribute it and/or modify 005 it under the terms of the GNU Lesser General Public License as 006 published by the Free Software Foundation; either version 2 of the 007 License, or (at your option) any later version. 008 009 This program is distributed in the hope that it will be useful, 010 but WITHOUT ANY WARRANTY; without even the implied warranty of 011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 GNU Lesser General Public License for more details. 013 014 You should have received a copy of the GNU Lesser General Public 015 License along with this program; if not, write to the Free Software 016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 017 USA */ 018 019 package org.objectweb.jac.ide; 020 021 import org.objectweb.jac.core.ObjectRepository; 022 import org.objectweb.jac.core.rtti.ClassRepository; 023 import java.util.Collection; 024 025 public class RelationLink extends Link { 026 027 public RelationLink() { 028 startRole = new RelationRole(this); 029 endRole = new RelationRole(this); 030 } 031 032 public RelationRole startRole() { 033 return (RelationRole)startRole; 034 } 035 036 public RelationRole endRole() { 037 return (RelationRole)endRole; 038 } 039 040 public static final int ORIENTATION_BOTH = 0; 041 public static final int ORIENTATION_STRAIGHT = 1; 042 public static final int ORIENTATION_REVERSE = -1; 043 044 int orientation = ORIENTATION_BOTH; 045 046 /** 047 * Get the value of orientation. 048 * @return value of orientation. 049 */ 050 public int getOrientation() { 051 return orientation; 052 } 053 /** 054 * Set the value of orientation. 055 * @param v Value to assign to orientation. 056 */ 057 public void setOrientation(int v) { 058 this.orientation = v; 059 } 060 061 boolean aggregation; 062 /** 063 * Get the value of aggregation. 064 * @return value of aggregation. 065 */ 066 public boolean isAggregation() { 067 return aggregation; 068 } 069 /** 070 * Set the value of aggregation. 071 * @param v Value to assign to aggregation. 072 */ 073 public void setAggregation(boolean v) { 074 this.aggregation = v; 075 } 076 077 boolean calculated; 078 /** 079 * Get the value of aggregation. 080 * @return value of aggregation. 081 */ 082 public boolean isCalculated() { 083 return calculated; 084 } 085 /** 086 * Set the value of aggregation. 087 * @param v Value to assign to aggregation. 088 */ 089 public void setCalculated(boolean v) { 090 this.calculated = v; 091 } 092 093 public static Collection endChoices(Object substance) { 094 return ObjectRepository.getObjects(ClassRepository.get().getClass(Class.class)); 095 } 096 097 /** 098 * Swaps start and end classes. (Does not work well with diagrams) 099 */ 100 public void reverse() { 101 RelationRole start = (RelationRole)startRole; 102 RelationRole end = (RelationRole)endRole; 103 startRole = end; 104 endRole = start; 105 } 106 }