]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/examples/org/simantics/databoard/example/old/UnitsExample.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / examples / org / simantics / databoard / example / old / UnitsExample.java
1 /*******************************************************************************
2  *  Copyright (c) 2010 Association for Decentralized Information Management in
3  *  Industry THTH ry.
4  *  All rights reserved. This program and the accompanying materials
5  *  are made available under the terms of the Eclipse Public License v1.0
6  *  which accompanies this distribution, and is available at
7  *  http://www.eclipse.org/legal/epl-v10.html
8  *
9  *  Contributors:
10  *      VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.databoard.example.old;
13
14 import org.simantics.databoard.Units;
15 import org.simantics.databoard.units.IUnitConverter;
16 import org.simantics.databoard.units.internal.UnitParseException;
17
18 public class UnitsExample {
19
20     public static void main(String[] args) {
21         try {
22                 IUnitConverter c;
23                 
24                 String sourceUnit = "cl";
25                 String targetUnit = "l";
26                 c = Units.createConverter(sourceUnit, targetUnit);
27                 
28                 double sourceValue = 100;
29                 
30             System.out.println(c);
31             System.out.println(sourceValue+" "+sourceUnit+" = "+c.convert(sourceValue)+" "+targetUnit);
32             
33 //            System.out.println( Magnitude.getSuitable(50000) );
34             
35             
36             System.out.println( "150 mph = "+Units.convert(150, "mph", "km/h") +" km/h");
37             System.out.println( "100 hp = "+Units.convert(100, "hp(M)", "kW") +" kW");
38             System.out.println( "100 lbs = "+Units.convert(100, "lbs", "kg") +" kg");
39
40             
41 //            c = Units.createConverter("in2", "cm2");
42 //            System.out.println();
43         } catch (UnitParseException e) {
44             // TODO Auto-generated catch block
45             e.printStackTrace();
46         }
47     }
48     
49 }