Skip to content
Snippets Groups Projects
Commit f2eb5642 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

simplification of abstract methods syntax (unnecessary params removed)

parent fe4a1d2d
No related branches found
No related tags found
1 merge request!44Resolve "semantic zoom"
......@@ -679,20 +679,20 @@ public abstract class AbstractImageGenerator {
// compartment/complexes)
if (element instanceof Species) {
if (((Species) element).getComplex() == null && element.getCompartment() == null) {
drawSpecies((Species) element, params.getVisibleLayoutsForElement(element), params);
drawSpecies((Species) element);
}
}
}
// draw all reactions
for (Reaction reaction : params.getModel().getSortedReactions()) {
drawReaction(reaction, params.getVisibleLayoutsForElement(reaction), params);
drawReaction(reaction);
}
// draw all compartments
for (Compartment compartment : params.getModel().getSortedCompartments()) {
// draw only compartment that don't have parents (aren't included in any
// compartment/complexes)
if (compartment.getCompartment() == null) {
drawCompartment(compartment, params.getVisibleLayoutsForElement(compartment), params);
drawCompartment(compartment);
}
}
......@@ -731,14 +731,10 @@ public abstract class AbstractImageGenerator {
*
* @param compartment
* object that we want to draw
* @param visibleLayouts
* list of {@link ColorSchema} used for coloring element in layouts
* @param params
* list of all params to create apropriate image
* @throws DrawingException
* thrown when there was a problem with drawing {@link Compartment}
*/
protected void drawCompartment(final Compartment compartment, List<ColorSchema> visibleLayouts, Params params) throws DrawingException {
protected void drawCompartment(final Compartment compartment) throws DrawingException {
// get a converter for this compartment
BioEntityConverterImpl converter = new BioEntityConverterImpl(compartment, colorExtractor);
ConverterParams compartmentParams = new ConverterParams().level(level).nested(params.nested);
......@@ -750,7 +746,7 @@ public abstract class AbstractImageGenerator {
// we draw compartment only when we have hierarchical view or it's
// standard compartment (not the pathway)
if (params.nested || !(compartment instanceof PathwayCompartment)) {
converter.draw(compartment, graphics, compartmentParams, visibleLayouts);
converter.draw(compartment, graphics, compartmentParams, params.getVisibleLayoutsForElement(compartment));
}
// If compartment should be filled, then we could skip drawing the inside
......@@ -762,12 +758,12 @@ public abstract class AbstractImageGenerator {
Collections.sort(result, Element.SIZE_COMPARATOR);
// draw all children of this compartment
for (Element element : result) {
for (Element child : result) {
// if a child is a standard species
if (element instanceof Species) {
drawSpecies((Species) element, params.getVisibleLayoutsForElement(element), params);
} else if (element instanceof Compartment) {
drawCompartment((Compartment) element, params.getVisibleLayoutsForElement(element), params);
if (child instanceof Species) {
drawSpecies((Species) child);
} else if (child instanceof Compartment) {
drawCompartment((Compartment) child);
} else {
// if a child is not a compartment or a species then we have a
// problem
......@@ -788,14 +784,10 @@ public abstract class AbstractImageGenerator {
*
* @param species
* object to be drawn
* @param visibleLayouts
* list of {@link ColorSchema} used for coloring species in layouts
* @param params
* list of all params to create apropriate image
* @throws DrawingException
* thrown when there was a problem with drawing a {@link Species}
*/
protected void drawSpecies(final Species species, List<ColorSchema> visibleLayouts, Params params) throws DrawingException {
protected void drawSpecies(final Species species) throws DrawingException {
/**
* Last conditions in this 'ifs' provides the certainty of visibility of
......@@ -827,7 +819,9 @@ public abstract class AbstractImageGenerator {
if (rescale) {
customScale = scale;
}
converter.draw(species, graphics, new ConverterParams().scale(customScale).level(level).sbgnFormat(sbgnFormat).nested(params.nested), visibleLayouts);
converter.draw(
species, graphics, new ConverterParams().scale(customScale).level(level).sbgnFormat(sbgnFormat).nested(params.nested),
params.getVisibleLayoutsForElement(species));
// if the species is a complex then we may want to draw children
// objects
......@@ -838,8 +832,8 @@ public abstract class AbstractImageGenerator {
if (!complex.getState().equalsIgnoreCase("brief")) {
// depending on current zoom level, children are drawn or not
if (zoomLevelMatcher.isTransparent(level, complex.getTransparencyLevel()) || !params.nested) {
for (Species a : complex.getElements()) {
drawSpecies(a, visibleLayouts, params);
for (Species child : complex.getElements()) {
drawSpecies(child);
}
}
}
......@@ -851,18 +845,15 @@ public abstract class AbstractImageGenerator {
*
* @param reaction
* object to be drawn
* @param visibleLayouts
* list of {@link ColorSchema} used for coloring reaction in layouts
* @param params
* list of all params to create apropriate image
* @throws DrawingException
*/
protected void drawReaction(final Reaction reaction, List<ColorSchema> visibleLayouts, Params params) throws DrawingException {
protected void drawReaction(final Reaction reaction) throws DrawingException {
if (!cross(reaction.getLines())) {
return;
}
BioEntityConverterImpl converter = new BioEntityConverterImpl(reaction, sbgnFormat, colorExtractor);
converter.draw(reaction, graphics, new ConverterParams().sbgnFormat(sbgnFormat).nested(params.nested).level(level), visibleLayouts);
converter.draw(
reaction, graphics, new ConverterParams().sbgnFormat(sbgnFormat).nested(params.nested).level(level), params.getVisibleLayoutsForElement(reaction));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment