medisyn
Class ProxyGroup

java.lang.Object
  extended by medisyn.ProxyGroup
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<ProxyGroup>

public class ProxyGroup
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable<ProxyGroup>

Represents a group of proxies that somehow belong together (e.g. they share the same type of videos like Sport, Action etc)

Author:
Leo Bosnjak

Nested Class Summary
static class ProxyGroup.GroupSizeComparer
          This class implements a Comparator for ProxyGroups.
static class ProxyGroup.ReverseGroupSizeComparer
          This class implements a Comparator for ProxyGroups.
 
Field Summary
private  java.awt.Color color
           
private  int id
           
private  java.lang.String name
           
private  java.util.Vector<X2XProxy> proxies
           
 
Constructor Summary
ProxyGroup()
          create empty ProxyGroup
ProxyGroup(int id, java.lang.String name)
          create existing ProxyGroup
 
Method Summary
 void addProxyToGroup(X2XProxy toAdd)
          add a proxy to this group
 double calcCategoryFreq(FileCategory cat)
          calculates the relative frequency of files of the FileCategory cat of this group (each proxy of it) TODO: change this according to formula in X2X-paper (playbackTime)
 ProxyGroup clone()
          clones the object, the proxies are NOT cloned
 ProxyGroup clone2()
          clones the object, the proxies ARE also cloned
 int compareTo(ProxyGroup o)
          Implements the compareTo() based on the group name.
 boolean equals(ProxyGroup other)
          is other ProxyGroup equal to this one?
 FileCategory getBestCat(java.util.Vector<FileCategory> fileCategories)
          find out the best semantic category for this group of proxies
 java.awt.Color getColor()
           
 int getId()
           
 X2XProxy getLeader()
          gets the leader of the group
 java.lang.String getName()
           
 java.util.Vector<X2XProxy> getProxies()
           
 int getSize()
          returns the number of proxies belonging to this group
 void removeProxyFromGroup(X2XProxy toRemove)
          remove a proxy from this group
 void setColor(java.awt.Color color)
           
 void setId(int id)
           
 boolean setLeader(X2XProxy newLeader)
          Sets the given prxy as the new leader of the group
 void setName(java.lang.String name)
           
 void setProxies(java.util.Vector<X2XProxy> proxies)
           
 java.lang.String toString()
          return String-representation of object
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

private int id

name

private java.lang.String name

proxies

private java.util.Vector<X2XProxy> proxies

color

private java.awt.Color color
Constructor Detail

ProxyGroup

public ProxyGroup()
create empty ProxyGroup


ProxyGroup

public ProxyGroup(int id,
                  java.lang.String name)
create existing ProxyGroup

Method Detail

addProxyToGroup

public void addProxyToGroup(X2XProxy toAdd)
add a proxy to this group

Parameters:
toAdd -

getLeader

public X2XProxy getLeader()
gets the leader of the group

Returns:
null - if leader could not be found

setLeader

public boolean setLeader(X2XProxy newLeader)
Sets the given prxy as the new leader of the group

Returns:
true - if successful, false if leader is not member of the group

removeProxyFromGroup

public void removeProxyFromGroup(X2XProxy toRemove)
remove a proxy from this group

Parameters:
toRemove -

getId

public int getId()
Returns:
the id

setId

public void setId(int id)
Parameters:
id - the id to set

getName

public java.lang.String getName()
Returns:
the name

setName

public void setName(java.lang.String name)
Parameters:
name - the name to set

getProxies

public java.util.Vector<X2XProxy> getProxies()
Returns:
the proxies

setProxies

public void setProxies(java.util.Vector<X2XProxy> proxies)
Parameters:
proxies - the proxies to set

getSize

public int getSize()
returns the number of proxies belonging to this group

Returns:
int - the number of proxies

toString

public java.lang.String toString()
return String-representation of object

Overrides:
toString in class java.lang.Object

calcCategoryFreq

public double calcCategoryFreq(FileCategory cat)
calculates the relative frequency of files of the FileCategory cat of this group (each proxy of it) TODO: change this according to formula in X2X-paper (playbackTime)


getBestCat

public FileCategory getBestCat(java.util.Vector<FileCategory> fileCategories)
                        throws java.lang.Exception
find out the best semantic category for this group of proxies

Returns:
FileCategory - the best semantic category
Throws:
java.lang.Exception

clone

public ProxyGroup clone()
clones the object, the proxies are NOT cloned

Overrides:
clone in class java.lang.Object

clone2

public ProxyGroup clone2()
clones the object, the proxies ARE also cloned


getColor

public java.awt.Color getColor()
Returns:
the color

setColor

public void setColor(java.awt.Color color)
Parameters:
color - the color to set

equals

public boolean equals(ProxyGroup other)
is other ProxyGroup equal to this one?

Parameters:
other -
Returns:
true if they are equal

compareTo

public int compareTo(ProxyGroup o)
Implements the compareTo() based on the group name. Compares this instance of ProxyGroup with the specified instance. Returns a negative integer if this instance comes first in a natural ordering, a positive integer if the specified instance comes first in a natural ordering, or zero if they're equal.

Specified by:
compareTo in interface java.lang.Comparable<ProxyGroup>
Parameters:
o - another instance of ProxyGroup
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.