Android Open Source - graph-android Util






From Project

Back to project page graph-android.

License

The source code is released under:

GNU General Public License

If you think the Android project graph-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package lorian.graph.function;
/*from   w w w.jav  a  2s  .c o m*/
import java.text.NumberFormat;
import java.util.Locale;

public class Util {
  public static String removeWhiteSpace(String s)
  {
    s = s.trim();
    String ss = ""; 
    for(int i=0;i<s.length();i++)
    {
      if(s.charAt(i) != ' ' && s.charAt(i) != '\t' && s.charAt(i) != '\n')
        ss += s.charAt(i);
    }
    return ss;
  }
  public static boolean StringContains(String s, char ch)
  {
    
    for(int i=0;i<s.length();i++)
    {
      if(s.charAt(i) == ch) return true;
    }
    return false;
  }
  public static boolean StringContains(String s, String chars)
  {
    for(int i=0;i<chars.length();i++)
    {
      if(StringContains(s, chars.charAt(i))) return true;
    }
    return false;
  }
  /*
  public static int getStringWidth(FontMetrics f, String s)
  {
    int width = 0;
    for(int i=0;i<s.length();i++)
    {
      if(s.charAt(i)<256)
        width += f.getWidths()[s.charAt(i)];
      else width += f.getWidths()['a'];
    }
    return width;
  }
  */
  public static String LowercaseAlphabethWithout(char character)
  {
    String s = "";
    for(char ch = 'a'; ch <= 'z'; ch++)
    {
      if(ch != character) s += ch;
    }
    return s;
  }
  
  public static String LowercaseAlphabethWithout(char character1, char character2)
  {
    String s = "";
    for(char ch = 'a'; ch <= 'z'; ch++)
    {
      if(ch != character1 && ch != character2) s += ch;
    }
    return s;
  }
  public static int StringIndexNotOf(String s, String chars)
  {
    int i;
    char ch;
    for(i=0;i<s.length();i++)
    {
      ch = s.charAt(i);
      if(!StringContains(chars, ch))
      {
        return i;
      }
    }
    return -1;
  }

  public static int StringArrayGetIndex(String[] array, String s)
  {
    int i=0;
    for(String ss: array)
    {
      if(ss.equals(s)) return i;
      i++;
    }
    return -1;
  }
  public static String StringReplace(String s, char oldchar, String replacestr)
  {
    String result = "";
    char ch;
    for(int i=0;i<s.length();i++)
    {
      ch = s.charAt(i);
      
      if(ch == oldchar)
      {
        result += replacestr;
      }
      else
        result += ch;
    }
    return result;
  }
  public static String GetString(double d)
  {
    if(Double.isInfinite(d)) return "" + MathChars.Infinity.getCode();
    else if(Double.isNaN(d)) return "NaN";
    else if(d == Math.rint(d)) return "" + (int) d;
    else return "" + round(d, 6);
  }
  public static double round(double valueToRound, int numberOfDecimalPlaces)
  {
    if(Double.isNaN(valueToRound)) return Double.NaN;
      double multipicationFactor = Math.pow(10, numberOfDecimalPlaces);
      double interestedInZeroDPs = valueToRound * multipicationFactor;
      return Math.round(interestedInZeroDPs) / multipicationFactor;
      
  }
  /*
  public static Color lighter(Color c, boolean transparant)
  {
    double org = 0.6;
    double white = 0.4;
    if(!transparant)
      return new Color((int) (c.getRed() * org + 0xff * white), (int) (c.getGreen() * org + 0xff * white), (int) (c.getBlue() * org + 0xff * white));
    else return new Color((int) (c.getRed() * org + 0xff * white), (int) (c.getGreen() * org + 0xff * white), (int) (c.getBlue() * org + 0xff * white), (int) (0.8 * 0xff));
  }
  */
  public static String doubleToString(double d)
  {
    NumberFormat f = NumberFormat.getInstance(Locale.US);
    f.setGroupingUsed(false);
    return f.format(d);
  }
  

}




Java Source Code List

com.michaelnovakjr.numberpicker.NumberPickerButton.java
com.michaelnovakjr.numberpicker.NumberPickerDialog.java
com.michaelnovakjr.numberpicker.NumberPickerPreference.java
com.michaelnovakjr.numberpicker.NumberPicker.java
lorian.graph.WindowSettings.java
lorian.graph.android.FunctionDataArray.java
lorian.graph.android.GraphActivity.java
lorian.graph.android.InputActivity.java
lorian.graph.android.Util.java
lorian.graph.android.WindowSettingsActivity.java
lorian.graph.android.opengl.Color.java
lorian.graph.android.opengl.GraphRenderer.java
lorian.graph.android.opengl.GraphSurfaceView.java
lorian.graph.function.Calculate.java
lorian.graph.function.Factor.java
lorian.graph.function.Function.java
lorian.graph.function.MathChars.java
lorian.graph.function.MathFunctions.java
lorian.graph.function.PointXY.java
lorian.graph.function.Term.java
lorian.graph.function.Util.java
lorian.graph.function.Variable.java
yuku.ambilwarna.AmbilWarnaDialog.java
yuku.ambilwarna.AmbilWarnaKotak.java