Skip to content

Commit

Permalink
Follow-up on the cleansing of the warnings in GAMA code
Browse files Browse the repository at this point in the history
Signed-off-by: AlexisDrogoul <alexis.drogoul@gmail.com>
  • Loading branch information
AlexisDrogoul committed Oct 5, 2016
1 parent 52b9fce commit cb31eaf
Show file tree
Hide file tree
Showing 71 changed files with 5,041 additions and 4,667 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ public Object privateExecuteIn(final IScope scope) throws GamaRuntimeException {
+ " is not equals to " + equals.value(scope), scope);
}
return null;
} else {
if (equals.value(scope) != null) {
throw GamaRuntimeException.error("Assert equals ERROR : " + value.serialize(false)
+ " is not equals to " + equals.value(scope), scope);
}
return null;
}
if (equals.value(scope) != null) {
throw GamaRuntimeException.error(
"Assert equals ERROR : " + value.serialize(false) + " is not equals to " + equals.value(scope),
scope);
}
return null;
}

if (isnot != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static boolean openPerspective(final String perspectiveId, final boolean
return true;

IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if ( activePage == null && perspectiveId != null )
if ( activePage == null )
try {
activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().openPage(perspectiveId, null);
} catch (final WorkbenchException e1) {
Expand Down
1 change: 1 addition & 0 deletions msi.gama.core/src/msi/gama/common/util/GeometryUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ public static IList<IShape> split_at(final IShape geom, final ILocation pt) {
distMin = dist;
}
}
@SuppressWarnings("null")
final Coordinate[] coords = ((LineString) geom2).getCoordinates();
final Point pt1 = FACTORY.createPoint(new GamaPoint(pt.getLocation()));
final int nb = coords.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public Object _init_(final IScope scope) {
return this;
}

@SuppressWarnings("null")
@Override
public void reset() {
// We first save the results of the various simulations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,8 @@ public Object getAgentVarValue(final IAgent a, final String name) {
public IGui getGui() {
if (getSpecies().isHeadless()) {
return GAMA.getHeadlessGui();
} else {
return GAMA.getRegularGui();
}
return GAMA.getRegularGui();
}

}
Expand Down
17 changes: 7 additions & 10 deletions msi.gama.core/src/msi/gama/kernel/model/GamlModelSpecies.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,21 +170,18 @@ public ISpecies getSpecies(final String speciesName, final SpeciesDescription sp
}
// hqnghi 11/Oct/13
// get experiementSpecies in any model
ISpecies sp = null;
ISpecies sp = getExperiment(speciesName);
if (sp == null) {
sp = getExperiment(speciesName);
if (sp == null) {
for (final ISpecies mm : getAllSpecies().values()) {
if (mm instanceof GamlModelSpecies && specDes.getOriginName().equals(mm.getName())) {
sp = ((GamlModelSpecies) mm).getExperiment(speciesName);
if (sp != null) {
return sp;
}
for (final ISpecies mm : getAllSpecies().values()) {
if (mm instanceof GamlModelSpecies && specDes.getOriginName().equals(mm.getName())) {
sp = ((GamlModelSpecies) mm).getExperiment(speciesName);
if (sp != null) {
return sp;
}
}
}
sp = getAllSpecies().get(speciesName);
}
sp = getAllSpecies().get(speciesName);
return sp;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public SimulationAgent getSimulation() {
public void setTopology(final IScope scope, final IShape shape) {
// A topology has already been computed. We update it and updates all
// the agents present in the spatial index
if (topology instanceof RootTopology) {
if (topology != null) {
topology.updateEnvironment(shape);
} else {
final IExpression expr = getSpecies().getFacet(IKeyword.TORUS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,8 @@ public IType getType() {
public Object get(final IScope scope, final String index) throws GamaRuntimeException {
if (getPopulation().hasVar(index)) {
return scope.getAgentVarValue(this, index);
} else {
return getAttribute(index);
}
return getAttribute(index);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ public void createVariablesFor(final IScope scope, final List<? extends IAgent>
// }
// }

@SuppressWarnings("null")
public void createAndUpdateVariablesFor(final IScope scope, final List<? extends IAgent> agents,
final List<? extends Map> initialValues, final boolean update) throws GamaRuntimeException {
if (agents == null || agents.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,8 @@ public ILocation normalizeLocation3D(final ILocation point, final boolean nullIf
return null;
}
return point;
} else {
throw GamaRuntimeException.error("The environement must be a 3D environment (e.g shape <- cube(100).",
null);
}
throw GamaRuntimeException.error("The environement must be a 3D environment (e.g shape <- cube(100).", null);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ public IAgent firstAtDistance(final IScope scope, final IShape source, final dou
final int id = findSpatialIndexes(f);
if (id != -1) {
return firstAtDistance(scope, source, f, all[id]);
} else {
return firstAtDistance(scope, source, f);
}
return firstAtDistance(scope, source, f);
}

@Override
Expand Down
43 changes: 21 additions & 22 deletions msi.gama.core/src/msi/gama/metamodel/topology/graph/AStar.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,29 +127,28 @@ protected void aStar(final V sourceNode, final V targetNode) {
isPathFound = true;
result = buildPath(current);
return;
} else {
openMap.remove(current.node);
closedMap.put(current.node, current);
final _Vertex<V, E> node = graph.getVertex(current.node);
final Set<E> edges = new HashSet<E>(node.getOutEdges());
if (!graph.isDirected()) {
edges.addAll(node.getInEdges());
}
openMap.remove(current.node);
closedMap.put(current.node, current);
final _Vertex<V, E> node = graph.getVertex(current.node);
final Set<E> edges = new HashSet<E>(node.getOutEdges());
if (!graph.isDirected()) {
edges.addAll(node.getInEdges());

}
for (final E edge : edges) {
final _Edge<V, E> eg = graph.getEdge(edge);
final V next = (V) (eg.getTarget().equals(current.node) ? eg.getSource() : eg.getTarget());
if (closedMap.containsKey(next))
continue;

final double h = heuristic(next, targetNode);
final double g = current.g + eg.getWeight();
final ASNode openNode = openMap.get(next);
if (openNode == null)
openMap.put(next, new ASNode(next, edge, current, g, h));
else if (g >= openNode.rank) {
continue;
}
}
for (final E edge : edges) {
final _Edge<V, E> eg = graph.getEdge(edge);
final V next = (V) (eg.getTarget().equals(current.node) ? eg.getSource() : eg.getTarget());
if (closedMap.containsKey(next))
continue;

final double h = heuristic(next, targetNode);
final double g = current.g + eg.getWeight();
final ASNode openNode = openMap.get(next);
if (openNode == null)
openMap.put(next, new ASNode(next, edge, current, g, h));
else if (g >= openNode.rank) {
continue;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public boolean init(final IScope scope) {
GAMA.startFrontmostExperiment();
}
return true;
} else
return false;
}
return false;
}

protected int getLayout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ protected final double hFromModelUnitsToPixels(final double mu) {
public double getxRatioBetweenPixelsAndModelUnits() {
if (currentLayer == null) {
return getDisplayWidth() / data.getEnvWidth();
} else {
return currentLayer.getSizeInPixels().x / data.getEnvWidth();
}
return currentLayer.getSizeInPixels().x / data.getEnvWidth();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,10 @@ public void validate(final StatementDescription description) {
description.error(ed.toString() + " is not the description of a species", IGamlIssue.WRONG_TYPE,
ed.getTarget());
return;
} else {
if (description.getKeyword().equals(GRID_POPULATION) && !target.isGrid()) {
description.error(target + " is not a grid", IGamlIssue.WRONG_TYPE, ed.getTarget());
return;
}

}
if (description.getKeyword().equals(GRID_POPULATION) && !target.isGrid()) {
description.error(target + " is not a grid", IGamlIssue.WRONG_TYPE, ed.getTarget());
return;
}
}
ed = description.getFacet(ASPECT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,8 @@ private Object getlistvalue(final IScope scope, final HashMap barvalues, final S
return null;
return ol.get(listvalue);

} else {
return o;
}
return o;

}

Expand Down
49 changes: 22 additions & 27 deletions msi.gama.core/src/msi/gama/outputs/layers/charts/ChartDataSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,20 @@ public String getCategories(final IScope scope, final int i) {
if (Xcategories.size() > i) {
return Xcategories.get(i);

} else {
for (int c = Xcategories.size(); c <= i; c++) {
this.Xcategories.add("c" + c);
}
return Xcategories.get(i);
}
for (int c = Xcategories.size(); c <= i; c++) {
this.Xcategories.add("c" + c);
}
return Xcategories.get(i);
}

public String getLastCategories(final IScope scope) {
if (Xcategories.size() > 0) {
return Xcategories.get(Xcategories.size() - 1);

} else {
this.Xcategories.add("c" + 0);
return Xcategories.get(Xcategories.size() - 1);
}
this.Xcategories.add("c" + 0);
return Xcategories.get(Xcategories.size() - 1);
}

public void setCategories(final ArrayList<String> categories) {
Expand Down Expand Up @@ -537,26 +535,23 @@ public ChartDataSeries createOrGetSerie(final IScope scope, final String id, fin
// TODO Auto-generated method stub
if (series.keySet().contains(id)) {
return series.get(id);
} else {
if (deletedseries.keySet().contains(id)) {
final ChartDataSeries myserie = deletedseries.get(id);
deletedseries.remove(id);
this.serieRemovalDate.put(id, -1);
myserie.setMysource(source);
myserie.setDataset(this);
myserie.setName(id);
addNewSerie(id, myserie, getDate(scope));
return myserie;
} else {
final ChartDataSeries myserie = new ChartDataSeries();
myserie.setMysource(source);
myserie.setDataset(this);
myserie.setName(id);
addNewSerie(id, myserie, getDate(scope));
return myserie;
}

}
if (deletedseries.keySet().contains(id)) {
final ChartDataSeries myserie = deletedseries.get(id);
deletedseries.remove(id);
this.serieRemovalDate.put(id, -1);
myserie.setMysource(source);
myserie.setDataset(this);
myserie.setName(id);
addNewSerie(id, myserie, getDate(scope));
return myserie;
}
final ChartDataSeries myserie = new ChartDataSeries();
myserie.setMysource(source);
myserie.setDataset(this);
myserie.setName(id);
addNewSerie(id, myserie, getDate(scope));
return myserie;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,10 @@ public void initChart(final IScope scope, final String chartname) {
AbstractRenderer getOrCreateRenderer(final IScope scope, final String serieid) {
if (RendererSet.containsKey(serieid)) {
return RendererSet.get(serieid);
} else {
final AbstractRenderer newrenderer = createRenderer(scope, serieid);
RendererSet.put(serieid, newrenderer);
return newrenderer;
}
final AbstractRenderer newrenderer = createRenderer(scope, serieid);
RendererSet.put(serieid, newrenderer);
return newrenderer;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,8 @@ public StringBuffer format(final double number, final StringBuffer toAppendTo, f
final int ind = chartdataset.XSeriesValues.indexOf(number);
if (ind >= 0) {
return new StringBuffer("" + chartdataset.Xcategories.get(ind));
} else {
return new StringBuffer("");

}
return new StringBuffer("");

}

Expand Down Expand Up @@ -412,10 +410,8 @@ public StringBuffer format(final double number, final StringBuffer toAppendTo, f
final int ind = chartdataset.YSeriesValues.indexOf(number);
if (ind >= 0) {
return new StringBuffer("" + chartdataset.Ycategories.get(ind));
} else {
return new StringBuffer("");

}
return new StringBuffer("");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,16 @@ public Shape getItemShape(final int row, final int col) {
if (isUseSize()) {
transform.setToScale(myoutput.getScale(myid, col), myoutput.getScale(myid, col));
return transform.createTransformedShape(super.getItemShape(row, col));
} else {
return super.getItemShape(row, col);
}
return super.getItemShape(row, col);
}
}

double getScale(final String serie, final int col) {
if (MarkerScale.containsKey(serie)) {
return MarkerScale.get(serie).get(col);
} else {
return 1;
}
return 1;
}

HashMap<String, ArrayList<Double>> MarkerScale = new HashMap<String, ArrayList<Double>>();
Expand Down Expand Up @@ -504,10 +502,8 @@ public StringBuffer format(final double number, final StringBuffer toAppendTo, f
final int ind = chartdataset.XSeriesValues.indexOf(number);
if (ind >= 0) {
return new StringBuffer("" + chartdataset.Xcategories.get(ind));
} else {
return new StringBuffer("");

}
return new StringBuffer("");

}

Expand Down
3 changes: 1 addition & 2 deletions msi.gama.core/src/msi/gama/runtime/AbstractScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,8 @@ public IGui getGui() {
}
if (experiment.getSpecies().isHeadless()) {
return GAMA.getHeadlessGui();
} else {
return GAMA.getRegularGui();
}
return GAMA.getRegularGui();
}

@Override
Expand Down
Loading

0 comments on commit cb31eaf

Please sign in to comment.