Commit 53854365 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

switch case must cover default and have breaks in specific case statements

parent 99aad31b
......@@ -114,13 +114,13 @@
<message key="ws.notPreceded"
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
</module>
<!-- <module name="OneStatementPerLine"/>
<module name="OneStatementPerLine"/>
<module name="MultipleVariableDeclarations"/>
<module name="ArrayTypeStyle"/>
<module name="MissingSwitchDefault"/>
<module name="FallThrough"/>
<module name="UpperEll"/>
<module name="ModifierOrder"/>
<!-- <module name="ModifierOrder"/>
<module name="EmptyLineSeparator">
<property name="tokens"
value="PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
......
......@@ -531,7 +531,7 @@ public class LayerXmlParser {
}
private String removeColor(String notes, String string) {
String lines[] = notes.split("[\n\r]+");
String[] lines = notes.split("[\n\r]+");
StringBuilder result = new StringBuilder("");
for (String line : lines) {
if (!line.startsWith(string + "=") && !line.startsWith(string + ":")) {
......
......@@ -874,7 +874,7 @@ public class RestAnnotationParser {
}
Color getColor(String notes, String string) {
String lines[] = notes.split("[\n\r]+");
String[] lines = notes.split("[\n\r]+");
for (String line : lines) {
if (line.startsWith(string + "=") || line.startsWith(string + ":")) {
String colorString = line.replace(string + "=", "").replace(string + ":", "");
......
......@@ -128,7 +128,10 @@ public class AntisenseRnaCellDesignerAliasConverter extends AbstractCellDesigner
path.closePath();
} else {
path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6);
double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight();
double x = alias.getX();
double y = alias.getY();
double width = alias.getWidth();
double height = alias.getHeight();
path.moveTo(x, y);
path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE);
......
......@@ -106,7 +106,10 @@ public class GeneCellDesignerAliasConverter extends AbstractCellDesignerAliasCon
return shape;
} else {
GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight();
double x = alias.getX();
double y = alias.getY();
double width = alias.getWidth();
double height = alias.getHeight();
path.moveTo(x, y);
path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE);
......
......@@ -137,7 +137,10 @@ public class RnaCellDesignerAliasConverter extends AbstractCellDesignerAliasConv
path.closePath();
} else {
path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6);
double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight();
double x = alias.getX();
double y = alias.getY();
double width = alias.getWidth();
double height = alias.getHeight();
path.moveTo(x, y);
path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE);
......
......@@ -708,10 +708,8 @@ public class ReactionFromXml {
index = 0;
}
Point2D p1, p2;
p1 = reactant.getLine().getLines().get(index).getP1();
p2 = reactant.getLine().getLines().get(index).getP2();
Point2D p1 = reactant.getLine().getLines().get(index).getP1();
Point2D p2 = reactant.getLine().getLines().get(index).getP2();
p1 = new Point2D.Double(p1.getX(), p1.getY());
p2 = new Point2D.Double(p2.getX(), p2.getY());
......@@ -930,10 +928,8 @@ public class ReactionFromXml {
index = 0;
}
if (index != null) {
Point2D p1, p2;
p1 = product.getLine().getLines().get(index).getP1();
p2 = product.getLine().getLines().get(index).getP2();
Point2D p1 = product.getLine().getLines().get(index).getP1();
Point2D p2 = product.getLine().getLines().get(index).getP2();
p1 = new Point2D.Double(p1.getX(), p1.getY());
p2 = new Point2D.Double(p2.getX(), p2.getY());
......
......@@ -432,7 +432,8 @@ public class SbgnmlXmlExporter {
double dy = nextPoint.getY() - centerPoint.getY();
double portToCenterDistance = OPERATOR_SIZE / 2 + OPERATOR_PORT_DISTANCE;
double dx2, dy2;
double dx2;
double dy2;
if (dx != 0) {
dx2 = Math.sqrt(Math.pow(portToCenterDistance, 2) / (1 + Math.pow(dy / dx, 2)));
dy2 = dx2 * dy / dx;
......
......@@ -542,6 +542,7 @@ public class SbgnmlXmlParser {
case SUBMAP:
logger.warn(new SbgnLogMarker(ProjectLogEntryType.PARSING_ISSUE, g, model),
"Submaps are not supported.");
break;
case UNSPECIFIED_ENTITY:
newSpecies = new Unknown(g.getId());
parseSpecies(g, newSpecies, true, model);
......@@ -1964,10 +1965,10 @@ public class SbgnmlXmlParser {
// Check if operator port is in the line from center point of the
// operator. If so, remove that redundant point.
double dx, dy;
dx = linePoints.get(0).getX() - operatorCenterPoint.getX();
dy = linePoints.get(0).getY() - operatorCenterPoint.getY();
double dx2, dy2;
double dx = linePoints.get(0).getX() - operatorCenterPoint.getX();
double dy = linePoints.get(0).getY() - operatorCenterPoint.getY();
double dx2;
double dy2;
if (arc.getNext().isEmpty()) {
dx2 = linePoints.get(linePoints.size() - 1).getX() - linePoints.get(0).getX();
dy2 = linePoints.get(linePoints.size() - 1).getY() - linePoints.get(0).getY();
......
......@@ -420,7 +420,7 @@ public abstract class AbstractImageGenerator {
* @throws DrawingException
* thrown when there was a problem with drawing map
*/
protected abstract void saveToFileImplementation(String fileName) throws IOException;;
protected abstract void saveToFileImplementation(String fileName) throws IOException;
/**
* Saves generated image into {@link OutputStream}.
......
......@@ -50,7 +50,10 @@ public class SBGNNucleicAcidFeatureConverter extends SpeciesConverter<Species> {
@Override
protected Shape getShape(final Species species) {
GeneralPath bottomRoundedRectangle = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
double x = species.getX(), y = species.getY(), width = species.getWidth(), height = species.getHeight();
double x = species.getX();
double y = species.getY();
double width = species.getWidth();
double height = species.getHeight();
bottomRoundedRectangle.moveTo(x, y);
bottomRoundedRectangle.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE);
......
......@@ -268,10 +268,11 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert
break;
case RIGTH:
currX = border.getMaxX() - getTextWidth(string, graphics);
break;
default:
throw new InvalidArgumentException("Don't know how to align text with: " + horizontalAlign);
}
graphics.drawString(string, (int) currX, (int) y);
y += lineHeight;
}
......
......@@ -240,9 +240,9 @@ public final class FontFinder {
break;
case RIGTH:
currX = (border.getMaxX() - textWidth);
break;
default:
throw new InvalidArgumentException("Don't know how to align text with: " + horizontalAlign);
}
graphics.drawString(string, (int) currX, (int) y);
......
......@@ -204,12 +204,10 @@ public class PlaceFinder {
* alias that should disable regions
*/
private void fillMatrixWithAlias(Element alias) {
Double a, b, c, d;
a = alias.getX();
b = alias.getX() + alias.getWidth();
c = alias.getY() + alias.getHeight();
d = alias.getY();
Double a = alias.getX();
Double b = alias.getX() + alias.getWidth();
Double c = alias.getY() + alias.getHeight();
Double d = alias.getY();
fillWithPoints(a, b, c, d);
}
......
......@@ -16,6 +16,7 @@ import org.sbml.jsbml.ext.render.LocalStyle;
import org.sbml.jsbml.ext.render.RenderGroup;
import org.sbml.jsbml.ext.render.VTextAnchor;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.species.Element;
......@@ -65,26 +66,30 @@ public abstract class SbmlElementExporter<T extends Element, S extends org.sbml.
group.setVTextAnchor(VTextAnchor.MIDDLE);
group.setTextAnchor(HTextAnchor.MIDDLE);
switch (element.getNameHorizontalAlign()) {
case CENTER:
group.setTextAnchor(HTextAnchor.MIDDLE);
break;
case LEFT:
group.setTextAnchor(HTextAnchor.START);
break;
case RIGTH:
group.setTextAnchor(HTextAnchor.END);
break;
case CENTER:
group.setTextAnchor(HTextAnchor.MIDDLE);
break;
case LEFT:
group.setTextAnchor(HTextAnchor.START);
break;
case RIGTH:
group.setTextAnchor(HTextAnchor.END);
break;
default:
throw new NotImplementedException("Support of " + element.getNameHorizontalAlign() + " is not implemented");
}
switch (element.getNameVerticalAlign()) {
case BOTTOM:
group.setVTextAnchor(VTextAnchor.BOTTOM);
break;
case MIDDLE:
group.setVTextAnchor(VTextAnchor.MIDDLE);
break;
case TOP:
group.setVTextAnchor(VTextAnchor.TOP);
break;
case BOTTOM:
group.setVTextAnchor(VTextAnchor.BOTTOM);
break;
case MIDDLE:
group.setVTextAnchor(VTextAnchor.MIDDLE);
break;
case TOP:
group.setVTextAnchor(VTextAnchor.TOP);
break;
default:
throw new NotImplementedException("Support of " + element.getNameVerticalAlign() + " is not implemented");
}
group.setStroke(getColorDefinition(element.getFontColor()).getId());
}
......
......@@ -127,34 +127,35 @@ public class SbmlModelUtils {
result.setGroup(new RenderGroup());
renderInformation.getListOfLineEndings().add(result);
switch (arrowType) {
case FULL:
createFullLineEnding(result);
break;
case BLANK:
createBlankLineEnding(result);
break;
case FULL_CROSSBAR:
createFullCrossBarLineEnding(result);
break;
case BLANK_CROSSBAR:
createBlankCrossBarLineEnding(result);
break;
case CROSSBAR:
createCrossBarLineEnding(result);
break;
case DIAMOND:
createDiamondLineEnding(result);
break;
case OPEN:
createOpenLineEnding(result);
break;
case CIRCLE:
createCircleLineEnding(result);
break;
default:
logger.warn("Unknown arrow type: " + arrowType);
case NONE:
break;
case FULL:
createFullLineEnding(result);
break;
case BLANK:
createBlankLineEnding(result);
break;
case FULL_CROSSBAR:
createFullCrossBarLineEnding(result);
break;
case BLANK_CROSSBAR:
createBlankCrossBarLineEnding(result);
break;
case CROSSBAR:
createCrossBarLineEnding(result);
break;
case DIAMOND:
createDiamondLineEnding(result);
break;
case OPEN:
createOpenLineEnding(result);
break;
case CIRCLE:
createCircleLineEnding(result);
break;
case NONE:
break;
default:
logger.warn("Unknown arrow type: " + arrowType);
break;
}
return result;
......
......@@ -99,7 +99,7 @@ public final class MultiPackageNamingUtils {
}
public static Boolean getTranscriptionFactorActiveStateFromFeatureTypeName(String featureTypeString) {
String tmp[] = featureTypeString.split("_");
String[] tmp = featureTypeString.split("_");
Boolean result = null;
if (tmp.length >= 2) {
if (tmp[tmp.length - 2].equalsIgnoreCase("TRUE")) {
......@@ -112,7 +112,7 @@ public final class MultiPackageNamingUtils {
}
public static String getTranscriptionFactorDirectionStateFromFeatureTypeName(String featureTypeString) {
String tmp[] = featureTypeString.split("_");
String[] tmp = featureTypeString.split("_");
String result = null;
if (tmp.length >= 1) {
result = tmp[tmp.length - 1];
......
......@@ -37,6 +37,7 @@ import lcsb.mapviewer.common.XmlParser;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.InvalidStateException;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.common.geometry.PointTransformation;
import lcsb.mapviewer.converter.InvalidInputDataExecption;
import lcsb.mapviewer.converter.model.celldesigner.geometry.ReactionCellDesignerConverter;
......@@ -601,29 +602,31 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
Class<? extends ReactionNode> nodeClass = null;
if (speciesRefernceGlyph.getRole() != null) {
switch (speciesRefernceGlyph.getRole()) {
case ACTIVATOR:
nodeClass = Trigger.class;
break;
case INHIBITOR:
nodeClass = Inhibition.class;
break;
case PRODUCT:
nodeClass = Product.class;
break;
case SIDEPRODUCT:
nodeClass = Product.class;
break;
case SIDESUBSTRATE:
nodeClass = Reactant.class;
break;
case SUBSTRATE:
nodeClass = Reactant.class;
break;
case MODIFIER:
nodeClass = Modifier.class;
break;
case UNDEFINED:
break;
case ACTIVATOR:
nodeClass = Trigger.class;
break;
case INHIBITOR:
nodeClass = Inhibition.class;
break;
case PRODUCT:
nodeClass = Product.class;
break;
case SIDEPRODUCT:
nodeClass = Product.class;
break;
case SIDESUBSTRATE:
nodeClass = Reactant.class;
break;
case SUBSTRATE:
nodeClass = Reactant.class;
break;
case MODIFIER:
nodeClass = Modifier.class;
break;
case UNDEFINED:
break;
default:
throw new NotImplementedException("Support for " + speciesRefernceGlyph.getRole() + " is not implemented");
}
}
return nodeClass;
......
......@@ -126,7 +126,7 @@ public class ProjectFactory {
}
String removeGlyph(String notes) {
String lines[] = notes.split("[\n\r]+");
String[] lines = notes.split("[\n\r]+");
StringBuilder result = new StringBuilder("");
for (String line : lines) {
if (!line.startsWith("Glyph:")) {
......@@ -137,7 +137,7 @@ public class ProjectFactory {
}
Glyph extractGlyph(Project project, String notes) throws InvalidGlyphFile {
String lines[] = notes.split("[\n\r]+");
String[] lines = notes.split("[\n\r]+");
for (String line : lines) {
if (line.startsWith("Glyph:")) {
String glyphString = line.replace("Glyph:", "").trim().toLowerCase();
......
......@@ -174,53 +174,53 @@ public class GpmlParser {
for (int i = 0; i < attributes.getLength(); i++) {
String value = attributes.item(i).getTextContent();
switch (attributes.item(i).getNodeName()) {
case ("GraphId"):
case ("GroupId"):
break;
case ("GroupRef"):
group.setGroupRef(value);
break;
case ("BiopaxRef"):
group.addBiopaxReference(value);
break;
case ("TextLabel"):
group.setTextLabel(value);
break;
case ("ZOrder"):
if (!value.isEmpty()) {
group.setzOrder(Integer.valueOf(value));
}
case ("Style"):
if (!"".equals(value)) {
if (!"Complex".equalsIgnoreCase(value) &&
!"Pathway".equalsIgnoreCase(value) &&
!"Group".equalsIgnoreCase(value)) {
throw new UnknownAttributeValueException(
"Unknown value of \"style\" attribute for group node: " + value
+ ". Only null, Complex, Group are supported.");
case ("GraphId"):
case ("GroupId"):
break;
case ("GroupRef"):
group.setGroupRef(value);
break;
case ("BiopaxRef"):
group.addBiopaxReference(value);
break;
case ("TextLabel"):
group.setTextLabel(value);
break;
case ("ZOrder"):
if (!value.isEmpty()) {
group.setzOrder(Integer.valueOf(value));
}
group.setStyle(value);
}
break;
default:
logger.warn(group.getLogMarker(),
"Unknown sub-node of " + eElement.getNodeName() + " node: " + eElement.getNodeName());
break;
break;
case ("Style"):
if (!"".equals(value)) {
if (!"Complex".equalsIgnoreCase(value) &&
!"Pathway".equalsIgnoreCase(value) &&
!"Group".equalsIgnoreCase(value)) {
throw new UnknownAttributeValueException(
"Unknown value of \"style\" attribute for group node: " + value
+ ". Only null, Complex, Group are supported.");
}
group.setStyle(value);
}
break;
default:
logger.warn(group.getLogMarker(),
"Unknown sub-node of " + eElement.getNodeName() + " node: " + eElement.getNodeName());
break;
}
}
graph.addGroup(group);
}
}
// Handling nested groups
Group gr1, gr2;
for (Node nNode : groups) {
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
String groupRef = eElement.getAttribute("GroupRef");
String groupId = eElement.getAttribute("GroupId");
if (groupRef != null && !groupRef.equals("")) {
gr1 = graph.getGroupByGroupId(groupRef);
gr2 = graph.getGroupByGroupId(groupId);
Group gr1 = graph.getGroupByGroupId(groupRef);
Group gr2 = graph.getGroupByGroupId(groupId);
gr1.addNode(gr2);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment