Skip to content

Commit

Permalink
Renamed get/setRenderingParameter methods to shorter names (renderext…
Browse files Browse the repository at this point in the history
…ra).
  • Loading branch information
egonw committed May 20, 2012
1 parent 5df385a commit 109fd2c
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 47 deletions.
38 changes: 19 additions & 19 deletions src/main/org/openscience/cdk/renderer/Renderer.java
Expand Up @@ -245,7 +245,7 @@ public void setScale(IChemModel chemModel) {
double scale = this.calculateScaleForBondLength(bondLength);

// store the scale so that other components can access it
this.rendererModel.getRenderingParameter(Scale.class).setValue(scale);
this.rendererModel.getParameter(Scale.class).setValue(scale);
}

/**
Expand All @@ -260,7 +260,7 @@ public void setScale(IReactionSet reactionSet) {
double scale = this.calculateScaleForBondLength(bondLength);

// store the scale so that other components can access it
this.rendererModel.getRenderingParameter(Scale.class).setValue(scale);
this.rendererModel.getParameter(Scale.class).setValue(scale);
}

/**
Expand All @@ -274,7 +274,7 @@ public void setScale(IReaction reaction) {
double scale = this.calculateScaleForBondLength(bondLength);

// store the scale so that other components can access it
this.rendererModel.getRenderingParameter(Scale.class).setValue(scale);
this.rendererModel.getParameter(Scale.class).setValue(scale);
}

/**
Expand All @@ -288,7 +288,7 @@ public void setScale(IMoleculeSet moleculeSet) {
double scale = this.calculateScaleForBondLength(bondLength);

// store the scale so that other components can access it
this.rendererModel.getRenderingParameter(Scale.class).setValue(scale);
this.rendererModel.getParameter(Scale.class).setValue(scale);
}

/**
Expand Down Expand Up @@ -719,7 +719,7 @@ public void setDrawCenter(double x, double y) {
}

public void setZoom(double z) {
getRenderer2DModel().getRenderingParameter(
getRenderer2DModel().getParameter(
ZoomFactor.class).setValue( z );
setup();
}
Expand Down Expand Up @@ -758,7 +758,7 @@ public void setZoomToFit(double drawWidth,
double diagramHeight) {

double m = this.rendererModel
.getRenderingParameter(Margin.class).getValue();
.getParameter(Margin.class).getValue();

// determine the zoom needed to fit the diagram to the screen
double widthRatio = drawWidth / (diagramWidth + (2 * m));
Expand All @@ -769,7 +769,7 @@ public void setZoomToFit(double drawWidth,
this.fontManager.setFontForZoom(zoom);

// record the zoom in the model, so that generators can use it
this.rendererModel.getRenderingParameter(
this.rendererModel.getParameter(
ZoomFactor.class).setValue(zoom);

}
Expand All @@ -790,10 +790,10 @@ private void paint(IDrawVisitor drawVisitor,
this.cachedDiagram = diagram;

this.fontManager.setFontName(
this.rendererModel.getRenderingParameter(FontName.class).getValue()
this.rendererModel.getParameter(FontName.class).getValue()
);
this.fontManager.setFontStyle(
this.rendererModel.getRenderingParameter(UsedFontStyle.class)
this.rendererModel.getParameter(UsedFontStyle.class)
.getValue()
);

Expand All @@ -810,7 +810,7 @@ private void paint(IDrawVisitor drawVisitor,
* the bounding box of the model
*/
private void setupTransformNatural(Rectangle2D modelBounds) {
double zoom = this.rendererModel.getRenderingParameter(
double zoom = this.rendererModel.getParameter(
ZoomFactor.class).getValue();
this.fontManager.setFontForZoom(zoom);
this.setup();
Expand Down Expand Up @@ -852,13 +852,13 @@ private void setupTransformToFit(Rectangle2D screenBounds,

// this controls whether editing a molecule causes it to re-center
// with each change or not
if (reset || rendererModel.getRenderingParameter(FitToScreen.class).getValue()) {
if (reset || rendererModel.getParameter(FitToScreen.class).getValue()) {
this.setModelCenter(
modelBounds.getCenterX(), modelBounds.getCenterY());
}

// set the scale in the renderer model for the generators
this.rendererModel.getRenderingParameter(Scale.class).setValue(scale);
this.rendererModel.getParameter(Scale.class).setValue(scale);

this.setup();
}
Expand All @@ -873,9 +873,9 @@ private void setupTransformToFit(Rectangle2D screenBounds,
*/
private double calculateScaleForBondLength(double modelBondLength) {
if (Double.isNaN(modelBondLength) || modelBondLength == 0) {
return rendererModel.getRenderingParameter(Scale.class).getDefault();
return rendererModel.getParameter(Scale.class).getDefault();
} else {
return this.rendererModel.getRenderingParameter(BondLength.class)
return this.rendererModel.getParameter(BondLength.class)
.getValue() / modelBondLength;
}
}
Expand All @@ -894,8 +894,8 @@ private Rectangle convertToDiagramBounds(Rectangle2D modelBounds) {
double mw = modelBounds.getWidth();
double mh = modelBounds.getHeight();

double scale = rendererModel.getRenderingParameter(Scale.class).getValue();
double zoom = rendererModel.getRenderingParameter(ZoomFactor.class).getValue();
double scale = rendererModel.getParameter(Scale.class).getValue();
double zoom = rendererModel.getParameter(ZoomFactor.class).getValue();

Point2d mc = this.toScreenCoordinates(cx, cy);

Expand All @@ -905,7 +905,7 @@ private Rectangle convertToDiagramBounds(Rectangle2D modelBounds) {
}

double margin = this.rendererModel
.getRenderingParameter(Margin.class).getValue();
.getParameter(Margin.class).getValue();
int w = (int) ((scale * zoom * mw) + (2 * margin));
int h = (int) ((scale * zoom * mh) + (2 * margin));
int x = (int) (mc.x - w / 2);
Expand All @@ -915,8 +915,8 @@ private Rectangle convertToDiagramBounds(Rectangle2D modelBounds) {
}

private void setup() {
double scale = rendererModel.getRenderingParameter(Scale.class).getValue();
double zoom = rendererModel.getRenderingParameter(ZoomFactor.class).getValue();
double scale = rendererModel.getParameter(Scale.class).getValue();
double zoom = rendererModel.getParameter(ZoomFactor.class).getValue();
// set the transform
try {
this.transform = new AffineTransform();
Expand Down
Expand Up @@ -78,11 +78,11 @@ public AtomNumberGenerator(Vector2d offset) {

public IRenderingElement generate(IAtomContainer ac, RendererModel model) {
ElementGroup numbers = new ElementGroup();
if (!model.getRenderingParameter(WillDrawAtomNumbers.class).getValue())
if (!model.getParameter(WillDrawAtomNumbers.class).getValue())
return numbers;

Vector2d offset = new Vector2d(this.offset.x,-this.offset.y);
offset.scale( 1/model.getRenderingParameter(Scale.class).getValue() );
offset.scale( 1/model.getParameter(Scale.class).getValue() );

int number = 1;
for (IAtom atom : ac.atoms()) {
Expand Down
Expand Up @@ -67,13 +67,13 @@ public Boolean getDefault() {
public IRenderingElement generate(
IAtomContainer ac, IAtom atom, RendererModel model) {
boolean drawNumbers =
model.getRenderingParameter(WillDrawAtomNumbers.class).getValue();
model.getParameter(WillDrawAtomNumbers.class).getValue();
if (!hasCoordinates(atom)
|| invisibleHydrogen(atom, model)
|| (invisibleCarbon(atom, ac, model)
&& !drawNumbers)) {
return null;
} else if (model.getRenderingParameter(CompactAtom.class).getValue()) {
} else if (model.getParameter(CompactAtom.class).getValue()) {
return this.generateCompactElement(atom, model);
} else {
String text;
Expand All @@ -94,7 +94,7 @@ public IRenderingElement generate(

public boolean hideAtomSymbol(IAtom atom, RendererModel model) {
return atom.getSymbol().equals("C") &&
!model.getRenderingParameter(KekuleStructure.class).getValue();
!model.getParameter(KekuleStructure.class).getValue();
}

public void decorate(TextGroupElement textGroup,
Expand All @@ -104,7 +104,7 @@ public void decorate(TextGroupElement textGroup,
Stack<Position> unused = getUnusedPositions(ac, atom);

boolean drawNumbers =
model.getRenderingParameter(WillDrawAtomNumbers.class).getValue();
model.getParameter(WillDrawAtomNumbers.class).getValue();
if (!invisibleCarbon(atom, ac, model) && drawNumbers) {
Position position = getNextPosition(unused);
String number = String.valueOf(ac.getAtomNumber(atom) + 1);
Expand Down
Expand Up @@ -59,10 +59,10 @@ public IRenderingElement generate(IAtomContainer ac, RendererModel model) {

// XXX : is this the best option?
final double ATOM_RADIUS =
((AtomRadius)model.getRenderingParameter(AtomRadius.class)).
((AtomRadius)model.getParameter(AtomRadius.class)).
getValue();

double scale = model.getRenderingParameter(Scale.class).getValue();
double scale = model.getParameter(Scale.class).getValue();
double modelAtomRadius = ATOM_RADIUS / scale;
double modelPointRadius = SCREEN_RADIUS / scale;
double modelSeparation = SCREEN_SEPARATION / scale;
Expand Down
Expand Up @@ -101,7 +101,7 @@ public IRenderingElement generate(IReaction reaction, RendererModel model) {
* @return a double in chem-model space
*/
public double getWidthForMappingLine(RendererModel model) {
double scale = model.getRenderingParameter(Scale.class).getValue();
double scale = model.getParameter(Scale.class).getValue();
return mappingLineWidth.getValue() / scale;
}

Expand Down
Expand Up @@ -49,12 +49,12 @@ public class ProductsBoxGenerator implements IGenerator<IReaction> {
private static double DISTANCE;

public IRenderingElement generate(IReaction reaction, RendererModel model) {
if(!model.getRenderingParameter(ShowReactionBoxes.class).getValue())
if(!model.getParameter(ShowReactionBoxes.class).getValue())
return null;
if (reaction.getProductCount() == 0)
return new ElementGroup();
DISTANCE = model.getRenderingParameter(BondLength.class)
.getValue() / model.getRenderingParameter(Scale.class).getValue() / 2;
DISTANCE = model.getParameter(BondLength.class)
.getValue() / model.getParameter(Scale.class).getValue() / 2;
Rectangle2D totalBounds = null;
for (IAtomContainer molecule : reaction.getProducts().molecules()) {
Rectangle2D bounds = Renderer.calculateBounds(molecule);
Expand All @@ -67,7 +67,7 @@ public IRenderingElement generate(IReaction reaction, RendererModel model) {
if (totalBounds == null) return null;

ElementGroup diagram = new ElementGroup();
Color foregroundColor = model.getRenderingParameter(
Color foregroundColor = model.getParameter(
BasicSceneGenerator.ForegroundColor.class).getValue();
diagram.add(new RectangleElement(
totalBounds.getMinX()-DISTANCE,
Expand Down
Expand Up @@ -59,11 +59,11 @@ public IRenderingElement generate(IAtomContainer ac, RendererModel model) {

// XXX : is this the best option?
final double ATOM_RADIUS =
((AtomRadius)model.getRenderingParameter(AtomRadius.class)).
((AtomRadius)model.getParameter(AtomRadius.class)).
getValue();

double modelRadius = SCREEN_RADIUS /
model.getRenderingParameter(Scale.class).getValue();
model.getParameter(Scale.class).getValue();
Map<IAtom,Integer> singleElectronsPerAtom = new HashMap<IAtom, Integer>();
for (ISingleElectron e : ac.singleElectrons()) {
IAtom atom = e.getAtom();
Expand Down
Expand Up @@ -44,21 +44,21 @@
public class ReactantsBoxGenerator implements IGenerator<IReaction> {

public IRenderingElement generate(IReaction reaction, RendererModel model) {
if (!model.getRenderingParameter(ShowReactionBoxes.class).getValue())
if (!model.getParameter(ShowReactionBoxes.class).getValue())
return null;
if (reaction.getReactantCount() == 0)
return new ElementGroup();

double d = model.getRenderingParameter(BondLength.class)
.getValue() / model.getRenderingParameter(Scale.class).getValue()/2;
double d = model.getParameter(BondLength.class)
.getValue() / model.getParameter(Scale.class).getValue()/2;
Rectangle2D totalBounds = Renderer.calculateBounds(reaction.getReactants());

ElementGroup diagram = new ElementGroup();
double minX = totalBounds.getMinX();
double minY = totalBounds.getMinY();
double maxX = totalBounds.getMaxX();
double maxY = totalBounds.getMaxY();
Color foregroundColor = model.getRenderingParameter(
Color foregroundColor = model.getParameter(
BasicSceneGenerator.ForegroundColor.class).getValue();
diagram.add(new RectangleElement(
minX - d, minY - d, maxX + d, maxY + d, foregroundColor
Expand Down
Expand Up @@ -49,16 +49,16 @@ public IRenderingElement generate(IReaction reaction, RendererModel model) {
if (totalBoundsReactants == null || totalBoundsProducts == null)
return null;

double d = model.getRenderingParameter(BondLength.class)
.getValue() / model.getRenderingParameter(Scale.class).getValue();
Color foregroundColor = model.getRenderingParameter(
double d = model.getParameter(BondLength.class)
.getValue() / model.getParameter(Scale.class).getValue();
Color foregroundColor = model.getParameter(
BasicSceneGenerator.ForegroundColor.class).getValue();
return new ArrowElement(
totalBoundsReactants.getMaxX() + d,
totalBoundsReactants.getCenterY(),
totalBoundsProducts.getMinX() - d,
totalBoundsReactants.getCenterY(),
1 / model.getRenderingParameter(Scale.class).getValue(), true,
1 / model.getParameter(Scale.class).getValue(), true,
foregroundColor
);
}
Expand Down
Expand Up @@ -44,15 +44,15 @@
public class ReactionBoxGenerator implements IGenerator<IReaction> {

public IRenderingElement generate(IReaction reaction, RendererModel model) {
if (!model.getRenderingParameter(ShowReactionBoxes.class).getValue())
if (!model.getParameter(ShowReactionBoxes.class).getValue())
return null;
double d = model.getRenderingParameter(BondLength.class)
.getValue() / model.getRenderingParameter(Scale.class).getValue();
double d = model.getParameter(BondLength.class)
.getValue() / model.getParameter(Scale.class).getValue();
Rectangle2D totalBounds = Renderer.calculateBounds(reaction);
if (totalBounds == null) return null;

ElementGroup diagram = new ElementGroup();
Color foregroundColor = model.getRenderingParameter(
Color foregroundColor = model.getParameter(
BasicSceneGenerator.ForegroundColor.class).getValue();
diagram.add(new RectangleElement(
totalBounds.getMinX()-d,
Expand Down
Expand Up @@ -49,7 +49,7 @@ public IRenderingElement generate(IReaction reaction, RendererModel model) {
Rectangle2D bounds1 =
Renderer.calculateBounds(reactants.getAtomContainer(0));
double axis = totalBoundsReactants.getCenterY();
Color color = model.getRenderingParameter(
Color color = model.getParameter(
BasicSceneGenerator.ForegroundColor.class).getValue();
for (int i = 1; i < reaction.getReactantCount(); i++) {
Rectangle2D bounds2 =
Expand Down

0 comments on commit 109fd2c

Please sign in to comment.