PIVOT-1032: Fix the EmptyBlock and NestedBlock style errors in
"core" (that is, non-demo or tutorial) classes.
git-svn-id: https://svn.apache.org/repos/asf/pivot/trunk@1860674 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java b/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java
index d71d2ad..f07e82f 100644
--- a/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java
+++ b/wtk/src/org/apache/pivot/wtk/DesktopApplicationContext.java
@@ -642,9 +642,8 @@
// Load the application
try {
Class<?> applicationClass = Class.forName(applicationClassName);
- if (useApplicationInstance) {
- // application has already been set, before calling this method
- } else {
+ // If the application has not already been set before calling this method...
+ if (!useApplicationInstance) {
application = (Application) applicationClass.getDeclaredConstructor().newInstance();
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
diff --git a/wtk/src/org/apache/pivot/wtk/GraphicsUtilities.java b/wtk/src/org/apache/pivot/wtk/GraphicsUtilities.java
index 2f66de8..8a61a75 100644
--- a/wtk/src/org/apache/pivot/wtk/GraphicsUtilities.java
+++ b/wtk/src/org/apache/pivot/wtk/GraphicsUtilities.java
@@ -342,7 +342,8 @@
float startX, startY;
float endX, endY;
- switch (PaintType.valueOf(paintType.toUpperCase(Locale.ENGLISH))) {
+ PaintType pType = PaintType.valueOf(paintType.toUpperCase(Locale.ENGLISH));
+ switch (pType) {
case SOLID_COLOR:
paint = decodeColor((String) JSON.get(dictionary, COLOR_KEY));
break;
@@ -357,12 +358,8 @@
paint = new GradientPaint(startX, startY, startColor, endX, endY, endColor);
break;
- case LINEAR_GRADIENT: {
- startX = JSON.getFloat(dictionary, START_X_KEY);
- startY = JSON.getFloat(dictionary, START_Y_KEY);
- endX = JSON.getFloat(dictionary, END_X_KEY);
- endY = JSON.getFloat(dictionary, END_Y_KEY);
-
+ case LINEAR_GRADIENT:
+ case RADIAL_GRADIENT:
@SuppressWarnings("unchecked")
List<Dictionary<String, ?>> stops = (List<Dictionary<String, ?>>) JSON.get(dictionary, STOPS_KEY);
@@ -379,37 +376,24 @@
colors[i] = color;
}
- paint = new LinearGradientPaint(startX, startY, endX, endY, fractions, colors);
- break;
- }
+ if (pType == PaintType.LINEAR_GRADIENT) {
+ startX = JSON.getFloat(dictionary, START_X_KEY);
+ startY = JSON.getFloat(dictionary, START_Y_KEY);
+ endX = JSON.getFloat(dictionary, END_X_KEY);
+ endY = JSON.getFloat(dictionary, END_Y_KEY);
- case RADIAL_GRADIENT: {
- float centerX = JSON.getFloat(dictionary, CENTER_X_KEY);
- float centerY = JSON.getFloat(dictionary, CENTER_Y_KEY);
- float radius = JSON.getFloat(dictionary, RADIUS_KEY);
+ paint = new LinearGradientPaint(startX, startY, endX, endY, fractions, colors);
+ } else {
+ float centerX = JSON.getFloat(dictionary, CENTER_X_KEY);
+ float centerY = JSON.getFloat(dictionary, CENTER_Y_KEY);
+ float radius = JSON.getFloat(dictionary, RADIUS_KEY);
- @SuppressWarnings("unchecked")
- List<Dictionary<String, ?>> stops = (List<Dictionary<String, ?>>) JSON.get(dictionary, STOPS_KEY);
-
- int n = stops.getLength();
- float[] fractions = new float[n];
- Color[] colors = new Color[n];
- for (int i = 0; i < n; i++) {
- Dictionary<String, ?> stop = stops.get(i);
-
- float offset = JSON.getFloat(stop, OFFSET_KEY);
- fractions[i] = offset;
-
- Color color = decodeColor((String) JSON.get(stop, COLOR_KEY));
- colors[i] = color;
+ paint = new RadialGradientPaint(centerX, centerY, radius, fractions, colors);
}
-
- paint = new RadialGradientPaint(centerX, centerY, radius, fractions, colors);
break;
- }
default:
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException("Paint type " + paintType + " is not supported.");
}
return paint;
diff --git a/wtk/src/org/apache/pivot/wtk/ListView.java b/wtk/src/org/apache/pivot/wtk/ListView.java
index cdbc80b..05e948c 100644
--- a/wtk/src/org/apache/pivot/wtk/ListView.java
+++ b/wtk/src/org/apache/pivot/wtk/ListView.java
@@ -1785,11 +1785,10 @@
item = itemsStateBindMapping.get(listData, index.intValue());
}
- if (itemsStateBindMapping == null) {
- // TODO: ?? what to do here? we need to set the MIXED state for the item
- } else {
+ if (itemsStateBindMapping != null) {
itemsStateBindMapping.setState(item, Button.State.MIXED);
}
+ // TODO: else ?? what to do here? we need to set the MIXED state for the item
items.add(item);
}
@@ -1806,11 +1805,10 @@
item = itemsStateBindMapping.get(listData, index.intValue());
}
- if (itemsStateBindMapping == null) {
- // TODO: ?? what to do here? we need to set the SELECTED state for the item
- } else {
+ if (itemsStateBindMapping != null) {
itemsStateBindMapping.setState(item, Button.State.SELECTED);
}
+ // TODO: else ?? what to do here? we need to set the SELECTED state for the item
items.add(item);
}