From: Cyrus H. <ch...@bo...> - 2013-12-29 21:36:17
|
I’m trying and failing to figure out how to change the background color of an image of a molecule I’m rendering with an AtomContainerRenderer. I have to confess to being a bit perplexed by the java idioms for various configurable properties and what not. It seems there’s an unholy mix of interfaces, classes, subclasses, properties, parameters, etc… all trying to do similar things, but this one in particular seems rather confusing. In the BasicSceneGenerator we have: public static class BackgroundColor extends AbstractGeneratorParameter<Color> { /** Returns the default value. * @return {@link Color}.WHITE */ public Color getDefault() { return Color.WHITE; } } So we have a concept of a BackgroundColor stored as an inner class, extending AbstractGeneratorParamater. How does one go about changing the default color? Or is there some sort of “active” background color that is distinct from the “default” background color? Changing current values or defaults by subclassing seems like killing an ant with a machine gun, but, what do I know? I see that there is also: private IGeneratorParameter<Color> backgroundColor = new BackgroundColor(); but given that this is private, that seems rather hard to muck with and I don’t see any getter/setters for backgroundColor. There is the getParameters method: /** {@inheritDoc} */ @TestMethod("testGetParameters") public List<IGeneratorParameter<?>> getParameters() { return Arrays.asList( new IGeneratorParameter<?>[] { backgroundColor, foregroundColor, margin, useAntiAliasing, fontStyle, fontName, zoomFactor, scale, bondLength, fitToScreen, showMoleculeTitle, showTooltip, arrowHeadWidth } ); } and I suppose I could try overloading that, but, again, that seems a rather heavy-handed approach to trying to change the background color. Any suggestions? Is there some remedial reading on parameters, abstract parameters, their generators, etc… that I should be reading before asking more stupid questions? thanks, Cyrus |