Mercurial > hg > jslab
diff src/samer/core_/util/Tools.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/samer/core_/util/Tools.java Tue Jan 17 17:50:20 2012 +0000 @@ -0,0 +1,52 @@ +/* + * Tools.java + * + * Copyright (c) 2000, Samer Abdallah, King's College London. + * All rights reserved. + * + * This software is provided AS iS and WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +package samer.core.util; + +import java.awt.*; +import java.io.*; +import java.util.*; +import java.awt.*; +import java.lang.reflect.*; +import samer.core.*; + +public class Tools +{ + // for scheme to use - a bit clunky! + + public static double[] doubleArray(int n) { return new double[n]; } + public static double doubleArray(double[] x, int i) { return x[i]; } + public static double doubleArray(double[] x, int i, double y) { return x[i]=y; } + public static double[] doubleArray(double[] x, Object[] y) { + for (int i=0; i<y.length; i++) + x[i]=((Double)X.DoubleCodec.decode(y[i])).doubleValue(); + return x; + } + public static double[] doubleArray(Object [] y) { + double [] x=new double[y.length]; + return doubleArray(x,y); + } + + private static Object aa=RenderingHints.VALUE_ANTIALIAS_OFF; + + public static void setAntialias(boolean f) { + aa= f ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF; + } + + public static Graphics initGraphics( Graphics g) + { + Graphics2D g2=(Graphics2D)g; + g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED); + //g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aa); + return g; + } +}