Permalink
Browse files

Changed wedge width to rendering parameter

  • Loading branch information...
1 parent ec9a21e commit 63b253cc164185dfb6bea84b732b737b18d350f9 @gilleain gilleain committed with egonw Jun 4, 2010
View
3 src/main/org/openscience/cdk/renderer/Renderer.java
@@ -41,6 +41,7 @@
import org.openscience.cdk.renderer.font.IFontManager;
import org.openscience.cdk.renderer.generators.IGenerator;
import org.openscience.cdk.renderer.generators.BasicBondGenerator.BondLength;
+import org.openscience.cdk.renderer.generators.BasicSceneGenerator.FitToScreen;
import org.openscience.cdk.renderer.generators.BasicSceneGenerator.FontName;
import org.openscience.cdk.renderer.generators.BasicSceneGenerator.Margin;
import org.openscience.cdk.renderer.generators.BasicSceneGenerator.Scale;
@@ -859,7 +860,7 @@ private void setupTransformToFit(Rectangle2D screenBounds,
// this controls whether editing a molecule causes it to re-center
// with each change or not
- if (reset || rendererModel.isFitToScreen()) {
+ if (reset || rendererModel.getRenderingParameter(FitToScreen.class).getValue()) {
this.setModelCenter(
modelBounds.getCenterX(), modelBounds.getCenterY());
}
View
17 src/main/org/openscience/cdk/renderer/generators/AtomNumberGenerator.java
@@ -52,6 +52,14 @@ public Color getDefault() {
}
private IGeneratorParameter<Color> textColor = new AtomNumberTextColor();
+
+ public static class WillDrawAtomNumbers extends
+ AbstractGeneratorParameter<Boolean> {
+ public Boolean getDefault() {
+ return Boolean.TRUE;
+ }
+ }
+ private WillDrawAtomNumbers willDrawAtomNumbers;
Vector2d offset;
@@ -69,7 +77,8 @@ public AtomNumberGenerator(Vector2d offset) {
public IRenderingElement generate(IAtomContainer ac, RendererModel model) {
ElementGroup numbers = new ElementGroup();
- if (!model.drawNumbers()) return numbers;
+ if (!model.getRenderingParameter(WillDrawAtomNumbers.class).getValue())
+ return numbers;
Vector2d offset = new Vector2d(this.offset.x,-this.offset.y);
offset.scale( 1/model.getRenderingParameter(Scale.class).getValue() );
@@ -90,7 +99,11 @@ public IRenderingElement generate(IAtomContainer ac, RendererModel model) {
}
public List<IGeneratorParameter<?>> getParameters() {
- return Arrays.asList( new IGeneratorParameter<?>[] {textColor} );
+ return Arrays.asList( new IGeneratorParameter<?>[] {
+ textColor,
+ willDrawAtomNumbers
+ }
+ );
}
View
31 src/main/org/openscience/cdk/renderer/generators/ExtendedAtomGenerator.java
@@ -20,6 +20,8 @@
import java.awt.Color;
import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
import java.util.Stack;
import javax.vecmath.Point2d;
@@ -32,6 +34,7 @@
import org.openscience.cdk.renderer.elements.IRenderingElement;
import org.openscience.cdk.renderer.elements.TextGroupElement;
import org.openscience.cdk.renderer.elements.TextGroupElement.Position;
+import org.openscience.cdk.renderer.generators.AtomNumberGenerator.WillDrawAtomNumbers;
import org.openscience.cdk.renderer.generators.parameter.AbstractGeneratorParameter;
/**
@@ -52,20 +55,30 @@ public Boolean getDefault() {
private IGeneratorParameter<Boolean> showImplicitHydrogens =
new ShowImplicitHydrogens();
+ public static class ShowAtomTypeNames extends
+ AbstractGeneratorParameter<Boolean> {
+ public Boolean getDefault() {
+ return Boolean.FALSE;
+ }
+ }
+ private ShowAtomTypeNames showAtomTypeNames;
+
public IRenderingElement generate(
IAtomContainer ac, IAtom atom, RendererModel model) {
-
+ boolean drawNumbers =
+ model.getRenderingParameter(WillDrawAtomNumbers.class).getValue();
if (!hasCoordinates(atom)
|| invisibleHydrogen(atom, model)
- || (invisibleCarbon(atom, ac, model) && !model.getDrawNumbers())) {
+ || (invisibleCarbon(atom, ac, model)
+ && !drawNumbers)) {
return null;
} else if (model.getRenderingParameter(CompactAtom.class).getValue()) {
return this.generateCompactElement(atom, model);
} else {
String text;
if (atom instanceof IPseudoAtom) {
text = ((IPseudoAtom) atom).getLabel();
- } else if (invisibleCarbon(atom, ac, model) && model.drawNumbers()) {
+ } else if (invisibleCarbon(atom, ac, model) && drawNumbers) {
text = String.valueOf(ac.getAtomNumber(atom) + 1);
} else {
text = atom.getSymbol();
@@ -89,7 +102,9 @@ public void decorate(TextGroupElement textGroup,
RendererModel model) {
Stack<Position> unused = getUnusedPositions(ac, atom);
- if (!invisibleCarbon(atom, ac, model) && model.getDrawNumbers()) {
+ boolean drawNumbers =
+ model.getRenderingParameter(WillDrawAtomNumbers.class).getValue();
+ if (!invisibleCarbon(atom, ac, model) && drawNumbers) {
Position position = getNextPosition(unused);
String number = String.valueOf(ac.getAtomNumber(atom) + 1);
textGroup.addChild(number, position);
@@ -184,4 +199,12 @@ public Position getPosition(IAtom atom, IAtom connectedAtom) {
}
}
+ public List<IGeneratorParameter<?>> getParameters() {
+ return Arrays.asList(
+ new IGeneratorParameter<?>[] {
+ showImplicitHydrogens,
+ showAtomTypeNames
+ }
+ );
+ }
}

0 comments on commit 63b253c

Please sign in to comment.