|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--universe.common.database.DBItem | +--universe.server.database.GalaxyBase | +--universe.server.database.GalaxyStd
Class used for standard irregular galaxies containing a a random scattering of star systems with no discernable structure. Subclasses which want to have a random generated galaxy which imposes some kind of overall structure should override the randomCoord method of this class. This class is suitable for small scale games with low to moderate star densities. At larger sizes and higher densities, a more subclass with a structure which is more visually and strategically intereseting is recommended.
GalaxyElliptical
,
GalaxySpiral
,
GalaxyGlobular
,
Serialized FormField Summary | |
static java.lang.String |
DESCRIPTION
|
private Coord |
myCenter
|
private float |
myDensity
|
private Coord |
mySpan
|
static java.util.Random |
ourRandGen
|
Fields inherited from class universe.server.database.GalaxyBase |
|
Constructor Summary | |
GalaxyStd()
This is not actually used, but is declared public in order to not interfere with subclassing. |
|
GalaxyStd(float width,
float height,
float depth,
float density)
This is the designated constructor which should be used to create instances this class. |
Method Summary | |
boolean |
containsCoord(Coord aCoord)
This method returns true if the given coordinate is contained within the retricted hull of the receiving galaxy. |
void |
generateSystems(float[] planetDistribution)
This method extends that of our super class to causes the receiving galaxy to generate the random collection of star systems which it will contain and assign planets to each of these. |
Coord |
getCenter()
Returns the center point of the galaxy. |
float |
getDensity()
Returns the average number of star systems per parsec. |
Coord |
getSpan()
Returns the height, width, and depth of this galaxy. |
Coord |
newSystemCoord()
This method returns a random coordinate within the overall shape of the galaxy (as tested with containsCoord). |
int |
starSystemCount()
Returns the number of star systems that will be present in the receiving galaxy after star system generation, as calculated from the usable dimensions of the galaxy and its assigned density. |
java.lang.String |
structureDescription()
This method returns a (usually one-word) string describing the structure of the galaxy. |
Methods inherited from class universe.server.database.GalaxyBase |
addSystem, getID, getIndex, getName, getSystems, hasGeneratedSystems, setName |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private Coord myCenter
private Coord mySpan
private float myDensity
public static java.util.Random ourRandGen
public static java.lang.String DESCRIPTION
Constructor Detail |
public GalaxyStd(float width, float height, float depth, float density)
width
- The width of the galaxy (in parsecs)height
- The height of the galaxy (in parsecs)depth
- The depth of the galaxy (in parsecs)density
- The average density (in systems per cubic parsec) of stars within the hull of the galaxy (not its bounding cube).public GalaxyStd()
Method Detail |
public Coord getSpan()
public Coord getCenter()
public float getDensity()
public java.lang.String structureDescription()
public int starSystemCount()
public Coord newSystemCoord()
While this method is primarily used by the standard contructor it can also be used to generate locations for random events in interstellar space within the galaxy.
Subclasses may choose to override this method in order to more efficiently generate coordinates within some kind of overall galactic structure, as this implementation will test random points throughout the bounding cube. However, overridding the containsCoord method is all that is minimally required to get a new shape. Subclasses wishing to have the star system distribution follow a general internal structure, however, will definately wish to override this method.
#containsCoord()
public boolean containsCoord(Coord aCoord)
This method is provided as a convenience to subclass implementations of newSystemCoord(), where unchecked random pertubrations and rounding may result in a system coordindates outside the bounds of the galaxy.
In this base class, this simply means that it is within the bounding cube around the galactic center. However, subclasses which have other specific shapes and wish to ensure that no system "leaks" out into the cube beyond should override this method to test those more restrictive boundaries.
aCoord
- The coordinate to be tested.newSystemCoord()
public void generateSystems(float[] planetDistribution) throws SchemeUnknownException, java.lang.InterruptedException
generateSystems
in class GalaxyBase
planetDistribution
- Array of floating point values representing the probability of finding planet mass at successive distances from its primary.
SchemeUnknownException
- If unable to determine a ID of the galaxy to which systems are to be added.
java.lang.InterruptedException
- If access to a resource needed for star system generation has been interrupted.GalaxyBase.hasGeneratedSystems()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |