Class PUtil

java.lang.Object
edu.umd.cs.piccolo.util.PUtil

public class PUtil extends Object
PUtil util methods for the Piccolo framework.

Version:
1.0
Author:
Jesse Grosjean
  • Field Details

    • DEFAULT_ACTIVITY_STEP_RATE

      public static long DEFAULT_ACTIVITY_STEP_RATE
      PActivities are broken into steps, this is how many milliseconds should pass between steps.
    • ACTIVITY_SCHEDULER_FRAME_DELAY

      public static int ACTIVITY_SCHEDULER_FRAME_DELAY
      Rate in milliseconds at which the activity timer will get invoked.
    • NULL_ITERATOR

      public static Iterator NULL_ITERATOR
      An iterator that iterates over an empty collection.
    • NULL_ENUMERATION

      public static Enumeration NULL_ENUMERATION
      A utility enumeration with no elements.
    • NULL_OUTPUT_STREAM

      public static OutputStream NULL_OUTPUT_STREAM
      Deprecated.
      This has been moved into a private static class of PObjectOutputStream
  • Constructor Details

    • PUtil

      public PUtil()
  • Method Details

    • createBasicScenegraph

      public static PCamera createBasicScenegraph()
      Creates the simplest possible scene graph. 1 Camera, 1 Layer, 1 Root
      Returns:
      a basic scene with 1 camera, layer and root
    • writeStroke

      public static void writeStroke(Stroke stroke, ObjectOutputStream out) throws IOException
      Serializes the given stroke object to the object output stream provided. By default strokes are not serializable. This method solves that problem.
      Parameters:
      stroke - stroke to be serialize
      out - stream to which the stroke is to be serialized
      Throws:
      IOException - can occur if exception occurs with underlying output stream
    • readStroke

      public static Stroke readStroke(ObjectInputStream in) throws IOException, ClassNotFoundException
      Reconstitutes a stroke from the provided Object Input Stream. According to the scheme found in writeStroke. By default strokes are not serializable.
      Parameters:
      in - stream from which Stroke is to be read
      Returns:
      a stroke object
      Throws:
      IOException - occurs if an exception occurs reading from in stream
      ClassNotFoundException - should never happen, but can if somehow the stroke class is not on the classpath
    • readPath

      public static GeneralPath readPath(ObjectInputStream in) throws IOException, ClassNotFoundException
      Reads a path from the provided inputStream in accordance with the serialization policy defined in writePath.
      Parameters:
      in - stream from which to read the path.
      Returns:
      reconstituted path
      Throws:
      IOException - if an unknown path type is read from the stream
      ClassNotFoundException - should never happen, but can if somehow the classpath is seriously messed up
    • writePath

      public static void writePath(GeneralPath path, ObjectOutputStream out) throws IOException
      Serializes the given path to the provided Object Output Stream.
      Parameters:
      path - path to be serialized
      out - stream to which the path should be serialized
      Throws:
      IOException - if unknown path segment type is encountered, or an exception occurs writing to the output stream