Mercurial > hg > jslab
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bf79fb79ee13 |
---|---|
1 /* | |
2 * Tools.java | |
3 * | |
4 * Copyright (c) 2000, Samer Abdallah, King's College London. | |
5 * All rights reserved. | |
6 * | |
7 * This software is provided AS iS and WITHOUT ANY WARRANTY; | |
8 * without even the implied warranty of MERCHANTABILITY or | |
9 * FITNESS FOR A PARTICULAR PURPOSE. | |
10 */ | |
11 | |
12 package samer.core.util; | |
13 | |
14 import java.awt.*; | |
15 import java.io.*; | |
16 import java.util.*; | |
17 import java.awt.*; | |
18 import java.lang.reflect.*; | |
19 import samer.core.*; | |
20 | |
21 public class Tools | |
22 { | |
23 // for scheme to use - a bit clunky! | |
24 | |
25 public static double[] doubleArray(int n) { return new double[n]; } | |
26 public static double doubleArray(double[] x, int i) { return x[i]; } | |
27 public static double doubleArray(double[] x, int i, double y) { return x[i]=y; } | |
28 public static double[] doubleArray(double[] x, Object[] y) { | |
29 for (int i=0; i<y.length; i++) | |
30 x[i]=((Double)X.DoubleCodec.decode(y[i])).doubleValue(); | |
31 return x; | |
32 } | |
33 public static double[] doubleArray(Object [] y) { | |
34 double [] x=new double[y.length]; | |
35 return doubleArray(x,y); | |
36 } | |
37 | |
38 private static Object aa=RenderingHints.VALUE_ANTIALIAS_OFF; | |
39 | |
40 public static void setAntialias(boolean f) { | |
41 aa= f ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF; | |
42 } | |
43 | |
44 public static Graphics initGraphics( Graphics g) | |
45 { | |
46 Graphics2D g2=(Graphics2D)g; | |
47 g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED); | |
48 //g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); | |
49 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, aa); | |
50 return g; | |
51 } | |
52 } |