X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.trend%2Fsrc%2Forg%2Fsimantics%2Ftrend%2Fimpl%2FViewRenderingProfile.java;fp=bundles%2Forg.simantics.trend%2Fsrc%2Forg%2Fsimantics%2Ftrend%2Fimpl%2FViewRenderingProfile.java;h=4fa70170414d6be89bf5e195abff345a1ffe840d;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=1d6a9d8b6ddf1a61a79bc106f9cd3f0b2d203c67;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.trend/src/org/simantics/trend/impl/ViewRenderingProfile.java b/bundles/org.simantics.trend/src/org/simantics/trend/impl/ViewRenderingProfile.java index 1d6a9d8b6..4fa701704 100644 --- a/bundles/org.simantics.trend/src/org/simantics/trend/impl/ViewRenderingProfile.java +++ b/bundles/org.simantics.trend/src/org/simantics/trend/impl/ViewRenderingProfile.java @@ -1,52 +1,52 @@ -package org.simantics.trend.impl; - -import java.awt.Color; - -import org.simantics.trend.configuration.ViewProfile; - -/** - * Internal caching class for chart rendering related data that only needs to be - * recreated when the rendered TrendSpec changes, not on every rendered frame. - * - * @author Tuukka Lehtonen - */ -class ViewRenderingProfile { - - public Color backgroundColor1 = Plot.PLOT_AREA_BG_GRADIENT_COLOR_BOTTOM; - public Color backgroundColor2 = Plot.PLOT_AREA_BG_GRADIENT_COLOR_TOP;; - public Color gridColor = Plot.GRID_LINE_COLOR; - - public ViewRenderingProfile read(ViewProfile p) { - if (p.backgroundColor != null) { - float[] bg = p.backgroundColor; - int len = bg.length; - if (len >= 6) { - backgroundColor1 = toColor(bg, 0); - backgroundColor2 = toColor(bg, 3); - } else if (len >= 3) { - backgroundColor1 = toColor(bg, 0); - backgroundColor2 = null; - } - } else { - backgroundColor1 = Plot.PLOT_AREA_BG_GRADIENT_COLOR_BOTTOM; - backgroundColor2 = Plot.PLOT_AREA_BG_GRADIENT_COLOR_TOP; - } - - if (p.gridColor != null && p.gridColor.length >= 3) { - gridColor = toColor(p.gridColor, 0); - } else { - gridColor = Plot.GRID_LINE_COLOR; - } - - return this; - } - - private static Color toColor(float[] array, int offset) { - return new Color(clamp(array[offset]), clamp(array[offset+1]), clamp(array[offset+2])); - } - - private static float clamp(float v) { - return Math.max(0, Math.min(v, 1)); - } - -} +package org.simantics.trend.impl; + +import java.awt.Color; + +import org.simantics.trend.configuration.ViewProfile; + +/** + * Internal caching class for chart rendering related data that only needs to be + * recreated when the rendered TrendSpec changes, not on every rendered frame. + * + * @author Tuukka Lehtonen + */ +class ViewRenderingProfile { + + public Color backgroundColor1 = Plot.PLOT_AREA_BG_GRADIENT_COLOR_BOTTOM; + public Color backgroundColor2 = Plot.PLOT_AREA_BG_GRADIENT_COLOR_TOP;; + public Color gridColor = Plot.GRID_LINE_COLOR; + + public ViewRenderingProfile read(ViewProfile p) { + if (p.backgroundColor != null) { + float[] bg = p.backgroundColor; + int len = bg.length; + if (len >= 6) { + backgroundColor1 = toColor(bg, 0); + backgroundColor2 = toColor(bg, 3); + } else if (len >= 3) { + backgroundColor1 = toColor(bg, 0); + backgroundColor2 = null; + } + } else { + backgroundColor1 = Plot.PLOT_AREA_BG_GRADIENT_COLOR_BOTTOM; + backgroundColor2 = Plot.PLOT_AREA_BG_GRADIENT_COLOR_TOP; + } + + if (p.gridColor != null && p.gridColor.length >= 3) { + gridColor = toColor(p.gridColor, 0); + } else { + gridColor = Plot.GRID_LINE_COLOR; + } + + return this; + } + + private static Color toColor(float[] array, int offset) { + return new Color(clamp(array[offset]), clamp(array[offset+1]), clamp(array[offset+2])); + } + + private static float clamp(float v) { + return Math.max(0, Math.min(v, 1)); + } + +}