public ColorRampFactory (ConfigurableFactory<?> parent, List<String> path) { super(ColorRamp.class, parent, path); addProperty(RAMP_TYPE); addProperty(OPACITY); addProperty(COLOR1); addProperty(ALPHA1); addProperty(COLOR2); addProperty(ALPHA2); addProperty(HUE1); addProperty(HUE2); addProperty(GRADIENTS); addProperty(THEME); }
@Override public void readConfiguration (JSONObject rootNode) throws ConfigurationException { super.readConfiguration(rootNode); gradients.clear(); try { readGradients(getPropertyValue(GRADIENTS), gradients); } catch (JSONException e) { throw new ConfigurationException("Error configuring factory "+ this.getClass().getName(), e); } }
@Override protected ColorRamp create () throws ConfigurationException { final String rampType = getPropertyValue(RAMP_TYPE); final double opacity = 1.0; //getPropertyValue(OPACITY); final String theme = getPropertyValue(THEME); final boolean islight = theme.equalsIgnoreCase("light"); Color color = hasPropertyValue(COLOR1)? ColorRampParameter.getColor(getPropertyValue(COLOR1)) : islight? new Color(55,55,55) : Color.WHITE; int alpha1 = getPropertyValue(ALPHA1); if (-1 == alpha1) alpha1 = (int) Math.floor(255*opacity); Color startColor = ColorRampParameter.getColorWithAlpha(getPropertyValue(COLOR1), alpha1); int alpha2 = getPropertyValue(ALPHA2); if (-1 == alpha2) alpha2 = (int) Math.floor(255*opacity); Color endColor = ColorRampParameter.getColorWithAlpha(getPropertyValue(COLOR2), alpha2); ramp = new SingleGradientColorRamp(startColor, endColor); ramp = new HueColorRamp(getPropertyValue(HUE1), getPropertyValue(HUE2));
public ImageRendererFactory (String name, ConfigurableFactory<?> parent, List<String> path) { super(name, getFactoryClass(), parent, path); addProperty(RENDERER_TYPE); addChildFactory(new ColorRampFactory(this, new ArrayList<String>())); }