]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.charts/src/org/simantics/charts/editor/BooleanToDoubleAdapter.java
Faster bounds calculation for zoom to selection and navigate to target
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / editor / BooleanToDoubleAdapter.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2011 VTT Technical Research Centre of Finland and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     VTT Technical Research Centre of Finland - initial API and implementation
10  *******************************************************************************/
11 package org.simantics.charts.editor;
12
13 import org.simantics.databoard.adapter.AdaptException;
14 import org.simantics.databoard.adapter.Adapter;
15 import org.simantics.databoard.adapter.RuntimeAdaptException;
16
17 public class BooleanToDoubleAdapter implements Adapter {
18
19         public static final BooleanToDoubleAdapter INSTANCE = new BooleanToDoubleAdapter();
20         
21         @Override
22         public Object adapt(Object obj) throws AdaptException {
23                 Boolean b = (Boolean) obj;
24                 return b ? 1.0 : 0.0;
25         }
26
27         @Override
28         public Object adaptUnchecked(Object obj) throws RuntimeAdaptException {
29                 Boolean b = (Boolean) obj;
30                 return b ? 1.0 : 0.0;
31         }
32
33 }
34