001 /* EVolve - an Extensible Software Visualization Framework 002 * Copyright (C) 2001-2002 Qin Wang 003 * 004 * This library is free software; you can redistribute it and/or 005 * modify it under the terms of the GNU Library General Public 006 * License as published by the Free Software Foundation; either 007 * version 2 of the License, or (at your option) any later version. 008 * 009 * This library 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 GNU 012 * Library General Public License for more details. 013 * 014 * You should have received a copy of the GNU Library General Public 015 * License along with this library; if not, write to the 016 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 017 * Boston, MA 02111-1307, USA. 018 */ 019 020 /* 021 * EVolve is distributed at http://www.sable.mcgill.ca/EVolve/ 022 */ 023 024 package EVolve.data; 025 026 import EVolve.*; 027 import java.awt.*; 028 029 public class Selection { 030 private String name; 031 private int entityType; 032 private Entity[] selected; 033 private int start, end; 034 private ReferenceLink[] link; 035 private Color color; 036 private static int total = 0; 037 // following two variable are only useful when the time is measured by invocation/allocations 038 private int startEvent = -1, endEvent = -1; 039 040 public Selection(int entityType, int[] selected, int start, int end) { 041 this.entityType = entityType; 042 this.selected = new Entity[selected.length]; 043 for (int i = 0; i < selected.length; i++) { 044 this.selected[i] = Scene.getDataManager().getEntity()[entityType][selected[i]]; 045 } 046 this.start = start; 047 this.end = end; 048 this.color = null; 049 this.link = new ReferenceLink[0]; 050 051 this.name = "Selection" + total; 052 total++; 053 } 054 055 public void setName(String name) { 056 this.name = name; 057 } 058 059 public String getName() { 060 return name; 061 } 062 063 public void setColor(Color color) { 064 this.color = color; 065 } 066 067 public Color getColor() { 068 return color; 069 } 070 071 public void setLink(ReferenceLink[] link) { 072 this.link = link; 073 } 074 075 public ReferenceLink[] getLink() { 076 return link; 077 } 078 079 public int getEntityType() { 080 return entityType; 081 } 082 083 public Entity[] getSelected() { 084 return selected; 085 } 086 087 public void setSelected(Entity[] selected) { 088 this.selected = selected; 089 } 090 091 public int getStart() { 092 return start; 093 } 094 095 public int getEnd() { 096 return end; 097 } 098 099 public int getStartEvent() { 100 return startEvent; 101 } 102 103 public int getEndEvent() { 104 return endEvent; 105 } 106 107 public void setStartEvent(int start) { 108 startEvent = start; 109 } 110 111 public void setEndEvent(int end) { 112 endEvent = end; 113 } 114 115 public Selection specialClone() { 116 int ids[] = new int[selected.length]; 117 118 for (int i=0; i<ids.length; i++) { 119 ids[i] = selected[i].getId(); 120 } 121 122 Selection returnVal = new Selection(entityType,ids,0,Integer.MAX_VALUE); 123 returnVal.setColor(color); 124 returnVal.setName(name); 125 returnVal.setLink(link); 126 127 return returnVal; 128 } 129 }