Class PolyLine


  • public class PolyLine
    extends java.lang.Object
    Defines a polyline built of multiple points defined by a JsonArray.

    This class can be used e.g. to build Q-by-U characteristics Controllers.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  PolyLine.Builder  
    • Constructor Summary

      Constructors 
      Constructor Description
      PolyLine​(double x1, java.lang.Double y1, double x2, java.lang.Double y2)
      Creates a PolyLine from two points.
      PolyLine​(java.lang.Double y)
      Creates a static PolyLine, i.e.
      PolyLine​(java.lang.String x, java.lang.String y, com.google.gson.JsonArray lineConfig)
      Creates a PolyLine from a JSON line configuration.
      PolyLine​(java.lang.String x, java.lang.String y, java.lang.String lineConfig)
      Creates a PolyLine from a JSON line configuration.
      PolyLine​(java.util.TreeMap<java.lang.Double,​java.lang.Double> points)
      Creates a PolyLine from a map of points.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static PolyLine.Builder create()
      Create a PolyLine builder.
      static PolyLine empty()
      Create a PolyLine that returns null for every 'x'.
      java.lang.Double getValue​(java.lang.Double x)
      Gets the Y-value for the given X.
      java.lang.Double getValue​(java.lang.Float x)
      Gets the Y-value for the given X.
      java.lang.Double getValue​(java.lang.Integer x)
      Gets the Y-value for the given X.
      static void printAsCsv​(PolyLine polyLine)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PolyLine

        public PolyLine​(java.lang.Double y)
        Creates a static PolyLine, i.e. the 'y' value is the same for each 'x'.
        Parameters:
        y - 'y' value
      • PolyLine

        public PolyLine​(double x1,
                        java.lang.Double y1,
                        double x2,
                        java.lang.Double y2)
        Creates a PolyLine from two points.
        Parameters:
        x1 - 'x' value of point 1
        y1 - 'y' value of point 1
        x2 - 'x' value of point 2
        y2 - 'y' value of point 2
      • PolyLine

        public PolyLine​(java.util.TreeMap<java.lang.Double,​java.lang.Double> points)
        Creates a PolyLine from a map of points.
        Parameters:
        points - a map of points
      • PolyLine

        public PolyLine​(java.lang.String x,
                        java.lang.String y,
                        java.lang.String lineConfig)
                 throws OpenemsError.OpenemsNamedException
        Creates a PolyLine from a JSON line configuration.
        Parameters:
        x - the name of the 'x' value inside the Json-Array
        y - the name of the 'y' value inside the Json-Array
        lineConfig - the configured x and y coordinates values; parsed to a Json-Array
        Throws:
        OpenemsError.OpenemsNamedException - on error
      • PolyLine

        public PolyLine​(java.lang.String x,
                        java.lang.String y,
                        com.google.gson.JsonArray lineConfig)
                 throws OpenemsError.OpenemsNamedException
        Creates a PolyLine from a JSON line configuration.

        Parse the given JSON line format to x and y parameters.

         [
          { "x": 0.9,  "y":-4000 },
          { "x": 0.93, "y":-1000 },
          { "x": 1.07, "y":1000 },
          { "x": 1.1,  "y":4000 }
         ]
         
        Parameters:
        x - the name of the 'x' value inside the Json-Array
        y - the name of the 'y' value inside the Json-Array
        lineConfig - the configured x and y coordinates values
        Throws:
        OpenemsError.OpenemsNamedException - on error
    • Method Detail

      • empty

        public static PolyLine empty()
        Create a PolyLine that returns null for every 'x'.
        Returns:
        a PolyLine
      • getValue

        public java.lang.Double getValue​(java.lang.Double x)
        Gets the Y-value for the given X.
        Parameters:
        x - the 'x' value, possibly null
        Returns:
        the 'y' value, possibly null
      • getValue

        public java.lang.Double getValue​(java.lang.Float x)
        Gets the Y-value for the given X. Convenience method that internally converts the Float to a Double.
        Parameters:
        x - the 'x' value, possibly null
        Returns:
        the 'y' value, possibly null
      • getValue

        public java.lang.Double getValue​(java.lang.Integer x)
        Gets the Y-value for the given X. Convenience method that internally converts the Integer to a Double.
        Parameters:
        x - the 'x' value, possibly null
        Returns:
        the 'y' value, possibly null
      • printAsCsv

        public static void printAsCsv​(PolyLine polyLine)