X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.ui%2Fsrc%2Forg%2Fsimantics%2Fui%2Fcolors%2FRGBAdapter.java;h=86e249e622a7ecfab0362ba63ef72bbc562b5bd8;hb=refs%2Fchanges%2F38%2F238%2F2;hp=fab078d8267782e1605933f2d4d9d5a5b4577468;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/colors/RGBAdapter.java b/bundles/org.simantics.ui/src/org/simantics/ui/colors/RGBAdapter.java index fab078d82..86e249e62 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/colors/RGBAdapter.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/colors/RGBAdapter.java @@ -1,53 +1,53 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.ui.colors; - -import org.eclipse.swt.graphics.RGB; -import org.simantics.databoard.Bindings; -import org.simantics.databoard.binding.Binding; -import org.simantics.db.AsyncReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.adaption.ResourceAdapter; -import org.simantics.db.procedure.AsyncProcedure; - -public class RGBAdapter implements ResourceAdapter { - - public static class RGBDouble { - public double red; - public double green; - public double blue; - } - - public static final Binding BINDING = Bindings.getBindingUnchecked(RGBDouble.class); - - @Override - public void adapt(AsyncReadGraph g, Resource source, Resource r, final AsyncProcedure procedure) { - g.forValue(r, BINDING, new AsyncProcedure() { - @Override - public void execute(AsyncReadGraph graph, RGBDouble result) { - procedure.execute(graph, - new RGB( - (int)(result.red*255.0), - (int)(result.green*255.0), - (int)(result.blue*255.0) - ) - ); - } - - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - procedure.exception(graph, throwable); - } - }); - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2011 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.ui.colors; + +import org.eclipse.swt.graphics.RGB; +import org.simantics.databoard.Bindings; +import org.simantics.databoard.binding.Binding; +import org.simantics.db.AsyncReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.adaption.ResourceAdapter; +import org.simantics.db.procedure.AsyncProcedure; + +public class RGBAdapter implements ResourceAdapter { + + public static class RGBDouble { + public double red; + public double green; + public double blue; + } + + public static final Binding BINDING = Bindings.getBindingUnchecked(RGBDouble.class); + + @Override + public void adapt(AsyncReadGraph g, Resource source, Resource r, final AsyncProcedure procedure) { + g.forValue(r, BINDING, new AsyncProcedure() { + @Override + public void execute(AsyncReadGraph graph, RGBDouble result) { + procedure.execute(graph, + new RGB( + (int)(result.red*255.0), + (int)(result.green*255.0), + (int)(result.blue*255.0) + ) + ); + } + + @Override + public void exception(AsyncReadGraph graph, Throwable throwable) { + procedure.exception(graph, throwable); + } + }); + } + +}