Whitespace

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@1104 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Dave Hoover
2011-01-01 05:03:08 +00:00
parent 96d7b697a3
commit f1ad37f799
6 changed files with 46 additions and 79 deletions
@@ -85,8 +85,7 @@ public class ColorPository implements Serializable
public HashIntMap<ColorRecord> colors = new HashIntMap<ColorRecord>();
/** Used when parsing the color definitions. */
public void addColor (ColorRecord record)
{
public void addColor (ColorRecord record) {
// validate the color id
if (record.colorId > 127) {
log.warning("Refusing to add color record; colorId > 127",
@@ -133,14 +132,12 @@ public class ColorPository implements Serializable
}
/** Returns a random starting id from the entries in this class. */
public ColorRecord randomStartingColor ()
{
public ColorRecord randomStartingColor () {
return randomStartingColor(RandomUtil.rand);
}
/** Returns a random starting id from the entries in this class. */
public ColorRecord randomStartingColor (Random rand)
{
public ColorRecord randomStartingColor (Random rand) {
// figure out our starter ids if we haven't already
if (_starters == null) {
ArrayList<ColorRecord> list = Lists.newArrayList();
@@ -164,23 +161,19 @@ public class ColorPository implements Serializable
}
/**
* Get the default ColorRecord defined for this color class, or
* null if none.
* Get the default ColorRecord defined for this color class, or null if none.
*/
public ColorRecord getDefault ()
{
public ColorRecord getDefault () {
return colors.get(defaultId);
}
// from interface Comparable<ClassRecord>
public int compareTo (ClassRecord other)
{
public int compareTo (ClassRecord other) {
return name.compareTo(other.name);
}
@Override
public String toString ()
{
public String toString () {
return "[id=" + classId + ", name=" + name + ", source=#" +
Integer.toString(source.getRGB() & 0xFFFFFF, 16) +
", range=" + StringUtil.toString(range) +
@@ -223,16 +216,14 @@ public class ColorPository implements Serializable
* to identify a colorization record. This value will always be a positive integer that
* fits into 16 bits.
*/
public int getColorPrint ()
{
public int getColorPrint () {
return ((cclass.classId << 8) | colorId);
}
/**
* Returns the data in this record configured as a colorization instance.
*/
public Colorization getColorization ()
{
public Colorization getColorization () {
// if (_zation == null) {
// _zation = new Colorization(getColorPrint(), cclass.source,
// cclass.range, offsets);
@@ -242,14 +233,12 @@ public class ColorPository implements Serializable
}
// from interface Comparable<ColorRecord>
public int compareTo (ColorRecord other)
{
public int compareTo (ColorRecord other) {
return name.compareTo(other.name);
}
@Override
public String toString ()
{
public String toString () {
return "[id=" + colorId + ", name=" + name +
", offsets=" + StringUtil.toString(offsets) + ", starter=" + starter + "]";
}
@@ -270,14 +259,13 @@ public class ColorPository implements Serializable
return _classes.values().iterator();
}
public Collection<ClassRecord> getClasses ()
public Collection<ClassRecord> getClasses ()
{
return _classes.values();
}
/**
* Returns an array containing the records for the colors in the
* specified class.
* Returns an array containing the records for the colors in the specified class.
*/
public ColorRecord[] enumerateColors (String className)
{
@@ -297,8 +285,7 @@ public class ColorPository implements Serializable
}
/**
* Returns an array containing the ids of the colors in the specified
* class.
* Returns an array containing the ids of the colors in the specified class.
*/
public int[] enumerateColorIds (String className)
{
@@ -488,8 +475,7 @@ public class ColorPository implements Serializable
}
/**
* Loads up a serialized color pository from the supplied resource
* manager.
* Loads up a serialized color pository from the supplied resource manager.
*/
public static ColorPository loadColorPository (ResourceManager rmgr)
{
@@ -502,8 +488,7 @@ public class ColorPository implements Serializable
}
/**
* Loads up a serialized color pository from the supplied resource
* manager.
* Loads up a serialized color pository from the supplied resource manager.
*/
public static ColorPository loadColorPository (InputStream source)
{
@@ -47,8 +47,7 @@ public class Colorization
/**
* Constructs a colorization record with the specified identifier.
*/
public Colorization (int colorizationId, Color rootColor,
float[] range, float[] offsets)
public Colorization (int colorizationId, Color rootColor, float[] range, float[] offsets)
{
this.colorizationId = colorizationId;
this.rootColor = rootColor;
@@ -56,8 +55,7 @@ public class Colorization
this.offsets = offsets;
// compute our HSV and fixed HSV
_hsv = Color.RGBtoHSB(rootColor.getRed(), rootColor.getGreen(),
rootColor.getBlue(), null);
_hsv = Color.RGBtoHSB(rootColor.getRed(), rootColor.getGreen(), rootColor.getBlue(), null);
_fhsv = toFixedHSV(_hsv, null);
}
@@ -70,9 +68,8 @@ public class Colorization
}
/**
* Adjusts the supplied color by the offsets in this colorization,
* taking the appropriate measures for hue (wrapping it around) and
* saturation and value (clipping).
* Adjusts the supplied color by the offsets in this colorization, taking the appropriate
* measures for hue (wrapping it around) and saturation and value (clipping).
*
* @return the RGB value of the recolored color.
*/
@@ -93,12 +90,11 @@ public class Colorization
}
/**
* Returns true if this colorization matches the supplied color, false
* otherwise.
* Returns true if this colorization matches the supplied color, false otherwise.
*
* @param hsv the HSV values for the color in question.
* @param fhsv the HSV values converted to fixed point via {@link
* #toFixedHSV} for the color in question.
* @param fhsv the HSV values converted to fixed point via {@link #toFixedHSV} for the color
* in question.
*/
public boolean matches (float[] hsv, int[] fhsv)
{
@@ -149,16 +145,14 @@ public class Colorization
}
/**
* Converts floating point HSV values to a fixed point integer
* representation.
* Converts floating point HSV values to a fixed point integer representation.
*
* @param hsv the HSV values to be converted.
* @param fhsv the destination array into which the fixed values will
* be stored. If this is null, a new array will be created of the
* appropriate length.
* @param fhsv the destination array into which the fixed values will be stored. If this is
* null, a new array will be created of the appropriate length.
*
* @return the <code>fhsv</code> parameter if it was non-null or the
* newly created target array.
* @return the <code>fhsv</code> parameter if it was non-null or the newly created target
* array.
*/
public static int[] toFixedHSV (float[] hsv, int[] fhsv)
{
@@ -37,8 +37,8 @@ import com.threerings.media.image.ColorPository.ColorRecord;
import com.threerings.tools.xml.CompiledConfigParser;
/**
* Parses the XML color repository definition and creates a {@link
* ColorPository} instance that reflects its contents.
* Parses the XML color repository definition and creates a {@link ColorPository} instance that
* reflects its contents.
*/
public class ColorPositoryParser extends CompiledConfigParser
{
@@ -422,7 +422,7 @@ public class ResourceManager
return (File.separatorChar == '/') ? path : path.replace(File.separatorChar, '/');
} catch (IOException e) {
log.warning("Failed to determine resource path [file=" + file + "].", e);
log.warning("Failed to determine resource path", "file", file, e);
return null;
}
}
@@ -937,16 +937,14 @@ public class ResourceManager
/** Used to unpack bundles on a separate thread. */
protected static class Unpacker extends Thread
{
public Unpacker (List<ResourceBundle> bundles, InitObserver obs)
{
public Unpacker (List<ResourceBundle> bundles, InitObserver obs) {
_bundles = bundles;
_obs = obs;
_startTime = System.currentTimeMillis();
}
@Override
public void run ()
{
public void run () {
try {
// Tell the observer were starting
if (_obs != null) {
@@ -998,11 +996,9 @@ public class ResourceManager
protected static class ObservedResource
{
/** The observers listening for modifications to this resource. */
public WeakObserverList<ModificationObserver> observers =
WeakObserverList.newFastUnsafe();
public WeakObserverList<ModificationObserver> observers = WeakObserverList.newFastUnsafe();
public ObservedResource (File file)
{
public ObservedResource (File file) {
_file = file;
_lastModified = file.lastModified();
}
@@ -1015,8 +1011,7 @@ public class ResourceManager
* @return <code>true</code> if the list of observers is empty and the resource should be
* removed from the observed list, <code>false</code> if it should remain in the list.
*/
public boolean checkForModification (String path)
{
public boolean checkForModification (String path) {
long newLastModified = _file.lastModified();
if (newLastModified > _lastModified) {
_resourceModifiedOp.init(path, _lastModified = newLastModified);
@@ -1036,15 +1031,13 @@ public class ResourceManager
protected static class ResourceModifiedOp
implements ObserverList.ObserverOp<ModificationObserver>
{
public void init (String path, long lastModified)
{
public void init (String path, long lastModified) {
_path = path;
_lastModified = lastModified;
}
// documentation inherited from interface ObserverOp
public boolean apply (ModificationObserver obs)
{
public boolean apply (ModificationObserver obs) {
obs.resourceModified(_path, _lastModified);
return true;
}
@@ -35,18 +35,16 @@ import com.threerings.util.CompiledConfig;
import com.threerings.tools.CompiledConfigTask;
/**
* An abstract base implementation of a parser that is used to compile
* configuration definitions into config objects for use by the client and
* server.
*
* An abstract base implementation of a parser that is used to compile configuration definitions
* into config objects for use by the client and server.
*
* @see CompiledConfig
* @see CompiledConfigTask
*/
public abstract class CompiledConfigParser
{
/**
* Parses the supplied configuration file into a serializable
* configuration object.
* Parses the supplied configuration file into a serializable configuration object.
*/
public Serializable parseConfig (File source)
throws IOException, SAXException
@@ -60,8 +58,7 @@ public abstract class CompiledConfigParser
}
/**
* Creates the config object instance that will be populated during
* the parsing process.
* Creates the config object instance that will be populated during the parsing process.
*/
protected abstract Serializable createConfigObject ();
@@ -30,9 +30,8 @@ import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
* Used to load and store compiled configuration data (generally XML files
* that are parsed into Java object models and then serialized for rapid
* and simple access on the client and server).
* Used to load and store compiled configuration data (generally XML files that are parsed into
* Java object models and then serialized for rapid and simple access on the client and server).
*/
public class CompiledConfig
{
@@ -52,8 +51,7 @@ public class CompiledConfig
}
/**
* Serializes the supplied configuration object to the specified file
* path.
* Serializes the supplied configuration object to the specified file path.
*/
public static void saveConfig (File target, Serializable config)
throws IOException