import java.awt.Point; import java.awt.Graphics; import java.awt.Color; public class MobileStation extends Point // To simplify location information, a SuperClass Point is used // Check Java API Documentation about Point Class definition! { private Rbs servingRbs; private String stationID; private static final Color servingColor = new Color(255,0,0); private static final Color mobileColor = new Color(0,0,255); /** * Constructor for objects of class MobileStation */ public MobileStation(String stationID, int x, int y) { super(x,y); this.stationID = stationID; servingRbs=null; }
/** * Inform the ID of the Base Station * @return StringID
*/ public String getID() { return stationID; }
/** * Perform Rbs service connection * @param Rbs The Serving Rbs
*/ public void connectRbs(Rbs servingRbs) { this.servingRbs = servingRbs; }
/** * Release currently connected Rbs
*/ public void releaseRbs() { servingRbs = null; }
/** * Return the currently connected Rbs to the Mobile Station
*/ public Rbs connectedRbs() { return servingRbs; }
/** * Draw a graphical representation of the Mobile Station * When it is in service range of an Rbs, * a line of sight will be drawn from the Rbs to the Mobile Station
*/ public void draw(Graphics g) { Color normalColor = g.getColor(); int x1 = (int) getX(); int y1 = (int) getY(); // Draw the mobile station representation g.setColor(mobileColor); g.fillOval(x1-1,y1-1,3,3); if ( servingRbs != null) { int x2 = (int) servingRbs.getCell().getX(); int y2 = (int) servingRbs.getCell().getY(); g.setColor(servingColor); g.drawLine(x1,y1,x2,y2); } g.setColor(normalColor); } }
|